microsoft / ALAppExtensions

Repository for collaboration on Microsoft AL application add-on and localization extensions for Microsoft Dynamics 365 Business Central.
MIT License
773 stars 610 forks source link

[Event Request] codeunit 816 "Purch. Post Invoice" - RunOnBeforePrepareDeferralLine #27315

Open RZ440 opened 1 week ago

RZ440 commented 1 week ago

Describe the request

Hello, can you please add a new Event RunOnBeforePrepareDeferralLine in codeunit 816 "Purch. Post Invoice"?

    local procedure PrepareDeferralLine(PurchHeader: Record "Purchase Header"; PurchLine: Record "Purchase Line"; AmountLCY: Decimal; AmountACY: Decimal; RemainAmtToDefer: Decimal; RemainAmtToDeferACY: Decimal; DeferralAccount: Code[20]; PurchAccount: Code[20])
    var
        DeferralTemplate: Record "Deferral Template";
        DeferralPostingBuffer: Record "Deferral Posting Buffer";
        IsHandled: Boolean;
    begin
        IsHandled := false;
        PurchPostInvoiceEvents.RunOnBeforePrepareDeferralLine(TempDeferralHeader, TempDeferralLine, PurchHeader, PurchLine, AmountLCY, AmountACY, RemainAmtToDefer, RemainAmtToDeferACY, DeferralAccount, PurchAccount, InvoicePostingParameters."Document No.", InvDefLineNo, IsHandled);
        if IsHandled then
            exit;
        DeferralTemplate.Get(PurchLine."Deferral Code");

        if TempDeferralHeader.Get(
            "Deferral Document Type"::Purchase, '', '', PurchLine."Document Type", PurchLine."Document No.", PurchLine."Line No.")
        then begin
            if TempDeferralHeader."Amount to Defer" <> 0 then begin
                DeferralUtilities.FilterDeferralLines(
                  TempDeferralLine, "Deferral Document Type"::Purchase.AsInteger(), '', '',
                  PurchLine."Document Type".AsInteger(), PurchLine."Document No.", PurchLine."Line No.");
codeunit 826 "Purch. Post Invoice Events"
.
.
.
    procedure RunOnCalculateVATAmountsAfterVatCalculationType(var TempInvoicePostingBuffer: Record "Invoice Posting Buffer" temporary; var PurchHeader: Record "Purchase Header"; VatPostingSetup: Record "VAT Posting Setup")
    begin
        OnCalculateVATAmountsAfterVatCalculationType(TempInvoicePostingBuffer, PurchHeader, VatPostingSetup);
    end;

    [IntegrationEvent(false, false)]
    local procedure OnCalculateVATAmountsAfterVatCalculationType(var TempInvoicePostingBuffer: Record "Invoice Posting Buffer" temporary; var PurchHeader: Record "Purchase Header"; VatPostingSetup: Record "VAT Posting Setup")
    begin
    end;

Additional context

We want to use our own logic for the PrepareDeferralLine function. Internal work item: AB#550247