Orbit PlatformFinancial Ledgers & Multi-Vertical AccountingIntermediate

Orbit Universal Double-Entry General Ledger & Multi-Vertical Chart of Accounts Specification

Exhaustive financial accounting specification and systems manual for Orbit universal double-entry general ledger, mathematical debit=credit invariants, multi-vertical Chart of Accounts (COA), day-end Z-report reconciliation, and immutable fiscal period locking.

·
8 min read

1. Accounting Topology & System Architecture

The core accounting engine is defined in database migration 027_phase8_labels_promos_ledger_zreports.sql and orchestrated by apps/api/src/modules/commerce/services/commerce-accounting.service.ts. It provides an enterprise double-entry accounting foundation that records the financial impact of every physical transaction:

[Operational Transaction Ingress]
 (Sales, Returns, Reagent Dosing, Faculty Payroll, Fee Challans)
                 |
                 v
  [Universal Accounting Service Engine]
  - Resolves Chart of Accounts Head (accounts table)
  - Constructs Balanced Journal Voucher (journal_entries table)
  - Synthesizes Line-Item Debits & Credits (journal_lines table)
                 |
                 v
   [Mathematical Balance Invariant Gate]
   Invariant: sum(journal_lines.debit) === sum(journal_lines.credit)
                 |
       +---------+---------+
       |                   |
   [BALANCED]          [UNBALANCED]
       |                   |
 [Post to Ledger]     [Reject: SQL Invariant Error]

2. Interactive General Ledger Journal Console

Financial controllers, bursars, and chief accountants audit real-time general ledger postings, inspect T-accounts, and verify day-end closing vouchers via the central financial console:

