Pycer records every payment, fee, and transfer as balanced debit-credit pairs using double-entry bookkeeping with bcmath precision and brand isolation.
Every time money moves in Pycer - a customer pays, a gateway deducts fees, a refund is issued - the system records it as a pair of balanced journal entries. This is double-entry bookkeeping, the same method used by accounting software and banks. It means you can always trace where money came from and where it went, and the total debits always equal the total credits.
How double-entry works in Pycer
When a $100 payment completes through Stripe (with a $2.90 gateway fee), Pycer creates four ledger entries across three accounts:The net effect: $100.00 credit = $97.10 debit + $2.90 debit. The books balance to zero.
Account types
Pycer uses standard GAAP account categories:
Account type
Examples
Debit effect
Credit effect
Asset
Cash, Customer Receivable
Increases balance
Decreases balance
Expense
Gateway Fee Revenue, Platform Fee
Increases balance
Decreases balance
Liability
Refund Payable
Decreases balance
Increases balance
Equity
Retained Earnings
Decreases balance
Increases balance
Balance calculation
All monetary math uses PHP’s bcmath extension - never floating-point arithmetic. Balances are validated at 4-decimal precision using bccomp().
Never manually update the op_ledger_accounts.balance column. Always use LedgerService - direct SQL edits will cause reconciliation mismatches.
Double-post prevention
Pycer guards against recording the same payment twice. Before inserting ledger entries, the system acquires a row lock:
SELECT * FROM op_ledger_transactionsWHERE merchant_id = ? AND reference_type = ? AND reference_id = ?FOR UPDATE
If a matching row exists, the operation is skipped. This runs inside a database transaction, so concurrent requests are serialized safely.
Brand isolation
Ledger accounts are scoped to a merchant_id (brand). Brand A’s cash balance is completely independent of Brand B’s. The repository enforces this at the query level:
This compares Pycer’s recorded transactions against the gateway’s reported totals and flags any discrepancies. For the GUI-based version, see the Balance Verification page in the admin dashboard.
Related pages
Payments - Ledger - view ledger entries and journal details in the UI