microsoft / ALAppExtensions

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

[Event Request] Codeunit 13 "Gen. Jnl.-Post Batch" – OnUpdateAndDeleteLinesOnBeforeUpdateLine #27005

Open RZ440 opened 1 month ago

RZ440 commented 1 month ago

Describe the request

Hello, can you please add a new event OnUpdateAndDeleteLinesOnBeforeUpdateLine in codeunit 13 "Gen. Jnl.-Post Batch"?

    local procedure UpdateAndDeleteLines(var GenJnlLine: Record "Gen. Journal Line")
    var
        TempGenJnlLine2: Record "Gen. Journal Line" temporary;
        RecordLinkManagement: Codeunit "Record Link Management";
        OldVATAmount: Decimal;
        OldVATPct: Decimal;
        IsHandled: Boolean;
    begin
        IsHandled := false;
        OnBeforeUpdateAndDeleteLines(GenJnlLine, SuppressCommit, IsHandled);
        if IsHandled then
            exit;

        ClearDataExchEntries(GenJnlLine);
        if GenJnlTemplate.Recurring then begin
            // Recurring journal
            LineCount := 0;
            GenJnlLine2.Copy(GenJnlLine);
            GenJnlLine2.SetCurrentKey("Journal Template Name", "Journal Batch Name", "Line No.");
            GenJnlLine2.FindSet(true);
            repeat
                LineCount := LineCount + 1;
                UpdateDialog(RefPostingState::"Updating lines", LineCount, NoOfRecords);
                IsHandled := false;
                OnUpdateAndDeleteLinesOnBeforeUpdateLine(GenJnlLine2, IsHandled);
                if not IsHandled then begin
                    OldVATAmount := GenJnlLine2."VAT Amount";
                    OldVATPct := GenJnlLine2."VAT %";
                    OnUpdateAndDeleteLinesOnBeforeUpdatePostingDate(GenJnlLine2);
                    if ShouldUpdateRecurringGenJournalLinePostingDate(GenJnlLine2) then
                        GenJnlLine2.Validate(
                          "Posting Date", CalcDate(GenJnlLine2."Recurring Frequency", GenJnlLine2."Posting Date"));
                   if not
                       (GenJnlLine2."Recurring Method" in
                        [GenJnlLine2."Recurring Method"::"F  Fixed",
                         GenJnlLine2."Recurring Method"::"RF Reversing Fixed"])
                    then
                        MultiplyAmounts(GenJnlLine2, 0)
                    else
                        if (GenJnlLine2."VAT %" = OldVATPct) and (GenJnlLine2."VAT Amount" <> OldVATAmount) then
                            GenJnlLine2.Validate("VAT Amount", OldVATAmount);
                    OnUpdateAndDeleteLinesOnBeforeModifyRecurringLine(GenJnlLine2);
                    GenJnlLine2.Modify();
                    OnUpdateAndDeleteLinesOnAfterModifyRecurringLine(GenJnlLine2);
                end;
            until GenJnlLine2.Next() = 0;
    [IntegrationEvent(false, false)]
    local procedure OnUpdateAndDeleteLinesOnBeforeUpdateLine(var GenJournalLine2: Record "Gen. Journal Line"; var IsHandled: Boolean)
    begin
    end;

Additional context

We would like to skip some lines that cannot easily be filtered. Internal work item: AB#545262