ERP Core / Accounting

Accounting - Domain Invariants & Business Rules

Invariants governing the zero-sum rule, immutability of posted entries, closed fiscal period locks, and precision integrity.

Domain Invariants & Business Rules (“The Law”)

Domain invariants represent absolute truths that the Accounting & FMS domain enforces. Any transaction violating these invariants is aborted.


1. Mathematical Zero-Sum Rule (Exact Integer Minor Unit Parity)

Every posted journal voucher must satisfy the fundamental double-entry equation down to the exact single minor unit (cent/fils):

$$ \sum \text{Debits} - \sum \text{Credits} = 0 \quad (\text{Exact integer parity in minor units}) $$

  • The Law: Total debits must equal total credits with zero imbalance. Even a single minor unit disparity (e.g., $0.01 or 1 cent) is strictly rejected.
  • Transaction Rule: If the zero-sum rule is violated, the system rejects the submission or posting entirely. No partial or unbalanced posting is ever permitted.
  • Multi-Leg Odd Cent Handling: When allocating split entries (such as three-way expense distributions), line items must balance in integer minor units (e.g., 10,000 cents debited, credits distributed as 3,333 + 3,333 + 3,334 = 10,000 cents).
  • Multi-Currency Rule: For vouchers involving foreign currencies, line items balance in transaction currency minor units, while functional currency equivalents balance in base functional minor units.

Structural Consequence of Violation

If a journal voucher were posted with unequal debits and credits, the General Ledger would drift from the fundamental accounting equation. This would produce invalid Trial Balance totals, inaccurate Balance Sheets, and unreconcilable statutory reports.


2. Immutability of Posted Entries

Once a journal entry transitions to Posted, it becomes immutable.

  • The Law: A posted journal voucher can never be updated or deleted in place.
  • Prohibited Operations: Editing amounts, adding or removing lines, changing accounts, altering cost centers, backdating the document, or deleting the voucher. The domain strictly rejects any in-place mutation or deletion of posted records.
  • Corrective Path: All corrections must be performed through the Storno reversal pattern, generating an offsetting posted voucher and preserving the complete audit trail.

Audit Rationale

Immutability is essential for regulatory compliance and forensic auditing. If posted entries could be silently modified, financial statements would lose their evidential value, and auditors could no longer rely on the ledger as a source of truth.


3. Closed Fiscal Period Lock

A closed or locked accounting period rejects any new posting.

  • The Law: Zero transactions can be posted into a locked or closed accounting period.
  • Transaction Rule: Any posting command targeting a closed or locked period is strictly rejected.
  • Reopening Rule: Reopening a closed period requires an explicit administrative action and is itself logged in the audit trail with a mandatory reason.

Reporting Consequence

The period lock invariant protects historical financial statements from retroactive alteration. Once a period is closed, its reports can be published to regulators, investors, and management with confidence.


4. Integer Minor Unit Precision Integrity

All monetary amounts within the Accounting domain are maintained as 64-bit integers in minor units (cents, pence, fils, halalas).

  • The Law: Ledger postings, account balances, and journal line items store integer minor units, completely eliminating floating-point rounding errors.
  • Minor Unit Ingestion: Transaction amounts submitted in decimal representations are converted to integer minor units at the domain boundary using the currency’s defined decimal precision multiplier (e.g. $12.50 \times 10^2 = 1250$).
  • Presentation Rendering: User-facing interfaces format stored minor units into standard decimal expressions (e.g. 1250 cents rendered as $12.50) without altering internal integer storage.

Numerical Correctness

Without integer minor unit precision, repeated binary floating-point representation errors could accumulate across millions of transactions, causing Trial Balance totals to disagree with source document sums by fractional but materially significant amounts.


5. Multi-Currency & Foreign Exchange (FX) Invariants

Operating multi-currency accounting requires mathematical invariants to protect ledger comparability and legal reporting:

1. Base Currency Rate Unitary Invariance

  • The Law: The organization’s base functional reporting currency exchange rate strictly equals $1.000000$ at all times.
  • Enforcement: Any administrative attempt to assign a non-unitary rate to the base currency is strictly rejected.

2. Strictly Positive Exchange Rates

  • The Law: All direct and inverse exchange rates must satisfy $\text{Rate} > 0$. Zero or negative values violate economic reality and are strictly rejected.

3. Single Sovereign Functional Currency

  • The Law: Exactly one currency may be designated as the active base functional currency. Designating a new base currency automatically demotes the previous base currency and generates an immutable forensic audit log.

4. Deterministic FX Triangulation

  • The Law: Cross-rate conversions between two foreign non-base currencies ($A$ and $B$) must triangulate consistently through the base functional currency: $$\text{CrossRate}(A \to B) = \frac{\text{RateToBase}(A)}{\text{RateToBase}(B)}$$

5. Point-In-Time Historical Snapshotting

  • The Law: When a journal voucher is prepared and posted, its exchange rate is permanently snapshot in the document header and line items. Future exchange rate adjustments never rewrite historical vouchers retroactively.

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