Please add new event in the codeunit 550 - OnUpdatePurchaseOnAfterPurchaseLineModify

[IntegrationEvent(false, false)]
local procedure OnUpdatePurchaseOnAfterPurchaseLineModify(VATRateChangeSetup: Record "VAT Rate Change Setup"; PurchaseHeader: Record "Purchase Header"; var PurchaseLine: Record "Purchase Line"; PurchaseLineOld: Record "Purchase Line")
begin
end;
local procedure UpdatePurchase()
var
    PurchaseHeader: Record "Purchase Header";
    PurchaseHeader2: Record "Purchase Header";
    PurchaseLine: Record "Purchase Line";
    PurchaseLineOld: Record "Purchase Line";
    VATRateChangeLogEntry: Record "VAT Rate Change Log Entry";
    RecRef: RecordRef;
    NewVATProdPotingGroup: Code[20];
    NewGenProdPostingGroup: Code[20];
    StatusChanged: Boolean;
    ConvertVATProdPostingGroup: Boolean;
    ConvertGenProdPostingGroup: Boolean;
    RoundingPrecision: Decimal;
    IsHandled: Boolean;
    IsModified: Boolean;
begin
    ProgressWindow.Update(1, PurchaseHeader.TableCaption);

    ConvertVATProdPostingGroup := ConvertVATProdPostGrp(VATRateChangeSetup."Update Purchase Documents");
    ConvertGenProdPostingGroup := ConvertGenProdPostGrp(VATRateChangeSetup."Update Purchase Documents");
    if not ConvertVATProdPostingGroup and not ConvertGenProdPostingGroup then
        exit;

    IsHandled := false;
    OnBeforeUpdatePurchase(VATRateChangeSetup, IsHandled);
    if IsHandled then
        exit;

    PurchaseHeader.SetFilter(
        "Document Type", '%1..%2|%3', PurchaseHeader."Document Type"::Quote, PurchaseHeader."Document Type"::Invoice,
        PurchaseHeader."Document Type"::"Blanket Order");
    OnUpdatePurchaseOnAfterPurchaseHeaderSetFilters(PurchaseHeader);
    if PurchaseHeader.Find('-') then
        repeat
            StatusChanged := false;
            if CanUpdatePurchase(PurchaseHeader, ConvertGenProdPostingGroup, ConvertVATProdPostingGroup) then begin
                if VATRateChangeSetup."Ignore Status on Purch. Docs." then
                    if PurchaseHeader.Status <> PurchaseHeader.Status::Open then begin
                        PurchaseHeader2 := PurchaseHeader;
                        PurchaseHeader.Status := PurchaseHeader.Status::Open;
                        PurchaseHeader.Modify();
                        StatusChanged := true;
                    end;
                if PurchaseHeader.Status = PurchaseHeader.Status::Open then begin
                    PurchaseLine.SetRange("Document Type", PurchaseHeader."Document Type");
                    PurchaseLine.SetRange("Document No.", PurchaseHeader."No.");
                    if PurchaseLine.FindSet() then
                        repeat
                            if LineInScope(
                                    PurchaseLine."Gen. Prod. Posting Group", PurchaseLine."VAT Prod. Posting Group", ConvertGenProdPostingGroup,
                                    ConvertVATProdPostingGroup)
                            then
                                if (PurchaseLine."Receipt No." = '') and
                                    (PurchaseLine."Return Shipment No." = '') and IncludeLine(PurchaseLine.Type.AsInteger(), PurchaseLine."No.")
                                then
                                    if PurchaseLine.Quantity = PurchaseLine."Outstanding Quantity" then begin
                                        if PurchaseHeader."Prices Including VAT" then
                                            PurchaseLineOld := PurchaseLine;

                                        RecRef.GetTable(PurchaseLine);
                                        UpdateRec(
                                            RecRef, ConvertVATProdPostGrp(VATRateChangeSetup."Update Purchase Documents"),
                                            ConvertGenProdPostGrp(VATRateChangeSetup."Update Purchase Documents"));

                                        PurchaseLine.Find();
                                        IsModified := false;
                                        if PurchaseHeader."Prices Including VAT" and VATRateChangeSetup."Perform Conversion" and
                                            (PurchaseLine."VAT %" <> PurchaseLineOld."VAT %") and
                                            UpdateUnitPriceInclVAT(PurchaseLine.Type)
                                        then begin
                                            RecRef.SetTable(PurchaseLine);
                                            RoundingPrecision := GetRoundingPrecision(PurchaseHeader."Currency Code");
                                            PurchaseLine.Validate(
                                                "Direct Unit Cost",
                                                Round(
                                                PurchaseLineOld."Direct Unit Cost" * (100 + PurchaseLine."VAT %") / (100 + PurchaseLineOld."VAT %"),
                                                RoundingPrecision));
                                            IsModified := true;
                                        end;
                                        if PurchaseLine."Prepayment %" <> 0 then begin
                                            PurchaseLine.UpdatePrepmtSetupFields();
                                            IsModified := true;
                                        end;
                                        if IsModified then begin
                                            PurchaseLine.Modify(true);
                                            OnUpdatePurchaseOnAfterPurchaseLineModify(VATRateChangeSetup, PurchaseHeader, PurchaseLine, PurchaseLineOld);
                                        end;
                                    end else
0

Thanks for reporting this. We agree, and we’ll publish a fix asap, either in an update for the current version or in the next major release. Please do not reply to this, as we do not monitor closed issues. If you have follow-up questions or requests, please create a new issue where you reference this one.

Build ID: 47182.

0
© 2022 pullanswer.com - All rights reserved.