ERP Core / Accounting

Accounting - Core Domain Concepts & Structural Topology

Chart of Accounts hierarchy, normal balance rules, cost centers, and analytical accounting dimensions.

The structure of the Accounting & FMS domain is built around a strict hierarchy of accounts, immutable balance rules, and analytical dimensions that keep internal reporting flexible without polluting the primary ledger.


1. Chart of Accounts Hierarchy Tree

The COA is organized as a strict tree where only the deepest level (leaf nodes) may receive postings:

Account Class (Root)
└── Main Group
    └── Sub-Group
        └── Detail / Posting Account  ← Only this level accepts journal lines
LevelPurpose
Account ClassHighest aggregation: Assets, Liabilities, Equity, Revenue, Expenses.
Main GroupMajor financial grouping, e.g., Current Assets or Operating Expenses.
Sub-GroupMore granular classification, e.g., Trade Receivables or Marketing Expenses.
Detail / Posting AccountThe operational account used in journal entry lines.

Example Hierarchy

Account ClassMain GroupSub-GroupPosting Account
AssetsCurrent AssetsCash & EquivalentsPetty Cash
AssetsCurrent AssetsTrade ReceivablesDomestic Customers
LiabilitiesCurrent LiabilitiesTrade PayablesForeign Suppliers
RevenueOperating RevenueProduct SalesLocal Sales
ExpensesOperating ExpensesMarketingDigital Advertising

2. Normal Balance Rules

The normal balance of an account indicates the side (debit or credit) on which the account increases:

Account TypeNormal BalanceIncreaseDecrease
AssetsDebitDebitCredit
ExpensesDebitDebitCredit
LiabilitiesCreditCreditDebit
EquityCreditCreditDebit
RevenueCreditCreditDebit

Fundamental Accounting Equation

$$ \text{Assets} = \text{Liabilities} + \text{Equity} $$

This equation is preserved at all times through the double-entry system. Every transaction maintains the equality by recording equal debit and credit amounts across affected accounts.


3. Cost Centers & Analytical Accounting

Cost centers provide multi-dimensional analytical tagging without polluting the primary COA. Each journal entry line may carry one or more analytical dimensions:

DimensionExample Values
Cost CenterHead Office, Factory A, Sales Region North
ProjectWebsite Relaunch, ERP Migration
DepartmentFinance, Operations, Marketing

Analytical Tagging Rules

  • Analytical tags are stored alongside journal lines and are used for internal allocation reports.
  • Tags never alter the mathematical balance of the entry.
  • A single journal line may carry multiple analytical dimensions, but the ledger balance remains governed solely by the COA account.
  • Analytical slices must roll up to the same primary account balance; they cannot introduce shadow balances.

4. Multi-Currency Registry & Integer Minor Unit Topology

The financial management system supports global transactions across international currencies while preserving a single functional reporting ledger persisted strictly in integer minor units (e.g. cents, fils, pence).

