Skip to content

KB-212 – Accounting Engine Architecture

Knowledge Base ID: KB-212
Chapter: 1 - Introduction & High-Level Architecture
Project: BLACK ERP
Version: 0.1
Status: Draft
Last Updated: 2026-06-26
Applies To: ADempiere 3.9.4


Purpose

The Accounting Engine is the core component responsible for transforming business transactions into accounting entries.

Every business process in ADempiere ultimately reaches the Accounting Engine.

Examples include:

  • Purchase Orders
  • Material Receipts
  • Vendor Invoices
  • Customer Invoices
  • Payments
  • Allocations
  • Inventory Transactions
  • Bank Statements
  • GL Journals
  • Production Orders
  • Projects

Regardless of the business module, every posted document generates accounting facts through the same architecture.


Design Philosophy

ADempiere separates business logic from accounting logic.

Business documents focus on operational processes.

The Accounting Engine is responsible for translating those operations into balanced accounting entries.

This separation allows:

  • Multiple accounting schemas
  • Different accounting standards
  • Extensible posting logic
  • Custom accounting rules
  • Consistent financial reporting

High-Level Architecture

The accounting flow begins when a business document reaches the Completed status.

At that moment, ADempiere invokes the posting engine.

Business Process
        │
        ▼
Business Document
        │
        ▼
Document Engine
        │
        ▼
Accounting Engine
        │
        ▼
Accounting Facts
        │
        ▼
FACT_ACCT

The generated accounting entries are stored in the FACT_ACCT table, which represents the General Ledger.


Main Components

The Accounting Engine is composed of several cooperating classes.

Component Responsibility
DocumentEngine Controls the document lifecycle
Doc Base accounting class
Doc_* Document-specific accounting implementation
Fact Represents an accounting document
FactLine Represents a debit or credit line
MAcctSchema Defines accounting rules
MAccount Resolves valid accounting combinations
Fact_Acct Stores posted accounting entries

Each component has a single responsibility and participates in the posting process.


Business Flow vs Accounting Flow

Business processing and accounting processing are independent.

Example:

Vendor Invoice

Business Layer
--------------
Validate
Complete
Approve

Accounting Layer
----------------
Load Document
Create Facts
Generate FactLines
Save Fact_Acct

Completing a document does not necessarily generate accounting immediately.

Accounting occurs only when the posting process executes.


Accounting Pipeline

Every posted document follows the same logical sequence.

Business Event
        │
        ▼
Document Completed
        │
        ▼
Load Accounting Document
        │
        ▼
Resolve Accounts
        │
        ▼
Generate Fact
        │
        ▼
Generate FactLines
        │
        ▼
Persist into FACT_ACCT

Although each document type implements its own accounting rules, the overall pipeline remains consistent.


Supported Accounting Documents

The Accounting Engine provides specialized implementations for different document types.

Examples include:

Document Accounting Class
Invoice Doc_Invoice
Payment Doc_Payment
Allocation Doc_AllocationHdr
Shipment / Receipt Doc_InOut
Inventory Doc_Inventory
Movement Doc_Movement
Match Invoice Doc_MatchInv
Match PO Doc_MatchPO
GL Journal Doc_GLJournal

Each implementation inherits common functionality from the base Doc class.


Extensibility

One of the main strengths of ADempiere is its extensible accounting architecture.

Developers can customize posting behavior by extending document-specific classes without redesigning the entire Accounting Engine.

The Mexican VAT Cash Basis implementation developed for BLACK ERP is an example of this approach, where the allocation posting logic was extended while preserving the standard accounting framework.


Key Concepts

Before exploring the implementation details, the following concepts should be understood:

  • Business Document
  • Accounting Document
  • Posting
  • Fact
  • FactLine
  • Account Combination
  • Accounting Schema
  • General Ledger

Each concept will be covered in the following chapters.


Next Chapter

Chapter 2 explains the Document Engine and how business documents transition into accounting documents before posting begins.


Revision History

Version Date Description
0.1 2026-06-26 Initial draft - Introduction & High-Level Architecture