# AIcentricERP Architecture Specification - **Product:** AIcentricERP - **Version:** 3.0.0 - **Service-Port:** 13820 - **Vertical-Type:** transactional_ledger - **Spec-Standard:** DF3-ARCH-1.0 - **DF3-Min-Version:** 3.10.0 - **Theme-Preset:** emerald-ledger - **Panel-UX-Preset:** master-detail - **Spec-Tier:** flagship --- ## §0. Executive Summary, Compliance & Legacy Intent **AIcentricERP** is a flagship enterprise core financial accounting, multi-subsidiary general ledger, subledger control, and continuous financial audit platform built as a modular single-process web console and Offstack-persisted ledger engine. Across **27 entities**, **116 bound domain facades**, and **118 unrolled HTTP routes**, it eliminates shadow month-end close workbooks, manual FX revaluation spreadsheets, email-driven 3-way AP matching, offline bank-feed tick-and-tie sheets, vendor bank-fraud email approvals, ASC 606 revenue waterfalls, and silent post-close ledger edits by enforcing atomic double-entry conservation (`sum(debits) == sum(credits)`), fiscal period close locks (`CLOSED-YYYY-MM`) gated by `CloseTask` DAG sign-offs, SOX 404 Segregation of Duties (`SoD`), 3-way PO-receipt-bill matching with deterministic basis-point tolerances, signed credit memo adjustments, fixed-asset depreciation schedules, FIFO/weighted-average inventory valuation, multi-subsidiary intercompany eliminations, bank statement reconciliation, cost-center budget encumbrance ceilings, selective S3 Object Lock evidence custody, sales tax/VAT calculation, Benford's Law first-digit chi-square anomaly screening (`chi2 > 15.51`), and zero-leakage bitemporal `(as_of, as_known_at)` trial balance and aging queries. ### Plain-Words Needs & Operator Workflows Finance teams across controllers, GL accountants, AR/AP clerks, treasury analysts, and external auditors operate from a single governed accounting plane: 1. **Chart of Accounts, Fiscal Close Cockpit & Immutable General Ledger:** Maintain a multi-currency Chart of Accounts (`ACC-####`) and `LegalEntity` (`LE-####`) registry; orchestrate month-end `CloseTask` (`CTSK-####`) checklists before locking `FiscalPeriod` (`PER-####`); post balanced double-entry journals (`JE-####`) with child `JournalLine` splits (`JEL-####`); execute `IntercompanyTransfer` (`ICT-####`) eliminations; and correct mistakes strictly via linked reversing or voiding entries, never via silent in-place mutation. 2. **Customer Governance, AR Invoices, ASC 606 Revenue & Credit Memos:** Govern `Customer` (`CUST-####`) credit limits and dunning pauses; issue customer invoices (`INV-####`) with structured EU VAT / US Sales Tax rates (`TAX-####`); allocate ASC 606 / IFRS 15 `RevenueSchedule` (`REV-####`) and `RevenueObligation` (`POB-####`) splits (`10000` bps conservation); apply signed negative credit memos (`CM-####`); and track server-computed bitemporal aging buckets. 3. **Vendor Bank-Fraud Governance, Procurement, 3-Way Match & SOX 404 SoD:** Govern `Vendor` (`VEND-####`) payment holds and dual-approval `VendorBankChange` (`VBC-####`) requests with SOX SoD; record `PurchaseOrder` (`PO-####`) and `GoodsReceipt` (`GRN-####`); match vendor `Bill` (`BILL-####`) submissions within configurable `tolerance_bps` (`<= 500` bps); and enforce SOX 404 SoD so creators never self-approve bills or match overrides. 4. **Treasury Cash, Bank Reconciliation, Assets, Inventory, Budgets & Audit:** Settle `Payment` (`PAY-####`) records idempotently with realized FX gain/loss to `ACC-8010`; reconcile `BankStatementLine` (`BNK-####`) camt.053/MT940/BAI2 feeds; maintain `FixedAsset` (`FA-####`) depreciation, `InventoryValuation` (`SKU-####`), `BudgetCommitment` (`BUD-####`) encumbrances, dated `FxRate` (`FXRT-####`) & period-end `FxRevaluation` (`FXR-####`), selective S3 Object Lock `EvidenceArtifact` (`EVID-####`) custody, and hash-chained `AuditLog` (`AUD-####`). ### Compliance & Regulatory Posture - **SOX Section 404 & COSO ICFR ([COSO](https://www.coso.org)):** Enforces immutable posted journal entries (reversals/voids only), Segregation of Duties (`SoD`) between AP/AR/GL/vendor-bank creators and approvers, hard fiscal period close locks (`CLOSED-YYYY-MM`), `CloseTask` sign-off trails, and tamper-evident SHA-256 hash-chained `AUD-####` records across all financial mutations. - **IFRS 15 & Five-Step Revenue Recognition ([IFRS 15](https://www.ifrs.org/issued-standards/list-of-standards/ifrs-15-revenue-from-contracts-with-customers/)):** Governs AR invoice lifecycle (`draft -> unpaid -> partially_paid -> paid` / `voided`), `RevenueSchedule` (`REV-####`) deferred recognition, `RevenueObligation` (`POB-####`) standalone selling price (`SSP`) allocation (`sum(allocated_cents) <= total_contract_cents` and `sum(allocation_bps) <= 10000`), signed credit memo adjustments, and multi-currency settlement tracking. - **EU VAT Directive 2006/112/EC & e-Invoicing 2014/55/EU ([VAT Dir.](https://eur-lex.europa.eu/eli/dir/2006/112/oj), [Dir. 2014/55/EU](https://eur-lex.europa.eu/eli/dir/2014/55/oj), [Peppol BIS 3.0](https://docs.peppol.eu/poacc/billing/3.0/), [XRechnung](https://xeinkauf.de/xrechnung/), [XBRL](https://www.xbrl.org/)):** Captures structured JSON invoice/tax payloads (`tax_code`, `jurisdiction`, `rate_bps`, `tax_amount_cents`), sequential document IDs, legal-entity jurisdiction pinning, and immutable period-locked records for 7–10 year statutory retention. - **IRS Recordkeeping, 1099-NEC & NACHA Controls ([IRS](https://www.irs.gov), [IRS 1099-NEC](https://www.irs.gov/forms-pubs/about-form-1099-nec), [NACHA](https://www.nacha.org/), [eCFR](https://www.ecfr.gov)):** Guarantees machine-sensible, indexed, verifiable electronic books with gapless monotonic document numbering, explicit trial-balance tie-outs, vendor tax ID protection, dual-approved vendor bank IBAN changes, and WORM-ready S3 export archival. - **GDPR Regulation (EU) 2016/679 Art. 17(3)(b) ([GDPR](https://eur-lex.europa.eu/eli/reg/2016/679/oj)):** Protects customer and vendor contact PII (`security.pii_fields`) via KMS at-rest encryption and role-based masking while honoring statutory tax/accounting retention overrides and forbidding S3 Object Lock on GDPR-erasable `contact_pii_export` artifacts. - **Security & Ledger Engineering References ([NIST CSRC](https://csrc.nist.gov), [OWASP](https://owasp.org), [OWASP Logging](https://cheatsheetseries.owasp.org/cheatsheets/Logging_Cheat_Sheet.html), [Stripe Idempotency](https://docs.stripe.com/api/idempotent_requests), [DynamoDB Tx](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/transaction-apis.html), [S3 Object Lock](https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lock.html), [ERPNext](https://github.com/frappe/erpnext), [Odoo](https://github.com/odoo/odoo), [TigerBeetle](https://github.com/tigerbeetle/tigerbeetle), [Formance Ledger](https://github.com/formancehq/ledger), [Beancount](https://github.com/beancount/beancount), [OCA Financial Tools](https://github.com/OCA/account-financial-tools), [Moto](https://github.com/getmoto/moto)):** Enforces fail-closed HS256 JWT (`AUTH_MODE=jwt`), `X-Corp-Id` tenant isolation, default-deny RBAC (`403 missing_role`), integer minor-unit arithmetic (`*_cents`, `*_micros`, `*_bps`), and strict `GET` read idempotency (`QG-READ-IDEMP`). ### Runtime Topology Single-process modular SPA + REST API server (`app/server.py` -> `app/spa_server.py` on port `13820`) backed exclusively by **Offstack** (`DynamoDB`, `S3`, `Secrets Manager` Core + `SQS`, `SNS`, `EventBridge`, `SSM`, `KMS` Extended verified in `toolkits/offstack/docs/OFFSTACK_AI_MANUAL.txt`) via the single storage confinement seam `app/offstack_store.py` (`forbid_sqlite_fallback=True`, `forbid_local_fallback=True`). ### Legacy Spec Disposition Matrix (`AIcentricERP_ARCHITECTURE.md v1.0/v2.0 -> v3.0.0 Flagship DF3-ARCH-1.0`) | Legacy Requirement | Disposition | Rationale & DF3-ARCH-1.0 Target | | :--- | :--- | :--- | | Core COA (`ACC-1010`), Double-Entry GL (`JE-0001`), AR Invoices (`INV-0042`), AP Bills (`BILL-0007`) | `PRESERVED` | Retained as canonical `alpha-corp` baseline seeds alongside 27 flagship entities (`§1.5`, `§2`) | | `sum(debits) == sum(credits)`, `CLOSED-YYYY-MM` period locks, FX gain/loss to `ACC-8010`, Benford `chi2 > 15.51` | `UPGRADED` | Formalized into 24 executable invariants across all 5 DF3 primitives (`§1.4`) | | `v2.0.0` 15-entity ledger baseline (`Account..AuditLog`) & `alpha-corp` / `beta-corp` / `zz-probe` tenancy | `UPGRADED` | Preserved all 15 entities and expanded with 12 researched enterprise ERP entities (`LegalEntity`, `IntercompanyTransfer`, `CloseTask`, `BankStatementLine`, `Vendor`, `VendorBankChange`, `Customer`, `RevenueSchedule`, `RevenueObligation`, `FxRate`, `BudgetCommitment`, `EvidenceArtifact`) meeting `LINT-20` Flagship Depth | | Legacy single-owner no-role auth, `limit=50`, float/Decimal wire amounts | `UPGRADED` | Replaced with fail-closed RBAC (`403 missing_role`), SOX SoD, `DEFAULT_LIST_LIMIT = 200`, and integer `*_cents`/`*_micros`/`*_bps` | | Legacy `app/sim_store.py`, single-table `aicentric_erp`, `bundle.js`, Vite/React/Nuitka tooling, port `13250`/`13251` | `SUPERSEDED_TECH` | Superseded by `app/offstack_store.py`, 28 partitioned Offstack DynamoDB tables + S3/KMS, modular `frontend/js/`, unique port `13820`, and PyInstaller VibeInstaller schema-v1 (`§5.1`, `§6`, `§9`) | | Legacy standalone FastMCP `13250` transport & HKCU registry token launcher assumptions | `INTENTIONALLY_DROPPED` | Superseded by DF3 single-process `app/server.py` + `app/spa_server.py` and schema-v1 `installer_config.json` (`§1.1`, `§9`) | ### Incumbent Parity & Research Coverage Matrix (`RESEARCH_SYNTHESIS.md` & `REGULATORY_AND_WORKFLOW_BRIEF.md`) | Research Capability / Pain Point | Modeled Entities & Routes | Executable Invariant(s) | Disposition | | :--- | :--- | :--- | :--- | | Period close checklist & task DAG replacing shadow close spreadsheets | `FiscalPeriod` (`/api/fiscal-periods`, `/close`, `/reopen`), `CloseTask` (`/api/close-tasks`, `/start`, `/signoff`, `/waive`) | `INV-STATE-01` | `IMPLEMENTED` | | Server-computed bitemporal AR/AP aging & trial balance tie-outs | `Invoice`, `Bill`, `Customer`, `Vendor`, `/api/reports/aging`, `/api/reports/trial-balance`, `/api/reports/tax-summary` | `INV-CONS-01`, `INV-CONS-02`, `INV-CEIL-07` | `IMPLEMENTED` | | Idempotent cash application, partial payments, signed credit memos & realized FX to `ACC-8010` | `Payment` (`/api/payments`, `/reverse`), `CreditMemo` (`/api/credit-memos`, `/apply`), `/api/invoices/{invoice_id}/pay`, `/api/bills/{bill_id}/pay` | `INV-IDEMP-01`, `INV-STATE-04` | `IMPLEMENTED` | | 3-way PO-GRN-Bill matching with bps tolerance & SOX 404 SoD (`creator != approver`) | `PurchaseOrder` (`/api/purchase-orders`, `/cancel`), `GoodsReceipt` (`/api/goods-receipts`), `Bill` (`/api/bills`, `/approve`, `/override-match`) | `INV-CEIL-02` | `IMPLEMENTED` | | Dated FX rate repository & period-end unrealized FX revaluation (`dry_run` preview) | `FxRate` (`/api/fx-rates`), `FxRevaluation` (`/api/fx-revaluations`) | `INV-IDEMP-03`, `INV-CEIL-04` | `IMPLEMENTED` | | Bank feed ingestion (`camt.053`/`MT940`/`BAI2`) & matching state machine | `BankStatementLine` (`/api/bank-statements`, `/match`, `/reconcile`, `/exclude`) | `INV-IDEMP-04` | `IMPLEMENTED` | | Fixed asset register, straight-line/double-declining depreciation & disposal gain/loss | `FixedAsset` (`/api/fixed-assets`, `/depreciate`, `/dispose`), `InventoryValuation` (`/api/inventory`, `/adjust`) | `INV-CEIL-03` | `IMPLEMENTED` | | Multi-subsidiary legal entities & intercompany cross-charge eliminations | `LegalEntity` (`/api/legal-entities`, `/toggle`), `IntercompanyTransfer` (`/api/intercompany-transfers`, `/post`, `/eliminate`, `/dispute`) | `INV-STATE-07` | `IMPLEMENTED` | | Immutable bitemporal audit corrections, Benford chi-square anomaly screening & SHA-256 chain | `JournalEntry` (`/api/journals`, `/reverse`, `/void`), `JournalLine` (`/api/journals/{journal_id}/lines`), `AuditLog` (`/api/audit-logs`), `/api/audit/benford` | `INV-CONS-01`, `INV-CONS-02`, `INV-ALLOC-01`, `INV-STATE-02`, `INV-STATE-03` | `IMPLEMENTED` | | Vendor bank-change dual approval (anti-fraud SoD) & customer credit-hold / dunning pause | `Vendor` (`/api/vendors`, `/hold`, `/archive`), `VendorBankChange` (`/api/vendor-bank-changes`, `/confirm`, `/approve`, `/reject`), `Customer` (`/api/customers`, `/credit-hold`, `/dunning-pause`) | `INV-STATE-06`, `INV-CEIL-07` | `IMPLEMENTED` | | FASB ASC 606 / IFRS 15 revenue recognition schedules & 10000-bps POB allocation | `RevenueSchedule` (`/api/revenue-schedules`, `/recognize`, `/pause`), `RevenueObligation` (`/api/revenue-schedules/{schedule_id}/obligations`) | `INV-CONS-03`, `INV-ALLOC-02` | `IMPLEMENTED` | | Cost-center budget encumbrance ceilings, EU VAT/US Sales Tax & selective S3 Object Lock evidence | `BudgetCommitment` (`/api/budgets`, `/activate`, `/encumber`, `/freeze`), `TaxRate` (`/api/tax-rates`, `/toggle`), `EvidenceArtifact` (`/api/evidence-artifacts`, `/content`, `/legal-hold`) | `INV-CEIL-01`, `INV-CEIL-05`, `INV-CEIL-06`, `INV-STATE-08` | `IMPLEMENTED` | | Async bulk CSV/XLSX/camt.053 batch import runner & BI lakehouse Parquet CDC projection | *(Deferred to V2 data-plane beyond transactional REST core; deterministic single-record idempotent REST APIs active in V1)* | `(none — outside transactional OLTP scope)` | `INTENTIONALLY_DEFERRED` | --- ## §1. Domain Architecture, Facades, Laws & Wire Entities ### §1.1 Service Surface & Inter-Vertical Boundary Law - **Entrypoints:** Canonical entrypoint **`app/server.py`** (direct-script safe: zero bare top-level relative imports so `python app/server.py` executes cleanly), reading `PORT` (default **`13820`**) plus `--port` and `--db` CLI flags for verification harnesses, exporting `build_server(port: int)`, and delegating HTTP/API routing and static UI serving to **`app/spa_server.py`**. - **Health Route (`GET /health`):** Auth/tenancy/role/HTTPS/rate-limit exempt, strictly **zero-RPC** (performs zero Offstack DynamoDB/S3/Secrets Manager calls and zero disk writes on module import or handler execution), returning `200 {"status": "ok", "app": "AIcentricERP", "engine": "offstack"}` even when Offstack is offline. - **Hard Inter-Vertical Boundary Law (BLOCKING):** Corporate performance management (`AIcentricCPM`), procurement spend catalogs (`AIcentricSpend`), warehouse management (`AIcentricWMS`), revenue/CRM pipelines (`AIcentricCRM`), ITSM (`AIcentricITSM`), SecOps (`AIcentricSecOps`), commerce (`AIcentricCommerce`), payroll/HR (`AIcentricHCM`), project accounting (`AIcentricPSA`), maritime logistics (`ShipTracking` / `AIcentricLogistics`), KMS (`AIcentricKMS`), and insurance (`AIcentricInsurance`) are external monorepo verticals. **`AIcentricERP` MUST NEVER import Python or JavaScript modules from any sibling vertical directory.** ### §1.2 Bound Domain Facades Target `<= 650` LOC per Python module under `app/`, `max_function_cc <= 25`, `max_function_lines <= 80`, `min_type_annotation_ratio >= 0.70`, `max_delegation_ratio < 0.50`, `max_undeclared_file_share <= 0.65`, zero silent `except: pass` handlers. All validation, double-entry arithmetic, SoD enforcement, and bitemporal filtering MUST live in declared domain modules, never in thin forwarding shims (**116 bound domain facades**): | Module | Facade Function | Domain Responsibility | | :--- | :--- | :--- | | `app/audit.py` | `get_time_axis_overview` | Return tenant min/max `effective_at` (`as_of`) and `recorded_at` (`as_known_at`) bitemporal bounds (`QG-READ-IDEMP`) | | `app/audit.py` | `list_audit_logs` | Read tamper-evident SHA-256 hash-chained `AUD-####` ledger (`admin_roles` only) with `limit=200`, `offset=0`, and `(as_of, as_known_at)` | | `app/accounts.py` | `list_accounts` | List Chart of Accounts rows newest-first with type/status/currency filters, `limit=200`, `offset=0`, and `(as_of, as_known_at)` | | `app/accounts.py` | `create_account` | Create GL account (`ACC-####`) enforcing unique `code` (`409 duplicate_key` on mismatch, `200` idempotent replay on exact match) | | `app/accounts.py` | `get_account` | Fetch single GL account by `account_id` at optional `(as_of, as_known_at)` (`404 account_not_found`) | | `app/accounts.py` | `update_account` | Patch mutable account `name` or `allow_manual_posting` flag + hash-chained `AUD-####` | | `app/accounts.py` | `archive_account` | Transition active GL account (`active -> archived`) refusing already-archived accounts (`400 unarchivable_account`) | | `app/periods.py` | `list_fiscal_periods` | List fiscal periods with status/`period_code` filters, `limit=200`, `offset=0`, and bitemporal snapshot filtering | | `app/periods.py` | `create_fiscal_period` | Create fiscal period (`PER-####`) enforcing unique `period_code` (`YYYY-MM`) and `start_date <= end_date` | | `app/periods.py` | `get_fiscal_period` | Fetch fiscal period by `period_id` at optional `(as_of, as_known_at)` (`404 period_not_found`) | | `app/periods.py` | `close_fiscal_period` | Lock fiscal period (`open/soft_closed -> closed`) refusing already-closed periods (`400 closed_period`) + S3 close binder | | `app/periods.py` | `reopen_fiscal_period` | Reopen closed fiscal period (`closed -> soft_closed`) requiring non-empty `reason` and admin role (`400 invalid_period_transition`) | | `app/periods.py` | `list_close_tasks` | List month-end close checklist tasks (`CTSK-####`) filtered by `period_id`, `owner_role`, `status`, `limit=200`, `offset=0` | | `app/periods.py` | `create_close_task` | Create period close task (`CTSK-####`) linked to `FiscalPeriod.period_id` (`REL-08`) | | `app/periods.py` | `start_close_task` | Transition `open -> in_progress` close task (`400 invalid_state_transition` otherwise) | | `app/periods.py` | `signoff_close_task` | Sign off `open/in_progress -> signed_off` close task stamping `signed_off_by` | | `app/periods.py` | `waive_close_task` | Waive `open/in_progress -> waived` close task requiring admin role and `reason` | | `app/taxes.py` | `list_tax_rates` | List Sales Tax / VAT / TDS rates with jurisdiction/`tax_type`/active filter, `limit=200`, `offset=0`, and bitemporal filtering | | `app/taxes.py` | `create_tax_rate` | Create tax rate (`TAX-####`) enforcing `0 <= rate_bps <= 3500` (`INV-CEIL-01`) and `liability_account_id` FK (`REL-04`) | | `app/taxes.py` | `toggle_tax_rate` | Enable or disable tax rate (`active` boolean toggle) + `AUD-####` | | `app/journals.py` | `list_journals` | List double-entry journals newest-first with status/`period_code`/`source_module` filters, `limit=200`, `offset=0`, and `(as_of, as_known_at)` | | `app/journals.py` | `record_journal` | Post immutable double-entry journal (`JE-####`) via DynamoDB `TransactWriteItems`, enforcing open `period_id` (`REL-01`) and `debits == credits` (`INV-STATE-03`) | | `app/journals.py` | `get_journal` | Fetch journal entry + lines at optional `(as_of, as_known_at)` (`404 journal_not_found`) | | `app/journals.py` | `reverse_journal` | Create linked offsetting reversing `JE-####` and mark source `reversed` (`400 unvoidable_journal` if not `posted`) | | `app/journals.py` | `void_journal` | Transition `posted -> voided` preserving immutable history (`400 unvoidable_journal` if not `posted`) + `AUD-####` | | `app/journals.py` | `list_journal_lines` | List nested `JournalLine` items for `{journal_id}` (`limit=200`, `offset=0`) with `(as_of, as_known_at)` | | `app/journals.py` | `add_journal_line` | Append `JournalLine` (`JEL-####`) enforcing `sum(debits) <= total_debit_cents` (`INV-CONS-01`), `sum(credits) <= total_credit_cents` (`INV-CONS-02`), and `allocation_bps <= 10000` (`INV-ALLOC-01`) | | `app/customers.py` | `list_customers` | List governed AR customer masters (`CUST-####`) filtered by `status`, `dunning_paused`, `customer_code` (`limit=200`, `offset=0`) | | `app/customers.py` | `create_customer` | Create AR customer master (`CUST-####`) enforcing unique `customer_code`, `credit_limit_cents <= 10000000000` (`INV-CEIL-07`), and KMS PII encryption | | `app/customers.py` | `get_customer` | Fetch customer master (`404 customer_not_found`) with role-based PII masking (`masked_pii_roles`) | | `app/customers.py` | `update_customer` | Patch mutable customer `legal_name`, `billing_email`, `billing_address`, or `credit_limit_cents` | | `app/customers.py` | `toggle_customer_credit_hold` | Toggle customer `status` between `active` and `credit_hold` + `AUD-####` | | `app/customers.py` | `toggle_dunning_pause` | Toggle customer `dunning_paused` flag (freezes/resumes dunning notices) | | `app/invoices.py` | `list_invoices` | List AR invoices newest-first with status/`customer_id`/currency filters, `limit=200`, `offset=0`, and `(as_of, as_known_at)` | | `app/invoices.py` | `issue_invoice` | Issue AR invoice (`INV-####`) with KMS-encrypted customer PII, optional `Customer` FK (`REL-13`), tax calculation, and unique `invoice_number` | | `app/invoices.py` | `get_invoice` | Fetch AR invoice (`404 invoice_not_found`) applying role-based PII masking (`masked_pii_roles`) at `(as_of, as_known_at)` | | `app/invoices.py` | `send_invoice` | Transition AR invoice `draft -> unpaid` (`400 invalid_state_transition` otherwise) + `AUD-####` | | `app/invoices.py` | `pay_invoice` | Settle AR invoice (`unpaid/partially_paid -> paid`) recording `PAY-####`, FX gain/loss to `ACC-8010`, and refusing paid/voided (`400 unpayable_invoice`) | | `app/invoices.py` | `void_invoice` | Void non-paid AR invoice (`draft/unpaid -> voided`, refusing `paid/voided` with `400 invalid_state_transition`) | | `app/invoices.py` | `list_credit_memos` | List AR/AP credit memos newest-first with `doc_kind`/status filters, `limit=200`, `offset=0`, and `(as_of, as_known_at)` | | `app/invoices.py` | `create_credit_memo` | Create signed negative credit memo (`CM-####`, `adjustment_cents <= 0`) linked optionally to `Invoice` (`REL-06`) | | `app/invoices.py` | `apply_credit_memo` | Apply `draft` credit memo to target AR/AP balance (`draft -> applied`, refusing non-draft with `400 invalid_state_transition`) | | `app/revenue.py` | `list_revenue_schedules` | List ASC 606 / IFRS 15 revenue recognition schedules (`REV-####`) filtered by `status`, `standard_mode` (`limit=200`, `offset=0`) | | `app/revenue.py` | `create_revenue_schedule` | Create revenue schedule (`REV-####`) with optional `invoice_id` (`REL-16`), `period_id` (`REL-17`), and `deferred_account_id` | | `app/revenue.py` | `get_revenue_schedule` | Fetch revenue schedule + obligations (`404 schedule_not_found`) | | `app/revenue.py` | `recognize_revenue_period` | Recognize periodic revenue (`active/recognizing -> recognizing/completed`) never exceeding `total_contract_cents` | | `app/revenue.py` | `pause_revenue_schedule` | Pause active revenue schedule (`active/recognizing -> paused`, refusing `completed` with `400 invalid_state_transition`) | | `app/revenue.py` | `list_revenue_obligations` | List nested ASC 606 `RevenueObligation` items (`POB-####`) for `{schedule_id}` (`limit=200`, `offset=0`) | | `app/revenue.py` | `add_revenue_obligation` | Add performance obligation (`POB-####`) enforcing `sum(allocation_bps) <= 10000` (`INV-ALLOC-02`) and `sum(allocated_cents) <= total_contract_cents` (`INV-CONS-03`) | | `app/revenue.py` | `delete_revenue_obligation` | Delete unfulfilled `RevenueObligation` (`POB-####`) without rewinding sequence counters | | `app/vendors.py` | `list_vendors` | List governed AP vendor masters (`VEND-####`) filtered by `status`, `payment_hold`, `vendor_code` (`limit=200`, `offset=0`) | | `app/vendors.py` | `create_vendor` | Create vendor master (`VEND-####`) enforcing unique `vendor_code` and KMS-encrypted contact PII | | `app/vendors.py` | `get_vendor` | Fetch vendor master (`404 vendor_not_found`) with role-based PII masking | | `app/vendors.py` | `update_vendor` | Patch mutable vendor `legal_name`, `contact_email`, or `ers_enabled` flag | | `app/vendors.py` | `toggle_vendor_hold` | Toggle vendor `payment_hold` boolean flag (`active <-> on_hold`) | | `app/vendors.py` | `archive_vendor` | Archive inactive/non-held vendor (`-> archived`, refusing already-archived with `400 invalid_state_transition`) | | `app/vendors.py` | `list_vendor_bank_changes` | List vendor bank IBAN change requests (`VBC-####`) filtered by `status`, `vendor_id` (`limit=200`, `offset=0`) | | `app/vendors.py` | `create_vendor_bank_change` | Open anti-fraud vendor bank change request (`VBC-####`) linked to `Vendor.vendor_id` (`REL-11`) | | `app/vendors.py` | `confirm_vendor_bank_change` | Confirm out-of-band vendor bank verification (`pending -> confirmed`) | | `app/vendors.py` | `approve_vendor_bank_change` | Dual-approve vendor bank change enforcing SOX SoD `approver_actor_id != requester_actor_id` (`INV-STATE-06`, `400 sod_violation`) | | `app/vendors.py` | `reject_vendor_bank_change` | Reject `pending/confirmed` vendor bank change (`-> rejected`) | | `app/procurement.py` | `list_purchase_orders` | List purchase orders newest-first with status/`vendor_id` filters, `limit=200`, `offset=0`, and `(as_of, as_known_at)` | | `app/procurement.py` | `create_purchase_order` | Create PO (`PO-####`) enforcing `0 <= tolerance_bps <= 500` (`INV-CEIL-02`), optional `Vendor` FK (`REL-14`), and unique `po_number` | | `app/procurement.py` | `get_purchase_order` | Fetch purchase order by `po_id` (`404 po_not_found`) at `(as_of, as_known_at)` | | `app/procurement.py` | `cancel_purchase_order` | Cancel open PO (`open -> cancelled`, refusing `received/matched/cancelled` with `400 invalid_state_transition`) | | `app/procurement.py` | `list_goods_receipts` | List goods receipts newest-first with `po_id`/status filters, `limit=200`, `offset=0`, and `(as_of, as_known_at)` | | `app/procurement.py` | `record_goods_receipt` | Record GRN (`GRN-####`) linked to `PurchaseOrder.po_id` (`REL-05`) and advance PO receipt status | | `app/bills.py` | `list_bills` | List AP vendor bills newest-first with status/`match_status`/`vendor_id` filters, `limit=200`, `offset=0`, and `(as_of, as_known_at)` | | `app/bills.py` | `record_bill` | Record AP bill (`BILL-####`) with KMS-encrypted vendor PII, optional `Vendor` FK (`REL-15`), 3-way variance check, and creator stamp | | `app/bills.py` | `get_bill` | Fetch AP bill (`404 bill_not_found`) with role-based PII masking at `(as_of, as_known_at)` | | `app/bills.py` | `approve_bill` | Approve matched AP bill enforcing SOX 404 SoD (`approver_actor != created_by_actor`, else `400 sod_violation`) | | `app/bills.py` | `override_bill_match` | Admin-only override of `variance_hold` AP bill (`match_status -> override_approved`) enforcing SOX 404 SoD + `AUD-####` | | `app/bills.py` | `pay_bill` | Disburse payment against approved/unpaid AP bill (`-> paid`), checking vendor bank-change hold, realized FX delta, and refusing double-pay (`400 unpayable_bill`) | | `app/payments.py` | `list_payments` | List AR/AP cash payments newest-first with direction/status filters, `limit=200`, `offset=0`, and `(as_of, as_known_at)` | | `app/payments.py` | `record_payment` | Settle payment (`PAY-####`) against `Account.bank_account_id` (`REL-07`) with `idempotency_key` deduplication (`INV-IDEMP-01`) | | `app/payments.py` | `get_payment` | Fetch single payment (`404 payment_not_found`) at `(as_of, as_known_at)` | | `app/payments.py` | `reverse_payment` | Reverse settled payment (`settled -> reversed`) posting offsetting GL entry + `AUD-####` | | `app/payments.py` | `list_bank_statements` | List imported `BankStatementLine` records (`BNK-####`) filtered by `status`, `bank_account_id`, `format_kind` (`limit=200`, `offset=0`) | | `app/payments.py` | `import_bank_statement_line` | Import `camt.053`/`MT940`/`BAI2` bank statement line (`BNK-####`) linked to `Account` (`REL-09`) with `idempotency_key` replay (`INV-IDEMP-04`) | | `app/payments.py` | `match_bank_line` | Match `unmatched` bank statement line (`unmatched -> matched`) to payment/invoice/bill | | `app/payments.py` | `reconcile_bank_line` | Reconcile `matched` bank statement line (`matched -> reconciled`, refusing `unmatched` with `400 invalid_state_transition`) | | `app/payments.py` | `exclude_bank_line` | Exclude `unmatched` bank statement line (`unmatched -> excluded`) with audit reason | | `app/fixed_assets.py` | `list_fixed_assets` | List fixed assets newest-first with `asset_class`/status filters, `limit=200`, `offset=0`, and `(as_of, as_known_at)` | | `app/fixed_assets.py` | `register_fixed_asset` | Register fixed asset (`FA-####`) enforcing `1 <= useful_life_months <= 600` (`INV-CEIL-03`) and `salvage_value_cents <= cost_cents` | | `app/fixed_assets.py` | `run_asset_depreciation` | Compute and post monthly straight-line/double-declining depreciation (`accumulated_depreciation_cents`++, `net_book_value_cents`--) | | `app/fixed_assets.py` | `dispose_fixed_asset` | Dispose active fixed asset (`-> disposed`) computing gain/loss against NBV and posting GL disposal entry | | `app/inventory.py` | `list_inventory_items` | List inventory SKUs newest-first with `valuation_method`/status filters, `limit=200`, `offset=0`, and `(as_of, as_known_at)` | | `app/inventory.py` | `create_inventory_item` | Register inventory SKU (`SKU-####`) with `fifo` or `weighted_avg` layer tracking and `total_value_cents = qty * unit_cost` | | `app/inventory.py` | `adjust_inventory_valuation` | Apply signed quantity/cost valuation layer adjustment (`qty_delta` receipt or COGS issue) preventing negative on-hand stock (`400 insufficient_inventory`) | | `app/intercompany.py` | `list_legal_entities` | List subsidiary legal entities (`LE-####`) filtered by `functional_currency`, `status` (`limit=200`, `offset=0`) | | `app/intercompany.py` | `create_legal_entity` | Create subsidiary legal entity (`LE-####`) enforcing unique `entity_code` and `aws_region` pinning | | `app/intercompany.py` | `toggle_legal_entity` | Toggle legal entity `status` (`active <-> inactive`) + `AUD-####` | | `app/intercompany.py` | `list_intercompany_transfers` | List intercompany transfers (`ICT-####`) filtered by `status`, `period_id` (`limit=200`, `offset=0`) | | `app/intercompany.py` | `create_intercompany_transfer` | Create draft intercompany charge (`ICT-####`) linking `LegalEntity` (`REL-22`) and `FiscalPeriod` (`REL-19`) | | `app/intercompany.py` | `get_intercompany_transfer` | Fetch intercompany transfer (`404 ic_transfer_not_found`) | | `app/intercompany.py` | `post_intercompany_transfer` | Post `draft -> posted` intercompany transfer (`400 invalid_state_transition` otherwise) | | `app/intercompany.py` | `eliminate_intercompany_transfer` | Eliminate `posted -> eliminated` intercompany transfer (`INV-STATE-07`, refusing `draft` with `400 invalid_state_transition`) | | `app/intercompany.py` | `dispute_intercompany_transfer` | Mark `draft/posted` intercompany transfer `disputed` with audit note | | `app/budgets.py` | `list_budgets` | List cost-center budget commitments (`BUD-####`) filtered by `status`, `cost_center`, `period_id` (`limit=200`, `offset=0`) | | `app/budgets.py` | `create_budget` | Create draft budget commitment (`BUD-####`) enforcing unique `budget_code` and `max_overrun_bps <= 2000` (`INV-CEIL-05`) | | `app/budgets.py` | `activate_budget` | Activate `draft -> active` budget commitment | | `app/budgets.py` | `encumber_budget` | Encumber funds against `active` budget (`INV-STATE-08`, enforcing `encumbered_cents <= allocated_cents * (10000 + max_overrun_bps) // 10000`) | | `app/budgets.py` | `freeze_budget` | Freeze `active` budget (`active -> frozen`, refusing `draft/frozen` with `400 invalid_state_transition`) | | `app/evidence.py` | `list_evidence_artifacts` | List S3 custody evidence artifacts (`EVID-####`) filtered by `doc_class`, `object_lock_mode`, `legal_hold` (`limit=200`, `offset=0`) | | `app/evidence.py` | `create_evidence_artifact` | Register evidence artifact (`EVID-####`) enforcing `size_bytes <= 10485760` (`INV-CEIL-06`) and forbidding S3 Object Lock on `contact_pii_export` | | `app/evidence.py` | `upload_evidence_bytes` | Upload evidence bytes (`<= 10485760` bytes) to Offstack S3 `erp-close-archives` computing SHA-256 | | `app/evidence.py` | `download_evidence_bytes` | Verify SHA-256 and stream evidence bytes from Offstack S3 (`QG-READ-IDEMP`) | | `app/evidence.py` | `toggle_evidence_legal_hold` | Toggle statutory `legal_hold` on evidence artifact + `AUD-####` | | `app/reporting.py` | `list_fx_rates` | List dated FX conversion rates (`FXRT-####`) filtered by `from_currency`, `to_currency`, `effective_date` (`limit=200`, `offset=0`, `(as_of, as_known_at)`) | | `app/reporting.py` | `upsert_fx_rate` | Create (`201`) or idempotently replay (`200`) dated FX rate on `rate_key` (`INV-IDEMP-03`, `rate_micros <= 1000000000` `INV-CEIL-04`) | | `app/reporting.py` | `list_fx_revaluations` | List period-end FX revaluation runs newest-first with `period_code`/currency filters, `limit=200`, `offset=0`, and `(as_of, as_known_at)` | | `app/reporting.py` | `run_fx_revaluation` | Compute unrealized/realized FX revaluation (`FXR-####`) across foreign-currency open items (`dry_run` preview or commit) | | `app/reporting.py` | `get_trial_balance` | Read-only zero-write bitemporal trial balance verifying `total_debits == total_credits` at `(as_of, as_known_at)` (`QG-READ-IDEMP`) | | `app/reporting.py` | `get_aging_report` | Read-only server-computed AR/AP aging buckets (`current`, `1_30`, `31_60`, `61_90`, `90_plus`) at `(as_of, as_known_at)` (`QG-READ-IDEMP`) | | `app/reporting.py` | `get_tax_summary` | Read-only jurisdiction VAT / Sales Tax liability summary at `(as_of, as_known_at)` (`QG-READ-IDEMP`) | | `app/reporting.py` | `run_benford_audit` | Run Benford's Law first-digit chi-square test across posted journals (`chi2 > 15.51` flags anomaly + `AUD-####`) | ### §1.3 Typed Python Facade Signatures Every `list_*` facade enforces `limit: int = 200, offset: int = 0` matching `§3` verbatim. The bitemporal facades (`list_audit_logs`, `list_accounts`, `create_account`, `get_account`, `update_account`, `archive_account`, `list_fiscal_periods`, `create_fiscal_period`, `get_fiscal_period`, `close_fiscal_period`, `reopen_fiscal_period`, `list_close_tasks`, `list_tax_rates`, `create_tax_rate`, `toggle_tax_rate`, `list_journals`, `record_journal`, `get_journal`, `reverse_journal`, `void_journal`, `list_journal_lines`, `add_journal_line`, `list_invoices`, `issue_invoice`, `get_invoice`, `send_invoice`, `pay_invoice`, `void_invoice`, `list_credit_memos`, `create_credit_memo`, `apply_credit_memo`, `list_purchase_orders`, `create_purchase_order`, `get_purchase_order`, `cancel_purchase_order`, `list_goods_receipts`, `record_goods_receipt`, `list_bills`, `record_bill`, `get_bill`, `approve_bill`, `override_bill_match`, `pay_bill`, `list_payments`, `record_payment`, `get_payment`, `reverse_payment`, `list_fixed_assets`, `register_fixed_asset`, `run_asset_depreciation`, `dispose_fixed_asset`, `list_inventory_items`, `create_inventory_item`, `adjust_inventory_valuation`, `list_fx_rates`, `upsert_fx_rate`, `list_fx_revaluations`, `run_fx_revaluation`, `get_trial_balance`, `get_aging_report`, `get_tax_summary`, `run_benford_audit`) accept and propagate `as_of: str = ""` (`effective_at <= as_of`) and `as_known_at: str = ""` (`recorded_at <= as_known_at`) with zero wall-clock shortcuts on historical reads. ```python from typing import Any def get_time_axis_overview( corp_id: str, ) -> dict[str, Any]: ... def list_audit_logs( corp_id: str, entity_type: str = "", action: str = "", anomaly_only: bool | None = None, limit: int = 200, offset: int = 0, actor_role: str = "owner", as_of: str = "", as_known_at: str = "", ) -> list[dict[str, Any]]: ... def list_accounts( corp_id: str, account_type: str = "", status: str = "", currency: str = "", limit: int = 200, offset: int = 0, as_of: str = "", as_known_at: str = "", ) -> list[dict[str, Any]]: ... def create_account( corp_id: str, code: str, name: str, account_type: str, normal_balance: str, currency: str = "USD", is_control_account: bool = False, allow_manual_posting: bool = True, as_of: str = "", as_known_at: str = "", ) -> dict[str, Any]: ... def get_account( corp_id: str, account_id: str, as_of: str = "", as_known_at: str = "", ) -> dict[str, Any]: ... def update_account( corp_id: str, account_id: str, name: str = "", allow_manual_posting: bool | None = None, as_of: str = "", as_known_at: str = "", ) -> dict[str, Any]: ... def archive_account( corp_id: str, account_id: str, as_of: str = "", as_known_at: str = "", ) -> dict[str, Any]: ... def list_fiscal_periods( corp_id: str, status: str = "", period_code: str = "", limit: int = 200, offset: int = 0, as_of: str = "", as_known_at: str = "", ) -> list[dict[str, Any]]: ... def create_fiscal_period( corp_id: str, period_code: str, start_date: str, end_date: str, close_checklist_complete: bool = False, as_of: str = "", as_known_at: str = "", ) -> dict[str, Any]: ... def get_fiscal_period( corp_id: str, period_id: str, as_of: str = "", as_known_at: str = "", ) -> dict[str, Any]: ... def close_fiscal_period( corp_id: str, period_id: str, actor_role: str = "owner", as_of: str = "", as_known_at: str = "", ) -> dict[str, Any]: ... def reopen_fiscal_period( corp_id: str, period_id: str, reason: str, actor_role: str = "owner", as_of: str = "", as_known_at: str = "", ) -> dict[str, Any]: ... def list_close_tasks( corp_id: str, period_id: str = "", owner_role: str = "", status: str = "", limit: int = 200, offset: int = 0, as_of: str = "", as_known_at: str = "", ) -> list[dict[str, Any]]: ... def create_close_task( corp_id: str, task_code: str, title: str, period_id: str, owner_role: str = "gl_accountant", sequence_order: int = 1, ) -> dict[str, Any]: ... def start_close_task( corp_id: str, close_task_id: str, ) -> dict[str, Any]: ... def signoff_close_task( corp_id: str, close_task_id: str, signed_off_by: str = "controller_1", ) -> dict[str, Any]: ... def waive_close_task( corp_id: str, close_task_id: str, reason: str = "non_material", ) -> dict[str, Any]: ... def list_tax_rates( corp_id: str, jurisdiction: str = "", tax_type: str = "", active: bool | None = None, limit: int = 200, offset: int = 0, as_of: str = "", as_known_at: str = "", ) -> list[dict[str, Any]]: ... def create_tax_rate( corp_id: str, tax_code: str, jurisdiction: str, tax_type: str, rate_bps: int, liability_account_id: str, active: bool = True, as_of: str = "", as_known_at: str = "", ) -> dict[str, Any]: ... def toggle_tax_rate( corp_id: str, tax_rate_id: str, active: bool, as_of: str = "", as_known_at: str = "", ) -> dict[str, Any]: ... def list_journals( corp_id: str, status: str = "", period_code: str = "", source_module: str = "", limit: int = 200, offset: int = 0, as_of: str = "", as_known_at: str = "", ) -> list[dict[str, Any]]: ... def record_journal( corp_id: str, period_id: str, posting_date: str, description: str, total_debit_cents: int, total_credit_cents: int, currency: str = "USD", fx_rate_micros: int = 1000000, reference: str = "", source_module: str = "gl_manual", lines: list[dict[str, Any]] | None = None, as_of: str = "", as_known_at: str = "", ) -> dict[str, Any]: ... def get_journal( corp_id: str, journal_id: str, as_of: str = "", as_known_at: str = "", ) -> dict[str, Any]: ... def reverse_journal( corp_id: str, journal_id: str, reason: str = "", posting_date: str = "", as_of: str = "", as_known_at: str = "", ) -> dict[str, Any]: ... def void_journal( corp_id: str, journal_id: str, reason: str = "", as_of: str = "", as_known_at: str = "", ) -> dict[str, Any]: ... def list_journal_lines( corp_id: str, journal_id: str, account_id: str = "", limit: int = 200, offset: int = 0, as_of: str = "", as_known_at: str = "", ) -> list[dict[str, Any]]: ... def add_journal_line( corp_id: str, journal_id: str, account_id: str, debit_cents: int = 0, credit_cents: int = 0, signed_amount_cents: int = 0, allocation_bps: int = 0, memo: str = "", as_of: str = "", as_known_at: str = "", ) -> dict[str, Any]: ... def list_customers( corp_id: str, status: str = "", dunning_paused: bool | None = None, customer_code: str = "", limit: int = 200, offset: int = 0, ) -> list[dict[str, Any]]: ... def create_customer( corp_id: str, customer_code: str, legal_name: str, billing_email: str, billing_address: str, credit_limit_cents: int = 5000000, ar_account_id: str = "", dunning_paused: bool = False, ) -> dict[str, Any]: ... def get_customer( corp_id: str, customer_id: str, actor_role: str = "ar_clerk", ) -> dict[str, Any]: ... def update_customer( corp_id: str, customer_id: str, legal_name: str = "", billing_email: str = "", billing_address: str = "", credit_limit_cents: int | None = None, ) -> dict[str, Any]: ... def toggle_customer_credit_hold( corp_id: str, customer_id: str, hold_active: bool = True, ) -> dict[str, Any]: ... def toggle_dunning_pause( corp_id: str, customer_id: str, dunning_paused: bool = True, ) -> dict[str, Any]: ... def list_invoices( corp_id: str, status: str = "", customer_id: str = "", currency: str = "", limit: int = 200, offset: int = 0, as_of: str = "", as_known_at: str = "", ) -> list[dict[str, Any]]: ... def issue_invoice( corp_id: str, invoice_number: str, customer_name: str, customer_email: str, billing_address: str, due_date: str, subtotal_cents: int, customer_id: str = "", tax_rate_id: str = "", currency: str = "USD", fx_rate_micros: int = 1000000, payment_terms: str = "net_30", ar_account_id: str = "ACC-1200", revenue_account_id: str = "ACC-4000", as_of: str = "", as_known_at: str = "", ) -> dict[str, Any]: ... def get_invoice( corp_id: str, invoice_id: str, as_of: str = "", as_known_at: str = "", ) -> dict[str, Any]: ... def send_invoice( corp_id: str, invoice_id: str, as_of: str = "", as_known_at: str = "", ) -> dict[str, Any]: ... def pay_invoice( corp_id: str, invoice_id: str, bank_account_id: str = "ACC-1010", amount_cents: int | None = None, settlement_fx_rate_micros: int = 1000000, payment_method: str = "ach", idempotency_key: str = "", as_of: str = "", as_known_at: str = "", ) -> dict[str, Any]: ... def void_invoice( corp_id: str, invoice_id: str, reason: str = "", as_of: str = "", as_known_at: str = "", ) -> dict[str, Any]: ... def list_credit_memos( corp_id: str, doc_kind: str = "", status: str = "", limit: int = 200, offset: int = 0, as_of: str = "", as_known_at: str = "", ) -> list[dict[str, Any]]: ... def create_credit_memo( corp_id: str, memo_number: str, doc_kind: str, adjustment_cents: int, reason: str, invoice_id: str = "", bill_id: str = "", tax_adjustment_cents: int = 0, as_of: str = "", as_known_at: str = "", ) -> dict[str, Any]: ... def apply_credit_memo( corp_id: str, credit_memo_id: str, as_of: str = "", as_known_at: str = "", ) -> dict[str, Any]: ... def list_revenue_schedules( corp_id: str, status: str = "", standard_mode: str = "", limit: int = 200, offset: int = 0, ) -> list[dict[str, Any]]: ... def create_revenue_schedule( corp_id: str, contract_ref: str, total_contract_cents: int, standard_mode: str = "asc_606", invoice_id: str = "", period_id: str = "", deferred_account_id: str = "", ) -> dict[str, Any]: ... def get_revenue_schedule( corp_id: str, schedule_id: str, ) -> dict[str, Any]: ... def recognize_revenue_period( corp_id: str, schedule_id: str, recognize_cents: int, period_id: str = "", ) -> dict[str, Any]: ... def pause_revenue_schedule( corp_id: str, schedule_id: str, reason: str = "contract_modification", ) -> dict[str, Any]: ... def list_revenue_obligations( corp_id: str, schedule_id: str, satisfaction_method: str = "", limit: int = 200, offset: int = 0, ) -> list[dict[str, Any]]: ... def add_revenue_obligation( corp_id: str, schedule_id: str, obligation_code: str, description: str, satisfaction_method: str = "ratable", allocation_bps: int = 10000, allocated_cents: int = 0, ) -> dict[str, Any]: ... def delete_revenue_obligation( corp_id: str, schedule_id: str, obligation_id: str, ) -> dict[str, Any]: ... def list_vendors( corp_id: str, status: str = "", payment_hold: bool | None = None, vendor_code: str = "", limit: int = 200, offset: int = 0, ) -> list[dict[str, Any]]: ... def create_vendor( corp_id: str, vendor_code: str, legal_name: str, contact_email: str, tax_id: str, bank_iban: str = "", ap_account_id: str = "", payment_hold: bool = False, ers_enabled: bool = False, ) -> dict[str, Any]: ... def get_vendor( corp_id: str, vendor_id: str, actor_role: str = "ap_clerk", ) -> dict[str, Any]: ... def update_vendor( corp_id: str, vendor_id: str, legal_name: str = "", contact_email: str = "", ers_enabled: bool | None = None, ) -> dict[str, Any]: ... def toggle_vendor_hold( corp_id: str, vendor_id: str, payment_hold: bool = True, ) -> dict[str, Any]: ... def archive_vendor( corp_id: str, vendor_id: str, ) -> dict[str, Any]: ... def list_vendor_bank_changes( corp_id: str, status: str = "", vendor_id: str = "", limit: int = 200, offset: int = 0, ) -> list[dict[str, Any]]: ... def create_vendor_bank_change( corp_id: str, vendor_id: str, new_iban: str, requester_actor_id: str = "ap_clerk_1", ) -> dict[str, Any]: ... def confirm_vendor_bank_change( corp_id: str, bank_change_id: str, ) -> dict[str, Any]: ... def approve_vendor_bank_change( corp_id: str, bank_change_id: str, approver_actor_id: str, ) -> dict[str, Any]: ... def reject_vendor_bank_change( corp_id: str, bank_change_id: str, reason: str = "verification_failed", ) -> dict[str, Any]: ... def list_purchase_orders( corp_id: str, status: str = "", vendor_id: str = "", limit: int = 200, offset: int = 0, as_of: str = "", as_known_at: str = "", ) -> list[dict[str, Any]]: ... def create_purchase_order( corp_id: str, po_number: str, vendor_name: str, expected_qty: int, unit_price_cents: int, vendor_id: str = "", currency: str = "USD", tolerance_bps: int = 100, actor_role: str = "ap_clerk", as_of: str = "", as_known_at: str = "", ) -> dict[str, Any]: ... def get_purchase_order( corp_id: str, po_id: str, as_of: str = "", as_known_at: str = "", ) -> dict[str, Any]: ... def cancel_purchase_order( corp_id: str, po_id: str, reason: str = "", as_of: str = "", as_known_at: str = "", ) -> dict[str, Any]: ... def list_goods_receipts( corp_id: str, po_id: str = "", status: str = "", limit: int = 200, offset: int = 0, as_of: str = "", as_known_at: str = "", ) -> list[dict[str, Any]]: ... def record_goods_receipt( corp_id: str, receipt_number: str, po_id: str, received_qty: int, received_value_cents: int, warehouse_code: str = "WH-MAIN", as_of: str = "", as_known_at: str = "", ) -> dict[str, Any]: ... def list_bills( corp_id: str, status: str = "", match_status: str = "", vendor_id: str = "", limit: int = 200, offset: int = 0, as_of: str = "", as_known_at: str = "", ) -> list[dict[str, Any]]: ... def record_bill( corp_id: str, bill_number: str, vendor_contact_email: str, vendor_tax_id: str, due_date: str, subtotal_cents: int, vendor_id: str = "", po_id: str = "", receipt_id: str = "", tax_rate_id: str = "", currency: str = "USD", fx_rate_micros: int = 1000000, created_by_actor: str = "ap_clerk_1", as_of: str = "", as_known_at: str = "", ) -> dict[str, Any]: ... def get_bill( corp_id: str, bill_id: str, as_of: str = "", as_known_at: str = "", ) -> dict[str, Any]: ... def approve_bill( corp_id: str, bill_id: str, approver_actor: str, actor_role: str = "erp_admin", as_of: str = "", as_known_at: str = "", ) -> dict[str, Any]: ... def override_bill_match( corp_id: str, bill_id: str, approver_actor: str, override_reason: str, actor_role: str = "erp_admin", as_of: str = "", as_known_at: str = "", ) -> dict[str, Any]: ... def pay_bill( corp_id: str, bill_id: str, bank_account_id: str = "ACC-1010", amount_cents: int | None = None, settlement_fx_rate_micros: int = 1000000, payment_method: str = "ach", idempotency_key: str = "", as_of: str = "", as_known_at: str = "", ) -> dict[str, Any]: ... def list_payments( corp_id: str, direction: str = "", status: str = "", limit: int = 200, offset: int = 0, as_of: str = "", as_known_at: str = "", ) -> list[dict[str, Any]]: ... def record_payment( corp_id: str, idempotency_key: str, direction: str, bank_account_id: str, amount_cents: int, invoice_id: str = "", bill_id: str = "", settlement_currency: str = "USD", settlement_fx_rate_micros: int = 1000000, payment_method: str = "ach", as_of: str = "", as_known_at: str = "", ) -> dict[str, Any]: ... def get_payment( corp_id: str, payment_id: str, as_of: str = "", as_known_at: str = "", ) -> dict[str, Any]: ... def reverse_payment( corp_id: str, payment_id: str, reason: str = "", as_of: str = "", as_known_at: str = "", ) -> dict[str, Any]: ... def list_bank_statements( corp_id: str, status: str = "", bank_account_id: str = "", format_kind: str = "", limit: int = 200, offset: int = 0, ) -> list[dict[str, Any]]: ... def import_bank_statement_line( corp_id: str, idempotency_key: str, bank_account_id: str, statement_date: str, amount_cents: int, format_kind: str = "camt_053", reference_text: str = "", ) -> dict[str, Any]: ... def match_bank_line( corp_id: str, statement_line_id: str, payment_id: str = "", ) -> dict[str, Any]: ... def reconcile_bank_line( corp_id: str, statement_line_id: str, ) -> dict[str, Any]: ... def exclude_bank_line( corp_id: str, statement_line_id: str, reason: str = "bank_fee_duplicate", ) -> dict[str, Any]: ... def list_fixed_assets( corp_id: str, asset_class: str = "", status: str = "", limit: int = 200, offset: int = 0, as_of: str = "", as_known_at: str = "", ) -> list[dict[str, Any]]: ... def register_fixed_asset( corp_id: str, asset_tag: str, asset_name: str, asset_class: str, acquisition_date: str, cost_cents: int, salvage_value_cents: int, useful_life_months: int, depreciation_method: str = "straight_line", asset_account_id: str = "ACC-1500", accum_depr_account_id: str = "ACC-1590", expense_account_id: str = "ACC-6200", as_of: str = "", as_known_at: str = "", ) -> dict[str, Any]: ... def run_asset_depreciation( corp_id: str, asset_id: str, period_id: str, as_of: str = "", as_known_at: str = "", ) -> dict[str, Any]: ... def dispose_fixed_asset( corp_id: str, asset_id: str, proceeds_cents: int, period_id: str, as_of: str = "", as_known_at: str = "", ) -> dict[str, Any]: ... def list_inventory_items( corp_id: str, valuation_method: str = "", status: str = "", limit: int = 200, offset: int = 0, as_of: str = "", as_known_at: str = "", ) -> list[dict[str, Any]]: ... def create_inventory_item( corp_id: str, sku_code: str, item_name: str, valuation_method: str, quantity_on_hand: int, unit_cost_cents: int, inventory_account_id: str = "ACC-1300", cogs_account_id: str = "ACC-5000", as_of: str = "", as_known_at: str = "", ) -> dict[str, Any]: ... def adjust_inventory_valuation( corp_id: str, sku_id: str, qty_delta: int, unit_cost_cents: int, reason: str, period_id: str, as_of: str = "", as_known_at: str = "", ) -> dict[str, Any]: ... def list_legal_entities( corp_id: str, functional_currency: str = "", status: str = "", limit: int = 200, offset: int = 0, ) -> list[dict[str, Any]]: ... def create_legal_entity( corp_id: str, entity_code: str, legal_name: str, functional_currency: str = "USD", jurisdiction: str = "US", aws_region: str = "us-east-1", ) -> dict[str, Any]: ... def toggle_legal_entity( corp_id: str, legal_entity_id: str, active: bool = True, ) -> dict[str, Any]: ... def list_intercompany_transfers( corp_id: str, status: str = "", period_id: str = "", limit: int = 200, offset: int = 0, ) -> list[dict[str, Any]]: ... def create_intercompany_transfer( corp_id: str, transfer_code: str, amount_cents: int, from_entity_id: str = "", to_entity_id: str = "", period_id: str = "", currency: str = "USD", ) -> dict[str, Any]: ... def get_intercompany_transfer( corp_id: str, ic_transfer_id: str, ) -> dict[str, Any]: ... def post_intercompany_transfer( corp_id: str, ic_transfer_id: str, ) -> dict[str, Any]: ... def eliminate_intercompany_transfer( corp_id: str, ic_transfer_id: str, ) -> dict[str, Any]: ... def dispute_intercompany_transfer( corp_id: str, ic_transfer_id: str, reason: str = "amount_mismatch", ) -> dict[str, Any]: ... def list_budgets( corp_id: str, status: str = "", cost_center: str = "", period_id: str = "", limit: int = 200, offset: int = 0, ) -> list[dict[str, Any]]: ... def create_budget( corp_id: str, budget_code: str, cost_center: str, allocated_cents: int, period_id: str = "", account_id: str = "", max_overrun_bps: int = 500, ) -> dict[str, Any]: ... def activate_budget( corp_id: str, budget_id: str, ) -> dict[str, Any]: ... def encumber_budget( corp_id: str, budget_id: str, amount_cents: int, ) -> dict[str, Any]: ... def freeze_budget( corp_id: str, budget_id: str, ) -> dict[str, Any]: ... def list_evidence_artifacts( corp_id: str, doc_class: str = "", object_lock_mode: str = "", legal_hold: bool | None = None, limit: int = 200, offset: int = 0, ) -> list[dict[str, Any]]: ... def create_evidence_artifact( corp_id: str, doc_class: str, target_ref_id: str, file_name: str, size_bytes: int = 1024, object_lock_mode: str = "none", retention_days: int = 2555, legal_hold: bool = False, ) -> dict[str, Any]: ... def upload_evidence_bytes( corp_id: str, artifact_id: str, payload: bytes, ) -> dict[str, Any]: ... def download_evidence_bytes( corp_id: str, artifact_id: str, ) -> dict[str, Any]: ... def toggle_evidence_legal_hold( corp_id: str, artifact_id: str, legal_hold: bool = True, ) -> dict[str, Any]: ... def list_fx_rates( corp_id: str, from_currency: str = "", to_currency: str = "", effective_date: str = "", limit: int = 200, offset: int = 0, as_of: str = "", as_known_at: str = "", ) -> list[dict[str, Any]]: ... def upsert_fx_rate( corp_id: str, rate_key: str, from_currency: str, to_currency: str, rate_micros: int, effective_date: str = "2026-01-15", as_of: str = "", as_known_at: str = "", ) -> dict[str, Any]: ... def list_fx_revaluations( corp_id: str, period_code: str = "", currency: str = "", limit: int = 200, offset: int = 0, as_of: str = "", as_known_at: str = "", ) -> list[dict[str, Any]]: ... def run_fx_revaluation( corp_id: str, period_id: str, currency: str, closing_fx_rate_micros: int, dry_run: bool = False, as_of: str = "", as_known_at: str = "", ) -> dict[str, Any]: ... def get_trial_balance( corp_id: str, period_code: str = "", as_of: str = "", as_known_at: str = "", ) -> dict[str, Any]: ... def get_aging_report( corp_id: str, ledger_side: str = "ar", as_of: str = "", as_known_at: str = "", ) -> dict[str, Any]: ... def get_tax_summary( corp_id: str, period_code: str = "", as_of: str = "", as_known_at: str = "", ) -> dict[str, Any]: ... def run_benford_audit( corp_id: str, period_code: str = "", as_of: str = "", as_known_at: str = "", ) -> dict[str, Any]: ... ``` ### §1.4 Behavioral Laws, Executable Invariants & Error Vocabulary - **LAW-01 — Pagination, Read Idempotency & Deterministic Ordering:** Every `list_*` route defaults to `DEFAULT_LIST_LIMIT = 200` (`1..500`, `400 invalid_limit`), `offset >= 0` (`400 invalid_offset`), emits `X-Total-Count`/`X-Limit`/`X-Offset`, and sorts newest-first (`Account` sorts `code ASC`). Every `GET` route writes zero DynamoDB/S3 rows or `AUD-####` entries (`QG-READ-IDEMP`). - **LAW-02 — Bitemporal Dual-Clock Isolation:** Every financial record persists immutable event-time `effective_at` (`as_of`) and system transaction-time `recorded_at` (`as_known_at`). Bitemporal queries exclude records where `effective_at > as_of` or `recorded_at > as_known_at`, propagating `(as_of, as_known_at)` through trial balance, aging, and tax summary with zero wall-clock shortcuts. - **LAW-03 — Double-Entry Zero-Sum Conservation (`INV-CONS-01`, `INV-CONS-02`):** `record_journal` requires `total_debit_cents > 0` and `total_debit_cents == total_credit_cents` (`400 unbalanced_journal`), committing atomically via DynamoDB `TransactWriteItems`. Appended `JournalLine` rows must satisfy `sum(debit_cents) <= total_debit_cents` and `sum(credit_cents) <= total_credit_cents`. - **LAW-04 — Allocation Basis-Point Ceilings (`INV-ALLOC-01`, `INV-ALLOC-02`):** Cumulative `JournalLine.allocation_bps` per `journal_id` and `RevenueObligation.allocation_bps` per `schedule_id` MUST satisfy `sum(allocation_bps) <= 10000` (`100.00%`); over-allocation rejects with `400 allocation_exceeds_10000_bps`. - **LAW-05 — Fiscal Period Close Locks & Close Tasks (`INV-STATE-01`):** Posting journals, depreciating assets, adjusting inventory, or settling payments into a `closed` `FiscalPeriod` fails closed with `400 closed_period`. Re-closing an already-closed period fails with `400 closed_period`. Reopening requires admin role and non-empty `reason`. `CloseTask` moves `open -> in_progress -> signed_off | waived`. - **LAW-06 — Immutable Journal Reversals & Voids (`INV-STATE-02`, `INV-STATE-03`):** Posted journals transition strictly via `reverse_journal` (`posted -> reversed`, minting an offsetting `JE-####` with `reverses_journal_id` and negated `signed_amount_cents`) or `void_journal` (`posted -> voided`). Re-voiding or reversing non-posted entries rejects with `400 unvoidable_journal`. - **LAW-07 — Chart of Accounts Uniqueness & Archive Guard (`INV-IDEMP-02`, `INV-STATE-05`):** `create_account` enforces per-corp unique `code` (`200` idempotent replay on identical payload, `409 duplicate_key` on mismatch). `archive_account` transitions `active -> archived`, rejecting already-archived or non-zero control accounts with `400 unarchivable_account`. - **LAW-08 — Customer Credit Limit, AR Invoices & Credit Memos (`INV-CEIL-07`, `INV-STATE-04`):** `Customer.credit_limit_cents` obeys `0 <= credit_limit_cents <= 10000000000` (`400 invalid_customer`). Invoices move `draft -> unpaid -> partially_paid -> paid` or `voided`; paying `paid`/`voided` raises `400 unpayable_invoice`. `CreditMemo.adjustment_cents` uses signed money (`min_value=-99999999999; max_value=0`). - **LAW-09 — ASC 606 / IFRS 15 Revenue Schedule Conservation (`INV-CONS-03`, `INV-ALLOC-02`):** Cumulative `RevenueObligation.allocated_cents` per `schedule_id` MUST NOT exceed `RevenueSchedule.total_contract_cents` (`400 allocation_mismatch`). `recognize_revenue_period` advances `recognized_cents` without exceeding `total_contract_cents`. - **LAW-10 — 3-Way PO-Receipt-Bill Match & Variance Hold (`INV-CEIL-02`):** `PurchaseOrder.tolerance_bps` obeys `0 <= tolerance_bps <= 500` (`400 invalid_purchase_order`). `record_bill` linked to `po_id` compares quantity and `subtotal_cents` against `PurchaseOrder` and `GoodsReceipt`; exceeding `tolerance_bps` sets `status=variance_hold`, blocking payment until `override_bill_match`. - **LAW-11 — SOX 404 Segregation of Duties (`SoD`, `INV-STATE-06`):** On `approve_bill` and `override_bill_match`, `approver_actor` MUST differ from `Bill.created_by_actor`; on `approve_vendor_bank_change`, `approver_actor_id` MUST differ from `VendorBankChange.requester_actor_id` (`400 sod_violation`). Vendors with `payment_hold=true` block disbursements (`400 unpayable_bill`). - **LAW-12 — Realized FX Settlement & Dated FX Rate Ceiling (`INV-CEIL-04`, `INV-IDEMP-03`):** `FxRate.rate_micros` obeys `1 <= rate_micros <= 1000000000` (`400 invalid_fx_rate`) and replays idempotently on `rate_key` (`200` / `409 duplicate_key`). Cash settlements compute signed `fx_gain_loss_cents` to `ACC-8010`. `run_fx_revaluation` supports `dry_run=true` without writes. - **LAW-13 — Tax Rate Cap Unity (`INV-CEIL-01`):** `TaxRate.rate_bps` obeys `0 <= rate_bps <= 3500` (`35.00%` max statutory rate); values above `3500` reject with `400 invalid_tax_rate`. - **LAW-14 — Fixed Asset Depreciation & Disposal Bounds (`INV-CEIL-03`):** `FixedAsset.useful_life_months` obeys `1 <= useful_life_months <= 600`; `salvage_value_cents <= cost_cents`. `run_asset_depreciation` never reduces `net_book_value_cents` below `salvage_value_cents` (`400 invalid_fixed_asset`). - **LAW-15 — Inventory Valuation & Non-Negative Stock:** `adjust_inventory_valuation` updates FIFO layer queues or weighted-average unit cost atomically and rejects stock issues causing `quantity_on_hand < 0` with `400 insufficient_inventory`. - **LAW-16 — Idempotent Payment & Bank Feed Deduplication (`INV-IDEMP-01`, `INV-IDEMP-04`):** `record_payment` and `import_bank_statement_line` require unique `idempotency_key` (`201` on create, `200` on exact replay, `409 duplicate_key` on mismatch). `BankStatementLine` moves `unmatched -> matched -> reconciled` (`400 invalid_state_transition` if un-matched). - **LAW-17 — Multi-Entity Intercompany Elimination (`INV-STATE-07`):** `IntercompanyTransfer` moves `draft -> posted -> eliminated` (or `disputed`). Attempting to eliminate a `draft` or `disputed` transfer rejects with `400 invalid_state_transition`. - **LAW-18 — Budget Commitment Encumbrance Ceiling (`INV-CEIL-05`, `INV-STATE-08`):** `BudgetCommitment.max_overrun_bps` obeys `0 <= max_overrun_bps <= 2000` (`400 invalid_budget`). Encumbering a `draft` or `frozen` budget rejects (`400 invalid_state_transition`), and over-encumbering beyond `allocated_cents * (10000 + max_overrun_bps) // 10000` rejects (`400 budget_exceeded`). - **LAW-19 — Selective S3 Object Lock Evidence Custody (`INV-CEIL-06`):** `EvidenceArtifact.size_bytes` obeys `1 <= size_bytes <= 10485760` (`400 invalid_evidence`). S3 Object Lock (`governance`/`compliance`) is allowed on statutory archives (`close_binder`, `vat_invoice_xml`, `match_packet`, `sox_workpaper`) and strictly forbidden on `contact_pii_export` (`400 invalid_evidence`). - **LAW-20 — Benford's Law Audit & Hash-Chained Audit Ledger:** `run_benford_audit` evaluates leading digits `1..9` against `log10(1+1/d)`; `chi2 > 15.51` (`chi2_bps > 155100`) sets `anomaly_flagged=true` and writes `AUD-####`. Every mutating endpoint appends a contiguous SHA-256 `prev_hash`/`entry_hash` `AuditLog` (`"0"*64` genesis). #### Executable Invariants Table | ID | Kind | Entity | Child Entity | Parent Field | Child Field | Ceiling Field | Setup Route | Setup Body | Probe Route | Probe Body | List Route | Expected Status | Expected Code | | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | | `INV-CONS-01` | `conservation_sum` | `JournalEntry` | `JournalLine` | `total_debit_cents` | `debit_cents` | `` | `POST /api/journals` | `{"period_id": "{period_id}", "posting_date": "2026-01-15", "description": "Probe debit sum", "total_debit_cents": 10000, "total_credit_cents": 10000, "currency": "USD", "fx_rate_micros": 1000000}` | `POST /api/journals/{journal_id}/lines` | `{"account_id": "{account_id}", "debit_cents": 15000, "credit_cents": 0, "signed_amount_cents": 15000, "allocation_bps": 10000, "memo": "Exceeds header debit"}` | `GET /api/journals/{journal_id}/lines` | `400` | `unbalanced_journal` | | `INV-CONS-02` | `conservation_sum` | `JournalEntry` | `JournalLine` | `total_credit_cents` | `credit_cents` | `` | `POST /api/journals` | `{"period_id": "{period_id}", "posting_date": "2026-01-15", "description": "Probe credit sum", "total_debit_cents": 10000, "total_credit_cents": 10000, "currency": "USD", "fx_rate_micros": 1000000}` | `POST /api/journals/{journal_id}/lines` | `{"account_id": "{account_id}", "debit_cents": 0, "credit_cents": 15000, "signed_amount_cents": -15000, "allocation_bps": 10000, "memo": "Exceeds header credit"}` | `GET /api/journals/{journal_id}/lines` | `400` | `unbalanced_journal` | | `INV-CONS-03` | `conservation_sum` | `RevenueSchedule` | `RevenueObligation` | `total_contract_cents` | `allocated_cents` | `` | `POST /api/revenue-schedules` | `{"contract_ref": "CTR-CONS-{sentinel}", "total_contract_cents": 100000, "standard_mode": "asc_606"}` | `POST /api/revenue-schedules/{schedule_id}/obligations` | `{"obligation_code": "POB-OVR-{sentinel}", "description": "Exceeds contract sum", "satisfaction_method": "ratable", "allocation_bps": 10000, "allocated_cents": 150000}` | `GET /api/revenue-schedules/{schedule_id}/obligations` | `400` | `allocation_mismatch` | | `INV-ALLOC-01` | `allocation_total` | `JournalEntry` | `JournalLine` | `` | `allocation_bps` | `` | `POST /api/journals` | `{"period_id": "{period_id}", "posting_date": "2026-01-15", "description": "Probe allocation bps", "total_debit_cents": 10000, "total_credit_cents": 10000, "currency": "USD", "fx_rate_micros": 1000000}` | `POST /api/journals/{journal_id}/lines` | `{"account_id": "{account_id}", "debit_cents": 5000, "credit_cents": 0, "signed_amount_cents": 5000, "allocation_bps": 6000, "memo": "Exceeds 10000 bps"}` | `GET /api/journals/{journal_id}/lines` | `400` | `allocation_exceeds_10000_bps` | | `INV-ALLOC-02` | `allocation_total` | `RevenueSchedule` | `RevenueObligation` | `` | `allocation_bps` | `` | `POST /api/revenue-schedules` | `{"contract_ref": "CTR-ALLOC-{sentinel}", "total_contract_cents": 100000, "standard_mode": "ifrs_15"}` | `POST /api/revenue-schedules/{schedule_id}/obligations` | `{"obligation_code": "POB-BPS-{sentinel}", "description": "Exceeds 10000 bps", "satisfaction_method": "point_in_time", "allocation_bps": 6000, "allocated_cents": 50000}` | `GET /api/revenue-schedules/{schedule_id}/obligations` | `400` | `allocation_exceeds_10000_bps` | | `INV-CEIL-01` | `monotonic_ceiling` | `TaxRate` | `` | `rate_bps` | `` | `rate_bps` | `POST /api/tax-rates` | `{"tax_code": "VAT_{sentinel}", "jurisdiction": "EU_VAT", "tax_type": "vat", "rate_bps": 2000, "liability_account_id": "{account_id}"}` | `POST /api/tax-rates` | `{"tax_code": "VAT_OVR_{sentinel}", "jurisdiction": "EU_VAT", "tax_type": "vat", "rate_bps": 3501, "liability_account_id": "{account_id}"}` | `GET /api/tax-rates` | `400` | `invalid_tax_rate` | | `INV-CEIL-02` | `monotonic_ceiling` | `PurchaseOrder` | `` | `tolerance_bps` | `` | `tolerance_bps` | `POST /api/purchase-orders` | `{"po_number": "PO-SET-{sentinel}", "vendor_name": "Nordic Steel AB", "expected_qty": 10, "unit_price_cents": 5000, "currency": "USD", "tolerance_bps": 100}` | `POST /api/purchase-orders` | `{"po_number": "PO-OVR-{sentinel}", "vendor_name": "Nordic Steel AB", "expected_qty": 10, "unit_price_cents": 5000, "currency": "USD", "tolerance_bps": 501}` | `GET /api/purchase-orders` | `400` | `invalid_purchase_order` | | `INV-CEIL-03` | `monotonic_ceiling` | `FixedAsset` | `` | `useful_life_months` | `` | `useful_life_months` | `POST /api/fixed-assets` | `{"asset_tag": "FA-SET-{sentinel}", "asset_name": "CNC Mill", "asset_class": "machinery", "acquisition_date": "2026-01-10", "cost_cents": 500000, "salvage_value_cents": 50000, "useful_life_months": 60, "depreciation_method": "straight_line"}` | `POST /api/fixed-assets` | `{"asset_tag": "FA-OVR-{sentinel}", "asset_name": "CNC Mill", "asset_class": "machinery", "acquisition_date": "2026-01-10", "cost_cents": 500000, "salvage_value_cents": 50000, "useful_life_months": 601, "depreciation_method": "straight_line"}` | `GET /api/fixed-assets` | `400` | `invalid_fixed_asset` | | `INV-CEIL-04` | `monotonic_ceiling` | `FxRate` | `` | `rate_micros` | `` | `rate_micros` | `POST /api/fx-rates` | `{"rate_key": "FX-SET-{sentinel}", "from_currency": "EUR", "to_currency": "USD", "rate_micros": 1085000, "effective_date": "2026-01-15"}` | `POST /api/fx-rates` | `{"rate_key": "FX-OVR-{sentinel}", "from_currency": "EUR", "to_currency": "USD", "rate_micros": 1000000001, "effective_date": "2026-01-15"}` | `GET /api/fx-rates` | `400` | `invalid_fx_rate` | | `INV-CEIL-05` | `monotonic_ceiling` | `BudgetCommitment` | `` | `max_overrun_bps` | `` | `max_overrun_bps` | `POST /api/budgets` | `{"budget_code": "BUD-SET-{sentinel}", "cost_center": "CC-ENG", "allocated_cents": 500000, "max_overrun_bps": 500}` | `POST /api/budgets` | `{"budget_code": "BUD-OVR-{sentinel}", "cost_center": "CC-ENG", "allocated_cents": 500000, "max_overrun_bps": 2001}` | `GET /api/budgets` | `400` | `invalid_budget` | | `INV-CEIL-06` | `monotonic_ceiling` | `EvidenceArtifact` | `` | `size_bytes` | `` | `size_bytes` | `POST /api/evidence-artifacts` | `{"doc_class": "close_binder", "target_ref_id": "PER-0001", "file_name": "close.json", "size_bytes": 4096, "object_lock_mode": "governance"}` | `POST /api/evidence-artifacts` | `{"doc_class": "close_binder", "target_ref_id": "PER-0001", "file_name": "huge.json", "size_bytes": 10485761, "object_lock_mode": "none"}` | `GET /api/evidence-artifacts` | `400` | `invalid_evidence` | | `INV-CEIL-07` | `monotonic_ceiling` | `Customer` | `` | `credit_limit_cents` | `` | `credit_limit_cents` | `POST /api/customers` | `{"customer_code": "CUST-SET-{sentinel}", "legal_name": "Acme Buyer LLC", "billing_email": "ap@acme.example", "billing_address": "100 Main St", "credit_limit_cents": 5000000}` | `POST /api/customers` | `{"customer_code": "CUST-OVR-{sentinel}", "legal_name": "Acme Buyer LLC", "billing_email": "ap@acme.example", "billing_address": "100 Main St", "credit_limit_cents": 10000000001}` | `GET /api/customers` | `400` | `invalid_customer` | | `INV-IDEMP-01` | `idempotent_replay` | `Payment` | `` | `` | `` | `` | `POST /api/payments` | `{"idempotency_key": "PAY-KEY-{sentinel}", "direction": "ar_receipt", "bank_account_id": "{account_id}", "amount_cents": 25000, "invoice_id": "{invoice_id}", "settlement_currency": "USD", "settlement_fx_rate_micros": 1000000, "payment_method": "ach"}` | `POST /api/payments` | `{"idempotency_key": "PAY-KEY-{sentinel}", "direction": "ar_receipt", "bank_account_id": "{account_id}", "amount_cents": 25000, "invoice_id": "{invoice_id}", "settlement_currency": "USD", "settlement_fx_rate_micros": 1000000, "payment_method": "ach"}` | `GET /api/payments` | `200` | `` | | `INV-IDEMP-02` | `idempotent_replay` | `Account` | `` | `` | `` | `` | `POST /api/accounts` | `{"code": "9101", "name": "Suspense Clearing", "account_type": "asset", "normal_balance": "debit", "currency": "USD"}` | `POST /api/accounts` | `{"code": "9101", "name": "Suspense Clearing", "account_type": "asset", "normal_balance": "debit", "currency": "USD"}` | `GET /api/accounts` | `200` | `` | | `INV-IDEMP-03` | `idempotent_replay` | `FxRate` | `` | `` | `` | `` | `POST /api/fx-rates` | `{"rate_key": "GBP-USD-{sentinel}", "from_currency": "GBP", "to_currency": "USD", "rate_micros": 1270000, "effective_date": "2026-01-15"}` | `POST /api/fx-rates` | `{"rate_key": "GBP-USD-{sentinel}", "from_currency": "GBP", "to_currency": "USD", "rate_micros": 1270000, "effective_date": "2026-01-15"}` | `GET /api/fx-rates` | `200` | `` | | `INV-IDEMP-04` | `idempotent_replay` | `BankStatementLine` | `` | `` | `` | `` | `POST /api/bank-statements` | `{"idempotency_key": "BNK-KEY-{sentinel}", "bank_account_id": "{account_id}", "statement_date": "2026-01-20", "amount_cents": 50000, "format_kind": "camt_053", "reference_text": "Wire 101"}` | `POST /api/bank-statements` | `{"idempotency_key": "BNK-KEY-{sentinel}", "bank_account_id": "{account_id}", "statement_date": "2026-01-20", "amount_cents": 50000, "format_kind": "camt_053", "reference_text": "Wire 101"}` | `GET /api/bank-statements` | `200` | `` | | `INV-STATE-01` | `state_precondition_refusal` | `FiscalPeriod` | `` | `status` | `` | `` | `POST /api/fiscal-periods/{period_id}/close` | `{}` | `POST /api/fiscal-periods/{period_id}/close` | `{}` | `GET /api/fiscal-periods` | `400` | `closed_period` | | `INV-STATE-02` | `state_precondition_refusal` | `JournalEntry` | `` | `status` | `` | `` | `POST /api/journals/{journal_id}/void` | `{}` | `POST /api/journals/{journal_id}/void` | `{}` | `GET /api/journals` | `400` | `unvoidable_journal` | | `INV-STATE-03` | `state_precondition_refusal` | `JournalEntry` | `` | `total_debit_cents` | `` | `` | `POST /api/journals` | `{"period_id": "{period_id}", "posting_date": "2026-01-15", "description": "Balanced setup entry", "total_debit_cents": 10000, "total_credit_cents": 10000, "currency": "USD", "fx_rate_micros": 1000000}` | `POST /api/journals` | `{"period_id": "{period_id}", "posting_date": "2026-01-15", "description": "Unbalanced reject entry", "total_debit_cents": 10000, "total_credit_cents": 9000, "currency": "USD", "fx_rate_micros": 1000000}` | `GET /api/journals` | `400` | `unbalanced_journal` | | `INV-STATE-04` | `state_precondition_refusal` | `Invoice` | `` | `status` | `` | `` | `POST /api/invoices/{invoice_id}/pay` | `{"bank_account_id": "{account_id}", "payment_method": "ach"}` | `POST /api/invoices/{invoice_id}/pay` | `{"bank_account_id": "{account_id}", "payment_method": "ach"}` | `GET /api/invoices` | `400` | `unpayable_invoice` | | `INV-STATE-05` | `state_precondition_refusal` | `Account` | `` | `status` | `` | `` | `POST /api/accounts/{account_id}/archive` | `{}` | `POST /api/accounts/{account_id}/archive` | `{}` | `GET /api/accounts` | `400` | `unarchivable_account` | | `INV-STATE-06` | `state_precondition_refusal` | `VendorBankChange` | `` | `status` | `` | `` | `POST /api/vendor-bank-changes` | `{"vendor_id": "{vendor_id}", "new_iban": "DE89370400440532013000", "requester_actor_id": "ap_clerk_99"}` | `POST /api/vendor-bank-changes/{bank_change_id}/approve` | `{"approver_actor_id": "ap_clerk_99"}` | `GET /api/vendor-bank-changes` | `400` | `sod_violation` | | `INV-STATE-07` | `state_precondition_refusal` | `IntercompanyTransfer` | `` | `status` | `` | `` | `POST /api/intercompany-transfers` | `{"transfer_code": "ICT-GATE-{sentinel}", "amount_cents": 45000, "currency": "USD"}` | `POST /api/intercompany-transfers/{ic_transfer_id}/eliminate` | `{}` | `GET /api/intercompany-transfers` | `400` | `invalid_state_transition` | | `INV-STATE-08` | `state_precondition_refusal` | `BudgetCommitment` | `` | `status` | `` | `` | `POST /api/budgets` | `{"budget_code": "BUD-GATE-{sentinel}", "cost_center": "CC-OPS", "allocated_cents": 250000, "max_overrun_bps": 500}` | `POST /api/budgets/{budget_id}/encumber` | `{"amount_cents": 10000}` | `GET /api/budgets` | `400` | `invalid_state_transition` | #### Closed Error Vocabulary Table Uniform error envelope across every non-2xx API reply: `{"ok": false, "error": {"code": "", "message": ""}}`. | Code | HTTP | Category | Trigger | | :--- | :--- | :--- | :--- | | `invalid_limit` | `400` | `validation` | Query `?limit=` non-integer or outside `1..500` | | `invalid_offset` | `400` | `validation` | Query `?offset=` negative or non-integer | | `invalid_timestamp` | `400` | `validation` | Malformed ISO-8601 `as_of`, `as_known_at`, or date range | | `invalid_content_length` | `400` | `validation` | Negative or non-integer HTTP `Content-Length` header | | `invalid_field` | `400` | `validation` | Missing required body field or schema pattern/range violation | | `invalid_tax_rate` | `400` | `refusal` | `TaxRate.rate_bps` outside `0..3500` (`INV-CEIL-01`) or unknown `jurisdiction` | | `invalid_purchase_order` | `400` | `refusal` | `PurchaseOrder.tolerance_bps` outside `0..500` (`INV-CEIL-02`) or non-positive qty/price | | `invalid_fixed_asset` | `400` | `refusal` | `FixedAsset.useful_life_months` outside `1..600` (`INV-CEIL-03`) or salvage > cost | | `invalid_fx_rate` | `400` | `refusal` | `FxRate.rate_micros` outside `1..1000000000` (`INV-CEIL-04`) or identical currency pair | | `invalid_budget` | `400` | `refusal` | `BudgetCommitment.max_overrun_bps` outside `0..2000` (`INV-CEIL-05`) or non-positive allocation | | `invalid_evidence` | `400` | `refusal` | `EvidenceArtifact.size_bytes` outside `1..10485760` (`INV-CEIL-06`) or Object Lock on `contact_pii_export` | | `invalid_customer` | `400` | `refusal` | `Customer.credit_limit_cents` outside `0..10000000000` (`INV-CEIL-07`) | | `invalid_period_transition` | `400` | `refusal` | Missing `reason` on fiscal period reopen or invalid date span | | `invalid_state_transition` | `400` | `refusal` | Disallowed workflow transition on close task, invoice, credit memo, revenue schedule, vendor, PO, bill, bank line, intercompany transfer, budget, payment, or asset | | `unbalanced_journal` | `400` | `refusal` | `total_debit_cents != total_credit_cents`, zero total, or line sum exceeding header (`INV-CONS-01`/`02`) | | `allocation_mismatch` | `400` | `refusal` | `RevenueObligation.allocated_cents` sum exceeds `RevenueSchedule.total_contract_cents` (`INV-CONS-03`) | | `allocation_exceeds_10000_bps` | `400` | `refusal` | Cumulative `allocation_bps` exceeds `10000` bps (`INV-ALLOC-01`/`02`) | | `budget_exceeded` | `400` | `refusal` | Encumbrance exceeds `allocated_cents * (10000 + max_overrun_bps) // 10000` | | `closed_period` | `400` | `refusal` | Attempt to post or re-close against a `closed` `FiscalPeriod` (`INV-STATE-01`) | | `unvoidable_journal` | `400` | `refusal` | Attempt to void or reverse a journal whose status is not `posted` (`INV-STATE-02`) | | `unarchivable_account` | `400` | `refusal` | Attempt to archive an already-archived or non-zero control GL account (`INV-STATE-05`) | | `unpayable_invoice` | `400` | `refusal` | Attempt to pay an already-`paid` or `voided` invoice (`INV-STATE-04`) | | `unpayable_bill` | `400` | `refusal` | Attempt to pay a `draft`, `variance_hold`, `paid`, or `voided` bill or vendor on `payment_hold` | | `sod_violation` | `400` | `refusal` | SOX 404 Segregation of Duties violation (`approver_actor == created_by_actor` / `requester_actor_id`) (`INV-STATE-06`) | | `insufficient_inventory` | `400` | `refusal` | Inventory valuation adjustment would reduce `quantity_on_hand` below `0` | | `unauthorized` | `401` | `auth` | Missing, expired, `alg=none`, or bad-signature HS256 JWT when `AUTH_MODE=jwt` | | `missing_corp` | `403` | `tenancy` | Omitted, empty, or unknown `X-Corp-Id` header | | `missing_role` | `403` | `rbac` | Omitted or empty `X-Role` header on any protected `/api/*` endpoint | | `invalid_role` | `403` | `rbac` | Non-empty `X-Role` outside declared `§2` closed role set | | `insufficient_role` | `403` | `rbac` | Valid role excluded from target `§4.1` route group | | `account_not_found` | `404` | `not_found` | Unknown or cross-tenant `account_id` | | `period_not_found` | `404` | `not_found` | Unknown or cross-tenant `period_id` | | `close_task_not_found` | `404` | `not_found` | Unknown or cross-tenant `close_task_id` | | `tax_rate_not_found` | `404` | `not_found` | Unknown or cross-tenant `tax_rate_id` | | `journal_not_found` | `404` | `not_found` | Unknown or cross-tenant `journal_id` | | `customer_not_found` | `404` | `not_found` | Unknown or cross-tenant `customer_id` | | `invoice_not_found` | `404` | `not_found` | Unknown or cross-tenant `invoice_id` | | `credit_memo_not_found` | `404` | `not_found` | Unknown or cross-tenant `credit_memo_id` | | `schedule_not_found` | `404` | `not_found` | Unknown or cross-tenant `schedule_id` | | `obligation_not_found` | `404` | `not_found` | Unknown or cross-tenant `obligation_id` | | `vendor_not_found` | `404` | `not_found` | Unknown or cross-tenant `vendor_id` | | `bank_change_not_found` | `404` | `not_found` | Unknown or cross-tenant `bank_change_id` | | `po_not_found` | `404` | `not_found` | Unknown or cross-tenant `po_id` | | `bill_not_found` | `404` | `not_found` | Unknown or cross-tenant `bill_id` | | `payment_not_found` | `404` | `not_found` | Unknown or cross-tenant `payment_id` | | `statement_line_not_found` | `404` | `not_found` | Unknown or cross-tenant `statement_line_id` | | `asset_not_found` | `404` | `not_found` | Unknown or cross-tenant `asset_id` | | `sku_not_found` | `404` | `not_found` | Unknown or cross-tenant `sku_id` | | `legal_entity_not_found` | `404` | `not_found` | Unknown or cross-tenant `legal_entity_id` | | `ic_transfer_not_found` | `404` | `not_found` | Unknown or cross-tenant `ic_transfer_id` | | `budget_not_found` | `404` | `not_found` | Unknown or cross-tenant `budget_id` | | `artifact_not_found` | `404` | `not_found` | Unknown or cross-tenant `artifact_id` or missing S3 payload | | `route_not_found` | `404` | `routing` | Unmatched HTTP method or API URL path | | `duplicate_key` | `409` | `conflict` | Conflicting duplicate natural unique key across tenant collections | | `payload_too_large` | `413` | `hardening` | Pre-read `Content-Length` exceeds `1_048_576` bytes | | `upgrade_required` | `426` | `hardening` | Cleartext HTTP request lacking `X-Forwarded-Proto: https` when `FORCE_HTTPS=true` | | `rate_limited` | `429` | `hardening` | Token-bucket rate limit exceeded (emits `Retry-After`) | | `sim_unavailable` | `503` | `infra` | Offstack DynamoDB or Secrets Manager unreachable or timed out | | `blob_unavailable` | `503` | `infra` | Offstack S3 or KMS unreachable during encrypted export or key wrap | | `service_busy` | `503` | `hardening` | Bounded HTTP concurrency semaphore saturated (emits `Retry-After`) | ### §1.5 Wire-Name Unity & Entity Schemas Exact 5 DF3 IR types (`ir.py`): `text | int | money | enum | bool`. Every request body field in `§3`, parameter in `§1.3`, column/input in `§6`–`§7`, and PII entry in `§4.2` matches exact field names below across all **27 entities**. - **Intentional Edit/Delete Coverage:** `Account`, `Customer`, and `Vendor` permit `PATCH` updates on governance metadata. Only draft `RevenueObligation` (`DELETE /api/revenue-schedules/{schedule_id}/obligations/{obligation_id}`) permits `DELETE`; immutable financial ledger records (`JournalEntry`, `JournalLine`, `Payment`, `AuditLog`, `FxRevaluation`, `GoodsReceipt`, `FxRate`, `IntercompanyTransfer`) forbid `PATCH`/`PUT`/`DELETE` entirely, using `reverse_*`/`void_*` or signed `CreditMemo` entries instead. #### Account (`accounts`, pk=`account_id`, list=`GET /api/accounts`, create=`POST /api/accounts`) | Field | IR Type | Required | Create | Unique | One-Word | Default / Initial | Constraints / Enum / Pattern | Notes | | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | | `account_id` | `text` | `no` | `no` | `yes` | `yes` | `auto:ACC-####` | `pattern=^ACC-[0-9]{4}$` | Server-assigned immutable PK | | `code` | `text` | `yes` | `yes` | `yes` | `yes` | `` | `pattern=^[0-9]{4,6}$` | Unique GL account code (`200` replay on identical payload; `409` on mismatch) | | `name` | `text` | `yes` | `yes` | `no` | `no` | `` | `min_length=2; max_length=120` | Display name (`PATCH` mutable) | | `account_type` | `enum` | `yes` | `yes` | `no` | `yes` | `asset` | `enum=[asset, liability, equity, revenue, expense]` | Accounting classification | | `normal_balance` | `enum` | `yes` | `yes` | `no` | `yes` | `debit` | `enum=[debit, credit]` | Standard balance side | | `currency` | `enum` | `no` | `yes` | `no` | `yes` | `USD` | `enum=[USD, EUR, GBP, RSD, CHF, JPY]` | ISO 4217 currency code | | `is_control_account` | `bool` | `no` | `yes` | `no` | `no` | `false` | `` | Subledger control flag (`AR`/`AP`/`Inventory`) | | `allow_manual_posting` | `bool` | `no` | `yes` | `no` | `no` | `true` | `` | Direct GL posting toggle (`PATCH` mutable) | | `balance_cents` | `money` | `no` | `no` | `no` | `no` | `0` | `min_value=-999999999999; max_value=999999999999` | Signed minor-unit GL balance | | `status` | `enum` | `no` | `no` | `no` | `yes` | `active` | `enum=[active, archived]` | Lifecycle state (`archive_account`) | | `effective_at` | `text` | `no` | `no` | `no` | `yes` | `2026-01-10T09:00:00Z` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,6})?Z$` | Bitemporal event stamp (`as_of`) | | `recorded_at` | `text` | `no` | `no` | `no` | `yes` | `2026-01-10T09:00:00Z` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,6})?Z$` | Bitemporal system stamp (`as_known_at`) | #### FiscalPeriod (`fiscal_periods`, pk=`period_id`, list=`GET /api/fiscal-periods`, create=`POST /api/fiscal-periods`) | Field | IR Type | Required | Create | Unique | One-Word | Default / Initial | Constraints / Enum / Pattern | Notes | | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | | `period_id` | `text` | `no` | `no` | `yes` | `yes` | `auto:PER-####` | `pattern=^PER-[0-9]{4}$` | Server-assigned immutable PK | | `period_code` | `text` | `yes` | `yes` | `yes` | `yes` | `` | `pattern=^[0-9]{4}-[0-9]{2}$` | Unique fiscal month (`YYYY-MM`) | | `start_date` | `text` | `yes` | `yes` | `no` | `yes` | `2026-01-01` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}$` | Period start ISO date | | `end_date` | `text` | `yes` | `yes` | `no` | `yes` | `2026-01-31` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}$` | Period end ISO date | | `close_checklist_complete` | `bool` | `no` | `yes` | `no` | `no` | `false` | `` | Pre-close reconciliation checklist flag | | `status` | `enum` | `no` | `no` | `no` | `yes` | `open` | `enum=[open, soft_closed, closed]` | Posting lock state (`CLOSED-YYYY-MM`) | | `locked_by_role` | `text` | `no` | `no` | `no` | `yes` | `` | `max_length=32` | Role that locked period | | `reopen_reason` | `text` | `no` | `no` | `no` | `no` | `` | `max_length=256` | Mandatory audit reason on reopen | | `effective_at` | `text` | `no` | `no` | `no` | `yes` | `2026-01-01T00:00:00Z` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,6})?Z$` | Bitemporal event stamp | | `recorded_at` | `text` | `no` | `no` | `no` | `yes` | `2026-01-01T00:00:00Z` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,6})?Z$` | Bitemporal system stamp | #### CloseTask (`close_tasks`, pk=`close_task_id`, list=`GET /api/close-tasks`, create=`POST /api/close-tasks`) | Field | IR Type | Required | Create | Unique | One-Word | Default / Initial | Constraints / Enum / Pattern | Notes | | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | | `close_task_id` | `text` | `no` | `no` | `yes` | `yes` | `auto:CTSK-####` | `pattern=^CTSK-[0-9]{4}$` | Close checklist task PK | | `task_code` | `text` | `yes` | `yes` | `yes` | `yes` | `` | `pattern=^[A-Z0-9_-]{3,32}$` | Unique close step identifier | | `title` | `text` | `yes` | `yes` | `no` | `no` | `` | `min_length=3; max_length=160` | Close checklist task description | | `period_id` | `text` | `yes` | `yes` | `no` | `yes` | `` | `pattern=^PER-[0-9]{4}$` | FK -> `FiscalPeriod.period_id` (`REL-08`) | | `owner_role` | `enum` | `no` | `yes` | `no` | `yes` | `gl_accountant` | `enum=[gl_accountant, ar_clerk, ap_clerk, controller, erp_admin]` | Responsible close role | | `sequence_order` | `int` | `no` | `yes` | `no` | `no` | `1` | `min_value=1; max_value=100` | Ordered close execution DAG rank | | `status` | `enum` | `no` | `no` | `no` | `yes` | `open` | `enum=[open, in_progress, signed_off, waived]` | Close task lifecycle | | `signed_off_by` | `text` | `no` | `no` | `no` | `yes` | `` | `max_length=64` | Controller/accountant sign-off actor | | `effective_at` | `text` | `no` | `no` | `no` | `yes` | `2026-01-31T18:00:00Z` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,6})?Z$` | Bitemporal event stamp | | `recorded_at` | `text` | `no` | `no` | `no` | `yes` | `2026-01-31T18:00:00Z` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,6})?Z$` | Bitemporal system stamp | #### TaxRate (`tax_rates`, pk=`tax_rate_id`, list=`GET /api/tax-rates`, create=`POST /api/tax-rates`) | Field | IR Type | Required | Create | Unique | One-Word | Default / Initial | Constraints / Enum / Pattern | Notes | | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | | `tax_rate_id` | `text` | `no` | `no` | `yes` | `yes` | `auto:TAX-####` | `pattern=^TAX-[0-9]{4}$` | Server-assigned immutable PK | | `tax_code` | `text` | `yes` | `yes` | `yes` | `yes` | `` | `pattern=^[A-Z0-9_-]{2,24}$` | Unique tax code | | `jurisdiction` | `enum` | `yes` | `yes` | `no` | `yes` | `US_STATE` | `enum=[US_FEDERAL, US_STATE, EU_VAT, UK_VAT, RS_PDV, GLOBAL]` | Tax authority | | `tax_type` | `enum` | `yes` | `yes` | `no` | `yes` | `sales_tax` | `enum=[sales_tax, vat, withholding_tds, reverse_charge]` | Tax regime mechanism | | `rate_bps` | `int` | `yes` | `yes` | `no` | `no` | `825` | `min_value=0; max_value=3500` | Rate in basis points (`INV-CEIL-01` cap `3500`) | | `liability_account_id` | `text` | `yes` | `yes` | `no` | `yes` | `` | `pattern=^ACC-[0-9]{4}$` | FK -> `Account.account_id` (`REL-04`) | | `active` | `bool` | `no` | `yes` | `no` | `no` | `true` | `` | Toggled via `toggle_tax_rate` | | `effective_at` | `text` | `no` | `no` | `no` | `yes` | `2026-01-01T00:00:00Z` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,6})?Z$` | Bitemporal event stamp | | `recorded_at` | `text` | `no` | `no` | `no` | `yes` | `2026-01-01T00:00:00Z` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,6})?Z$` | Bitemporal system stamp | #### JournalEntry (`journals`, pk=`journal_id`, list=`GET /api/journals`, create=`POST /api/journals`) | Field | IR Type | Required | Create | Unique | One-Word | Default / Initial | Constraints / Enum / Pattern | Notes | | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | | `journal_id` | `text` | `no` | `no` | `yes` | `yes` | `auto:JE-####` | `pattern=^JE-[0-9]{4}$` | Server-assigned immutable PK | | `period_id` | `text` | `yes` | `yes` | `no` | `yes` | `` | `pattern=^PER-[0-9]{4}$` | FK -> `FiscalPeriod.period_id` (`REL-01`) | | `posting_date` | `text` | `yes` | `yes` | `no` | `yes` | `2026-01-15` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}$` | Accounting posting date | | `description` | `text` | `yes` | `yes` | `no` | `no` | `` | `min_length=3; max_length=256` | Immutable journal memo | | `total_debit_cents` | `money` | `yes` | `yes` | `no` | `no` | `1000` | `min_value=1; max_value=99999999999` | Must equal `total_credit_cents` (`INV-CONS-01`) | | `total_credit_cents` | `money` | `yes` | `yes` | `no` | `no` | `1000` | `min_value=1; max_value=99999999999` | Must equal `total_debit_cents` (`INV-CONS-02`) | | `currency` | `enum` | `no` | `yes` | `no` | `yes` | `USD` | `enum=[USD, EUR, GBP, RSD, CHF, JPY]` | Transaction currency | | `fx_rate_micros` | `int` | `no` | `yes` | `no` | `no` | `1000000` | `min_value=1; max_value=1000000000` | Fixed-point FX multiplier (`1000000 = 1.0`) | | `reference` | `text` | `no` | `yes` | `no` | `yes` | `` | `max_length=64` | Linked document label | | `source_module` | `enum` | `no` | `yes` | `no` | `yes` | `gl_manual` | `enum=[gl_manual, ar_subledger, ap_subledger, fx_reval, fixed_assets, inventory_cogs, tax_engine]` | Originating ledger module | | `period_code` | `text` | `no` | `no` | `no` | `yes` | `2026-01` | `pattern=^[0-9]{4}-[0-9]{2}$` | Derived fiscal period code | | `reverses_journal_id` | `text` | `no` | `no` | `no` | `yes` | `` | `pattern=^JE-[0-9]{4}$` | Non-FK optional reference string; do not enforce FK existence | | `status` | `enum` | `no` | `no` | `no` | `yes` | `posted` | `enum=[posted, reversed, voided]` | Append-only posting state | | `benford_flagged` | `bool` | `no` | `no` | `no` | `no` | `false` | `` | Benford first-digit anomaly flag | | `effective_at` | `text` | `no` | `no` | `no` | `yes` | `2026-01-15T10:00:00Z` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,6})?Z$` | Bitemporal event stamp (`as_of`) | | `recorded_at` | `text` | `no` | `no` | `no` | `yes` | `2026-01-15T10:00:00Z` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,6})?Z$` | Bitemporal system stamp (`as_known_at`) | #### JournalLine (`journal_lines`, pk=`line_id`, list=`GET /api/journals/{journal_id}/lines`, create=`POST /api/journals/{journal_id}/lines`) | Field | IR Type | Required | Create | Unique | One-Word | Default / Initial | Constraints / Enum / Pattern | Notes | | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | | `line_id` | `text` | `no` | `no` | `yes` | `yes` | `auto:JEL-####` | `pattern=^JEL-[0-9]{4}$` | Server-assigned nested line PK | | `journal_id` | `text` | `yes` | `yes` | `no` | `yes` | `` | `pattern=^JE-[0-9]{4}$` | FK -> `JournalEntry.journal_id` (`REL-02`) | | `account_id` | `text` | `yes` | `yes` | `no` | `yes` | `` | `pattern=^ACC-[0-9]{4}$` | FK -> `Account.account_id` (`REL-03`) | | `debit_cents` | `money` | `no` | `yes` | `no` | `no` | `0` | `min_value=0; max_value=99999999999` | Unsigned debit minor units | | `credit_cents` | `money` | `no` | `yes` | `no` | `no` | `0` | `min_value=0; max_value=99999999999` | Unsigned credit minor units | | `signed_amount_cents` | `money` | `yes` | `yes` | `no` | `no` | `0` | `min_value=-99999999999; max_value=99999999999` | Signed net line amount (`+` debit / `-` credit for reversals) | | `allocation_bps` | `int` | `no` | `yes` | `no` | `no` | `0` | `min_value=0; max_value=10000` | Cost allocation share (`INV-ALLOC-01` sum `<= 10000`) | | `tax_rate_id` | `text` | `no` | `yes` | `no` | `yes` | `` | `pattern=^TAX-[0-9]{4}$` | Non-FK optional reference string; do not enforce FK existence | | `memo` | `text` | `no` | `yes` | `no` | `no` | `` | `max_length=160` | Line-level audit memo | | `effective_at` | `text` | `no` | `no` | `no` | `yes` | `2026-01-15T10:00:00Z` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,6})?Z$` | Inherited event stamp | | `recorded_at` | `text` | `no` | `no` | `no` | `yes` | `2026-01-15T10:00:00Z` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,6})?Z$` | System write stamp | #### Customer (`customers`, pk=`customer_id`, list=`GET /api/customers`, create=`POST /api/customers`) | Field | IR Type | Required | Create | Unique | One-Word | Default / Initial | Constraints / Enum / Pattern | Notes | | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | | `customer_id` | `text` | `no` | `no` | `yes` | `yes` | `auto:CUST-####` | `pattern=^CUST-[0-9]{4}$` | Governed AR customer PK | | `customer_code` | `text` | `yes` | `yes` | `yes` | `yes` | `` | `pattern=^[A-Z0-9_-]{3,32}$` | Unique customer master code | | `legal_name` | `text` | `yes` | `yes` | `no` | `no` | `` | `min_length=2; max_length=120` | Customer legal name (`security.pii_fields`) | | `billing_email` | `text` | `yes` | `yes` | `no` | `yes` | `` | `pattern=^[^@\s]+@[^@\s]+\.[^@\s]+$` | Customer billing email (`security.pii_fields`) | | `billing_address` | `text` | `yes` | `yes` | `no` | `no` | `` | `min_length=5; max_length=240` | Customer billing address (`security.pii_fields`) | | `credit_limit_cents` | `money` | `no` | `yes` | `no` | `no` | `5000000` | `min_value=0; max_value=10000000000` | AR credit exposure cap (`INV-CEIL-07`) | | `ar_account_id` | `text` | `no` | `yes` | `no` | `yes` | `` | `pattern=^ACC-[0-9]{4}$` | Optional FK -> `Account.account_id` (`REL-12`) | | `dunning_paused` | `bool` | `no` | `yes` | `no` | `no` | `false` | `` | Disputed-invoice dunning pause flag | | `status` | `enum` | `no` | `no` | `no` | `yes` | `active` | `enum=[active, credit_hold, archived]` | Credit hold lifecycle | | `created_at` | `text` | `no` | `no` | `no` | `yes` | `2026-01-10T09:00:00Z` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,6})?Z$` | Write-once UTC timestamp | #### Invoice (`invoices`, pk=`invoice_id`, list=`GET /api/invoices`, create=`POST /api/invoices`) | Field | IR Type | Required | Create | Unique | One-Word | Default / Initial | Constraints / Enum / Pattern | Notes | | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | | `invoice_id` | `text` | `no` | `no` | `yes` | `yes` | `auto:INV-####` | `pattern=^INV-[0-9]{4}$` | Server-assigned immutable PK | | `invoice_number` | `text` | `yes` | `yes` | `yes` | `yes` | `` | `pattern=^INV-[A-Z0-9-]{4,20}$` | Unique EU VAT Art. 226 sequential number | | `customer_name` | `text` | `yes` | `yes` | `no` | `no` | `` | `min_length=2; max_length=120` | Customer legal name (`security.pii_fields`) | | `customer_email` | `text` | `yes` | `yes` | `no` | `yes` | `` | `pattern=^[^@\s]+@[^@\s]+\.[^@\s]+$` | Customer billing email (`security.pii_fields`) | | `billing_address` | `text` | `yes` | `yes` | `no` | `no` | `` | `min_length=5; max_length=240` | Customer billing address (`security.pii_fields`) | | `due_date` | `text` | `yes` | `yes` | `no` | `yes` | `2026-02-15` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}$` | Contractual due date | | `subtotal_cents` | `money` | `yes` | `yes` | `no` | `no` | `10000` | `min_value=1; max_value=99999999999` | Pre-tax invoice subtotal | | `customer_id` | `text` | `no` | `yes` | `no` | `yes` | `` | `pattern=^CUST-[0-9]{4}$` | Optional FK -> `Customer.customer_id` (`REL-13`) | | `tax_rate_id` | `text` | `no` | `yes` | `no` | `yes` | `` | `max_length=32` | Non-FK optional reference string; do not enforce FK existence | | `currency` | `enum` | `no` | `yes` | `no` | `yes` | `USD` | `enum=[USD, EUR, GBP, RSD, CHF, JPY]` | Invoice currency | | `fx_rate_micros` | `int` | `no` | `yes` | `no` | `no` | `1000000` | `min_value=1; max_value=1000000000` | Posting FX rate in micros | | `payment_terms` | `enum` | `no` | `yes` | `no` | `yes` | `net_30` | `enum=[net_30, net_15, 2_10_net_30, due_on_receipt]` | Early-pay discount/terms | | `ar_account_id` | `text` | `no` | `yes` | `no` | `yes` | `ACC-1200` | `max_length=16` | Non-FK optional reference string; do not enforce FK existence | | `revenue_account_id` | `text` | `no` | `yes` | `no` | `yes` | `ACC-4000` | `max_length=16` | Non-FK optional reference string; do not enforce FK existence | | `tax_amount_cents` | `money` | `no` | `no` | `no` | `no` | `0` | `min_value=0; max_value=99999999999` | Server-computed tax minor units | | `total_amount_cents` | `money` | `no` | `no` | `no` | `no` | `10000` | `min_value=1; max_value=99999999999` | `subtotal_cents + tax_amount_cents` | | `paid_amount_cents` | `money` | `no` | `no` | `no` | `no` | `0` | `min_value=0; max_value=99999999999` | Settled minor units | | `remaining_due_cents` | `money` | `no` | `no` | `no` | `no` | `10000` | `min_value=0; max_value=99999999999` | Open receivable balance | | `journal_id` | `text` | `no` | `no` | `no` | `yes` | `` | `pattern=^JE-[0-9]{4}$` | Non-FK optional reference string; do not enforce FK existence | | `status` | `enum` | `no` | `no` | `no` | `yes` | `draft` | `enum=[draft, unpaid, partially_paid, paid, overdue, voided]` | AR lifecycle status | | `effective_at` | `text` | `no` | `no` | `no` | `yes` | `2026-01-16T09:00:00Z` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,6})?Z$` | Bitemporal event stamp | | `recorded_at` | `text` | `no` | `no` | `no` | `yes` | `2026-01-16T09:00:00Z` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,6})?Z$` | Bitemporal system stamp | #### CreditMemo (`credit_memos`, pk=`credit_memo_id`, list=`GET /api/credit-memos`, create=`POST /api/credit-memos`) | Field | IR Type | Required | Create | Unique | One-Word | Default / Initial | Constraints / Enum / Pattern | Notes | | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | | `credit_memo_id` | `text` | `no` | `no` | `yes` | `yes` | `auto:CM-####` | `pattern=^CM-[0-9]{4}$` | Server-assigned immutable PK | | `memo_number` | `text` | `yes` | `yes` | `yes` | `yes` | `` | `pattern=^CM-[A-Z0-9-]{4,20}$` | Unique credit/debit memo code | | `doc_kind` | `enum` | `yes` | `yes` | `no` | `yes` | `ar_credit_memo` | `enum=[ar_credit_memo, ap_debit_memo]` | Subledger adjustment direction | | `adjustment_cents` | `money` | `yes` | `yes` | `no` | `no` | `-5000` | `min_value=-99999999999; max_value=0` | Signed negative adjustment (`Signed Money`) | | `reason` | `text` | `yes` | `yes` | `no` | `no` | `` | `min_length=3; max_length=256` | Audit justification | | `invoice_id` | `text` | `no` | `yes` | `no` | `yes` | `` | `pattern=^INV-[0-9]{4}$` | Optional FK -> `Invoice.invoice_id` (`REL-06`) | | `bill_id` | `text` | `no` | `yes` | `no` | `yes` | `` | `max_length=32` | Non-FK optional reference string; do not enforce FK existence | | `tax_adjustment_cents` | `money` | `no` | `yes` | `no` | `no` | `0` | `min_value=-99999999999; max_value=0` | Signed negative VAT/tax reversal | | `status` | `enum` | `no` | `no` | `no` | `yes` | `draft` | `enum=[draft, applied, voided]` | Lifecycle state (`apply_credit_memo`) | | `effective_at` | `text` | `no` | `no` | `no` | `yes` | `2026-01-18T10:00:00Z` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,6})?Z$` | Bitemporal event stamp | | `recorded_at` | `text` | `no` | `no` | `no` | `yes` | `2026-01-18T10:00:00Z` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,6})?Z$` | Bitemporal system stamp | #### RevenueSchedule (`revenue_schedules`, pk=`schedule_id`, list=`GET /api/revenue-schedules`, create=`POST /api/revenue-schedules`) | Field | IR Type | Required | Create | Unique | One-Word | Default / Initial | Constraints / Enum / Pattern | Notes | | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | | `schedule_id` | `text` | `no` | `no` | `yes` | `yes` | `auto:REV-####` | `pattern=^REV-[0-9]{4}$` | ASC 606 / IFRS 15 schedule PK | | `contract_ref` | `text` | `yes` | `yes` | `yes` | `yes` | `` | `pattern=^[A-Z0-9_-]{3,32}$` | Unique customer contract reference | | `total_contract_cents` | `money` | `yes` | `yes` | `no` | `no` | `100000` | `min_value=1; max_value=99999999999` | Transaction price (`INV-CONS-03` sum cap) | | `standard_mode` | `enum` | `no` | `yes` | `no` | `yes` | `asc_606` | `enum=[asc_606, ifrs_15]` | Accounting standard regime | | `invoice_id` | `text` | `no` | `yes` | `no` | `yes` | `` | `pattern=^INV-[0-9]{4}$` | Optional FK -> `Invoice.invoice_id` (`REL-16`) | | `period_id` | `text` | `no` | `yes` | `no` | `yes` | `` | `pattern=^PER-[0-9]{4}$` | Optional FK -> `FiscalPeriod.period_id` (`REL-17`) | | `deferred_account_id` | `text` | `no` | `yes` | `no` | `yes` | `` | `max_length=16` | Non-FK optional reference string; do not enforce FK existence | | `recognized_cents` | `money` | `no` | `no` | `no` | `no` | `0` | `min_value=0; max_value=99999999999` | Cumulative recognized revenue | | `status` | `enum` | `no` | `no` | `no` | `yes` | `active` | `enum=[active, recognizing, completed, paused]` | Recognition lifecycle | | `created_at` | `text` | `no` | `no` | `no` | `yes` | `2026-01-16T10:00:00Z` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,6})?Z$` | Write-once UTC timestamp | #### RevenueObligation (`revenue_obligations`, pk=`obligation_id`, list=`GET /api/revenue-schedules/{schedule_id}/obligations`, create=`POST /api/revenue-schedules/{schedule_id}/obligations`) | Field | IR Type | Required | Create | Unique | One-Word | Default / Initial | Constraints / Enum / Pattern | Notes | | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | | `obligation_id` | `text` | `no` | `no` | `yes` | `yes` | `auto:POB-####` | `pattern=^POB-[0-9]{4}$` | Nested performance obligation PK | | `schedule_id` | `text` | `no` | `no` | `no` | `yes` | `` | `pattern=^REV-[0-9]{4}$` | Path-bound FK -> `RevenueSchedule.schedule_id` (`REL-18`) | | `obligation_code` | `text` | `yes` | `yes` | `no` | `yes` | `` | `pattern=^[A-Z0-9_-]{3,32}$` | Performance obligation code | | `description` | `text` | `yes` | `yes` | `no` | `no` | `` | `min_length=2; max_length=160` | Distinct good/service promise | | `satisfaction_method` | `enum` | `no` | `yes` | `no` | `yes` | `ratable` | `enum=[ratable, point_in_time, milestone]` | ASC 606 satisfaction pattern | | `allocation_bps` | `int` | `yes` | `yes` | `no` | `no` | `5000` | `min_value=1; max_value=10000` | SSP share (`INV-ALLOC-02` sum `<= 10000`) | | `allocated_cents` | `money` | `yes` | `yes` | `no` | `no` | `50000` | `min_value=1; max_value=99999999999` | Allocated transaction price (`INV-CONS-03`) | | `created_at` | `text` | `no` | `no` | `no` | `yes` | `2026-01-16T10:05:00Z` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,6})?Z$` | Write-once UTC timestamp | #### Vendor (`vendors`, pk=`vendor_id`, list=`GET /api/vendors`, create=`POST /api/vendors`) | Field | IR Type | Required | Create | Unique | One-Word | Default / Initial | Constraints / Enum / Pattern | Notes | | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | | `vendor_id` | `text` | `no` | `no` | `yes` | `yes` | `auto:VEND-####` | `pattern=^VEND-[0-9]{4}$` | Governed AP vendor master PK | | `vendor_code` | `text` | `yes` | `yes` | `yes` | `yes` | `` | `pattern=^[A-Z0-9_-]{3,32}$` | Unique vendor master key | | `legal_name` | `text` | `yes` | `yes` | `no` | `no` | `` | `min_length=2; max_length=120` | Supplier legal name (`security.pii_fields`) | | `contact_email` | `text` | `yes` | `yes` | `no` | `yes` | `` | `pattern=^[^@\s]+@[^@\s]+\.[^@\s]+$` | Vendor billing contact (`security.pii_fields`) | | `tax_id` | `text` | `yes` | `yes` | `no` | `yes` | `` | `min_length=4; max_length=32` | Non-FK optional reference string; do not enforce FK existence | | `bank_iban` | `text` | `no` | `yes` | `no` | `yes` | `` | `max_length=34` | Mod-97 validated settlement IBAN | | `ap_account_id` | `text` | `no` | `yes` | `no` | `yes` | `` | `pattern=^ACC-[0-9]{4}$` | Optional FK -> `Account.account_id` (`REL-10`) | | `payment_hold` | `bool` | `no` | `yes` | `no` | `no` | `false` | `` | Anti-fraud payment hold flag | | `ers_enabled` | `bool` | `no` | `yes` | `no` | `no` | `false` | `` | Evaluated Receipt Settlement flag | | `status` | `enum` | `no` | `no` | `no` | `yes` | `active` | `enum=[active, on_hold, archived]` | Vendor governance state | | `created_at` | `text` | `no` | `no` | `no` | `yes` | `2026-01-10T09:00:00Z` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,6})?Z$` | Write-once UTC timestamp | #### VendorBankChange (`vendor_bank_changes`, pk=`bank_change_id`, list=`GET /api/vendor-bank-changes`, create=`POST /api/vendor-bank-changes`) | Field | IR Type | Required | Create | Unique | One-Word | Default / Initial | Constraints / Enum / Pattern | Notes | | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | | `bank_change_id` | `text` | `no` | `no` | `yes` | `yes` | `auto:VBC-####` | `pattern=^VBC-[0-9]{4}$` | Bank-change anti-fraud request PK | | `vendor_id` | `text` | `yes` | `yes` | `no` | `yes` | `` | `pattern=^VEND-[0-9]{4}$` | FK -> `Vendor.vendor_id` (`REL-11`) | | `new_iban` | `text` | `yes` | `yes` | `no` | `yes` | `` | `min_length=15; max_length=34; pattern=^[A-Z]{2}[0-9A-Z]{13,32}$` | Requested payout IBAN (`security.pii_fields`) | | `requester_actor_id` | `text` | `no` | `yes` | `no` | `yes` | `ap_clerk_1` | `min_length=2; max_length=64` | Non-FK optional reference string; do not enforce FK existence | | `approver_actor_id` | `text` | `no` | `no` | `no` | `yes` | `` | `max_length=64` | Non-FK optional reference string; do not enforce FK existence | | `status` | `enum` | `no` | `no` | `no` | `yes` | `pending` | `enum=[pending, confirmed, approved, rejected]` | Dual-control anti-fraud gate (`INV-STATE-06`) | | `created_at` | `text` | `no` | `no` | `no` | `yes` | `2026-01-18T11:00:00Z` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,6})?Z$` | Write-once UTC timestamp | #### PurchaseOrder (`purchase_orders`, pk=`po_id`, list=`GET /api/purchase-orders`, create=`POST /api/purchase-orders`) | Field | IR Type | Required | Create | Unique | One-Word | Default / Initial | Constraints / Enum / Pattern | Notes | | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | | `po_id` | `text` | `no` | `no` | `yes` | `yes` | `auto:PO-####` | `pattern=^PO-[0-9]{4}$` | Server-assigned immutable PK | | `po_number` | `text` | `yes` | `yes` | `yes` | `yes` | `` | `pattern=^PO-[A-Z0-9-]{4,20}$` | Unique procurement order code | | `vendor_name` | `text` | `yes` | `yes` | `no` | `no` | `` | `min_length=2; max_length=120` | Supplier legal name | | `expected_qty` | `int` | `yes` | `yes` | `no` | `no` | `10` | `min_value=1; max_value=1000000` | Ordered unit quantity | | `unit_price_cents` | `money` | `yes` | `yes` | `no` | `no` | `5000` | `min_value=1; max_value=9999999999` | Contracted unit price | | `vendor_id` | `text` | `no` | `yes` | `no` | `yes` | `` | `pattern=^VEND-[0-9]{4}$` | Optional FK -> `Vendor.vendor_id` (`REL-14`) | | `currency` | `enum` | `no` | `yes` | `no` | `yes` | `USD` | `enum=[USD, EUR, GBP, RSD, CHF, JPY]` | PO currency | | `tolerance_bps` | `int` | `no` | `yes` | `no` | `no` | `100` | `min_value=0; max_value=500` | 3-way match variance ceiling (`INV-CEIL-02` max `500`) | | `total_amount_cents` | `money` | `no` | `no` | `no` | `no` | `50000` | `min_value=1; max_value=99999999999` | `expected_qty * unit_price_cents` | | `status` | `enum` | `no` | `no` | `no` | `yes` | `open` | `enum=[open, partially_received, received, matched, cancelled]` | Procurement lifecycle | | `effective_at` | `text` | `no` | `no` | `no` | `yes` | `2026-01-12T08:00:00Z` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,6})?Z$` | Bitemporal event stamp | | `recorded_at` | `text` | `no` | `no` | `no` | `yes` | `2026-01-12T08:00:00Z` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,6})?Z$` | Bitemporal system stamp | #### GoodsReceipt (`goods_receipts`, pk=`receipt_id`, list=`GET /api/goods-receipts`, create=`POST /api/goods-receipts`) | Field | IR Type | Required | Create | Unique | One-Word | Default / Initial | Constraints / Enum / Pattern | Notes | | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | | `receipt_id` | `text` | `no` | `no` | `yes` | `yes` | `auto:GRN-####` | `pattern=^GRN-[0-9]{4}$` | Server-assigned immutable PK | | `receipt_number` | `text` | `yes` | `yes` | `yes` | `yes` | `` | `pattern=^GRN-[A-Z0-9-]{4,20}$` | Unique warehouse GRN reference | | `po_id` | `text` | `yes` | `yes` | `no` | `yes` | `` | `pattern=^PO-[0-9]{4}$` | FK -> `PurchaseOrder.po_id` (`REL-05`) | | `received_qty` | `int` | `yes` | `yes` | `no` | `no` | `10` | `min_value=1; max_value=1000000` | Verified received quantity | | `received_value_cents` | `money` | `yes` | `yes` | `no` | `no` | `50000` | `min_value=1; max_value=99999999999` | GRNI accrual value | | `warehouse_code` | `text` | `no` | `yes` | `no` | `yes` | `WH-MAIN` | `min_length=2; max_length=32` | Receiving facility code | | `status` | `enum` | `no` | `no` | `no` | `yes` | `accepted` | `enum=[accepted, quarantined, reversed]` | Inspection outcome | | `effective_at` | `text` | `no` | `no` | `no` | `yes` | `2026-01-13T12:00:00Z` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,6})?Z$` | Bitemporal event stamp | | `recorded_at` | `text` | `no` | `no` | `no` | `yes` | `2026-01-13T12:00:00Z` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,6})?Z$` | Bitemporal system stamp | #### Bill (`bills`, pk=`bill_id`, list=`GET /api/bills`, create=`POST /api/bills`) | Field | IR Type | Required | Create | Unique | One-Word | Default / Initial | Constraints / Enum / Pattern | Notes | | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | | `bill_id` | `text` | `no` | `no` | `yes` | `yes` | `auto:BILL-####` | `pattern=^BILL-[0-9]{4}$` | Server-assigned immutable PK | | `bill_number` | `text` | `yes` | `yes` | `yes` | `yes` | `` | `pattern=^BILL-[A-Z0-9-]{4,20}$` | Unique vendor invoice number | | `vendor_contact_email` | `text` | `yes` | `yes` | `no` | `yes` | `` | `pattern=^[^@\s]+@[^@\s]+\.[^@\s]+$` | Vendor billing email (`security.pii_fields`) | | `vendor_tax_id` | `text` | `yes` | `yes` | `no` | `yes` | `` | `min_length=4; max_length=32` | Non-FK optional reference string; do not enforce FK existence (`security.pii_fields`) | | `due_date` | `text` | `yes` | `yes` | `no` | `yes` | `2026-02-20` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}$` | Payment due date | | `subtotal_cents` | `money` | `yes` | `yes` | `no` | `no` | `50000` | `min_value=1; max_value=99999999999` | Pre-tax vendor bill subtotal | | `vendor_id` | `text` | `no` | `yes` | `no` | `yes` | `` | `pattern=^VEND-[0-9]{4}$` | Optional FK -> `Vendor.vendor_id` (`REL-15`) | | `po_id` | `text` | `no` | `yes` | `no` | `yes` | `` | `max_length=32` | Non-FK optional reference string; do not enforce FK existence | | `receipt_id` | `text` | `no` | `yes` | `no` | `yes` | `` | `max_length=32` | Non-FK optional reference string; do not enforce FK existence | | `tax_rate_id` | `text` | `no` | `yes` | `no` | `yes` | `` | `max_length=32` | Non-FK optional reference string; do not enforce FK existence | | `currency` | `enum` | `no` | `yes` | `no` | `yes` | `USD` | `enum=[USD, EUR, GBP, RSD, CHF, JPY]` | Bill currency | | `fx_rate_micros` | `int` | `no` | `yes` | `no` | `no` | `1000000` | `min_value=1; max_value=1000000000` | Posting FX rate in micros | | `created_by_actor` | `text` | `no` | `yes` | `no` | `yes` | `ap_clerk_1` | `min_length=2; max_length=64` | SOX 404 SoD creator actor ID | | `approved_by_actor` | `text` | `no` | `no` | `no` | `yes` | `` | `max_length=64` | Distinct approver actor ID | | `tax_amount_cents` | `money` | `no` | `no` | `no` | `no` | `0` | `min_value=0; max_value=99999999999` | Server-computed VAT/sales tax | | `total_amount_cents` | `money` | `no` | `no` | `no` | `no` | `50000` | `min_value=1; max_value=99999999999` | Total payable amount | | `paid_amount_cents` | `money` | `no` | `no` | `no` | `no` | `0` | `min_value=0; max_value=99999999999` | Disbursed minor units | | `variance_bps` | `int` | `no` | `no` | `no` | `no` | `0` | `min_value=0; max_value=10000` | Computed 3-way match variance | | `match_status` | `enum` | `no` | `no` | `no` | `yes` | `unmatched` | `enum=[unmatched, matched, variance_blocked, override_approved]` | 3-way PO-receipt-bill match state | | `status` | `enum` | `no` | `no` | `no` | `yes` | `unpaid` | `enum=[draft, unpaid, approved, paid, variance_hold, voided]` | AP bill lifecycle status | | `effective_at` | `text` | `no` | `no` | `no` | `yes` | `2026-01-17T09:00:00Z` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,6})?Z$` | Bitemporal event stamp | | `recorded_at` | `text` | `no` | `no` | `no` | `yes` | `2026-01-17T09:00:00Z` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,6})?Z$` | Bitemporal system stamp | #### Payment (`payments`, pk=`payment_id`, list=`GET /api/payments`, create=`POST /api/payments`) | Field | IR Type | Required | Create | Unique | One-Word | Default / Initial | Constraints / Enum / Pattern | Notes | | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | | `payment_id` | `text` | `no` | `no` | `yes` | `yes` | `auto:PAY-####` | `pattern=^PAY-[0-9]{4}$` | Server-assigned immutable PK | | `idempotency_key` | `text` | `yes` | `yes` | `yes` | `yes` | `` | `min_length=4; max_length=64` | Non-FK idempotency key string; do not enforce FK existence (`INV-IDEMP-01`) | | `direction` | `enum` | `yes` | `yes` | `no` | `yes` | `ar_receipt` | `enum=[ar_receipt, ap_disbursement]` | Cash flow direction | | `bank_account_id` | `text` | `yes` | `yes` | `no` | `yes` | `` | `pattern=^ACC-[0-9]{4}$` | FK -> `Account.account_id` (`REL-07`) | | `amount_cents` | `money` | `yes` | `yes` | `no` | `no` | `10000` | `min_value=1; max_value=99999999999` | Settlement minor units | | `invoice_id` | `text` | `no` | `yes` | `no` | `yes` | `` | `max_length=32` | Non-FK optional reference string; do not enforce FK existence | | `bill_id` | `text` | `no` | `yes` | `no` | `yes` | `` | `max_length=32` | Non-FK optional reference string; do not enforce FK existence | | `settlement_currency` | `enum` | `no` | `yes` | `no` | `yes` | `USD` | `enum=[USD, EUR, GBP, RSD, CHF, JPY]` | Settlement currency | | `settlement_fx_rate_micros` | `int` | `no` | `yes` | `no` | `no` | `1000000` | `min_value=1; max_value=1000000000` | Settlement FX rate in micros | | `payment_method` | `enum` | `no` | `yes` | `no` | `yes` | `ach` | `enum=[ach, sepa, wire, check, card]` | Clearing rail | | `fx_gain_loss_cents` | `money` | `no` | `no` | `no` | `no` | `0` | `min_value=-99999999999; max_value=99999999999` | Signed realized FX delta posted to `ACC-8010` | | `journal_id` | `text` | `no` | `no` | `no` | `yes` | `` | `pattern=^JE-[0-9]{4}$` | Non-FK optional reference string; do not enforce FK existence | | `status` | `enum` | `no` | `no` | `no` | `yes` | `settled` | `enum=[settled, reversed]` | Settlement state (`reverse_payment`) | | `effective_at` | `text` | `no` | `no` | `no` | `yes` | `2026-01-19T11:00:00Z` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,6})?Z$` | Bitemporal event stamp | | `recorded_at` | `text` | `no` | `no` | `no` | `yes` | `2026-01-19T11:00:00Z` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,6})?Z$` | Bitemporal system stamp | #### BankStatementLine (`bank_statements`, pk=`statement_line_id`, list=`GET /api/bank-statements`, create=`POST /api/bank-statements`) | Field | IR Type | Required | Create | Unique | One-Word | Default / Initial | Constraints / Enum / Pattern | Notes | | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | | `statement_line_id` | `text` | `no` | `no` | `yes` | `yes` | `auto:BNK-####` | `pattern=^BNK-[0-9]{4}$` | Bank statement feed line PK | | `idempotency_key` | `text` | `yes` | `yes` | `yes` | `yes` | `` | `min_length=4; max_length=64` | Non-FK idempotency key string; do not enforce FK existence (`INV-IDEMP-04`) | | `bank_account_id` | `text` | `yes` | `yes` | `no` | `yes` | `` | `pattern=^ACC-[0-9]{4}$` | FK -> `Account.account_id` (`REL-09`) | | `statement_date` | `text` | `yes` | `yes` | `no` | `yes` | `2026-01-20` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}$` | Value date of bank transaction | | `amount_cents` | `money` | `yes` | `yes` | `no` | `no` | `50000` | `min_value=-99999999999; max_value=99999999999` | Signed bank inflow/outflow (`Signed Money`) | | `format_kind` | `enum` | `no` | `yes` | `no` | `yes` | `camt_053` | `enum=[camt_053, mt940, bai2, csv_feed]` | Bank statement wire format | | `reference_text` | `text` | `no` | `yes` | `no` | `no` | `` | `max_length=160` | Remittance memo for fuzzy match | | `matched_payment_id` | `text` | `no` | `no` | `no` | `yes` | `` | `max_length=32` | Non-FK optional reference string; do not enforce FK existence | | `status` | `enum` | `no` | `no` | `no` | `yes` | `unmatched` | `enum=[unmatched, matched, reconciled, excluded]` | Bank rec state machine | | `created_at` | `text` | `no` | `no` | `no` | `yes` | `2026-01-20T09:00:00Z` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,6})?Z$` | Write-once UTC timestamp | #### FixedAsset (`fixed_assets`, pk=`asset_id`, list=`GET /api/fixed-assets`, create=`POST /api/fixed-assets`) | Field | IR Type | Required | Create | Unique | One-Word | Default / Initial | Constraints / Enum / Pattern | Notes | | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | | `asset_id` | `text` | `no` | `no` | `yes` | `yes` | `auto:FA-####` | `pattern=^FA-[0-9]{4}$` | Server-assigned immutable PK | | `asset_tag` | `text` | `yes` | `yes` | `yes` | `yes` | `` | `pattern=^[A-Z0-9-]{3,32}$` | Unique physical asset tag | | `asset_name` | `text` | `yes` | `yes` | `no` | `no` | `` | `min_length=2; max_length=120` | Asset description | | `asset_class` | `enum` | `yes` | `yes` | `no` | `yes` | `machinery` | `enum=[machinery, it_equipment, buildings, vehicles, intangible]` | Asset book class | | `acquisition_date` | `text` | `yes` | `yes` | `no` | `yes` | `2026-01-05` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}$` | Capitalization date | | `cost_cents` | `money` | `yes` | `yes` | `no` | `no` | `500000` | `min_value=1; max_value=99999999999` | Historical capitalized cost | | `salvage_value_cents` | `money` | `yes` | `yes` | `no` | `no` | `50000` | `min_value=0; max_value=99999999999` | Residual floor (`<= cost_cents`) | | `useful_life_months` | `int` | `yes` | `yes` | `no` | `no` | `60` | `min_value=1; max_value=600` | Depreciation horizon (`INV-CEIL-03` max `600`) | | `depreciation_method` | `enum` | `no` | `yes` | `no` | `yes` | `straight_line` | `enum=[straight_line, double_declining]` | Depreciation formula | | `asset_account_id` | `text` | `no` | `yes` | `no` | `yes` | `ACC-1500` | `max_length=16` | Non-FK optional reference string; do not enforce FK existence | | `accum_depr_account_id` | `text` | `no` | `yes` | `no` | `yes` | `ACC-1590` | `max_length=16` | Non-FK optional reference string; do not enforce FK existence | | `expense_account_id` | `text` | `no` | `yes` | `no` | `yes` | `ACC-6200` | `max_length=16` | Non-FK optional reference string; do not enforce FK existence | | `accumulated_depreciation_cents` | `money` | `no` | `no` | `no` | `no` | `0` | `min_value=0; max_value=99999999999` | Cumulative booked depreciation | | `net_book_value_cents` | `money` | `no` | `no` | `no` | `no` | `500000` | `min_value=0; max_value=99999999999` | `cost_cents - accumulated_depreciation_cents` | | `status` | `enum` | `no` | `no` | `no` | `yes` | `active` | `enum=[active, fully_depreciated, disposed, impaired]` | Asset lifecycle state | | `effective_at` | `text` | `no` | `no` | `no` | `yes` | `2026-01-05T08:00:00Z` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,6})?Z$` | Bitemporal event stamp | | `recorded_at` | `text` | `no` | `no` | `no` | `yes` | `2026-01-05T08:00:00Z` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,6})?Z$` | Bitemporal system stamp | #### InventoryValuation (`inventory_items`, pk=`sku_id`, list=`GET /api/inventory`, create=`POST /api/inventory`) | Field | IR Type | Required | Create | Unique | One-Word | Default / Initial | Constraints / Enum / Pattern | Notes | | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | | `sku_id` | `text` | `no` | `no` | `yes` | `yes` | `auto:SKU-####` | `pattern=^SKU-[0-9]{4}$` | Server-assigned immutable PK | | `sku_code` | `text` | `yes` | `yes` | `yes` | `yes` | `` | `pattern=^[A-Z0-9-]{3,32}$` | Unique stock keeping code | | `item_name` | `text` | `yes` | `yes` | `no` | `no` | `` | `min_length=2; max_length=120` | Inventory item label | | `valuation_method` | `enum` | `yes` | `yes` | `no` | `yes` | `fifo` | `enum=[fifo, weighted_avg]` | Costing algorithm | | `quantity_on_hand` | `int` | `yes` | `yes` | `no` | `no` | `100` | `min_value=0; max_value=10000000` | Current on-hand units | | `unit_cost_cents` | `money` | `yes` | `yes` | `no` | `no` | `2500` | `min_value=0; max_value=999999999` | Current unit cost | | `inventory_account_id` | `text` | `no` | `yes` | `no` | `yes` | `ACC-1300` | `max_length=16` | Non-FK optional reference string; do not enforce FK existence | | `cogs_account_id` | `text` | `no` | `yes` | `no` | `yes` | `ACC-5000` | `max_length=16` | Non-FK optional reference string; do not enforce FK existence | | `total_value_cents` | `money` | `no` | `no` | `no` | `no` | `250000` | `min_value=0; max_value=99999999999` | Subledger inventory balance | | `status` | `enum` | `no` | `no` | `no` | `yes` | `active` | `enum=[active, discontinued]` | SKU status | | `effective_at` | `text` | `no` | `no` | `no` | `yes` | `2026-01-11T08:00:00Z` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,6})?Z$` | Bitemporal event stamp | | `recorded_at` | `text` | `no` | `no` | `no` | `yes` | `2026-01-11T08:00:00Z` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,6})?Z$` | Bitemporal system stamp | #### LegalEntity (`legal_entities`, pk=`legal_entity_id`, list=`GET /api/legal-entities`, create=`POST /api/legal-entities`) | Field | IR Type | Required | Create | Unique | One-Word | Default / Initial | Constraints / Enum / Pattern | Notes | | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | | `legal_entity_id` | `text` | `no` | `no` | `yes` | `yes` | `auto:LE-####` | `pattern=^LE-[0-9]{4}$` | Multi-subsidiary legal entity PK | | `entity_code` | `text` | `yes` | `yes` | `yes` | `yes` | `` | `pattern=^[A-Z0-9_-]{2,24}$` | Unique subsidiary code | | `legal_name` | `text` | `yes` | `yes` | `no` | `no` | `` | `min_length=2; max_length=120` | Registered subsidiary name | | `functional_currency` | `enum` | `no` | `yes` | `no` | `yes` | `USD` | `enum=[USD, EUR, GBP, RSD, CHF, JPY]` | Functional reporting currency | | `jurisdiction` | `enum` | `no` | `yes` | `no` | `yes` | `US` | `enum=[US, DE, FR, GB, RS, CH]` | Statutory tax jurisdiction | | `aws_region` | `text` | `no` | `yes` | `no` | `yes` | `us-east-1` | `pattern=^[a-z]{2}-[a-z]+-[0-9]+$` | EU VAT Art. 247 data residency pin | | `status` | `enum` | `no` | `no` | `no` | `yes` | `active` | `enum=[active, inactive]` | Legal entity operational state | | `created_at` | `text` | `no` | `no` | `no` | `yes` | `2026-01-05T08:00:00Z` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,6})?Z$` | Write-once UTC timestamp | #### IntercompanyTransfer (`intercompany_transfers`, pk=`ic_transfer_id`, list=`GET /api/intercompany-transfers`, create=`POST /api/intercompany-transfers`) | Field | IR Type | Required | Create | Unique | One-Word | Default / Initial | Constraints / Enum / Pattern | Notes | | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | | `ic_transfer_id` | `text` | `no` | `no` | `yes` | `yes` | `auto:ICT-####` | `pattern=^ICT-[0-9]{4}$` | Intercompany elimination transfer PK | | `transfer_code` | `text` | `yes` | `yes` | `yes` | `yes` | `` | `pattern=^[A-Z0-9_-]{3,32}$` | Unique intercompany cross-charge ref | | `amount_cents` | `money` | `yes` | `yes` | `no` | `no` | `50000` | `min_value=1; max_value=99999999999` | Intercompany charge amount | | `from_entity_id` | `text` | `no` | `yes` | `no` | `yes` | `` | `pattern=^LE-[0-9]{4}$` | Optional FK -> `LegalEntity.legal_entity_id` (`REL-22`) | | `to_entity_id` | `text` | `no` | `yes` | `no` | `yes` | `` | `pattern=^LE-[0-9]{4}$` | Non-FK optional reference string; do not enforce FK existence | | `period_id` | `text` | `no` | `yes` | `no` | `yes` | `` | `pattern=^PER-[0-9]{4}$` | Optional FK -> `FiscalPeriod.period_id` (`REL-19`) | | `currency` | `enum` | `no` | `yes` | `no` | `yes` | `USD` | `enum=[USD, EUR, GBP, RSD, CHF, JPY]` | Transfer currency | | `status` | `enum` | `no` | `no` | `no` | `yes` | `draft` | `enum=[draft, posted, eliminated, disputed]` | Elimination state (`INV-STATE-07`) | | `created_at` | `text` | `no` | `no` | `no` | `yes` | `2026-01-20T10:00:00Z` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,6})?Z$` | Write-once UTC timestamp | #### BudgetCommitment (`budgets`, pk=`budget_id`, list=`GET /api/budgets`, create=`POST /api/budgets`) | Field | IR Type | Required | Create | Unique | One-Word | Default / Initial | Constraints / Enum / Pattern | Notes | | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | | `budget_id` | `text` | `no` | `no` | `yes` | `yes` | `auto:BUD-####` | `pattern=^BUD-[0-9]{4}$` | Cost-center budget commitment PK | | `budget_code` | `text` | `yes` | `yes` | `yes` | `yes` | `` | `pattern=^[A-Z0-9_-]{3,32}$` | Unique budget line key | | `cost_center` | `text` | `yes` | `yes` | `no` | `yes` | `CC-GEN` | `pattern=^[A-Z0-9_-]{2,24}$` | Cost center code | | `allocated_cents` | `money` | `yes` | `yes` | `no` | `no` | `500000` | `min_value=1; max_value=99999999999` | Approved budget ceiling | | `period_id` | `text` | `no` | `yes` | `no` | `yes` | `` | `pattern=^PER-[0-9]{4}$` | Optional FK -> `FiscalPeriod.period_id` (`REL-20`) | | `account_id` | `text` | `no` | `yes` | `no` | `yes` | `` | `pattern=^ACC-[0-9]{4}$` | Optional FK -> `Account.account_id` (`REL-21`) | | `max_overrun_bps` | `int` | `no` | `yes` | `no` | `no` | `500` | `min_value=0; max_value=2000` | Permitted tolerance (`INV-CEIL-05` max `2000`) | | `encumbered_cents` | `money` | `no` | `no` | `no` | `no` | `0` | `min_value=0; max_value=99999999999` | Committed encumbrances | | `status` | `enum` | `no` | `no` | `no` | `yes` | `draft` | `enum=[draft, active, frozen]` | Budget lifecycle (`INV-STATE-08`) | | `created_at` | `text` | `no` | `no` | `no` | `yes` | `2026-01-10T09:00:00Z` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,6})?Z$` | Write-once UTC timestamp | #### EvidenceArtifact (`evidence_artifacts`, pk=`artifact_id`, list=`GET /api/evidence-artifacts`, create=`POST /api/evidence-artifacts`) | Field | IR Type | Required | Create | Unique | One-Word | Default / Initial | Constraints / Enum / Pattern | Notes | | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | | `artifact_id` | `text` | `no` | `no` | `yes` | `yes` | `auto:EVID-####` | `pattern=^EVID-[0-9]{4}$` | S3 custody artifact PK | | `doc_class` | `enum` | `yes` | `yes` | `no` | `yes` | `close_binder` | `enum=[close_binder, vat_invoice_xml, match_packet, sox_workpaper, contact_pii_export]` | Regulatory classification (`contact_pii_export` forbids Object Lock) | | `target_ref_id` | `text` | `yes` | `yes` | `no` | `yes` | `` | `min_length=3; max_length=64` | Non-FK optional reference string; do not enforce FK existence | | `file_name` | `text` | `yes` | `yes` | `no` | `yes` | `` | `min_length=3; max_length=120` | Artifact filename | | `size_bytes` | `int` | `no` | `yes` | `no` | `no` | `1024` | `min_value=1; max_value=10485760` | Payload size cap (`INV-CEIL-06` 10 MB) | | `object_lock_mode` | `enum` | `no` | `yes` | `no` | `yes` | `none` | `enum=[none, governance, compliance]` | Selective S3 Object Lock mode | | `retention_days` | `int` | `no` | `yes` | `no` | `no` | `2555` | `min_value=1; max_value=3650` | Statutory retention days (`2555` = 7y) | | `legal_hold` | `bool` | `no` | `yes` | `no` | `no` | `false` | `` | Litigation/audit hold lock | | `has_bytes` | `bool` | `no` | `no` | `no` | `no` | `false` | `` | True once S3 object uploaded | | `sha256` | `text` | `no` | `no` | `no` | `yes` | `` | `max_length=64` | Verified S3 payload SHA-256 | | `created_at` | `text` | `no` | `no` | `no` | `yes` | `2026-01-19T12:00:00Z` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,6})?Z$` | Write-once UTC timestamp | #### FxRate (`fx_rates`, pk=`fx_rate_id`, list=`GET /api/fx-rates`, create=`POST /api/fx-rates`) | Field | IR Type | Required | Create | Unique | One-Word | Default / Initial | Constraints / Enum / Pattern | Notes | | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | | `fx_rate_id` | `text` | `no` | `no` | `yes` | `yes` | `auto:FXRT-####` | `pattern=^FXRT-[0-9]{4}$` | Dated FX rate PK | | `rate_key` | `text` | `yes` | `yes` | `yes` | `yes` | `` | `min_length=4; max_length=64` | Idempotent natural key (`INV-IDEMP-03`) | | `from_currency` | `enum` | `yes` | `yes` | `no` | `yes` | `EUR` | `enum=[USD, EUR, GBP, RSD, CHF, JPY]` | Source currency | | `to_currency` | `enum` | `yes` | `yes` | `no` | `yes` | `USD` | `enum=[USD, EUR, GBP, RSD, CHF, JPY]` | Functional target currency | | `rate_micros` | `int` | `yes` | `yes` | `no` | `no` | `1085000` | `min_value=1; max_value=1000000000` | Fixed-point FX rate (`INV-CEIL-04` max `1000000000`) | | `effective_date` | `text` | `no` | `yes` | `no` | `yes` | `2026-01-15` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}$` | Effective FX valuation date | | `effective_at` | `text` | `no` | `no` | `no` | `yes` | `2026-01-15T00:00:00Z` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,6})?Z$` | Bitemporal event stamp | | `recorded_at` | `text` | `no` | `no` | `no` | `yes` | `2026-01-15T00:01:00Z` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,6})?Z$` | Bitemporal system stamp | #### FxRevaluation (`fx_revaluations`, pk=`reval_id`, list=`GET /api/fx-revaluations`, create=`POST /api/fx-revaluations`) | Field | IR Type | Required | Create | Unique | One-Word | Default / Initial | Constraints / Enum / Pattern | Notes | | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | | `reval_id` | `text` | `no` | `no` | `yes` | `yes` | `auto:FXR-####` | `pattern=^FXR-[0-9]{4}$` | Server-assigned immutable PK | | `period_id` | `text` | `yes` | `yes` | `no` | `yes` | `` | `max_length=32` | Non-FK optional reference string; do not enforce FK existence | | `currency` | `enum` | `yes` | `yes` | `no` | `yes` | `EUR` | `enum=[USD, EUR, GBP, RSD, CHF, JPY]` | Revalued foreign currency | | `closing_fx_rate_micros` | `int` | `yes` | `yes` | `no` | `no` | `1085000` | `min_value=1; max_value=1000000000` | Period-end closing FX rate in micros | | `dry_run` | `bool` | `no` | `yes` | `no` | `no` | `false` | `` | Preview without posting GL entry | | `period_code` | `text` | `no` | `no` | `no` | `yes` | `2026-01` | `pattern=^[0-9]{4}-[0-9]{2}$` | Revaluation period code | | `unrealized_delta_cents` | `money` | `no` | `no` | `no` | `no` | `0` | `min_value=-99999999999; max_value=99999999999` | Signed unrealized FX adjustment (`Signed Money`) | | `journal_id` | `text` | `no` | `no` | `no` | `yes` | `` | `pattern=^JE-[0-9]{4}$` | Non-FK optional reference string; do not enforce FK existence | | `effective_at` | `text` | `no` | `no` | `no` | `yes` | `2026-01-31T23:59:00Z` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,6})?Z$` | Bitemporal event stamp | | `recorded_at` | `text` | `no` | `no` | `no` | `yes` | `2026-01-31T23:59:00Z` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,6})?Z$` | Bitemporal system stamp | #### AuditLog (`audit_logs`, pk=`audit_id`, list=`GET /api/audit-logs`, create=`read_only`) | Field | IR Type | Required | Create | Unique | One-Word | Default / Initial | Constraints / Enum / Pattern | Notes | | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | | `audit_id` | `text` | `no` | `no` | `yes` | `yes` | `auto:AUD-####` | `pattern=^AUD-[0-9]{4}$` | Append-only audit entry PK | | `entity_type` | `enum` | `yes` | `no` | `no` | `yes` | `journal` | `enum=[account, period, close_task, tax_rate, journal, customer, invoice, credit_memo, revenue_schedule, vendor, vendor_bank_change, purchase_order, goods_receipt, bill, payment, bank_statement, fixed_asset, inventory, legal_entity, intercompany_transfer, budget, evidence, fx_rate, fx_reval, benford]` | Audited entity category | | `entity_id` | `text` | `yes` | `no` | `no` | `yes` | `` | `max_length=32` | Non-FK optional reference string; do not enforce FK existence | | `actor_role` | `text` | `yes` | `no` | `no` | `yes` | `` | `pattern=^[a-z_]+$` | Caller `X-Role` | | `action` | `text` | `yes` | `no` | `no` | `yes` | `` | `pattern=^[a-z_]+$` | Mutating operation tag | | `benford_chi2_bps` | `int` | `no` | `no` | `no` | `no` | `0` | `min_value=0; max_value=10000000` | Scaled Benford chi-square (`155100 = 15.51`) | | `anomaly_flagged` | `bool` | `no` | `no` | `no` | `no` | `false` | `` | Fraud/audit anomaly flag | | `prev_hash` | `text` | `yes` | `no` | `no` | `yes` | `` | `pattern=^[0-9a-f]{64}$` | Prior tenant hash or `"0"*64` genesis | | `entry_hash` | `text` | `yes` | `no` | `yes` | `yes` | `` | `pattern=^[0-9a-f]{64}$` | SHA-256 hash chain digest | | `effective_at` | `text` | `no` | `no` | `no` | `yes` | `2026-01-10T09:00:00Z` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,6})?Z$` | Bitemporal event stamp | | `recorded_at` | `text` | `no` | `no` | `no` | `yes` | `2026-01-10T09:00:00Z` | `pattern=^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,6})?Z$` | Write-once audit UTC stamp | ### §1.5b Explicit Entity Relations All **22** creatable single-hop precondition-free FK links (`From Entity` holds `Via FK`, `To Entity` is the referenced parent; zero `read_only` children, exact `§3`-verbatim routes with zero `?query` suffixes): | ID | From Entity | To Entity | Via FK | Parent Create Route | Link Route | Reader Route | Child Create Route | Child Verify Route | | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | | `REL-01` | `JournalEntry` | `FiscalPeriod` | `period_id` | `POST /api/fiscal-periods` | `POST /api/journals` | `GET /api/journals` | `POST /api/journals` | `GET /api/journals` | | `REL-02` | `JournalLine` | `JournalEntry` | `journal_id` | `POST /api/journals` | `POST /api/journals/{journal_id}/lines` | `GET /api/journals/{journal_id}/lines` | `POST /api/journals/{journal_id}/lines` | `GET /api/journals/{journal_id}/lines` | | `REL-03` | `JournalLine` | `Account` | `account_id` | `POST /api/accounts` | `POST /api/journals/{journal_id}/lines` | `GET /api/journals/{journal_id}/lines` | `POST /api/journals/{journal_id}/lines` | `GET /api/journals/{journal_id}/lines` | | `REL-04` | `TaxRate` | `Account` | `liability_account_id` | `POST /api/accounts` | `POST /api/tax-rates` | `GET /api/tax-rates` | `POST /api/tax-rates` | `GET /api/tax-rates` | | `REL-05` | `GoodsReceipt` | `PurchaseOrder` | `po_id` | `POST /api/purchase-orders` | `POST /api/goods-receipts` | `GET /api/goods-receipts` | `POST /api/goods-receipts` | `GET /api/goods-receipts` | | `REL-06` | `CreditMemo` | `Invoice` | `invoice_id` | `POST /api/invoices` | `POST /api/credit-memos` | `GET /api/credit-memos` | `POST /api/credit-memos` | `GET /api/credit-memos` | | `REL-07` | `Payment` | `Account` | `bank_account_id` | `POST /api/accounts` | `POST /api/payments` | `GET /api/payments` | `POST /api/payments` | `GET /api/payments` | | `REL-08` | `CloseTask` | `FiscalPeriod` | `period_id` | `POST /api/fiscal-periods` | `POST /api/close-tasks` | `GET /api/close-tasks` | `POST /api/close-tasks` | `GET /api/close-tasks` | | `REL-09` | `BankStatementLine` | `Account` | `bank_account_id` | `POST /api/accounts` | `POST /api/bank-statements` | `GET /api/bank-statements` | `POST /api/bank-statements` | `GET /api/bank-statements` | | `REL-10` | `Vendor` | `Account` | `ap_account_id` | `POST /api/accounts` | `POST /api/vendors` | `GET /api/vendors` | `POST /api/vendors` | `GET /api/vendors` | | `REL-11` | `VendorBankChange` | `Vendor` | `vendor_id` | `POST /api/vendors` | `POST /api/vendor-bank-changes` | `GET /api/vendor-bank-changes` | `POST /api/vendor-bank-changes` | `GET /api/vendor-bank-changes` | | `REL-12` | `Customer` | `Account` | `ar_account_id` | `POST /api/accounts` | `POST /api/customers` | `GET /api/customers` | `POST /api/customers` | `GET /api/customers` | | `REL-13` | `Invoice` | `Customer` | `customer_id` | `POST /api/customers` | `POST /api/invoices` | `GET /api/invoices` | `POST /api/invoices` | `GET /api/invoices` | | `REL-14` | `PurchaseOrder` | `Vendor` | `vendor_id` | `POST /api/vendors` | `POST /api/purchase-orders` | `GET /api/purchase-orders` | `POST /api/purchase-orders` | `GET /api/purchase-orders` | | `REL-15` | `Bill` | `Vendor` | `vendor_id` | `POST /api/vendors` | `POST /api/bills` | `GET /api/bills` | `POST /api/bills` | `GET /api/bills` | | `REL-16` | `RevenueSchedule` | `Invoice` | `invoice_id` | `POST /api/invoices` | `POST /api/revenue-schedules` | `GET /api/revenue-schedules` | `POST /api/revenue-schedules` | `GET /api/revenue-schedules` | | `REL-17` | `RevenueSchedule` | `FiscalPeriod` | `period_id` | `POST /api/fiscal-periods` | `POST /api/revenue-schedules` | `GET /api/revenue-schedules` | `POST /api/revenue-schedules` | `GET /api/revenue-schedules` | | `REL-18` | `RevenueObligation` | `RevenueSchedule` | `schedule_id` | `POST /api/revenue-schedules` | `POST /api/revenue-schedules/{schedule_id}/obligations` | `GET /api/revenue-schedules/{schedule_id}/obligations` | `POST /api/revenue-schedules/{schedule_id}/obligations` | `GET /api/revenue-schedules/{schedule_id}/obligations` | | `REL-19` | `IntercompanyTransfer` | `FiscalPeriod` | `period_id` | `POST /api/fiscal-periods` | `POST /api/intercompany-transfers` | `GET /api/intercompany-transfers` | `POST /api/intercompany-transfers` | `GET /api/intercompany-transfers` | | `REL-20` | `BudgetCommitment` | `FiscalPeriod` | `period_id` | `POST /api/fiscal-periods` | `POST /api/budgets` | `GET /api/budgets` | `POST /api/budgets` | `GET /api/budgets` | | `REL-21` | `BudgetCommitment` | `Account` | `account_id` | `POST /api/accounts` | `POST /api/budgets` | `GET /api/budgets` | `POST /api/budgets` | `GET /api/budgets` | | `REL-22` | `IntercompanyTransfer` | `LegalEntity` | `from_entity_id` | `POST /api/legal-entities` | `POST /api/intercompany-transfers` | `GET /api/intercompany-transfers` | `POST /api/intercompany-transfers` | `GET /api/intercompany-transfers` | --- ## §2. Tenancy & Probe-Ready Deterministic Seed Fixtures - **Tenancy:** `header = "X-Corp-Id"`, `missing_status = 403`, `unknown_status = 403`, `code = "missing_corp"`, `roles = ["owner", "erp_admin", "controller", "gl_accountant", "ar_clerk", "ap_clerk", "auditor", "viewer"]`, `admin_roles = ["owner", "erp_admin", "controller", "auditor"]`, `role_headers = ["X-Role", "X-User-Role"]`. - **Corps:** `corps = ["alpha-corp"]`, `probe_corps = ["beta-corp", "zz-probe"]`. - **Deterministic Numeric GL Conservation, 10000-bps Allocation & Signed Ledger Arithmetic (`alpha-corp`):** - **Double-Entry GL Balance (`sum(debits) == sum(credits)`):** `JE-0001` (`50000 == 50000` via `JEL-0001 +50000` / `JEL-0002 -50000`, `5000 + 5000 = 10000` bps), `JE-0002` (`25000 == 25000` via `JEL-0003 +25000` / `JEL-0004 -25000`, `5000 + 5000 = 10000` bps), `JE-0003` (`15000 == 15000` via `JEL-0005 +15000` / `JEL-0006 -15000`, `5000 + 5000 = 10000` bps). Total seeded GL `sum(total_debit_cents) = 90000 == sum(total_credit_cents) = 90000`. - **ASC 606 Revenue Conservation & `10000`-bps Allocation:** `REV-0001` (`total_contract_cents = 120000`) = `POB-0001 (7500 bps, 90000 cents)` + `POB-0002 (2500 bps, 30000 cents)` (`sum_bps = 10000`, `sum_cents = 120000`); `REV-0002` (`80000` cents) = `POB-0003 (10000 bps, 80000 cents)`; `REV-0003` (`60000` cents) = `POB-0004 (10000 bps, 60000 cents)`. - **Signed Credit Memos & Cash Flows:** `CM-0001 (-2500)` + `CM-0002 (-1500)` = `-4000` cents; `BNK-0001 (+50000)` + `BNK-0002 (-25000)` + `BNK-0003 (+10000)` = `+35000` cents. - Deterministic past ISO UTC timestamps (`2026-01-01T00:00:00Z`–`2026-01-31T23:59:00Z`) guarantee reproducible bitemporal `(as_of, as_known_at)` cuts without clock jitter. Lazy Startup initialization runs once inside `build_server()`/`main()` startup (never lazily inside `GET` handlers for `QG-READ-IDEMP`) (zero RPCs at import), guarded by `_seed_complete=True` in `erp_sequences`. `beta-corp` and `zz-probe` start with **0 rows** across all 27 collections. | Collection | Alpha Count | Beta/Probe Count | Sequence Key | Initial Counter | Boundary-Splitting Guarantee | | :--- | :--- | :--- | :--- | :--- | :--- | | `accounts` | `9` | `0` | `ACC` | `9` | `ACC-1010` (`1010` Cash, `asset`, `active`), `ACC-1200` (`1200` AR), `ACC-1300` (`1300` Inventory), `ACC-1500` (`1500` Equipment), `ACC-1590` (`1590` Accum Depr), `ACC-2000` (`2000` AP), `ACC-4000` (`4000` Revenue), `ACC-5000` (`5000` COGS), `ACC-8010` (`8010` FX Gain/Loss) | | `fiscal_periods` | `3` | `0` | `PER` | `3` | `PER-0001` (`2025-12`, `closed` for `reopen`), `PER-0002` (`2026-01`, `open` default), `PER-0003` (`2026-02`, `open` for `close`) | | `close_tasks` | `3` | `0` | `CTSK` | `3` | `CTSK-0001` (`open` for `start`), `CTSK-0002` (`in_progress` for `signoff`), `CTSK-0003` (`open` for `waive`) | | `tax_rates` | `2` | `0` | `TAX` | `2` | `TAX-0001` (`US_CA_825`, `US_STATE`, `825` bps, `active=true`), `TAX-0002` (`EU_DE_VAT`, `EU_VAT`, `1900` bps, `active=false`) | | `journals` | `3` | `0` | `JE` | `3` | `JE-0001` (`posted`, `gl_manual`, `50000/50000`), `JE-0002` (`posted`, `25000/25000` for `reverse`), `JE-0003` (`posted`, `ar_subledger`, `15000/15000` for `void`) | | `journal_lines` | `6` | `0` | `JEL` | `6` | `JEL-0001/0002` (`JE-0001`), `JEL-0003/0004` (`JE-0002`), `JEL-0005/0006` (`JE-0003`), `sum(debits) == sum(credits) == 90000` | | `customers` | `3` | `0` | `CUST` | `3` | `CUST-0042` (`active`, `dunning_paused=false`), `CUST-0001` (`active` for `credit-hold`), `CUST-0002` (`credit_hold`, `dunning_paused=true`) | | `invoices` | `4` | `0` | `INV` | `4` | `INV-0042` (`CUST-0042`, `unpaid` legacy pin), `INV-0001` (`draft` for `send`), `INV-0002` (`unpaid` `EUR` for `pay`), `INV-0003` (`draft` for `void`) | | `credit_memos` | `2` | `0` | `CM` | `2` | `CM-0001` (`ar_credit_memo`, `-2500`, `draft` for `apply`), `CM-0002` (`ap_debit_memo`, `-1500`, `applied`) | | `revenue_schedules` | `3` | `0` | `REV` | `3` | `REV-0001` (`asc_606`, `active`, `120000` for `recognize`), `REV-0002` (`ifrs_15`, `active`, `80000` for `pause`), `REV-0003` (`asc_606`, `paused`, `60000`) | | `revenue_obligations` | `4` | `0` | `POB` | `4` | `POB-0001` (`7500` bps, `90000`), `POB-0002` (`2500` bps, `30000`), `POB-0003` (`10000` bps, `80000`), `POB-0004` (`REV-0003` for `DELETE`) | | `vendors` | `3` | `0` | `VEND` | `3` | `VEND-0007` (`active`, `payment_hold=false`), `VEND-0008` (`active` for `hold`), `VEND-0009` (`on_hold`, `ers_enabled=true` for `archive`) | | `vendor_bank_changes` | `3` | `0` | `VBC` | `3` | `VBC-0001` (`VEND-0007`, `pending` for `confirm`), `VBC-0002` (`VEND-0008`, `confirmed` for `approve`), `VBC-0003` (`VEND-0009`, `pending` for `reject`) | | `purchase_orders` | `2` | `0` | `PO` | `2` | `PO-0001` (`open`, `VEND-0007`, `100` bps), `PO-0002` (`received`, `VEND-0009`, `200` bps) | | `goods_receipts` | `2` | `0` | `GRN` | `2` | `GRN-0001` (`PO-0002`, `accepted`), `GRN-0002` (`PO-0001`, `quarantined`) | | `bills` | `4` | `0` | `BILL` | `4` | `BILL-0007` (`VEND-0007`, `unpaid`, `ap_clerk_1`), `BILL-0001` (`draft`, `matched` for `approve`), `BILL-0002` (`variance_hold`, `variance_blocked` for `override-match`), `BILL-0003` (`approved` for `pay`) | | `payments` | `2` | `0` | `PAY` | `2` | `PAY-0001` (`ar_receipt`, `USD`, `settled`), `PAY-0002` (`ap_disbursement`, `EUR`, `fx_gain_loss_cents=450`, `settled`) | | `bank_statements` | `3` | `0` | `BNK` | `3` | `BNK-0001` (`unmatched`, `camt_053`, `+50000` for `match`), `BNK-0002` (`matched`, `mt940`, `-25000` for `reconcile`), `BNK-0003` (`unmatched`, `bai2`, `+10000` for `exclude`) | | `fixed_assets` | `2` | `0` | `FA` | `2` | `FA-0001` (`machinery`, `straight_line`, `active` for `depreciate`), `FA-0002` (`it_equipment`, `double_declining`, `active` for `dispose`) | | `inventory_items` | `2` | `0` | `SKU` | `2` | `SKU-0001` (`fifo`, `100` units), `SKU-0002` (`weighted_avg`, `50` units) | | `legal_entities` | `2` | `0` | `LE` | `2` | `LE-0001` (`US-HQ`, `USD`, `us-east-1`, `active`), `LE-0002` (`DE-SUB`, `EUR`, `eu-central-1`, `inactive`) | | `intercompany_transfers` | `3` | `0` | `ICT` | `3` | `ICT-0001` (`draft` for `post`), `ICT-0002` (`posted` for `eliminate`), `ICT-0003` (`draft` for `dispute`) | | `budgets` | `3` | `0` | `BUD` | `3` | `BUD-0001` (`draft`, `CC-ENG` for `activate`), `BUD-0002` (`active`, `CC-OPS` for `encumber`), `BUD-0003` (`active`, `CC-FIN` for `freeze`) | | `evidence_artifacts` | `2` | `0` | `EVID` | `2` | `EVID-0001` (`close_binder`, `governance`, `legal_hold=false`), `EVID-0002` (`vat_invoice_xml`, `none`, `legal_hold=true`) | | `fx_rates` | `2` | `0` | `FXRT` | `2` | `FXRT-0001` (`EUR`->`USD`, `1085000`, `2026-01-15`), `FXRT-0002` (`GBP`->`USD`, `1270000`, `2026-01-20`) | | `fx_revaluations` | `2` | `0` | `FXR` | `2` | `FXR-0001` (`EUR`, `2026-01`), `FXR-0002` (`GBP`, `2026-01`) | | `audit_logs` | `2` | `0` | `AUD` | `2` | Contiguous hash-chained genesis (`AUD-0001` `prev_hash="0"*64`, `AUD-0002` `prev_hash=AUD-0001.entry_hash`) | - **Populated Nullable & Blob-Digest Seeds (`SHOW` Clarity):** In `alpha-corp` demo fixtures, populate `>= 1` non-empty seeded value for every nullable and blob-backed `*_sha256` digest column (paired with a seeded S3 object where applicable) so Stage-B `SHOW` probes render cleanly without empty-column `UNGROUND` edge cases. --- ## §3. Unrolled REST Route Contract All `GET` routes are strictly write-free (`QG-READ-IDEMP`), default `DEFAULT_LIST_LIMIT = 200` (`1 <= limit <= 500`), slice via `?offset=0` (`>= 0`), emit `X-Total-Count`, `X-Limit`, and `X-Offset`, and reject invalid pagination with `400 invalid_limit` / `400 invalid_offset`. | # | Method | Path | Facade | Request Body / Query | Response | Errors | | :--- | :--- | :--- | :--- | :--- | :--- | :--- | | `1` | `GET` | `/health` | `(exempt zero-RPC)` | `(none)` | `200 {"status": "ok", "app": "AIcentricERP", "engine": "offstack"}` | `(none)` | | `2` | `GET` | `/` | `(exempt static SPA)` | `(none)` | `200 text/html (frontend/dist/index.html)` | `(none)` | | `3` | `GET` | `/api/time-axis` | `get_time_axis_overview` | `(none)` | `200 bitemporal bounds dict` | `missing_corp`, `missing_role`, `invalid_role`, `sim_unavailable` | | `4` | `GET` | `/api/audit-logs` | `list_audit_logs` | `?entity_type&action&anomaly_only&limit=200&offset=0&as_of&as_known_at` | `200 list[dict]` | `invalid_limit`, `invalid_offset`, `invalid_timestamp`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `sim_unavailable` | | `5` | `GET` | `/api/accounts` | `list_accounts` | `?account_type&status¤cy&limit=200&offset=0&as_of&as_known_at` | `200 list[dict]` | `invalid_limit`, `invalid_offset`, `invalid_timestamp`, `missing_corp`, `missing_role`, `invalid_role`, `sim_unavailable` | | `6` | `POST` | `/api/accounts` | `create_account` | `{code, name, account_type, normal_balance, currency?, is_control_account?, allow_manual_posting?}` | `201 Account / 200 replay` | `invalid_field`, `duplicate_key`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `7` | `GET` | `/api/accounts/{account_id}` | `get_account` | `?as_of&as_known_at` | `200 Account` | `invalid_timestamp`, `account_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `sim_unavailable` | | `8` | `PATCH` | `/api/accounts/{account_id}` | `update_account` | `{name?, allow_manual_posting?}` | `200 Account + AUD` | `invalid_field`, `account_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `9` | `POST` | `/api/accounts/{account_id}/archive` | `archive_account` | `{}` | `200 archived Account + AUD` | `unarchivable_account`, `account_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `sim_unavailable` | | `10` | `GET` | `/api/fiscal-periods` | `list_fiscal_periods` | `?status&period_code&limit=200&offset=0&as_of&as_known_at` | `200 list[dict]` | `invalid_limit`, `invalid_offset`, `invalid_timestamp`, `missing_corp`, `missing_role`, `invalid_role`, `sim_unavailable` | | `11` | `POST` | `/api/fiscal-periods` | `create_fiscal_period` | `{period_code, start_date, end_date, close_checklist_complete?}` | `201 FiscalPeriod + AUD` | `invalid_field`, `invalid_period_transition`, `duplicate_key`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `12` | `GET` | `/api/fiscal-periods/{period_id}` | `get_fiscal_period` | `?as_of&as_known_at` | `200 FiscalPeriod` | `invalid_timestamp`, `period_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `sim_unavailable` | | `13` | `POST` | `/api/fiscal-periods/{period_id}/close` | `close_fiscal_period` | `{}` | `200 closed FiscalPeriod + S3 binder + AUD` | `closed_period`, `period_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `blob_unavailable`, `sim_unavailable` | | `14` | `POST` | `/api/fiscal-periods/{period_id}/reopen` | `reopen_fiscal_period` | `{reason}` | `200 reopened FiscalPeriod + AUD` | `invalid_period_transition`, `period_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `15` | `GET` | `/api/close-tasks` | `list_close_tasks` | `?period_id&owner_role&status&limit=200&offset=0&as_of&as_known_at` | `200 list[dict]` | `invalid_limit`, `invalid_offset`, `invalid_timestamp`, `missing_corp`, `missing_role`, `invalid_role`, `sim_unavailable` | | `16` | `POST` | `/api/close-tasks` | `create_close_task` | `{task_code, title, period_id, owner_role?, sequence_order?}` | `201 CloseTask + AUD` | `invalid_field`, `period_not_found`, `duplicate_key`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `17` | `POST` | `/api/close-tasks/{close_task_id}/start` | `start_close_task` | `{}` | `200 in_progress CloseTask + AUD` | `invalid_state_transition`, `close_task_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `sim_unavailable` | | `18` | `POST` | `/api/close-tasks/{close_task_id}/signoff` | `signoff_close_task` | `{signed_off_by?}` | `200 signed_off CloseTask + AUD` | `invalid_state_transition`, `close_task_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `19` | `POST` | `/api/close-tasks/{close_task_id}/waive` | `waive_close_task` | `{reason?}` | `200 waived CloseTask + AUD` | `invalid_state_transition`, `close_task_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `20` | `GET` | `/api/tax-rates` | `list_tax_rates` | `?jurisdiction&tax_type&active&limit=200&offset=0&as_of&as_known_at` | `200 list[dict]` | `invalid_limit`, `invalid_offset`, `invalid_timestamp`, `missing_corp`, `missing_role`, `invalid_role`, `sim_unavailable` | | `21` | `POST` | `/api/tax-rates` | `create_tax_rate` | `{tax_code, jurisdiction, tax_type, rate_bps, liability_account_id, active?}` | `201 TaxRate + AUD` | `invalid_field`, `invalid_tax_rate`, `account_not_found`, `duplicate_key`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `22` | `POST` | `/api/tax-rates/{tax_rate_id}/toggle` | `toggle_tax_rate` | `{active}` | `200 TaxRate + AUD` | `invalid_field`, `tax_rate_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `23` | `GET` | `/api/journals` | `list_journals` | `?status&period_code&source_module&limit=200&offset=0&as_of&as_known_at` | `200 list[dict]` | `invalid_limit`, `invalid_offset`, `invalid_timestamp`, `missing_corp`, `missing_role`, `invalid_role`, `sim_unavailable` | | `24` | `POST` | `/api/journals` | `record_journal` | `{period_id, posting_date, description, total_debit_cents, total_credit_cents, currency?, fx_rate_micros?, reference?, source_module?, lines?}` | `201 JournalEntry + AUD` | `invalid_field`, `unbalanced_journal`, `closed_period`, `period_not_found`, `account_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `25` | `GET` | `/api/journals/{journal_id}` | `get_journal` | `?as_of&as_known_at` | `200 JournalEntry` | `invalid_timestamp`, `journal_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `sim_unavailable` | | `26` | `POST` | `/api/journals/{journal_id}/reverse` | `reverse_journal` | `{reason?, posting_date?}` | `200 reversing JournalEntry + AUD` | `unvoidable_journal`, `closed_period`, `journal_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `27` | `POST` | `/api/journals/{journal_id}/void` | `void_journal` | `{reason?}` | `200 voided JournalEntry + AUD` | `unvoidable_journal`, `journal_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `28` | `GET` | `/api/journals/{journal_id}/lines` | `list_journal_lines` | `?account_id&limit=200&offset=0&as_of&as_known_at` | `200 list[dict]` | `invalid_limit`, `invalid_offset`, `invalid_timestamp`, `journal_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `sim_unavailable` | | `29` | `POST` | `/api/journals/{journal_id}/lines` | `add_journal_line` | `{account_id, debit_cents?, credit_cents?, signed_amount_cents, allocation_bps?, tax_rate_id?, memo?}` | `201 JournalLine + AUD` | `invalid_field`, `unbalanced_journal`, `allocation_exceeds_10000_bps`, `journal_not_found`, `account_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `30` | `GET` | `/api/customers` | `list_customers` | `?status&dunning_paused&customer_code&limit=200&offset=0` | `200 list[dict]` (PII masked for `viewer`/`auditor`) | `invalid_limit`, `invalid_offset`, `missing_corp`, `missing_role`, `invalid_role`, `sim_unavailable` | | `31` | `POST` | `/api/customers` | `create_customer` | `{customer_code, legal_name, billing_email, billing_address, credit_limit_cents?, ar_account_id?, dunning_paused?}` | `201 Customer + AUD` | `invalid_field`, `invalid_customer`, `account_not_found`, `duplicate_key`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `32` | `GET` | `/api/customers/{customer_id}` | `get_customer` | `(none)` | `200 Customer` | `customer_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `sim_unavailable` | | `33` | `PATCH` | `/api/customers/{customer_id}` | `update_customer` | `{legal_name?, billing_email?, billing_address?, credit_limit_cents?}` | `200 Customer + AUD` | `invalid_field`, `invalid_customer`, `customer_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `34` | `POST` | `/api/customers/{customer_id}/credit-hold` | `toggle_customer_credit_hold` | `{hold_active?}` | `200 Customer + AUD` | `customer_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `35` | `POST` | `/api/customers/{customer_id}/dunning-pause` | `toggle_dunning_pause` | `{dunning_paused?}` | `200 Customer + AUD` | `customer_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `36` | `GET` | `/api/invoices` | `list_invoices` | `?status&customer_id¤cy&limit=200&offset=0&as_of&as_known_at` | `200 list[dict]` | `invalid_limit`, `invalid_offset`, `invalid_timestamp`, `missing_corp`, `missing_role`, `invalid_role`, `sim_unavailable` | | `37` | `POST` | `/api/invoices` | `issue_invoice` | `{invoice_number, customer_name, customer_email, billing_address, due_date, subtotal_cents, customer_id?, tax_rate_id?, currency?, fx_rate_micros?, payment_terms?, ar_account_id?, revenue_account_id?}` | `201 Invoice + AUD` | `invalid_field`, `customer_not_found`, `duplicate_key`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `38` | `GET` | `/api/invoices/{invoice_id}` | `get_invoice` | `?as_of&as_known_at` | `200 Invoice (PII masked for viewer/auditor)` | `invalid_timestamp`, `invoice_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `sim_unavailable` | | `39` | `POST` | `/api/invoices/{invoice_id}/send` | `send_invoice` | `{}` | `200 unpaid Invoice + AUD` | `invalid_state_transition`, `invoice_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `sim_unavailable` | | `40` | `POST` | `/api/invoices/{invoice_id}/pay` | `pay_invoice` | `{bank_account_id?, amount_cents?, settlement_fx_rate_micros?, payment_method?, idempotency_key?}` | `200 paid Invoice + PAY + AUD` | `unpayable_invoice`, `closed_period`, `invoice_not_found`, `account_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `41` | `POST` | `/api/invoices/{invoice_id}/void` | `void_invoice` | `{reason?}` | `200 voided Invoice + AUD` | `invalid_state_transition`, `invoice_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `42` | `GET` | `/api/credit-memos` | `list_credit_memos` | `?doc_kind&status&limit=200&offset=0&as_of&as_known_at` | `200 list[dict]` | `invalid_limit`, `invalid_offset`, `invalid_timestamp`, `missing_corp`, `missing_role`, `invalid_role`, `sim_unavailable` | | `43` | `POST` | `/api/credit-memos` | `create_credit_memo` | `{memo_number, doc_kind, adjustment_cents, reason, invoice_id?, bill_id?, tax_adjustment_cents?}` | `201 CreditMemo + AUD` | `invalid_field`, `invoice_not_found`, `duplicate_key`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `44` | `POST` | `/api/credit-memos/{credit_memo_id}/apply` | `apply_credit_memo` | `{}` | `200 applied CreditMemo + AUD` | `invalid_state_transition`, `credit_memo_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `sim_unavailable` | | `45` | `GET` | `/api/revenue-schedules` | `list_revenue_schedules` | `?status&standard_mode&limit=200&offset=0` | `200 list[dict]` | `invalid_limit`, `invalid_offset`, `missing_corp`, `missing_role`, `invalid_role`, `sim_unavailable` | | `46` | `POST` | `/api/revenue-schedules` | `create_revenue_schedule` | `{contract_ref, total_contract_cents, standard_mode?, invoice_id?, period_id?, deferred_account_id?}` | `201 RevenueSchedule + AUD` | `invalid_field`, `invoice_not_found`, `period_not_found`, `duplicate_key`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `47` | `GET` | `/api/revenue-schedules/{schedule_id}` | `get_revenue_schedule` | `(none)` | `200 RevenueSchedule + obligations` | `schedule_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `sim_unavailable` | | `48` | `POST` | `/api/revenue-schedules/{schedule_id}/recognize` | `recognize_revenue_period` | `{recognize_cents, period_id?}` | `200 RevenueSchedule + JE + AUD` | `invalid_field`, `invalid_state_transition`, `closed_period`, `schedule_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `49` | `POST` | `/api/revenue-schedules/{schedule_id}/pause` | `pause_revenue_schedule` | `{reason?}` | `200 paused RevenueSchedule + AUD` | `invalid_state_transition`, `schedule_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `50` | `GET` | `/api/revenue-schedules/{schedule_id}/obligations` | `list_revenue_obligations` | `?satisfaction_method&limit=200&offset=0` | `200 list[dict]` | `invalid_limit`, `invalid_offset`, `schedule_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `sim_unavailable` | | `51` | `POST` | `/api/revenue-schedules/{schedule_id}/obligations` | `add_revenue_obligation` | `{obligation_code, description, satisfaction_method?, allocation_bps, allocated_cents}` | `201 RevenueObligation + AUD` | `invalid_field`, `allocation_mismatch`, `allocation_exceeds_10000_bps`, `schedule_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `52` | `DELETE` | `/api/revenue-schedules/{schedule_id}/obligations/{obligation_id}` | `delete_revenue_obligation` | `(none)` | `200 {"deleted": true}` | `schedule_not_found`, `obligation_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `sim_unavailable` | | `53` | `GET` | `/api/vendors` | `list_vendors` | `?status&payment_hold&vendor_code&limit=200&offset=0` | `200 list[dict]` (PII masked for `viewer`/`auditor`) | `invalid_limit`, `invalid_offset`, `missing_corp`, `missing_role`, `invalid_role`, `sim_unavailable` | | `54` | `POST` | `/api/vendors` | `create_vendor` | `{vendor_code, legal_name, contact_email, tax_id, bank_iban?, ap_account_id?, payment_hold?, ers_enabled?}` | `201 Vendor + AUD` | `invalid_field`, `account_not_found`, `duplicate_key`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `55` | `GET` | `/api/vendors/{vendor_id}` | `get_vendor` | `(none)` | `200 Vendor` | `vendor_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `sim_unavailable` | | `56` | `PATCH` | `/api/vendors/{vendor_id}` | `update_vendor` | `{legal_name?, contact_email?, ers_enabled?}` | `200 Vendor + AUD` | `invalid_field`, `vendor_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `57` | `POST` | `/api/vendors/{vendor_id}/hold` | `toggle_vendor_hold` | `{payment_hold?}` | `200 Vendor + AUD` | `vendor_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `58` | `POST` | `/api/vendors/{vendor_id}/archive` | `archive_vendor` | `{}` | `200 archived Vendor + AUD` | `invalid_state_transition`, `vendor_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `sim_unavailable` | | `59` | `GET` | `/api/vendor-bank-changes` | `list_vendor_bank_changes` | `?status&vendor_id&limit=200&offset=0` | `200 list[dict]` | `invalid_limit`, `invalid_offset`, `missing_corp`, `missing_role`, `invalid_role`, `sim_unavailable` | | `60` | `POST` | `/api/vendor-bank-changes` | `create_vendor_bank_change` | `{vendor_id, new_iban, requester_actor_id?}` | `201 VendorBankChange + AUD` | `invalid_field`, `vendor_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `61` | `POST` | `/api/vendor-bank-changes/{bank_change_id}/confirm` | `confirm_vendor_bank_change` | `{}` | `200 confirmed VendorBankChange + AUD` | `invalid_state_transition`, `bank_change_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `sim_unavailable` | | `62` | `POST` | `/api/vendor-bank-changes/{bank_change_id}/approve` | `approve_vendor_bank_change` | `{approver_actor_id}` | `200 approved VendorBankChange + AUD` | `sod_violation`, `invalid_state_transition`, `bank_change_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `63` | `POST` | `/api/vendor-bank-changes/{bank_change_id}/reject` | `reject_vendor_bank_change` | `{reason?}` | `200 rejected VendorBankChange + AUD` | `invalid_state_transition`, `bank_change_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `64` | `GET` | `/api/purchase-orders` | `list_purchase_orders` | `?status&vendor_id&limit=200&offset=0&as_of&as_known_at` | `200 list[dict]` | `invalid_limit`, `invalid_offset`, `invalid_timestamp`, `missing_corp`, `missing_role`, `invalid_role`, `sim_unavailable` | | `65` | `POST` | `/api/purchase-orders` | `create_purchase_order` | `{po_number, vendor_name, expected_qty, unit_price_cents, vendor_id?, currency?, tolerance_bps?}` | `201 PurchaseOrder + AUD` | `invalid_field`, `invalid_purchase_order`, `vendor_not_found`, `duplicate_key`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `66` | `GET` | `/api/purchase-orders/{po_id}` | `get_purchase_order` | `?as_of&as_known_at` | `200 PurchaseOrder` | `invalid_timestamp`, `po_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `sim_unavailable` | | `67` | `POST` | `/api/purchase-orders/{po_id}/cancel` | `cancel_purchase_order` | `{reason?}` | `200 cancelled PurchaseOrder + AUD` | `invalid_state_transition`, `po_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `68` | `GET` | `/api/goods-receipts` | `list_goods_receipts` | `?po_id&status&limit=200&offset=0&as_of&as_known_at` | `200 list[dict]` | `invalid_limit`, `invalid_offset`, `invalid_timestamp`, `missing_corp`, `missing_role`, `invalid_role`, `sim_unavailable` | | `69` | `POST` | `/api/goods-receipts` | `record_goods_receipt` | `{receipt_number, po_id, received_qty, received_value_cents, warehouse_code?}` | `201 GoodsReceipt + AUD` | `invalid_field`, `po_not_found`, `duplicate_key`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `70` | `GET` | `/api/bills` | `list_bills` | `?status&match_status&vendor_id&limit=200&offset=0&as_of&as_known_at` | `200 list[dict]` | `invalid_limit`, `invalid_offset`, `invalid_timestamp`, `missing_corp`, `missing_role`, `invalid_role`, `sim_unavailable` | | `71` | `POST` | `/api/bills` | `record_bill` | `{bill_number, vendor_contact_email, vendor_tax_id, due_date, subtotal_cents, vendor_id?, po_id?, receipt_id?, tax_rate_id?, currency?, fx_rate_micros?, created_by_actor?}` | `201 Bill + AUD` | `invalid_field`, `vendor_not_found`, `duplicate_key`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `72` | `GET` | `/api/bills/{bill_id}` | `get_bill` | `?as_of&as_known_at` | `200 Bill (PII masked for viewer/auditor)` | `invalid_timestamp`, `bill_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `sim_unavailable` | | `73` | `POST` | `/api/bills/{bill_id}/approve` | `approve_bill` | `{approver_actor}` | `200 approved Bill + AUD` | `sod_violation`, `invalid_state_transition`, `bill_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `74` | `POST` | `/api/bills/{bill_id}/override-match` | `override_bill_match` | `{approver_actor, override_reason}` | `200 override_approved Bill + AUD` | `sod_violation`, `invalid_state_transition`, `bill_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `75` | `POST` | `/api/bills/{bill_id}/pay` | `pay_bill` | `{bank_account_id?, amount_cents?, settlement_fx_rate_micros?, payment_method?, idempotency_key?}` | `200 paid Bill + PAY + AUD` | `unpayable_bill`, `closed_period`, `bill_not_found`, `account_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `76` | `GET` | `/api/payments` | `list_payments` | `?direction&status&limit=200&offset=0&as_of&as_known_at` | `200 list[dict]` | `invalid_limit`, `invalid_offset`, `invalid_timestamp`, `missing_corp`, `missing_role`, `invalid_role`, `sim_unavailable` | | `77` | `POST` | `/api/payments` | `record_payment` | `{idempotency_key, direction, bank_account_id, amount_cents, invoice_id?, bill_id?, settlement_currency?, settlement_fx_rate_micros?, payment_method?}` | `201 Payment / 200 idempotent replay` | `invalid_field`, `closed_period`, `account_not_found`, `duplicate_key`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `78` | `GET` | `/api/payments/{payment_id}` | `get_payment` | `?as_of&as_known_at` | `200 Payment` | `invalid_timestamp`, `payment_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `sim_unavailable` | | `79` | `POST` | `/api/payments/{payment_id}/reverse` | `reverse_payment` | `{reason?}` | `200 reversed Payment + AUD` | `invalid_state_transition`, `closed_period`, `payment_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `80` | `GET` | `/api/bank-statements` | `list_bank_statements` | `?status&bank_account_id&format_kind&limit=200&offset=0` | `200 list[dict]` | `invalid_limit`, `invalid_offset`, `missing_corp`, `missing_role`, `invalid_role`, `sim_unavailable` | | `81` | `POST` | `/api/bank-statements` | `import_bank_statement_line` | `{idempotency_key, bank_account_id, statement_date, amount_cents, format_kind?, reference_text?}` | `201 BankStatementLine / 200 replay` | `invalid_field`, `account_not_found`, `duplicate_key`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `82` | `POST` | `/api/bank-statements/{statement_line_id}/match` | `match_bank_line` | `{payment_id?}` | `200 matched BankStatementLine + AUD` | `invalid_state_transition`, `statement_line_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `83` | `POST` | `/api/bank-statements/{statement_line_id}/reconcile` | `reconcile_bank_line` | `{}` | `200 reconciled BankStatementLine + AUD` | `invalid_state_transition`, `statement_line_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `sim_unavailable` | | `84` | `POST` | `/api/bank-statements/{statement_line_id}/exclude` | `exclude_bank_line` | `{reason?}` | `200 excluded BankStatementLine + AUD` | `invalid_state_transition`, `statement_line_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `85` | `GET` | `/api/fixed-assets` | `list_fixed_assets` | `?asset_class&status&limit=200&offset=0&as_of&as_known_at` | `200 list[dict]` | `invalid_limit`, `invalid_offset`, `invalid_timestamp`, `missing_corp`, `missing_role`, `invalid_role`, `sim_unavailable` | | `86` | `POST` | `/api/fixed-assets` | `register_fixed_asset` | `{asset_tag, asset_name, asset_class, acquisition_date, cost_cents, salvage_value_cents, useful_life_months, depreciation_method?, asset_account_id?, accum_depr_account_id?, expense_account_id?}` | `201 FixedAsset + AUD` | `invalid_field`, `invalid_fixed_asset`, `duplicate_key`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `87` | `POST` | `/api/fixed-assets/{asset_id}/depreciate` | `run_asset_depreciation` | `{period_id}` | `200 FixedAsset + JE + AUD` | `invalid_fixed_asset`, `closed_period`, `asset_not_found`, `period_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `88` | `POST` | `/api/fixed-assets/{asset_id}/dispose` | `dispose_fixed_asset` | `{proceeds_cents, period_id}` | `200 disposed FixedAsset + JE + AUD` | `invalid_state_transition`, `closed_period`, `asset_not_found`, `period_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `89` | `GET` | `/api/inventory` | `list_inventory_items` | `?valuation_method&status&limit=200&offset=0&as_of&as_known_at` | `200 list[dict]` | `invalid_limit`, `invalid_offset`, `invalid_timestamp`, `missing_corp`, `missing_role`, `invalid_role`, `sim_unavailable` | | `90` | `POST` | `/api/inventory` | `create_inventory_item` | `{sku_code, item_name, valuation_method, quantity_on_hand, unit_cost_cents, inventory_account_id?, cogs_account_id?}` | `201 InventoryValuation + AUD` | `invalid_field`, `duplicate_key`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `91` | `POST` | `/api/inventory/{sku_id}/adjust` | `adjust_inventory_valuation` | `{qty_delta, unit_cost_cents, reason, period_id}` | `200 InventoryValuation + JE + AUD` | `insufficient_inventory`, `closed_period`, `sku_not_found`, `period_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `92` | `GET` | `/api/legal-entities` | `list_legal_entities` | `?functional_currency&status&limit=200&offset=0` | `200 list[dict]` | `invalid_limit`, `invalid_offset`, `missing_corp`, `missing_role`, `invalid_role`, `sim_unavailable` | | `93` | `POST` | `/api/legal-entities` | `create_legal_entity` | `{entity_code, legal_name, functional_currency?, jurisdiction?, aws_region?}` | `201 LegalEntity + AUD` | `invalid_field`, `duplicate_key`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `94` | `POST` | `/api/legal-entities/{legal_entity_id}/toggle` | `toggle_legal_entity` | `{active?}` | `200 LegalEntity + AUD` | `legal_entity_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `95` | `GET` | `/api/intercompany-transfers` | `list_intercompany_transfers` | `?status&period_id&limit=200&offset=0` | `200 list[dict]` | `invalid_limit`, `invalid_offset`, `missing_corp`, `missing_role`, `invalid_role`, `sim_unavailable` | | `96` | `POST` | `/api/intercompany-transfers` | `create_intercompany_transfer` | `{transfer_code, amount_cents, from_entity_id?, to_entity_id?, period_id?, currency?}` | `201 IntercompanyTransfer + AUD` | `invalid_field`, `legal_entity_not_found`, `period_not_found`, `duplicate_key`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `97` | `GET` | `/api/intercompany-transfers/{ic_transfer_id}` | `get_intercompany_transfer` | `(none)` | `200 IntercompanyTransfer` | `ic_transfer_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `sim_unavailable` | | `98` | `POST` | `/api/intercompany-transfers/{ic_transfer_id}/post` | `post_intercompany_transfer` | `{}` | `200 posted IntercompanyTransfer + AUD` | `invalid_state_transition`, `ic_transfer_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `sim_unavailable` | | `99` | `POST` | `/api/intercompany-transfers/{ic_transfer_id}/eliminate` | `eliminate_intercompany_transfer` | `{}` | `200 eliminated IntercompanyTransfer + AUD` | `invalid_state_transition`, `ic_transfer_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `sim_unavailable` | | `100` | `POST` | `/api/intercompany-transfers/{ic_transfer_id}/dispute` | `dispute_intercompany_transfer` | `{reason?}` | `200 disputed IntercompanyTransfer + AUD` | `invalid_state_transition`, `ic_transfer_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `101` | `GET` | `/api/budgets` | `list_budgets` | `?status&cost_center&period_id&limit=200&offset=0` | `200 list[dict]` | `invalid_limit`, `invalid_offset`, `missing_corp`, `missing_role`, `invalid_role`, `sim_unavailable` | | `102` | `POST` | `/api/budgets` | `create_budget` | `{budget_code, cost_center, allocated_cents, period_id?, account_id?, max_overrun_bps?}` | `201 BudgetCommitment + AUD` | `invalid_field`, `invalid_budget`, `period_not_found`, `account_not_found`, `duplicate_key`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `103` | `POST` | `/api/budgets/{budget_id}/activate` | `activate_budget` | `{}` | `200 active BudgetCommitment + AUD` | `invalid_state_transition`, `budget_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `sim_unavailable` | | `104` | `POST` | `/api/budgets/{budget_id}/encumber` | `encumber_budget` | `{amount_cents}` | `200 BudgetCommitment + AUD` | `invalid_field`, `invalid_state_transition`, `budget_exceeded`, `budget_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `105` | `POST` | `/api/budgets/{budget_id}/freeze` | `freeze_budget` | `{}` | `200 frozen BudgetCommitment + AUD` | `invalid_state_transition`, `budget_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `sim_unavailable` | | `106` | `GET` | `/api/evidence-artifacts` | `list_evidence_artifacts` | `?doc_class&object_lock_mode&legal_hold&limit=200&offset=0` | `200 list[dict]` | `invalid_limit`, `invalid_offset`, `missing_corp`, `missing_role`, `invalid_role`, `sim_unavailable` | | `107` | `POST` | `/api/evidence-artifacts` | `create_evidence_artifact` | `{doc_class, target_ref_id, file_name, size_bytes?, object_lock_mode?, retention_days?, legal_hold?}` | `201 EvidenceArtifact + AUD` | `invalid_field`, `invalid_evidence`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `108` | `PUT` | `/api/evidence-artifacts/{artifact_id}/content` | `upload_evidence_bytes` | `raw bytes (<= 10 MB)` | `200 EvidenceArtifact + sha256 + AUD` | `invalid_evidence`, `artifact_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `blob_unavailable`, `sim_unavailable` | | `109` | `GET` | `/api/evidence-artifacts/{artifact_id}/content` | `download_evidence_bytes` | `(none)` | `200 raw bytes` (`QG-READ-IDEMP`) | `artifact_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `blob_unavailable`, `sim_unavailable` | | `110` | `POST` | `/api/evidence-artifacts/{artifact_id}/legal-hold` | `toggle_evidence_legal_hold` | `{legal_hold?}` | `200 EvidenceArtifact + AUD` | `artifact_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `111` | `GET` | `/api/fx-rates` | `list_fx_rates` | `?from_currency&to_currency&effective_date&limit=200&offset=0&as_of&as_known_at` | `200 list[dict]` | `invalid_limit`, `invalid_offset`, `invalid_timestamp`, `missing_corp`, `missing_role`, `invalid_role`, `sim_unavailable` | | `112` | `POST` | `/api/fx-rates` | `upsert_fx_rate` | `{rate_key, from_currency, to_currency, rate_micros, effective_date?}` | `201 FxRate / 200 replay + AUD` | `invalid_field`, `invalid_fx_rate`, `duplicate_key`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `113` | `GET` | `/api/fx-revaluations` | `list_fx_revaluations` | `?period_code¤cy&limit=200&offset=0&as_of&as_known_at` | `200 list[dict]` | `invalid_limit`, `invalid_offset`, `invalid_timestamp`, `missing_corp`, `missing_role`, `invalid_role`, `sim_unavailable` | | `114` | `POST` | `/api/fx-revaluations` | `run_fx_revaluation` | `{period_id, currency, closing_fx_rate_micros, dry_run?}` | `201 FxRevaluation / 200 dry-run` | `invalid_field`, `closed_period`, `period_not_found`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | | `115` | `GET` | `/api/reports/trial-balance` | `get_trial_balance` | `?period_code&as_of&as_known_at` | `200 bitemporal TrialBalance` | `invalid_timestamp`, `missing_corp`, `missing_role`, `invalid_role`, `sim_unavailable` | | `116` | `GET` | `/api/reports/aging` | `get_aging_report` | `?ledger_side=ar&as_of&as_known_at` | `200 bitemporal AR/AP aging buckets` | `invalid_field`, `invalid_timestamp`, `missing_corp`, `missing_role`, `invalid_role`, `sim_unavailable` | | `117` | `GET` | `/api/reports/tax-summary` | `get_tax_summary` | `?period_code&as_of&as_known_at` | `200 jurisdiction VAT/Sales Tax summary` | `invalid_timestamp`, `missing_corp`, `missing_role`, `invalid_role`, `sim_unavailable` | | `118` | `POST` | `/api/audit/benford` | `run_benford_audit` | `{period_code?}` | `200 Benford chi-square summary + AUD` | `invalid_field`, `missing_corp`, `missing_role`, `invalid_role`, `insufficient_role`, `payload_too_large`, `sim_unavailable` | --- ## §4. Authorization Precedence, RBAC & Production Hardening ### §4.0 Check Precedence `1. Exempt (#1, #2, /js/*, /css/*, /static/vendor/*)` -> `2. URL-decode + posixpath.normpath() + route match (404 route_not_found) + FORCE_HTTPS=true (426 upgrade_required)` -> `3. Pre-read Content-Length cap (400 invalid_content_length / 413 payload_too_large BEFORE rfile.read())` -> `4. Bounded concurrency (503 service_busy + Retry-After)` -> `5. Tiered token-bucket rate limit (429 rate_limited + Retry-After)` -> `6. AUTH_MODE=jwt HS256 verification (401 unauthorized)` -> `7. X-Corp-Id tenancy check (403 missing_corp)` -> `8. X-Role presence (403 missing_role on omitted/empty X-Role — NEVER defaults to owner or any privileged role)` -> `9. Valid closed role check (403 invalid_role)` -> `10. RBAC route matrix check (403 insufficient_role)` -> `11. Input validation, SoD, period lock & double-entry invariants (400/404/409)` -> `12. Hash-chained AUD-#### append (mutating ops only)`. *(HS256 `AUTH_MODE=jwt` & `/{pk}` Precedence: verified HS256 `Authorization: Bearer` tokens supply `corp`/`role` claims even when `X-Corp-Id`/`X-Role` headers are omitted, while empty `JWT_SECRET` fails closed `401`/`403`; on `/{pk}` routes, resolve `404 _not_found` BEFORE body `400 missing_required` validation.)* ### §4.1 Exhaustive Disjoint Role × Route RBAC Matrix **Exempt (Auth/Corp/Role Bypass):** `#1`, `#2`, `/js/*`, `/css/*`, `/static/vendor/*`. Every protected `/api/*` request with omitted or empty `X-Role` returns **`403 missing_role`**. | Route Group | Routes (#) | Allowed Roles | Denied / Notes | | :--- | :--- | :--- | :--- | | Standard Ledger, Subledger, Evidence & Bitemporal Report Reads | `#3, #5, #7, #10, #12, #15, #20, #23, #25, #28, #30, #32, #36, #38, #42, #45, #47, #50, #53, #55, #59, #64, #66, #68, #70, #72, #76, #78, #80, #85, #89, #92, #95, #97, #101, #106, #109, #111, #113, #115, #116, #117` | `owner`, `erp_admin`, `controller`, `gl_accountant`, `ar_clerk`, `ap_clerk`, `auditor`, `viewer` | Omitted `X-Role` -> `403 missing_role`; `viewer`/`auditor` see masked PII | | General Ledger, Tax, Assets, Inventory, FX, Intercompany, Close Tasks & Budgets | `#6, #8, #9, #16, #17, #21, #22, #24, #26, #27, #29, #86, #87, #88, #90, #91, #96, #98, #100, #102, #104, #112, #114` | `owner`, `erp_admin`, `controller`, `gl_accountant` | `ar_clerk`, `ap_clerk`, `auditor`, `viewer` -> `403 insufficient_role` | | Accounts Receivable Customers, Invoices, Credit Memos & ASC 606 Revenue | `#31, #33, #34, #35, #37, #39, #40, #41, #43, #44, #46, #48, #49, #51, #52` | `owner`, `erp_admin`, `controller`, `gl_accountant`, `ar_clerk` | `ap_clerk`, `auditor`, `viewer` -> `403 insufficient_role` | | Vendors, Procurement POs, Goods Receipts, AP Bills, Cash & Bank Feeds | `#54, #56, #57, #60, #61, #65, #67, #69, #71, #75, #77, #79, #81, #82, #83, #84` | `owner`, `erp_admin`, `controller`, `gl_accountant`, `ap_clerk` | `ar_clerk`, `auditor`, `viewer` -> `403 insufficient_role` | | SOX 404 Governance: Period Close, Task Signoff/Waive, AP/Bank SoD, Intercompany Elim, Budgets & Custody | `#11, #13, #14, #18, #19, #58, #62, #63, #73, #74, #93, #94, #99, #103, #105, #107, #108, #110, #118` | `owner`, `erp_admin`, `controller` | `gl_accountant`, `ar_clerk`, `ap_clerk`, `auditor`, `viewer` -> `403 insufficient_role`; creator cannot self-approve (`400 sod_violation`) | | Sensitive Tamper-Evident Audit Ledger Read | `#4` | `owner`, `erp_admin`, `controller`, `auditor` | Restricted strictly to `admin_roles`; `gl_accountant`, `ar_clerk`, `ap_clerk`, `viewer` -> `403 insufficient_role` | *(Disjoint Partition Check: union covers `#3..#118` (`116` routes) with zero overlap and zero unmapped routes; Exempt = `{#1, #2}`.)* ### §4.2 Security, Privacy & Compliance Hardening - **PII Target Unity (`SEC-PII-AT-REST`, `SEC-COMPLIANCE-HARDENING`):** `encrypt_at_rest = true`, `security.pii_fields = ["Customer.legal_name", "Customer.billing_email", "Customer.billing_address", "Invoice.customer_name", "Invoice.customer_email", "Invoice.billing_address", "Vendor.legal_name", "Vendor.contact_email", "VendorBankChange.new_iban", "Bill.vendor_contact_email", "Bill.vendor_tax_id"]`, `masked_pii_roles = ["viewer", "auditor"]`. PII fields are encrypted via Offstack KMS/Secrets Manager envelope keys at rest, masked in read responses for `masked_pii_roles`, and scrubbed from structured logs and error envelopes. - **Tamper-Evident Audit Chain:** Every mutating API route appends one `AUD-####` entry to `erp_audit_logs` carrying `prev_hash` (`"0"*64` genesis per tenant) and 64-hex SHA-256 `entry_hash`. All `GET` routes write zero audit rows. - **Web & Production Hardening (`SEC-CRYPTO-HYGIENE`, `SEC-WEB-HARDENING`, `SEC-PROD-HARDENING`):** Fail-closed HS256 `AUTH_MODE=jwt` (no `alg=none`, no query-string secrets), pre-read `413 payload_too_large` (`1_048_576` bytes), tiered token-bucket `429 rate_limited` + `Retry-After`, bounded semaphore `503 service_busy`, `FORCE_HTTPS=true` (`426 upgrade_required`), and strict security headers (`X-Content-Type-Options: nosniff`, `X-Frame-Options: DENY`, `Referrer-Policy: no-referrer`, `Cache-Control: no-store` on `/api/*`, `Content-Security-Policy: default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data:; connect-src 'self'; frame-ancestors 'none'` with zero `'unsafe-eval'`). - **Rate-Limit Defaults & Header-Less JWT Claims (`SEC-PROD-HARDENING`):** Default rate limits are `>= 600 req/min` (`burst >= 100`), honoring `RATE_LIMIT_BURST`/`RATE_LIMIT_RPS` env overrides immediately; under `AUTH_MODE=jwt` with non-empty `JWT_SECRET`, verified HS256 `Authorization: Bearer ` tokens derive `corp`/`role` directly even when `X-Corp-Id`/`X-Role` headers are omitted (empty `JWT_SECRET` fails closed `401`/`403`). --- ## §5. Infrastructure & Enabling Services ### §5.1 Offstack Enabling Infrastructure Contract (`app/offstack_store.py`) > **PROMINENT BUILDER DIRECTIVE:** `toolkits/offstack/docs/OFFSTACK_AI_MANUAL.txt` (~4K tokens covering 75 AWS services / 4,512 operations) is ALWAYS available during build and verification. Read `[CONNECT]`, `[RDBMS]`, `[AUTH_TENANCY]`, `[SERVICES_ALL_75]`, `[NOT_IN_OFFSTACK]`, and `[HIGH_IMPACT_GOTCHAS]` before writing or modifying `app/offstack_store.py`. - **Single Confinement Seam (`SEC-STORAGE`):** 100% of `boto3`/`botocore` calls live exclusively inside `app/offstack_store.py` (`forbid_sqlite_fallback = true`, `forbid_local_fallback = true`). When Offstack DynamoDB, S3, KMS, or Secrets Manager is unreachable or times out, fail loud with `503 sim_unavailable` or `503 blob_unavailable` — zero SQLite, local JSON/CSV files, or in-memory fallback dicts. - **Endpoint Precedence, Fail-Fast Timeouts & Cold-Empty Reset:** - Honor `OFFSTACK_DYNAMODB_URL` / `DYNAMODB_ENDPOINT_URL` / `AWS_ENDPOINT_URL_DYNAMODB` (`:13160`), `OFFSTACK_S3_URL` / `S3_ENDPOINT_URL` / `AWS_ENDPOINT_URL_S3` (`:13161`), `AWS_ENDPOINT_URL_SECRETS_MANAGER` alongside `AWS_ENDPOINT_URL_SECRETSMANAGER` (`:4594`), `AWS_ENDPOINT_URL_{SQS,SNS,EVENTBRIDGE,EVENTS,SSM,KMS}`, and `OFFSTACK_GATEWAY_URL` / `AWS_ENDPOINT_URL` (`:4566`). Restrict hard-required startup env vars solely to `OffstackSidecar`-auto-exported URLs; app encryption/JWT keys fall back to Secrets Manager or an ephemeral dev default when unset; zero raw credential or PII logging on upstream errors. - Configure `botocore.config.Config(connect_timeout=1, read_timeout=5, retries={"max_attempts": 1})`. Coerce `Decimal -> int` for all `*_cents`/`*_micros`/`*_bps` fields on DynamoDB reads. - Ban DynamoDB table `Scan` on all tenant/request paths (`Query` on `corp_id` PK or GSIs only), with an explicit **`reset_store()` Scan/wipe carve-out**: `reset_store(corp_id: str = "")` checks connectivity via `list_tables`, clears existing `erp_*` tables and `erp-close-archives` S3 objects safely even on a cold-empty Offstack instance, and performs zero RPCs at module import (`_ensure_seeded()` runs once inside `build_server()`/`main()` startup (never lazily inside `GET` handlers for `QG-READ-IDEMP`)). - Scope S3 Object Lock (`GOVERNANCE`/`COMPLIANCE` retention) strictly to immutable close binders, VAT invoice XMLs, match packets, and SOX workpapers (`erp-close-archives`); never Object-Lock `contact_pii_export` or GDPR-erasable contact metadata (store customer/vendor PII links in DynamoDB to avoid S3's 10-tag-per-object limit). - **Startup Seeding & Transactional Rollback (`QG-READ-IDEMP`, `QG-STORAGE-TX-PERF`):** Module import and `GET /health` perform zero Offstack RPCs; `_ensure_seeded()`/`bootstrap_store()` seeds `alpha-corp` once idempotently and synchronously before binding the HTTP listener inside `build_server()`/`main()` (aborting on first `StoreUnavailable`, honoring `SEED_DEMO_DATA`, never in background `time.sleep` threads or lazily inside `GET` handlers). Expose `@contextmanager def atomic(corp: str | None = None)` (`with store.atomic():` zero-arg callable) inside `app/offstack_store.py` with an explicit `try: ... yield ... except Exception:` rollback block, `ddb.transact_write_items()` for multi-item writes, and `ddb.get_item()` for cold key lookups. Never write local `wal`/`tx_*.json` journal files or `fcntl`/`msvcrt` lock files under `forbid_local_fallback=true`, and rely on `botocore` `connect_timeout` via `boto3.client(...)` directly without raw TCP `socket.create_connection` pre-flights (honoring an injected `store.ddb` attribute) so offline `QG-STORAGE-TX-PERF` mocks run cleanly; custom local `endpoint_url` `boto3.client(...)` calls may use short local dummy `aws_access_key_id`/`aws_secret_access_key` fallbacks (never real keys or `JWT_SECRET`) so standalone VibeInstaller `.exe` runs succeed without `~/.aws/credentials`. #### Verified Offstack Services Map (`Core` + Verified `Extended`) | AWS Service | Tier | Resource / Prefix | Purpose | | :--- | :--- | :--- | :--- | | `DynamoDB` | `Core` | `27 erp_*` domain tables + `erp_sequences` | 28 tenant-partitioned tables (`PK=corp_id`), `TransactWriteItems` atomic journal+balance commits, GSI1–GSI3 indexes, atomic `erp_sequences` | | `S3` | `Core` | `erp-close-archives` | Selective Object Lock snapshots (`close_binder`, `vat_invoice_xml`, `match_packet`, `sox_workpaper`), tax exports, and SOX audit seal archives | | `Secrets Manager` | `Core` | `aicentricerp/jwt-hmac`, `aicentricerp/pii-envelope` | HS256 JWT secret & PII field encryption key storage/rotation | | `SQS` | `Extended` | `aicentricerp-subledger-events`, `aicentricerp-posting-dlq` | Async subledger posting queue & dead-letter recovery for failed batch jobs | | `SNS` | `Extended` | `aicentricerp-audit-alerts` | Benford's Law anomaly (`chi2 > 15.51`), `variance_hold`, and vendor bank-change escalation alerts | | `EventBridge` | `Extended` | `aicentricerp-close-bus` | Period close, depreciation batch, ASC 606 recognition, and FX revaluation domain events | | `SSM` | `Extended` | `/aicentricerp/config/*` | Non-secret statutory retention windows, `tolerance_bps` defaults, and FX precision settings | | `KMS` | `Extended` | `alias/aicentricerp-pii-key` | Envelope encryption keys for `security.pii_fields` and close binder SHA-256 signing | *(Zero `[NOT_IN_OFFSTACK]` services declared: `ec2`, `ecs`, `eks`, `docdb`, `sagemaker*`, `bedrock*`, `inspector2` are strictly absent.)* ### §5.2 Optional AI Gateway Integration Autonomous Benford anomaly explanations and month-end variance triage route strictly through **ArtificialIntelligenceOptimizer (`aioptimizer`)** resolved dynamically from `AIO_BASE_URL` (`http://127.0.0.1:14787`) or `%LOCALAPPDATA%\ArtificialIntelligenceOptimizer\aioptimizer.json` using explicit pinned model slugs (`x-aio-pin-model: 1`) and zero hardcoded model auto-routing. --- ## §6. Frontend Architecture, Theme & DF3 DOM Determinism - **Modular JS Source Tree (`<= 800` LOC/file — ZERO `bundle.js`, ZERO `frontend/dist/js/`):** All first-party JavaScript lives exclusively under **`frontend/js/`** (`frontend/js/api.js`, `frontend/js/ledger.js`, `frontend/js/app.js`, `frontend/js/panels.js`), loaded cleanly from `frontend/dist/index.html`. **`frontend/js/api.js` is the sole file allowed to invoke `fetch()` (`SEC-API-BOUNDARY`)**, injecting `#corp-select` (`X-Corp-Id`), `#role-select` (`X-Role`), `#as-of-input` (`as_of`), and `#as-known-at-input` (`as_known_at`). Zero `innerHTML`, `outerHTML`, `insertAdjacentHTML`, or `document.write` (`SEC-XSS`), zero inline `