nx_coa_lib.nx
buildroot/runtime/nx_coa_lib.nx
about
nx_coa_lib.nx -- F982: CHART OF ACCOUNTS + PERIOD CLOSE, on the sovereign ledger.
nx_ledger deliberately has ONE balance convention (credits - debits, custodial sense) because a
primitive should not guess. This is the layer that makes a balance INTERPRETABLE: it records what
KIND each account is, and therefore which side is its NORMAL balance.
asset, expense -> DEBIT-normal (natural balance = debits - credits)
liability, equity, revenue -> CREDIT-normal (natural balance = credits - debits)
So a funded bank account reads +$100 instead of -$100, without the ledger having to take sides.
★DATA-DRIVEN (rule 11): the type->side map is STORED, not hardcoded. Adding an account kind is a
DATA write (coa_type_put), not a code change and not a recompile.
★FAIL-CLOSED (rule 26 analog): an account with no registered type, or a type with no registered
side, does NOT silently default to a side -- coa_natural returns 0 (unknown) and writes nothing.
Guessing a sign on money is how a balance sheet inverts silently.
PERIOD CLOSE: closing a period appends a lock record. coa_post_ok REFUSES posting into a closed
period. Locks are append-only like everything else -- a close is a fact, not a mutable flag.
Closing is IDEMPOTENT (rule 10): closing an already-closed period is a no-op that still reports closed.
license_tier: ORIGINAL No hw writes (Rule 26). LIB (no main).
dependencies 1 imports · 2 importers
imports: nx_ledger_lib.nx
imported by: nx_coa_gate.nxnx_stmt_lib.nx
structs
| none |
consts
| none |
functions
| 26 | func coa_put(prefix: *u8, acct: *u8, atype: *u8) -> i64 |
| 37 | func coa_type_put(prefix: *u8, atype: *u8, side: *u8) -> i64 |
| 48 | func coa_type(prefix: *u8, acct: *u8, out: *u8) -> i64 |
| 58 | func coa_side(prefix: *u8, atype: *u8, out: *u8) -> i64 |
| 70 | func coa_natural(ledger_prefix: *u8, coa_prefix: *u8, acct: *u8, out: *i64) -> i64 |
| 83 | func coa_period_close(prefix: *u8, period: *u8) -> i64 |
| 94 | func coa_period_closed(prefix: *u8, period: *u8) -> i64 |
| 105 | func coa_post_ok(prefix: *u8, period: *u8) -> i64 |