bcquality/community/knowledge/finance/post-ledger-entries-through-posting-codeunits.good.al
Jesper Schulz-Wedde 3cb00e4d2d Add Finance posting domain-knowledge pilot
Adds three atomic domain-rule knowledge files under community/knowledge/finance/ as a pilot for Type-A (normative) Business Central domain knowledge: post through the posting engine, treat posted ledger entries as immutable, and treat the Dimension Set ID as the source of truth for dimensions. Includes a good/bad AL sample pair for the posting rule.

These encode BC-specific invariants that LLMs reliably get wrong, fitting the existing remedial/atomic knowledge grain with no schema or contract changes. Passes the repo frontmatter validator and is discovered by the knowledge index.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-26 10:40:50 +02:00

26 lines
1.1 KiB
AL

// Demonstration only. Self-contained illustration, not derived from the
// Business Central base application source.
//
// GOOD: build a journal line and let the posting engine create the ledger
// entry. The platform assigns Entry No., writes the balancing entry, creates
// the register, and resolves dimensions and VAT.
codeunit 50100 "Post GL Adjustment"
{
procedure PostAdjustment(AccountNo: Code[20]; BalAccountNo: Code[20]; Amount: Decimal; PostingDate: Date)
var
GenJnlLine: Record "Gen. Journal Line";
GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line";
begin
GenJnlLine.Init();
GenJnlLine."Posting Date" := PostingDate;
GenJnlLine."Document Type" := GenJnlLine."Document Type"::" ";
GenJnlLine."Account Type" := GenJnlLine."Account Type"::"G/L Account";
GenJnlLine.Validate("Account No.", AccountNo);
GenJnlLine."Bal. Account Type" := GenJnlLine."Bal. Account Type"::"G/L Account";
GenJnlLine.Validate("Bal. Account No.", BalAccountNo);
GenJnlLine.Validate(Amount, Amount);
GenJnlLine."Source Code" := 'ADJUST';
GenJnlPostLine.Run(GenJnlLine);
end;
}