microsoft / ALAppExtensions

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

[Event Request] Codeunit 12 "Gen. Jnl.-Post Line" - OnInitGLEntryVATOnBeforeSummarizeVAT #27009

Open RZ440 opened 3 months ago

RZ440 commented 3 months ago

Describe the request

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

    procedure InitGLEntryVAT(GenJnlLine: Record "Gen. Journal Line"; AccNo: Code[20]; BalAccNo: Code[20]; Amount: Decimal; AmountAddCurr: Decimal; UseAmtAddCurr: Boolean)
    var
        GLEntry: Record "G/L Entry";
    begin
        OnBeforeInitGLEntryVAT(GenJnlLine, GLEntry);
        if UseAmtAddCurr then
            InitGLEntry(GenJnlLine, GLEntry, AccNo, Amount, AmountAddCurr, true, true)
        else begin
            InitGLEntry(GenJnlLine, GLEntry, AccNo, Amount, 0, false, true);
            GLEntry."Additional-Currency Amount" := AmountAddCurr;
            GLEntry."Bal. Account No." := BalAccNo;
        end;
        OnInitGLEntryVATOnBeforeSummarizeVAT(GenJnlLine, GLEntry, VATEntry);
        SummarizeVATFromInitGLEntryVAT(GLEntry, Amount);
        OnAfterInitGLEntryVAT(GenJnlLine, GLEntry);
    end;
    [IntegrationEvent(false, false)]
    local procedure OnInitGLEntryVATOnBeforeSummarizeVAT(GenJournalLine: Record "Gen. Journal Line"; var GLEntry: Record "G/L Entry"; VATEntry: Record "VAT Entry")
    begin
    end;

Additional context

You rejected the request recommending to use OnAfterCopyGLEntryFromGenJnlLine(Rec, GenJnlLine) in CopyFromGenJnlLine called from InitGLEntry. We are using OnAfterCopyGLEntryFromGenJnlLine to fill additional fields that are to be set in all G/L Entries. But some fields we would like to set only in G/L Entries created in InitGLEntryVAT, but in InitGLEntry/CopyFromGenJnlLine/OnAfterCopyGLEntryFromGenJnlLine we do not know where it is called from. Internal work item: AB#544405