Design details: Posting engine structure

Posting interface and some other functions in codeunit 12 use posting engine functions to prepare and insert general ledger entry and VAT entry records. The posting engine is also responsible for general ledger register creation.

The functions in the following table provide a standard framework for designing posting procedures (such as Code, CustPostApplyCustledgEntry, VendPostApplyVendLedgEntry, UnapplyCustLedgEntry, UnapplyVendLedgEntry, and Reverse) and exclusive access to table 17, G/L Entry.

RoutineDescription
StartPostingInitializes posting buffer TempGLEntryBuf, locks G/L Entry and VAT Entry tables, and initializes Accounting Period, G/L Register, and Exchange Rate. Should be called only once, then NextEntryNo is 0.
ContinuePostingChecks and posts unrealized VAT for previous transaction increment NextTransactionNo and prepares post of next line.
FinishPostingCompletes posting by inserting G/L entries from temporary buffer into database table. Always used together with StartPosting. Checks for inconsistencies.
InitGLEntryUsed to initialize new G/L entry for Gen. Jnl Line. Returns GLEntry as parameter.
InitGLEntryVATSame as InitGLEntry, but also assigns Bal. Account No. and SummarizeVAT.
InitGLEntryVATCopySimilar to InitGLEntryVAT, but also copies posting groups data from VAT Entry before SummarizeVAT.
InsertGLEntryThe only function that inserts G/L entry into global TempGLEntryBuf table. Always use this function for insert.
CreateGLEntryPerforms an InitGLEntry, assigns Additional Currency Amount, and then performs InsertGLEntry. Replaces several lines of code with a single function call.
CreateGLEntryBalAccSame as CreateGLEntry, but also assigns Bal. Account Type and Bal. Account No.
CreateGLEntryVATSame as CreateGLEntry, but with additional processing for posting groups and saving to temporary VAT buffer:

GLEntry.CopyPostingGroupsFromDtldCVBuf(DtldCVLedgEntryBuf,GenJnlLine."Gen. Posting Type");

InsertVATEntriesFromTemp(DtldCVLedgEntryBuf,GLEntry);
CreateGLEntryVATCollectAdjSame as CreateGLEntry, but with additional collection of adjustments and saving to temporary VAT buffer:

CollectAdjustment(AdjAmount,GLEntry.Amount,GLEntry."Additional-Currency Amount",OriginalDateSet);

InsertVATEntriesFromTemp(DtldCVLedgEntryBuf,GLEntry);
CreateGLEntryFromVATEntrySame as CreateGLEntry, but also copies posting groups from VAT entry.

Design Details: Posting Interface Structure

Find free e-learning modules for Business Central here