Technical docs

Transaction System

How money movements become accounting records. You do not need to be an accountant to understand this.

The Big Picture

User creates a Transaction → System derives Events → Events get reviewed → Approved Events create Journal Entries → Journal lines hit GL accounts.

Core Concepts

Three entities handle different concerns. Users think in transactions, the system creates events, accountants see journals.

ConceptWhat It IsExampleWho Sees It
TransactionWhat the user did"Received $500 from Acme Corp"Users
EventWhat it means to accounting"Sale recorded for $500"System
Journal EntryThe accounting record"Dr Bank $500, Cr Revenue $500"Accountants

Why This Separation?

  • Users think in transactions: "I got paid" not "debit cash, credit revenue"
  • System needs events: One transaction might create multiple accounting entries
  • Accountants need journals: Proper double-entry records for compliance

Transaction Lifecycle

Every transaction follows this state machine from creation to posting.

Key Services

  • TransactionService - Creates transactions
  • EventBuilder - Derives events from intent
  • TransactionReviewService - Evaluates completeness
  • JournalGenerationService - Creates journal entries

State Transitions

  • Created → EventsBuilt: Automatic via EventBuilder
  • EventsBuilt → Review: Automatic evaluation
  • Review → Approved: All checks pass or overridden
  • Approved → Posted: Journal entry created

Transaction Intents

The Intent field determines what events are created from a transaction.

IntentEvents CreatedTypical Use Case
CUSTOMER_PAYMENT_RECEIVEDSale, Cash ReceiptCustomer pays for goods/services
SUPPLIER_PAYMENT_MADEExpense, Cash DisbursementPaying a vendor
TRANSFERCash MovementMoving money between accounts
INVOICE_SETTLEMENTAR SettlementCustomer pays existing invoice
BILL_SETTLEMENTAP SettlementPaying an existing bill
OWNER_CONTRIBUTIONEquity IncreaseOwner puts money in
OWNER_WITHDRAWALEquity DecreaseOwner takes money out
REFUND_ISSUEDContra-RevenueRefunding a customer
REFUND_RECEIVEDContra-ExpenseReceiving refund from vendor

Service Architecture

The accounting engine is composed of focused services that collaborate through the transaction lifecycle.

ServiceResponsibility
TransactionServiceCreates/updates transactions, orchestrates event derivation
EventBuilderBuilds events from transaction based on Intent
TransactionReviewServiceEvaluates events, applies review flags
PostingPolicyServiceManages posting rules, CRUD for policies
JournalGenerationServiceCreates journal entries from approved events
CategoryServiceCRUD for transaction categories
AuditServiceRecords all changes for audit trail