Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
fridrichovsky opened this issue Jan 13, 2025 · 0 comments
Open

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

fridrichovsky opened this issue Jan 13, 2025 · 0 comments
Labels
event-request Request for adding an event Finance GitHub request for Finance area

Comments

@fridrichovsky
Copy link
Contributor

fridrichovsky commented Jan 13, 2025

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

@JesperSchulz JesperSchulz added event-request Request for adding an event Finance GitHub request for Finance area labels Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
event-request Request for adding an event Finance GitHub request for Finance area
Projects
None yet
Development

No branches or pull requests

2 participants