code wiki / (root) / nx_spend_analyze.nx

nx_spend_analyze.nx

buildroot/runtime/nx_spend_analyze.nx

3881 B75 linesdepth 2pulls 2 transitivereach 3 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_spend_analyze.nx -- the SPEND-PATTERN analyzer (the operator's headline ask: "manage spend patterns to be optimal for THEIR situation"). Categorizes spending into needs/wants/savings, benchmarks against 50/30/20, finds recurring/subscription drains (+ their annual cost), and computes the situation-aware recommendation: exactly how much to cut from discretionary to hit a savings target, and WHERE (the largest want). Integer-exact (cents/bps). Reads a category array; pairs with nx_money_situation (income) to judge "optimal for THEM". license_tier: ORIGINAL

dependencies 1 imports · 2 importers

nx_syscalls.nx nx_spend_analyze.nx nx_money_ledger.nx nx_spend_analyze_gate.nx

imports: nx_syscalls.nx

imported by: nx_money_ledger.nxnx_spend_analyze_gate.nx

structs

none

consts

8const SP_FIELDS: i64 = 3 // per category: [amount_cents, class, recurring]
9const SP_NEED: i64 = 0 // class: essential need
10const SP_WANT: i64 = 1 // class: discretionary want
11const SP_SAVE: i64 = 2 // class: savings / debt-paydown
13const B5030_NEEDS: i64 = 5000
14const B5030_WANTS: i64 = 3000
15const B5030_SAVE: i64 = 2000

functions

17func sp_total(cats: *i64, n: i64) -> i64 { var s: i64 = 0; var i: i64 = 0; while i < n { s = s + cats[i*SP_FIELDS+0]; i = i + 1 } return s }
18func sp_total_by_class(cats: *i64, n: i64, class: i64) -> i64
23func sp_class_pct_bps(cats: *i64, n: i64, class: i64) -> i64
29func sp_class_gap_bps(cats: *i64, n: i64, class: i64, target_bps: i64) -> i64
called by 1: main calls 1: sp_class_pct_bps
34func sp_largest_want(cats: *i64, n: i64) -> i64
called by 2: mainmain
48func sp_recurring_total(cats: *i64, n: i64) -> i64
called by 1: main
53func sp_recurring_want_total(cats: *i64, n: i64) -> i64
58func sp_recurring_want_annual(cats: *i64, n: i64) -> i64 { return sp_recurring_want_total(cats, n) * 12 }
called by 1: main calls 1: sp_recurring_want_total
61func sp_potential_savings(cats: *i64, n: i64, cut_bps: i64) -> i64 { return sp_total_by_class(cats, n, SP_WANT) * cut_bps / 10000 }
called by 1: main calls 1: sp_total_by_class
65func sp_required_want_cut(target_save: i64, current_save: i64, wants_total: i64) -> i64
called by 1: main
72func sp_target_reachable_by_wants(target_save: i64, current_save: i64, wants_total: i64) -> i64
called by 1: main