Skip to content

[Event Request] Codeunit 6620 "Copy Document Mgt." - OnAfterUpdateVendLedgEntry #27968

Closed
@Athon-dev

Description

Describe the request

Hello, we would like to have more parameters in the aforementioned event (same as in the sales process for event OnAfterUpdateVendLedgEntry). We also created a correlated task for the OnBeforeUpdateVendLedgEntry event: #27967

procedure UpdateVendLedgEntry(var ToPurchHeader: Record "Purchase Header"; FromDocType: Enum "Gen. Journal Document Type"; FromDocNo: Code[20])
    var
        VendLedgEntry: Record "Vendor Ledger Entry";
        IsHandled: Boolean;
    begin
        IsHandled := false;
        OnBeforeUpdateVendLedgEntry(ToPurchHeader, VendLedgEntry, IsHandled);
        if not IsHandled then begin
            VendLedgEntry.SetCurrentKey("Document No.");
            if FromDocType = "Purchase Document Type From"::"Posted Invoice" then
                VendLedgEntry.SetRange("Document Type", VendLedgEntry."Document Type"::Invoice)
            else
                VendLedgEntry.SetRange("Document Type", VendLedgEntry."Document Type"::"Credit Memo");
            VendLedgEntry.SetRange("Document No.", FromDocNo);
            VendLedgEntry.SetRange("Vendor No.", ToPurchHeader."Pay-to Vendor No.");
            VendLedgEntry.SetRange(Open, true);
            if VendLedgEntry.FindFirst() then begin
                if FromDocType = "Purchase Document Type From"::"Posted Invoice" then begin
                    ToPurchHeader."Applies-to Doc. Type" := ToPurchHeader."Applies-to Doc. Type"::Invoice;
                    ToPurchHeader."Applies-to Doc. No." := FromDocNo;
                end else begin
                    ToPurchHeader."Applies-to Doc. Type" := ToPurchHeader."Applies-to Doc. Type"::"Credit Memo";
                    ToPurchHeader."Applies-to Doc. No." := FromDocNo;
                end;
                VendLedgEntry.CalcFields("Remaining Amount");
                VendLedgEntry."Amount to Apply" := VendLedgEntry."Remaining Amount";
                VendLedgEntry."Accepted Payment Tolerance" := 0;
                VendLedgEntry."Accepted Pmt. Disc. Tolerance" := false;
                CODEUNIT.Run(CODEUNIT::"Vend. Entry-Edit", VendLedgEntry);
            end;
        end;

        //> NEW EVENT
        //OLD CODE: OnAfterUpdateVendLedgEntry(ToPurchHeader, FromDocNo);
        OnAfterUpdateVendLedgEntry(ToPurchHeader, FromDocType, FromDocNo, VendLedgEntry);
       //< NEW EVENT
    end;
    
   [IntegrationEvent(false, false)]
   //> NEW EVENT
   //OLD CODE: local procedure OnAfterUpdateVendLedgEntry(var PurchaseHeader: Record "Purchase Header"; FromDocumentNo: Code[20])
   local procedure OnAfterUpdateVendLedgEntry(var PurchaseHeader: Record "Purchase Header"; FromDocType: Enum "Gen. Journal Document Type"; FromDocumentNo: Code[20]; var VendLedgEntry: Record "Vendor Ledger Entry")
   //< NEW EVENT
   begin
   end;

Additional context

We need the same behavior as the sales process to apply the same logic to the purchase process as well.
Internal work item: AB#563447

Metadata

Assignees

No one assigned

    Labels

    SCMGitHub request for SCM areaevent-requestRequest for adding an eventships-in-future-updateFix ships in a future update

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions