Skip to content

URD: Finance

ModuleCORE-12Versionv0.6
StatusIn-progressDate2026-06-15

Business documentation. This URD is Finance's feature list - each feature below is one Functional Area (<AREA>). The same <AREA> keys the feature's PRDs (PRD-<AREA>-NNN) and tests (TC-<AREA>-NNN), and each feature is listed in the Delivery feature catalog. See the Feature Spine convention.

1. Purpose

Define the user-facing requirements for Finance - the merchant's books. The module must track money across accounts (cash, bank, QR, mobile-POS), record every movement as a balanced double-entry voucher, classify income and expense by category, and create most postings automatically in response to sales, purchases, and stock movements so owners do not record routine money flows by hand.

2. Scope

IncludedExcluded
Money accounts / wallets (Cash, Bank, QR, Mobile-POS)Payment-gateway processing (Payment module)
Internal control accounts (Inventory, Cost of Goods Sold)Tax invoice issuance (Invoice module)
Vouchers: receipt, payment, transfer, adjustmentStock quantity & costing math (Inventory module)
Ledger lines (debit / credit) per voucherBudget tracking, P&L, cash-flow forecast (future)
Income / expense categories (seeded + custom)Recurring / scheduled expenses (future)
Auto posting from sale payment, PO receipt, stock movementReceipt-image capture / OCR (future)
Voucher void by balanced reversalMulti-currency conversion (single currency per voucher)

3. Definitions

TermDefinition
Account (wallet)A place money lives - a cash drawer, bank account, QR acceptance account, or mobile-POS terminal. Holds a running balance.
Internal control accountA non-cash bookkeeping account (Inventory, Cost of Goods Sold) the system maintains automatically; not user money.
VoucherOne bookkeeping document recording a money event: a receipt (money in), payment (money out), transfer (between accounts), or adjustment.
Ledger lineOne debit or credit row inside a voucher. A voucher always balances: total debits equal total credits where both sides apply.
CategoryThe income/expense classification on a movement (e.g. Sale, Purchase, Rent).
Default accountThe account a given type of automatic posting routes to by default - one per type per merchant.
VoidCancelling an issued voucher by posting an equal-and-opposite reversal, preserving the original for audit.

4. Conceptual Model

Conceptual only - the full schema, enums, and invariants live in the finance developer domain model.

5. Feature Catalog

The feature list of this module. Each row is one feature (a Functional Area). Detail in §6. Mirrored in the Delivery feature catalog.

Feature IDFeaturePhaseStatusPriority
WALAccountsP1In-progressHigh
VCHVouchers & PostingP1In-progressHigh
EVTEvent-Driven PostingP1BuiltHigh
TXNLedger LinesP1BuiltHigh
CATCategoriesP1BuiltHigh
LDGPartner ledger & P&LP2PlannedHigh

Status: live from Plane where mapped, otherwise registry-declared. Vocabulary mirrors Plane (state-group / phase).

6. Features

