microsoft / ALAppExtensions

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

Codeunit 5988 - OnPostDocumentLinesAfterPostLedgerEntry #26774

Closed LaChris123 closed 4 days ago

LaChris123 commented 6 days ago

Describe the request

The following events are required for this object:

[IntegrationEvent(false, false)] local procedure OnPostDocumentLinesAfterPostLedgerEntry(ServiceHeader: Record "Service Header"; var TotalServiceLine: Record "Service Line"; ServiceLine: Record "Service Line"; var ServPostingJnlsMgt: Codeunit "Serv-Posting Journals Mgt."; GenJnlLineDocType: Enum "Gen. Journal Document Type"; GenJnlLineDocNo: Code[20]; GenJnlLineExtDocNo: Code[35]; var InvoicePostingInterface: Interface "Invoice Posting"; var Window: Dialog; var IsHandled: Boolean) begin end;

Additional context

procedure PostDocumentLines(var Window: Dialog)
var 
begin
...          
      // Post sales and VAT to G/L entries from posting buffer
        if Invoice then begin
#if not CLEAN20
            if ServMgtSetup."Invoice Posting Setup" = "Service Invoice Posting"::"Invoice Posting (Default)" then begin
                OnPostDocumentLinesOnBeforePostInvoicePostBuffer(
                    ServHeader, TempInvoicePostBuffer, TotalServiceLine, TotalServiceLineLCY);
                LineCount := 0;
                if TempInvoicePostBuffer.Find('+') then
                    repeat
                        LineCount += 1;
                        //EVENT REQUEST
                        IsHandled := false;
                        OnUpdateWindow3BeforePostDocumentLines(ServHeader, Window, IsHandled);
                        if not IsHandled then
                            //EVENT REQUEST
                            Window.Update(3, LineCount);
                        ServPostingJnlsMgt.SetPostingDate("Posting Date");
                        ServPostingJnlsMgt.PostInvoicePostBufferLine(
                            TempInvoicePostBuffer, GenJnlLineDocType.AsInteger(), GenJnlLineDocNo, GenJnlLineExtDocNo);
                    until TempInvoicePostBuffer.Next(-1) = 0;
            end else begin
#endif
                GetInvoicePostingParameters();
                InvoicePostingInterface.SetParameters(InvoicePostingParameters);
                InvoicePostingInterface.SetTotalLines(TotalServiceLine, TotalServiceLineLCY);
                ServPostingJnlsMgt.PostLines(ServHeader, InvoicePostingInterface, Window, TotalAmount);
#if not CLEAN20
            end;
#endif

            // Post customer entry
                Window.Update(4, 1);
#if not CLEAN20
            if ServMgtSetup."Invoice Posting Setup" = "Service Invoice Posting"::"Invoice Posting (Default)" then begin
                ServPostingJnlsMgt.SetPostingDate("Posting Date");
                ServPostingJnlsMgt.PostCustomerEntry(
                    TotalServiceLine, TotalServiceLineLCY, GenJnlLineDocType.AsInteger(), GenJnlLineDocNo, GenJnlLineExtDocNo);
            end else
#endif
            ServPostingJnlsMgt.PostLedgerEntry(ServHeader, InvoicePostingInterface);

            // post Balancing account
            //EVENT REQUEST
            IsHandled := false;
            OnPostDocumentLinesAfterPostLedgerEntry(ServHeader, TotalServiceLine, ServLine, ServPostingJnlsMgt, GenJnlLineDocType, GenJnlLineDocNo, GenJnlLineExtDocNo, InvoicePostingInterface, Window, IsHandled);
            if not IsHandled then
                //EVENT REQUEST
                if "Bal. Account No." <> '' then begin
                    Window.Update(5, 1);
#if not CLEAN20
                    if ServMgtSetup."Invoice Posting Setup" = "Service Invoice Posting"::"Invoice Posting (Default)" then begin
                        ServPostingJnlsMgt.SetPostingDate("Posting Date");
                        ServPostingJnlsMgt.PostBalancingEntry(
                            TotalServiceLine, TotalServiceLineLCY, GenJnlLineDocType.AsInteger(), GenJnlLineDocNo, GenJnlLineExtDocNo);
                    end else
#endif
                ServPostingJnlsMgt.PostBalancingEntry(ServHeader, InvoicePostingInterface);
                end;
        end;

Internal work item: AB#539995

JesperSchulz commented 4 days ago

Thanks for reporting this. We agree, and we’ll publish a fix asap, either in an update for the current version or in the next major release. Please do not reply to this, as we do not monitor closed issues. If you have follow-up questions or requests, please create a new issue where you reference this one.

Build ID: 21513.