bcquality/community/knowledge/finance/post-ledger-entries-through-posting-codeunits.bad.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

24 lines
934 B
AL

// Demonstration only. Self-contained illustration, not derived from the
// Business Central base application source.
//
// BAD: insert straight into the ledger table and hand-compute Entry No.
// The row is unbalanced (no balancing entry), has no register, no resolved
// dimensions, and no VAT. FindLast + "+ 1" races under concurrency and will
// collide on the primary key. Reconciliation treats the result as corrupt.
codeunit 50100 "Post GL Adjustment"
{
procedure PostAdjustment(AccountNo: Code[20]; Amount: Decimal; PostingDate: Date)
var
GLEntry: Record "G/L Entry";
LastGLEntry: Record "G/L Entry";
begin
if LastGLEntry.FindLast() then;
GLEntry.Init();
GLEntry."Entry No." := LastGLEntry."Entry No." + 1;
GLEntry."G/L Account No." := AccountNo;
GLEntry.Amount := Amount;
GLEntry."Posting Date" := PostingDate;
GLEntry.Insert();
end;
}