One sub-section per feature, in catalog order. Each feature keeps its description, requirements, and acceptance together. Priority = MoSCoW (Must / Should / Could / Won't).

WAL - Accounts In-progress

Feature ID: expenses/WAL · Phase: P1 · PRDs: - · Dev: @nx/finance

What it does for users: merchants hold money across cash drawers, bank, QR, and mobile-POS accounts - each with a running balance and a default per type - while the system auto-creates default and internal control accounts for every new merchant.

Requirements

IDPRequirement
URD-WAL-001MHold accounts of types Cash, Bank, QR, and Mobile-POS, each owned by one merchant
URD-WAL-002MMaintain a default account per type per merchant for routing automatic postings
URD-WAL-003MAuto-create each merchant's default and internal control accounts when the merchant is created
URD-WAL-004MTrack each account's running current balance as vouchers post
URD-WAL-005SAllow account currency (default VND)
URD-WAL-006SRestrict account visibility to merchants the user is granted (admins see all)

Acceptance

AC-WAL-01: Default & control accounts on new merchant
GivenWhenThen
A merchant is createdThe merchant event is reconciledThe merchant's default accounts are seeded
Internal Inventory and Cost-of-Goods-Sold control accounts exist

VCH - Vouchers & Posting In-progress

Feature ID: expenses/VCH · Phase: P1 · PRDs: - · Dev: @nx/finance

What it does for users: every money event is recorded as a balanced voucher - receipts auto-issued when sales are paid, payments when purchase orders are received, and cost-of-goods postings on stock movement - with manual transfers, draft lifecycle, and void-by-reversal for owners.

Requirements

IDPRequirement
URD-VCH-001MRecord money events as vouchers of type receipt, payment, transfer, or adjustment
URD-VCH-002MEvery voucher is balanced - debits equal credits where both sides apply
URD-VCH-003MAuto-issue a receipt voucher when a sale payment succeeds, classified as Sale
URD-VCH-004MAuto-issue a payment voucher to the vendor when a purchase order is received
URD-VCH-005MAuto-post cost of goods sold and stock adjustments to internal control accounts on stock movement
URD-VCH-006MAutomatic postings are idempotent - a repeated event never double-posts
URD-VCH-007MLink each voucher to its source document (sale order, purchase order, stock movement, manual)
URD-VCH-008SNumber each issued voucher per merchant, per type, per month
URD-VCH-009SSupport a manual lifecycle: draft → issue, and delete a draft before issue
URD-VCH-010STransfer money between two accounts as a single balanced transfer voucher
URD-VCH-011SVoid an issued voucher via a balanced reversal; the original is preserved
URD-VCH-012CAttribute a voucher to a POS shift session for shift cash movements

Acceptance

AC-VCH-01: Auto receipt on paid sale
GivenWhenThen
A sale order is paidThe payment-succeeded event arrivesA receipt voucher is issued, classified as Sale, linked to the sale order
The receiving account's balance goes up by the amount
The same event arrives againProcessed a second timeNo second voucher is created (idempotent)
AC-VCH-02: Auto payment on purchase-order receipt
GivenWhenThen
A purchase order is receivedThe PO-received event arrivesA payment voucher is issued to the vendor, linked to the purchase order
Inventory value is positiveThe voucher balances a stock asset leg against the cash leg(s)
AC-VCH-03: Transfer between accounts
GivenWhenThen
Two accounts of the merchantOwner transfers an amount A → BOne transfer voucher posts a debit and a credit of equal value
Account A goes down and Account B goes up by the same amount
AC-VCH-04: Void by reversal
GivenWhenThen
An issued voucherOwner voids itA balanced reversal voucher is posted; the original is preserved
Affected account balances return to their pre-voucher state

EVT - Event-Driven Posting Built

Feature ID: finance/EVT · Phase: P1 · PRDs: PRD-EVT-001 · Dev: @nx/finance

What it does for users: Finance keeps the books complete without manual entry by reacting to what already happens - a paid sale, a received purchase order, stock issued for a sale, an inventory value change, a new merchant - and posting the matching voucher off a message stream, asynchronously. Taking a payment never waits on the books; a momentary Finance outage catches up rather than loses entries; and a replayed event never double-posts.

Requirements

IDPRequirement
URD-EVT-001MFinance consumes operational events asynchronously; the originating sale / purchase / stock action is never blocked on a posting
URD-EVT-002MSubscribe to sale payment succeeded, purchase order received, inventory issued for sale, inventory adjusted, and merchant created
URD-EVT-003MA succeeded sale payment posts a receipt voucher, plus a change-return payment voucher when cash tendered exceeds the order total
URD-EVT-004MA received purchase order posts a vendor payment voucher, with an inventory asset leg when received value is positive
URD-EVT-005MStock issued for a sale posts a cost-of-goods voucher when the cost basis is positive
URD-EVT-006MAn operator-driven inventory value change posts a single-line inventory adjustment voucher
URD-EVT-007MA new merchant seeds its default and internal control accounts from the merchant lifecycle event
URD-EVT-008MEvery automatic posting is idempotent - a redelivered event replays the existing voucher, never a second one
URD-EVT-009MAn event is acknowledged only after its posting commits; a failed handler leaves the event for redelivery (at-least-once)
URD-EVT-010SEvents carry only identifiers; the worker resolves the full source and party identity (vendor, PO code, accounts) before posting
URD-EVT-011SPostings short-circuit with no voucher when there is nothing to book (no finance routing, zero cost basis, zero value delta, no change due)
URD-EVT-012SThe consumer drains in-flight work and closes cleanly on a shutdown signal

Acceptance

AC-EVT-01: Async posting does not block the sale
GivenWhenThen
A sale order is paidThe payment-succeeded event is publishedThe sale completes immediately without waiting on Finance
The Finance consumer reads the eventA balanced receipt voucher is posted, linked to the sale order
AC-EVT-02: Idempotent redelivery
GivenWhenThen
An event already produced its voucherThe same event is delivered againThe existing voucher is replayed - no second voucher is created
AC-EVT-03: At-least-once on handler failure
GivenWhenThen
A money-relevant event is deliveredThe handler fails before the posting commitsThe event is not acknowledged and is redelivered
The event is redeliveredThe handler succeedsThe voucher is posted exactly once
AC-EVT-04: Cost-of-goods on stock issued
GivenWhenThen
Stock is issued for a sale with a positive cost basisThe inventory-issued event arrivesA cost-of-goods voucher posts against the inventory control account
The cost basis is zeroThe event arrivesNo voucher is posted; the skip is logged
AC-EVT-05: Clean short-circuit when nothing to book
GivenWhenThen
A payment carries no finance routing, or change due is zeroThe event arrivesNo voucher is posted and no error is raised
An inventory change has zero value deltaThe event arrivesNo voucher is posted; the skip is logged

TXN - Ledger Lines Built

Feature ID: expenses/TXN · Phase: P1 · PRDs: - · Dev: @nx/finance

What it does for users: each voucher posts debit and credit ledger lines against accounts, carrying the affected account, an optional category, an amount, a balance-before/after snapshot, and a traceability link to the source document.

Requirements

IDPRequirement
URD-TXN-001MEach voucher posts debit/credit ledger lines against accounts
URD-TXN-002MA line carries the account it affects, an optional category, an amount, and balance-before/after snapshot
URD-TXN-003MLines share the voucher's currency
URD-TXN-004SA line may reference its source document for traceability

Acceptance

AC-TXN-01: Balanced ledger lines
GivenWhenThen
A voucher is postedLedger lines are writtenEach line carries its account, amount, and balance-before/after snapshot
Lines share the voucher's currency

CAT - Categories Built

Feature ID: expenses/CAT · Phase: P1 · PRDs: - · Dev: @nx/finance

What it does for users: money movements are classified as income or expense using 14 seeded system categories applied automatically to auto-generated vouchers, with merchants free to add custom categories nested under a parent.

Requirements

IDPRequirement
URD-CAT-001MProvide 14 seeded system categories spanning income and expense
URD-CAT-002MCategories are typed income or expense
URD-CAT-003MApply a system category automatically to auto-generated vouchers (e.g. Sale, Purchase)
URD-CAT-004SMerchants may add custom categories, nested under a parent

Acceptance

AC-CAT-01: System categories on auto vouchers
GivenWhenThen
An auto-generated voucher (e.g. Sale, Purchase)It is issuedA matching system category is applied automatically
A merchant adds a custom category under a parentSavedIt is available for classifying movements

LDG - Partner Ledger & P&L Planned

Feature ID: finance/LDG · Phase: P2 (Jul-Aug) · PRDs: PRD-LDG-001 · Dev: @nx/finance

What it does for users: merchants see who owes them and whom they owe - one partner ledger, receivables (customers) and payables (vendors) - and whether they actually made money, via a P&L for any period.

Requirements

IDPRequirement
URD-LDG-001MCustomer receivables are tracked (a charge sale raises debt; a receipt settles it)
URD-LDG-002MVendor payables work end-to-end (raised on PO receipt; settled by payment voucher)
URD-LDG-003MOne partner-ledger view: by partner, both directions, running balances
URD-LDG-004MA P&L report for a period (revenue − COGS − expenses)
URD-LDG-005SReceivables/payables settle via finance vouchers
URD-LDG-006SLedger filters by partner type and period

Acceptance

AC-LDG-01: Two-way ledger + P&L
GivenWhenThen
A B2B sale on credit and a received POOwner opens the partner ledgerCustomer debt and vendor debt both show with correct balances
A month of tradingOwner opens P&LRevenue, COGS and expenses reconcile to the accounts

7. Constraints & Non-Goals

Constraints

IDConstraint
C-01Every voucher must balance (debits equal credits where both sides apply)
C-02Exactly one default account per type per merchant
C-03Automatic postings must be idempotent under repeated events
C-04All ledger lines in a voucher share the voucher's currency (single-currency; default VND)
C-05The 14 seeded system categories are not merchant-owned
C-06Records use soft-delete; issued vouchers are never hard-deleted - they are voided
C-07Internal control accounts must exist before cost-of-goods postings

Non-Goals

  • Budget tracking and variance
  • Recurring / scheduled expense automation
  • Profit & loss statement and cash-flow forecasting
  • Receipt-image capture / OCR
  • Multi-currency conversion within a single voucher

8. Version History

DateAuthorDescriptionVer
2026-02-26P. Do - Product OwnerInitial user storiesv0.1
2026-04-16P. Do - Product OwnerWallets, transactions, categories scopev0.3
2026-05-30Docs migrationRestructured to verified double-entry voucher model (accounts / vouchers / ledger lines / categories); corrected account types and transaction modelv0.4
2026-06-04Claude (AI pair)Reorganize by feature (Feature Spine)v0.5
2026-06-15Finance squadAdd EVT Event-Driven Posting feature (sale → GL seam)v0.6

Proprietary and Confidential. Unauthorized copying, distribution, or use of this software is strictly prohibited.