Skip to content

[Event Request] Codeunit 12 "Gen. Jnl.-Post Line"."Code" #27928

@fridrichovsky

Description

@fridrichovsky

Describe the request

Please add new event

local procedure "Code"(var GenJnlLine: Record "Gen. Journal Line"; CheckLine: Boolean)
var
    Balancing: Boolean;
    IsTransactionConsistent: Boolean;
    IsPosted: Boolean;
begin
    IsPosted := false;
    OnBeforeCode(GenJnlLine, CheckLine, IsPosted, GLReg, GLEntryNo);
    if IsPosted then
        exit;

    GetJournalsSourceCode();

    if GenJnlLine.EmptyLine() then begin
        InitLastDocDate(GenJnlLine);
        exit;
    end;

    if GenJnlLine."VAT Reporting Date" = 0D then begin
        GLSetup.Get();
        if (GenJnlLine."Document Date" = 0D) and (GLSetup."VAT Reporting Date" = GLSetup."VAT Reporting Date"::"Document Date") then
            GenJnlLine."VAT Reporting Date" := GenJnlLine."Posting Date"
        else
            GenJnlLine."VAT Reporting Date" := GLSetup.GetVATDate(GenJnlLine."Posting Date", GenJnlLine."Document Date");
    end;

    CheckGenJnlLine(GenJnlLine, CheckLine);

    //---------------------------------------------------------------OnCodeOnAfterCheckGenJnlLine:BEGIN
    OnCodeOnAfterCheckGenJnlLine(GenJnlLine, CheckLine);
    //---------------------------------------------------------------OnCodeOnAfterCheckGenJnlLine:END

    AmountRoundingPrecision := InitAmounts(GenJnlLine);

    if GenJnlLine."Bill-to/Pay-to No." = '' then
        case true of
            GenJnlLine."Account Type" in [GenJnlLine."Account Type"::Customer, GenJnlLine."Account Type"::Vendor]:
                GenJnlLine."Bill-to/Pay-to No." := GenJnlLine."Account No.";
            GenJnlLine."Bal. Account Type" in [GenJnlLine."Bal. Account Type"::Customer, GenJnlLine."Bal. Account Type"::Vendor]:
                GenJnlLine."Bill-to/Pay-to No." := GenJnlLine."Bal. Account No.";
        end;
    if GenJnlLine."Document Date" = 0D then
        GenJnlLine."Document Date" := GenJnlLine."Posting Date";
    if GenJnlLine."Due Date" = 0D then
        GenJnlLine."Due Date" := GenJnlLine."Posting Date";

    FindJobLineSign(GenJnlLine);

    OnBeforeStartOrContinuePosting(GenJnlLine, LastDocType.AsInteger(), LastDocNo, LastDate, NextEntryNo);

    if NextEntryNo = 0 then
        StartPosting(GenJnlLine)
    else
        ContinuePosting(GenJnlLine);

    OnCodeOnAfterStartOrContinuePosting(GenJnlLine, LastDocType, LastDocNo, LastDate, NextEntryNo);

    if GenJnlLine."Account No." <> '' then begin
        if (GenJnlLine."Bal. Account No." <> '') and
           (not GenJnlLine."System-Created Entry") and
           (GenJnlLine."Account Type" in
            [GenJnlLine."Account Type"::Customer,
             GenJnlLine."Account Type"::Vendor,
             GenJnlLine."Account Type"::"Fixed Asset"])
        then begin
            CODEUNIT.Run(CODEUNIT::"Exchange Acc. G/L Journal Line", GenJnlLine);
            //----------------------------------------------------OnCodeOnAfterRunExhangeAccGLJournalLine:BEGIN
            //OnCodeOnAfterRunExhangeAccGLJournalLine(GenJnlLine, Balancing, NextEntryNo);
            OnCodeOnAfterRunExhangeAccGLJournalLine(GenJnlLine, Balancing, NextEntryNo, JobLine);
            //----------------------------------------------------OnCodeOnAfterRunExhangeAccGLJournalLine:END
            Balancing := true;
        end;

        PostGenJnlLine(GenJnlLine, Balancing);
    end;

    if GenJnlLine."Bal. Account No." <> '' then begin
        CODEUNIT.Run(CODEUNIT::"Exchange Acc. G/L Journal Line", GenJnlLine);
        //----------------------------------------------------OnCodeOnAfterRunExhangeAccGLJournalLine:BEGIN
        //OnCodeOnAfterRunExhangeAccGLJournalLine(GenJnlLine, Balancing, NextEntryNo);
        OnCodeOnAfterRunExhangeAccGLJournalLine(GenJnlLine, Balancing, NextEntryNo, JobLine);
        //----------------------------------------------------OnCodeOnAfterRunExhangeAccGLJournalLine:END
        PostGenJnlLine(GenJnlLine, not Balancing);
    end;

    CheckPostUnrealizedVAT(GenJnlLine, true);

    CreateDeferralScheduleFromGL(GenJnlLine, Balancing);

    OnCodeOnBeforeFinishPosting(GenJnlLine, Balancing, FirstEntryNo);
    IsTransactionConsistent := FinishPosting(GenJnlLine);

    OnAfterGLFinishPosting(
        GlobalGLEntry, GenJnlLine, IsTransactionConsistent, FirstTransactionNo, GLReg, TempGLEntryBuf,
        NextEntryNo, NextTransactionNo);

    GLEntryInconsistent := not IsTransactionConsistent;
end;

//---------------------------------------------------------------OnCodeOnAfterCheckGenJnlLine:BEGIN
[IntegrationEvent(true, false)]
local procedure OnCodeOnAfterCheckGenJnlLine(var GenJnlLine: Record "Gen. Journal Line"; CheckLine: Boolean)
begin
end;
//---------------------------------------------------------------OnCodeOnAfterCheckGenJnlLine:END

//----------------------------------------------------OnCodeOnAfterRunExhangeAccGLJournalLine:BEGIN
[IntegrationEvent(true, false)]
//local procedure OnCodeOnAfterRunExhangeAccGLJournalLine(var GenJournalLine: Record "Gen. Journal Line"; Balancing: Boolean; var NextEntryNo: Integer)
local procedure OnCodeOnAfterRunExhangeAccGLJournalLine(var GenJournalLine: Record "Gen. Journal Line"; Balancing: Boolean; var NextEntryNo: Integer; var JobLine: Boolean)
begin
end;
//----------------------------------------------------OnCodeOnAfterRunExhangeAccGLJournalLine:END

Additional context

We need OnCodeOnAfterCheckGenJnlLine for check after all standard checks.
We need split OnCodeOnAfterRunExhangeAccGLJournalLine event when run for Bal. Account and when not. May be some bool paramater helps.
We need option know and change global variabl JobLine

Internal work item: AB#562613

Metadata

Metadata

Assignees

No one assigned

    Labels

    FinanceGitHub request for Finance areaevent-requestRequest for adding an eventships-in-future-updateFix ships in a future update

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions