ALAppExtensions icon indicating copy to clipboard operation
ALAppExtensions copied to clipboard

[Event Request] codeunit 90 "Purch.-Post" - OnPostInvoiceOnBeforePostLedgerEntry

Open RZ440 opened this issue 2 years ago • 2 comments

Describe the request

Hello, can you please add a new event OnPostInvoiceOnBeforePostLedgerEntry to codeunit 90 "Purch.-Post"?

    local procedure PostInvoice(var PurchHeader: Record "Purchase Header")
    var
        TotalAmount: Decimal;
        IsHandled: Boolean;
    begin
        IsHandled := false;
        OnBeforePostInvoice(PurchHeader, PreviewMode, SuppressCommit, GenJnlPostLine, IsHandled, Window, HideProgressWindow, TotalPurchLine, TotalPurchLineLCY, InvoicePostingInterface, InvoicePostingParameters, GenJnlLineDocNo, GenJnlLineExtDocNo, GenJnlLineDocType, SrcCode);
        if IsHandled then
            exit;

        with PurchHeader do begin
            // Post purchase and VAT to G/L entries from buffer
#if not CLEAN23
            if UseLegacyInvoicePosting() then
                PostInvoicePostingBuffer(PurchHeader, TotalAmount)
            else begin
#endif
                GetInvoicePostingParameters();
                InvoicePostingInterface.SetParameters(InvoicePostingParameters);
                InvoicePostingInterface.SetTotalLines(TotalPurchLine, TotalPurchLineLCY);
                InvoicePostingInterface.PostLines(PurchHeader, GenJnlPostLine, Window, TotalAmount);
#if not CLEAN23
            end;
#endif

            OnPostInvoiceOnAfterPostLines(PurchHeader, SrcCode, GenJnlLineDocType, GenJnlLineDocNo, GenJnlLineExtDocNo, GenJnlPostLine, TotalPurchLine, TotalPurchLineLCY);

            // Check External Document number
            if PurchSetup."Ext. Doc. No. Mandatory" or (GenJnlLineExtDocNo <> '') then
                CheckExternalDocumentNumber(VendLedgEntry, PurchHeader);

            // Post vendor entries
            if GuiAllowed and not HideProgressWindow then
                Window.Update(4, 1);

            IsHandled := false;
            OnPostInvoiceOnBeforePostLedgerEntry(PurchHeader, TotalPurchLine, GenJnlPostLine, TotalPurchLineLCY, SuppressCommit, VendLedgEntry, IsHandled);
            if IsHandled then
                exit;

#if not CLEAN23
            if UseLegacyInvoicePosting() then
                PostVendorEntry(
                    PurchHeader, TotalPurchLine, TotalPurchLineLCY, GenJnlLineDocType, GenJnlLineDocNo, GenJnlLineExtDocNo, SrcCode)
            else
#endif
            InvoicePostingInterface.PostLedgerEntry(PurchHeader, GenJnlPostLine);
[IntegrationEvent(false, false)]
local procedure OnPostInvoiceOnBeforePostLedgerEntry(PurchHeader: Record "Purchase Header"; TotalPurchLine: Record "Purchase Line"; var GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line"; TotalPurchLineLCY: Record "Purchase Line"; CommitIsSupressed: Boolean; var VendorLedgerEntry: Record "Vendor Ledger Entry"; var IsHandled: Boolean)
begin
end;

Additional context

An event is needed to stop posting in certain scenarios. Internal work item: AB#500432

RZ440 avatar Feb 13 '24 06:02 RZ440

Please provide more details about this requirement. What exactly you need to skip and why you cannot do it using your own implementation of this posting procedure?

AlexanderYakunin avatar Feb 20 '24 07:02 AlexanderYakunin

After consulting with the responsible developers, we agreed that we didn't need the event. The ticket can be closed.

RZ440 avatar Feb 20 '24 15:02 RZ440