Sandbox
Double-Entry Invariant Enforced

Double-Entry Ledger

The accounting foundation for financial platforms. Production-grade double-entry engine with bcmath precision, 21-account chart of accounts, TigerBeetle driver for extreme throughput, and automatic GL posting from domain events.

Core Engine

LedgerService enforces the double-entry invariant on every journal posting — debits must equal credits to the penny. All arithmetic uses PHP's bcmath extension for exact decimal precision.

Journal Entries

Every financial event creates a balanced journal entry. Multi-leg entries are atomic — either all lines post or none do. Supports debit/credit, account codes, and optional narrative description.

  • Atomic multi-leg entries in DB transaction
  • Debit = Credit invariant enforced pre-commit
  • bcmath 4-decimal precision throughout
  • Immutable entry log with timestamp

Trial Balance

Generate a trial balance at any point in time by summing all journal entry lines per account. Total debits and total credits must balance to zero — the ledger's self-verification mechanism.

  • Point-in-time trial balance query
  • Net balance per account code
  • Automatic imbalance detection and alert
  • CSV and JSON export

Chart of Accounts

21 pre-configured accounts across 5 account types, ready for a financial platform. Extend or replace the default chart per tenant.

Assets

  • 1000 Cash
  • 1100 Receivables
  • 1200 Crypto Holdings
  • 1300 Prepaid

Liabilities

  • 2000 Payables
  • 2100 Customer Deposits
  • 2200 Accrued Liabilities
  • 2300 Deferred Revenue

Equity

  • 3000 Capital
  • 3100 Retained Earnings
  • 3200 Distributions

Revenue

  • 4000 Fee Income
  • 4100 Interest Income
  • 4200 FX Gains
  • 4300 Other Income

Expenses

  • 5000 Operating Expenses
  • 5100 Network Fees
  • 5200 FX Losses
  • 5300 Provisions
  • 5400 Depreciation
  • 5500 Other Expenses

Storage Drivers

Choose the right storage backend for your throughput requirement. Both drivers share the same LedgerService interface — swap without changing business logic.

EloquentDriver

Default — MySQL
Default

Uses Eloquent ORM with MySQL. Transactions use DB::transaction() with lockForUpdate() for balance consistency. Best for most deployments.

  • Zero additional infrastructure
  • Full Eloquent query builder access
  • Thousands of TPS on standard hardware

TigerBeetleDriver

Optional — high throughput
Optional

Connects to a TigerBeetle cluster for financial-grade fault-tolerant storage. Designed for millions of accounts and billions of transfers with strict consistency.

  • 1M+ TPS on commodity hardware
  • ACID with Byzantine fault tolerance
  • Built for financial workloads

Auto-Posting & Reconciliation

PostingRuleEngine

Domain events trigger automatic GL postings through a configurable rule engine. When a payment completes, fee is collected, or interest accrues — corresponding journal entries post without manual intervention.

  • Event-driven posting rules
  • Configurable debit/credit mappings per event
  • Zero manual posting for routine transactions
  • Full posting log with event reference

Reconciliation

Compare GL balances against domain balances (wallet, account, reserve) and flag any discrepancies. Run on-demand or schedule nightly for automated financial close.

  • GL vs domain balance comparison
  • Discrepancy flagging with entity reference
  • Scheduled via artisan command
  • Webhook notification on mismatch

Build on Solid Accounting Foundations

The double-entry engine handles the accounting invariants so you can focus on product logic. Start with MySQL, scale to TigerBeetle when you need it.