Accounting Model¶
Double-Entry Core¶
Uses standard double-entry accounting. Every financial event (invoice, payment) generates a balanced Journal Entry where Total Debits = Total Credits.
Invoicing¶
Unified invoices table for both Sales and Purchases.
| Direction | Accounting Entry |
|---|---|
outgoing |
Sales invoice — Debit AR, Credit Revenue/VAT |
incoming |
Purchase/Expense — Debit Expense/VAT, Credit AP |
Payments¶
| Direction | Accounting Entry |
|---|---|
incoming |
From customer — Debit Bank, Credit AR |
outgoing |
To supplier — Debit AP, Credit Bank |
Data Precision¶
- Money: Stored as integers in minor units (e.g., 10.00 EUR =
1000) - Quantity: Stored as integers in micros (e.g., 1.5 units =
1500000)
Architecture (DDD-Hexagonal)¶
domain/— pure business logic and invariantsapplication/— use cases (orchestration)infrastructure/— D1 repositories, Hono routes
Entity-Relationship Overview¶
Key entities and their relationships:
COMPANIES ──── COMPANY_USERS ──── USERS
├── CONTACTS
├── ACCOUNTS
├── FISCAL_YEARS ──── ACCOUNTING_PERIODS
├── TAX_RATES
├── JOURNAL_ENTRIES ──── JOURNAL_ENTRY_LINES
│ ──── INVOICES ──── INVOICE_LINES
├── PAYMENTS ──── PAYMENT_ALLOCATIONS
├── BANK_ACCOUNTS
├── DOCUMENTS
└── AUDIT_LOGS
Key Entity Attributes¶
COMPANIES: id, name, legal_name, vat_number, country, base_currency, fiscal_year_start_month
JOURNAL_ENTRIES: id, company_id, entry_date, source_type, source_id, description, status, created_by, posted_by, reversed_by
INVOICES: id, company_id, contact_id, direction, document_type, issue_date, due_date, currency, status, subtotal_amount, tax_amount, total_amount, amount_paid
PAYMENTS: id, company_id, contact_id, direction, payment_date, amount, currency, bank_account_id, reference, journal_entry_id
ACCOUNTS: id, company_id, code, name, type, subtype, currency, is_system, is_active