erDiagram
    CURRENCY ||--o{ EXCHANGE_RATE : "maintains historical rates"
    CURRENCY ||--o{ JOURNAL_ENTRY : "denominates"
    JOURNAL_ENTRY ||--|{ JOURNAL_ENTRY_LINE : "contains"
    ACCOUNT ||--o{ JOURNAL_ENTRY_LINE : "posts to"
    JOURNAL_ENTRY_LINE ||--o{ GENERAL_LEDGER_POSTING : "commits to"

    CURRENCY {
        uuid id
        string code "ISO 4217 (USD, EUR, SAR)"
        string name "Currency Name"
        string symbol "Symbol ($, €, SAR)"
        integer precision "Decimal scale (0..6)"
        boolean symbol_first "Prefix vs suffix placement"
        boolean is_base "Base reporting flag"
        boolean is_active "Active toggle"
        decimal exchange_rate "Cached rate to base"
    }

    EXCHANGE_RATE {
        uuid id
        uuid currency_id
        string currency_code "ISO 4217"
        decimal rate "Direct rate: 1 Foreign = Rate Base"
        decimal inverse_rate "Inverse rate: 1 Base = Inverse Foreign"
        date effective_date "Snapshot cutoff date"
        string source "Central bank or market source"
    }

    JOURNAL_ENTRY {
        uuid id
        string entry_number "Unique voucher code"
        date entry_date "Transaction date"
        string status "draft, pending_approval, approved, posted, reversed"
        string currency "Transaction currency ISO code"
        decimal exchange_rate "Snapshot rate to base"
        integer total_debit "Integer minor units (cents)"
        integer total_credit "Integer minor units (cents)"
        string creator_id "Maker ID"
        string approver_id "Checker ID"
    }

    JOURNAL_ENTRY_LINE {
        uuid id
        uuid journal_entry_id
        uuid account_id
        uuid cost_center_id
        string type "debit / credit"
        integer amount "Transaction currency minor units"
        integer amount_functional "Base reporting currency minor units"
    }

    ACCOUNT {
        uuid id
        string code "Unique account code"
        string name "Account title"
        string type "asset, liability, equity, revenue, expense"
        string classification "class, main_group, sub_group, posting"
        string normal_balance "debit, credit"
        boolean is_leaf "True = accepts postings"
        integer current_balance "Running balance in minor units"
    }

    GENERAL_LEDGER_POSTING {
        uuid id
        uuid account_id
        uuid journal_entry_id
        uuid journal_entry_line_id
        date posting_date "Transaction date"
        integer debit "Base functional minor units"
        integer credit "Base functional minor units"
        integer balance_after "Running account balance after post"
    }

Dual-Denomination Mechanics

  1. Transaction Currency (amount): Every voucher line records the monetary value in the commercial transaction currency as integer minor units (e.g. $500.00$ USD is stored as 50000 cents).
  2. Functional Reporting Currency (amount_functional): The line records the converted equivalent in the organization’s base reporting currency, also as integer minor units: $$\text{Amount}{\text{functional}} = \operatorname{round}(\text{Amount}{\text{transaction}} \times \text{ExchangeRate})$$
  3. General Ledger Parity: General Ledger postings, Account running balances, and the Trial Balance aggregate strictly using integer functional minor units, guaranteeing zero-sum balance down to the single cent without floating-point errors.

5. Aggregate Roots & Entity Boundaries

The tactical domain model is structured into well-defined Aggregate Roots that encapsulate transactional consistency and domain invariants:

1. Journal Voucher Aggregate

  • Aggregate Root: Journal Voucher
  • Internal Entities: Journal Entry Line, Voucher Approval Link
  • Invariants Enforced: Mathematical zero-sum equality ($\sum \text{Debits} = \sum \text{Credits}$), non-leaf account prevention, Maker-Checker validation, immutability upon transition to Posted, and date-period alignment.
  • External References: References Account and Cost Center by unique identifier without holding direct aggregate references.

2. Chart of Accounts (COA) Aggregate

  • Aggregate Root: Account
  • Invariants Enforced: Hierarchical taxonomy depth, normal balance direction (Debit vs Credit), prohibition of direct postings to non-leaf aggregator accounts, and running balance cache updates.

3. Fiscal Calendar Aggregate

  • Aggregate Root: Fiscal Year
  • Internal Entities: Fiscal Period
  • Invariants Enforced: Continuous date coverage without gaps or overlaps, soft-close and hard-lock enforcement, and nominal account zeroing upon annual close.

4. Currency Master Aggregate

  • Aggregate Root: Currency
  • Internal Entities: Exchange Rate Snapshot
  • Invariants Enforced: Single sovereign base currency (rate strictly 1.0), positive exchange rates, and historical snapshot immutability.

Our Premium Sponsors

Obelaw is proudly open-source. Continued development, bug fixes, and community support are made possible by the generosity of our sponsors.

Sponsor Obelaw