Orbit Universal General Ledger & Chart of Accounts
Production UI
Double-Entry Journal Verification, Multi-Vertical Ledgers & Trial Balance AuditingUniversal General Ledger Console
Total Journal Debits
PKR 14,820,500
Current Accounting Period
Status: Verified Balanced
Total Journal Credits
PKR 14,820,500
Current Accounting Period
Mathematical Imbalance: 0.00
Active Accounts (COA)
48 HEADS
5 Master Account Classes
Multi-Vertical Mappings Active
Z-Report Ledgers
100% POSTED
Zero Unposted Registers
All Till Vouchers Closed
Double-Entry Journal Entry Preview (#JV-2026-1042)
Balanced 100%
Account CodeAccount TitleClassificationDebit (PKR)Credit (PKR)
GL 1010Operational Bank ClearingAsset85,000.000.00
GL 4010Sales Revenue · Retail & F&BRevenue0.0073,275.86
GL 2110Output Sales Tax / VAT PayableLiability0.0011,724.14
Trial Balance Invariant Sum:85,000.0085,000.00

3. Relational Schema & Mathematical Invariant Design

The database schema models double-entry accounting through four primary relational tables:

3.1 Relational Models

  1. accounts: Master Chart of Accounts hierarchy storing account codes, descriptive titles, account classification types (ASSET, LIABILITY, EQUITY, REVENUE, EXPENSE), and active statuses.
  2. journal_entries: Header records containing unique sequential entry numbers (entryNo), operational source references (referenceType, referenceId), human audit descriptions, posting timestamps, and authorizing user IDs.
  3. journal_lines: Individual transaction legs recording the target accountId, debit amount, credit amount, and memo notes.
  4. z_reports: Cashier register day-end summaries linking fiscal date totals directly to their generated journalEntryId.

3.2 Mathematical Balance Invariant

Every posted journal entry must satisfy the fundamental double-entry invariant:

$$\sum_^ \texti \equiv \sum^ \text_i$$

At the application service level, postJournalEntry() calculates the absolute discrepancy:

const totalDebit = lines.reduce((acc, line) => acc + Number(line.debit || 0), 0);
const totalCredit = lines.reduce((acc, line) => acc + Number(line.credit || 0), 0);

if (Math.abs(totalDebit - totalCredit) > 0.001) {
  throw new BadRequestException(
    `Mathematical balance invariant violation: Debits (${totalDebit}) must equal Credits (${totalCredit})`,
  );
}

Any attempt to commit an unbalanced transaction immediately rolls back the database transaction, preventing orphaned or asymmetrical entries.


4. Universal Chart of Accounts (COA) Taxonomy

The Orbit Chart of Accounts uses a standardized 5-tier classification structure shared across all industry verticals:

Universal Chart of Accounts Multi-Vertical Hierarchy
ORBIT LEDGERUniversal COA Root1000s · ASSETS2000s · LIABILITIES3000s · EQUITY4000s · REVENUE5000s · EXPENSESSUB-ASSETSGL 1010 Bank · GL 1110 Khata AR · GL 1130 Staff Advances · GL 1300 StockSUB-REVENUESGL 4010 Retail/Dine · GL 4015 Clinical Lab · GL 4030 School TuitionSUB-EXPENSESGL 5000 COGS · GL 5002 Reagents · GL 5005 Food Waste · GL 5010 Faculty Payroll

4.1 Master Account Directory Table

Account CodePrimary ClassOperational Application VerticalNormal BalancePosting Context
GL 1010AssetUniversal (All Verticals)DebitLiquid bank checking and card acquiring settlement accounts.
GL 1020AssetUniversal (All Verticals)DebitPhysical cash register till float and on-premise vault cash.
GL 1110AssetCommerce & DineDebitCustomer Khata credit receivables due within 30-90 days.
GL 1130AssetEdu & InstitutionDebitEmergency salary advances disbursed to academic faculty.
GL 1300AssetCommerce & DineDebitStore inventory asset and raw food ingredient valuations.
GL 1350AssetHealth & DiagnosticDebitClinical laboratory reagent stock and testing consumables.
GL 2110LiabilityUniversal (All Verticals)CreditAccrued sales tax, VAT, and provincial services tax payable.
GL 2130LiabilityHealth & ClinicCreditDoctor referral commission incentive liabilities payable.
GL 2140LiabilityEdu & InstitutionCreditEmployee provident fund and retirement pension deductions.
GL 4010RevenueCommerce & DineCreditGross retail sales merchandise and restaurant dining revenues.
GL 4015RevenueHealth & PathologyCreditDiagnostic lab testing, radiology, and specimen panel fees.
GL 4030RevenueEdu & AcademicCreditStudent monthly composite tuition and facility fees billed.
GL 5000ExpenseCommerce & RetailDebitCost of Goods Sold (COGS) recognized upon item checkout.
GL 5002ExpenseHealth & LaboratoryDebitAnalytical reagent consumption recognized on analyzer test run.
GL 5005ExpenseDine & HospitalityDebitBurnt dishes, kitchen line scraps, and expired stock wastage.
GL 5010ExpenseEdu & AcademicDebitGross faculty base salaries and teaching compensation expense.

5. Day-End Z-Report Auditing & Automated Voucher Posting

At the conclusion of each operating shift or business day, cashiers print a Z-Report to reconcile physical cash drawers with system sales records.

5.1 Shift Reconciliation Workflow

  1. Blind Count Ingress: The cashier inputs counted physical currency denominations (e.g., 5000, 1000, 500, 100 PKR notes) without previewing system expected totals.
  2. Supervisor Discrepancy Approval: If variance exceeds approved tolerance thresholds (such as $\pm 500\text$ ), a supervisor authorization PIN is mandated.
  3. Automated Journal Voucher Generation: The system creates a balanced day-end journal voucher in journal_entries and updates z_reports.journalEntryId:
Debit:  GL 1020 (Cash in Till)                 = Actual Counted Cash
Debit:  GL 1010 (Bank Clearing)               = Total Electronic Payments
Debit:  GL 5090 (Cash Shortage Expense)        = Variance (if short)
Credit: GL 5095 (Cash Overage Income)          = Variance (if over)
Credit: GL 4010 (Gross Sales Revenue)         = Net Sales Total
Credit: GL 2110 (Output Tax Payable)          = Collected Sales Tax

The Z-Report status advances to POSTED, locking the business day against retroactive cashier modifications.


6. Financial Engine Throughput & Reconciliation Telemetry

The general ledger engine delivers fast posting throughput:

Empirical System Benchmarks

Universal General Ledger & Journal Engine Benchmark

Verified Dataset

P99 Barcode & Cart Ingestion

Hardware Validated
4.2ms
96% faster than REST polling

Continuous 60 FPS hardware scanner stream

Offline Replay Queue Durability

Air-Gapped Tested
100%
Zero dropped tickets during outage

Tested over 120-minute edge network drop

Double-Entry Ledger Variance

Audit Certified
0.00₨
Mathematical zero-drift balance

Strict transactional debits equals credits

Multi-Station KDS Event Dispatch

Sub-Millisecond
< 14ms
Real-time kitchen station routing

Simultaneous bump bar and kitchen chimes

Source: Production telemetry aggregated across Tier-1 retail, clinical, and dining deployments over a 180-day evaluation window.


7. Failure Modes & Recovery SOP

The following operational contingency protocols resolve financial accounting exceptions:

FailureRoot CauseRecovery SOP
Unbalanced journal voucher rejectedRounding error across multi-rate tax items causing fractional cent discrepancyEngine automatically assigns fractional rounding differences ($< 0.05$) to Rounding Discrepancies (GL 5095).
Posting rejected: closed fiscal periodOperational transaction dated in a month that has already been closedTransaction must be posted to the current open fiscal period. A supervisor logs an adjustment memo citing the original date.
Z-Report status shows ledger errorMismatched currency denomination totals or transient database deadlockReview z_reports.ledgerError. Re-trigger repostZReportLedger(zReportId) from the financial controller console.
Khata settlement not updating AR balancePayment voucher was created without linking the customer khata account IDEnsure receipt tender specifies the khataAccountId. Re-index customer aging buckets via recalculateCustomerKhataBalance().
Trial balance displays non-zero discrepancyHistorical direct SQL update bypassed service-level balance invariantsRun forensic audit script auditLedgerIntegrity(). Identify orphaned journal lines and post balancing adjustment vouchers.

8. Cross-Vertical Internal Linkages

The universal General Ledger links financial operations across all product modules: