code wiki / (root) / nx_coa_lib.nx

nx_coa_lib.nx

buildroot/runtime/nx_coa_lib.nx

5118 B108 linesdepth 8pulls 13 transitivereach 4 importersview sourcekind library
docsdependenciesstructsconstsfunctions

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

nx_ledger_lib.nx nx_coa_lib.nx nx_coa_gate.nx nx_stmt_lib.nx

imports: nx_ledger_lib.nx

imported by: nx_coa_gate.nxnx_stmt_lib.nx

structs

none

consts

none

functions

26func coa_put(prefix: *u8, acct: *u8, atype: *u8) -> i64
called by 3: mainmainmain calls 2: canon_encodereg_put
37func coa_type_put(prefix: *u8, atype: *u8, side: *u8) -> i64
called by 3: mainmainmain calls 2: canon_encodereg_put
48func coa_type(prefix: *u8, acct: *u8, out: *u8) -> i64
called by 2: coa_naturalstmt_by_kind calls 1: reg_get
58func coa_side(prefix: *u8, atype: *u8, out: *u8) -> i64
called by 1: coa_natural calls 1: reg_get
70func coa_natural(ledger_prefix: *u8, coa_prefix: *u8, acct: *u8, out: *i64) -> i64
83func coa_period_close(prefix: *u8, period: *u8) -> i64
called by 1: main calls 2: canon_encodereg_put
94func coa_period_closed(prefix: *u8, period: *u8) -> i64
called by 2: maincoa_post_ok calls 1: reg_get
105func coa_post_ok(prefix: *u8, period: *u8) -> i64
called by 1: main calls 1: coa_period_closed