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 change Request] Codeunit 13 "Gen. Jnl.-Post Batch" - OnProcessBalanceOfLinesOnAfterCalcShouldCheckDocNoBasedOnNoSeries #26999

Open RZ440 opened 1 month ago

RZ440 commented 1 month ago

Describe the request

Hello, can you please add ???LastDocNo??? and ???CurrentBalance??? to the event OnProcessBalanceOfLinesOnAfterCalcShouldCheckDocNoBasedOnNoSeries in codeunit 13 "Gen. Jnl.-Post Batch"?

local procedure ProcessBalanceOfLines(var GenJnlLine: Record "Gen. Journal Line"; var GenJnlLineVATInfoSource: Record "Gen. Journal Line"; var VATInfoSourceLineIsInserted: Boolean; var LastLineNo: Integer; CurrentICPartner: Code[20])
.
.
.
        repeat
            LineCount := LineCount + 1;
            UpdateDialog(RefPostingState::"Checking balance", LineCount, NoOfRecords);

            if not GenJnlLine.EmptyLine() then begin
                ShouldCheckDocNoBasedOnNoSeries := not PreviewMode and (GenJnlBatch."No. Series" <> '') and (LastDocNo <> GenJnlLine."Document No.");
                SkipCheckingPostingNoSeries := false;
                OnProcessBalanceOfLinesOnAfterCalcShouldCheckDocNoBasedOnNoSeries(GenJnlLine, GenJnlBatch, ShouldCheckDocNoBasedOnNoSeries, SkipCheckingPostingNoSeries, LastDocNo, CurrentBalance);
                if ShouldCheckDocNoBasedOnNoSeries then begin
#if not CLEAN24
#pragma warning disable AL0432
                    // raises the old event.
                    GenJnlLine.ObsoleteCheckDocNoBasedOnNoSeries(LastDocNo, GenJnlBatch."No. Series", NoSeriesMgt);
#pragma warning restore AL0432
#endif
                    if GenJnlLine."Document No." = NoSeriesBatch.PeekNextNo(GenJnlBatch."No. Series", GenJnlLine."Posting Date") then
                        // No. used is same as peek so need to save it.
                        NoSeriesBatch.GetNextNo(GenJnlBatch."No. Series", GenJnlLine."Posting Date")
                    else
                        // manual nos should be allowed.
                        NoSeriesBatch.TestManual(GenJnlBatch."No. Series", GenJnlLine."Document No.");
                end;
                if not SkipCheckingPostingNoSeries then
                    if GenJnlLine."Posting No. Series" <> '' then
                        GenJnlLine.TestField("Posting No. Series", GenJnlBatch."Posting No. Series");
                CheckCorrection(GenJnlLine, PaymentApplication, PaymentBalanceVAT, LastGenJournalLine);
            end;
    [IntegrationEvent(false, false)]
    local procedure OnProcessBalanceOfLinesOnAfterCalcShouldCheckDocNoBasedOnNoSeries(var GenJournalLine: Record "Gen. Journal Line"; var GenJournalBatch: Record "Gen. Journal Batch"; var ShouldCheckDocNoBasedOnNoSeries: Boolean; var SkipCheckingPostingNoSeries: Boolean; LastDocNo: Code[20]; CurrentBalance: Decimal)
    begin
    end;

Additional context

In some cases we would like to check the document number based on current balance per document. Internal work item: AB#545271