microsoft / ALAppExtensions

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

[Event Request] codeunit 1250 "Match General Journal Lines" - OnPrepareVendorLedgerEntryForApplicationOnBeforeSetAmountToApply #27201

Closed RZ440 closed 6 days ago

RZ440 commented 2 months ago

Describe the request

Hello, can you please add a new Event OnPrepareVendorLedgerEntryForApplicationOnBeforeSetAmountToApply in codeunit 1250 "Match General Journal Lines"?

    local procedure PrepareVendorLedgerEntryForApplication(var VendorLedgerEntry: Record "Vendor Ledger Entry"; var GenJournalLine: Record "Gen. Journal Line")
    begin
        VendorLedgerEntry.CalcFields("Remaining Amount", "Remaining Amt. (LCY)");
        OnPrepareVendorLedgerEntryForApplicationOnBeforeSetAmountToApply(VendorLedgerEntry);
        VendorLedgerEntry."Applies-to ID" := GenJournalLine."Document No.";
        if Abs(VendorLedgerEntry."Remaining Amt. (LCY)") < Abs(GenJournalLine."Amount (LCY)") then
            VendorLedgerEntry."Amount to Apply" := VendorLedgerEntry."Remaining Amount"
        else
            VendorLedgerEntry."Amount to Apply" := -GenJournalLine.Amount;

        CODEUNIT.Run(CODEUNIT::"Vend. Entry-Edit", VendorLedgerEntry);
    end;
    [IntegrationEvent(false, false)]
    local procedure OnPrepareVendorLedgerEntryForApplicationOnBeforeSetAmountToApply(var VendorLedgerEntry: Record "Vendor Ledger Entry")
    begin
    end;

Additional context

We have additional values to calculate the Remaining Amount and need to recalculate it before being allocated and the record being modified. Internal work item: AB#547387

JesperSchulz commented 6 days ago

Availability update: We will publish a fix for this issue in the next update for release 25.

Build ID to track: 26242.