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 12 "Gen. Jnl.-Post Line" - OnCreateGLEntryVATOnBeforeInsertGLEntry #27012

Open RZ440 opened 1 month ago

RZ440 commented 1 month ago

Describe the request

In the Event Request #26834 we asked for a new event OnCreateGLEntryVATOnBeforeInsertGLEntry in Codeunit 12 "Gen. Jnl.-Post Line".

    procedure CreateGLEntryVAT(GenJnlLine: Record "Gen. Journal Line"; AccNo: Code[20]; Amount: Decimal; AmountAddCurr: Decimal; VATAmount: Decimal; DtldCVLedgEntryBuf: Record "Detailed CV Ledg. Entry Buffer")
    var
        GLEntry: Record "G/L Entry";
    begin
        OnBeforeCreateGLEntryVAT(GenJnlLine, DtldCVLedgEntryBuf);
        InitGLEntry(GenJnlLine, GLEntry, AccNo, Amount, 0, false, true);
        GLEntry."Additional-Currency Amount" := AmountAddCurr;
        GLEntry."VAT Amount" := VATAmount;
        GLEntry.CopyPostingGroupsFromDtldCVBuf(DtldCVLedgEntryBuf, DtldCVLedgEntryBuf."Gen. Posting Type".AsInteger());
        OnCreateGLEntryVATOnBeforeInsertGLEntry(GenJnlLine, GLEntry);
        InsertGLEntry(GenJnlLine, GLEntry, true);
        InsertVATEntriesFromTemp(DtldCVLedgEntryBuf, GLEntry);
    end;
    [IntegrationEvent(false, false)]
    local procedure OnCreateGLEntryVATOnBeforeInsertGLEntry(GenJournalLine: Record "Gen. Journal Line"; var GLEntry: Record "G/L Entry")
    begin
    end;

Additional context

You rejected the request recommending to use OnBeforeInsertGlEntry. But we would like to set some fields only in G/L Entries created in CreateGLEntryVAT, but in InsertGLEntry we do not know where it is called from. Internal work item: AB#544382