ERP Core / Accounting

Accounting - Operational Workflows & State Machines

Journal entry lifecycle, fiscal year-end close, and state transition tables for financial documents.

The Accounting & FMS domain defines explicit workflows and state machines to ensure that every financial document moves through a controlled, auditable lifecycle.


1. Journal Entry Lifecycle

flowchart LR
    A[Draft Preparation] --> B{Balance Validation}
    B -->|Invalid| A
    B -->|Valid| C[Maker-Checker Approval]
    C -->|Rejected| A
    C -->|Approved| D[Posting]
    D --> E[General Ledger Lock]
StageBusiness Responsibility
Draft PreparationA user creates a journal voucher and attaches debit/credit lines.
Balance ValidationThe system enforces the zero-sum rule before allowing progression.
Maker-Checker ApprovalA second authorized user reviews and approves the voucher.
PostingThe voucher is committed to the GL and account balances are updated.
GL LockPosted entries become immutable and traceable in reporting.

Maker-Checker Separation

The approver of a journal voucher must be a different actor than its creator. This separation of duties prevents single-actor fraud and satisfies common internal control frameworks.


2. Journal Entry State Transitions

Current StateTrigger / EventNext StateBusiness Validation Rule
DraftSubmit for reviewPending ApprovalVoucher must balance; period must be open.
Pending ApprovalApprover rejectsRejectedRejection reason is mandatory.
Pending ApprovalApprover approvesApprovedApprover is not the voucher creator.
ApprovedPost command issuedPostedPeriod is open; no pending reversals exist.
PostedReverse command issuedReversedA reversing journal voucher is created and posted.

State Invariants

  • A voucher in Rejected state can be edited and resubmitted.
  • A voucher in Approved state cannot be edited; it must either be posted or sent back to draft by an authorized officer.
  • A voucher in Posted state can only transition to Reversed through a formal reversal document.

3. Fiscal Year-End Close

flowchart TB
    A[Period Reconciliation] --> B[Income Summary Transfer]
    B --> C[Retained Earnings Transfer]
    C --> D[Nominal Account Zeroing]
    D --> E[Opening Balance Roll-forward]
    E --> F[Period Lock]
StepDescription
Period ReconciliationAll sub-ledgers, bank statements, and control accounts are reconciled.
Income Summary TransferRevenue and expense accounts are closed to a temporary Income Summary account.
Retained Earnings TransferThe net result is transferred to Retained Earnings within Equity.
Nominal Account ZeroingRevenue and expense accounts begin the new period with zero balance.
Opening Balance Roll-forwardAsset, liability, and equity balances are carried forward as opening balances.
Period LockThe closed period is locked to prevent retroactive changes.

Close Preconditions

Before a fiscal year can be closed, the system verifies:

  • All journal vouchers for the period are posted.
  • All sub-ledgers reconcile with the General Ledger.
  • All required audit adjustments have been recorded.

4. Multi-Currency Conversion & Exchange Rate Ingestion Workflow

flowchart TD
    A[Rate Ingestion Source<br/>Central Bank / Commercial Feed / Authorized User] --> B[Currency Validation<br/>Verify ISO 4217 code exists & active]
    B --> C{Invariant Gate<br/>Base Currency?}
    C -->|Yes: Rate != 1.0| D[Reject: Base Rate Must Equal 1.0]
    C -->|No: Rate > 0| E[Compute Direct & Inverse Rates<br/>Direct: 1 Foreign = Rate Base<br/>Inverse: 1 Base = 1/Rate Foreign]
    E --> F[Persist Historical Rate Snapshot<br/>Date-stamped effective rate record]
    F --> G[Update Effective Current Rate<br/>Cached rate for operational conversions]
    G --> H[Emit Event: ExchangeRateUpdated<br/>Append Forensic Audit Trail]
    H --> I[Conversion Engine Ready<br/>Direct, Inverse, & Triangulated conversions]

Multi-Currency Conversion Rules

All multi-currency operations adhere to deterministic conversion and precision rules:

  1. Direct Conversion (Foreign to Base): Transaction amounts denominated in foreign currencies are converted to the base functional currency by multiplying the transaction amount by the effective direct exchange rate: $$\text{Amount}{\text{functional}} = \operatorname{round}(\text{Amount}{\text{transaction}} \times \text{ExchangeRate}_{\text{direct}})$$

  2. Inverse Conversion (Base to Foreign): For budgetary allocations and quotations originated in the functional currency, conversion to foreign denominations applies the reciprocal inverse rate ($1 / \text{Rate}$).

  3. Cross-Rate Triangulation: Direct cross-currency conversions between two non-base foreign currencies ($A$ and $B$) route deterministically through the base functional currency to eliminate bilateral arbitrage and rounding inconsistencies: $$\text{Rate}(A \to B) = \frac{\text{RateToBase}(A)}{\text{RateToBase}(B)}$$

  4. Integer Minor Unit Parity: All conversions are executed and rounded into integer minor units (such as cents, pence, or fils). This guarantees that rounding differences are captured explicitly in designated foreign exchange gain/loss accounts rather than contaminating ledger balance equations.


5. Reversal & Correction Workflow (Storno Pattern)

When an error is detected in a posted journal voucher, the immutability invariant prevents modification or deletion. Corrections follow a formal Storno reversal lifecycle:

sequenceDiagram
    participant Auditor as Finance Officer / Maker
    participant Validation as Invariant Engine
    participant Checker as Authorized Approver
    participant Ledger as General Ledger
    participant Audit as Forensic Audit Log

    Auditor->>Validation: Request Reversal for Posted Voucher #JV-1000
    Validation->>Validation: Verify Target Voucher is in "Posted" State
    Validation->>Validation: Verify Target Period or Active Period is Open
    Validation->>Auditor: Generate Draft Reversal Voucher #JV-1001 (Storno)
    Auditor->>Checker: Submit Reversal with Documented Reason
    Checker->>Validation: Validate Zero-Sum Balance & Period Lock
    Checker->>Ledger: Approve & Post Reversal Voucher #JV-1001
    Ledger->>Ledger: Post Equal & Inverted Debits/Credits
    Ledger->>Audit: Append Correction Chain Link (JV-1000 ↔ JV-1001)
    Audit->>Audit: Emit Event: JournalEntryReversed

Correction Protocol Invariants

  1. Explicit Lineage: Every reversal voucher maintains an explicit reference to the original erroneous voucher.
  2. Current Period Posting: If the original voucher was posted in a closed fiscal period, the reversal voucher is posted into the earliest open fiscal period, preventing retroactive disruption of filed financial returns.
  3. Replacement Vouchers: When a corrected transaction is required to replace the reversed entry, the replacement voucher references both the original and reversal documents, completing a three-way correction chain.
  4. Segregation of Duties: Reversal vouchers require the same Maker-Checker approval protocol as standard commercial journal vouchers.

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