nx_spend_analyze.nx
buildroot/runtime/nx_spend_analyze.nx
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
imports: nx_syscalls.nx
imported by: nx_money_ledger.nxnx_spend_analyze_gate.nx
structs
| none |
consts
| 8 | const SP_FIELDS: i64 = 3 // per category: [amount_cents, class, recurring] |
| 9 | const SP_NEED: i64 = 0 // class: essential need |
| 10 | const SP_WANT: i64 = 1 // class: discretionary want |
| 11 | const SP_SAVE: i64 = 2 // class: savings / debt-paydown |
| 13 | const B5030_NEEDS: i64 = 5000 |
| 14 | const B5030_WANTS: i64 = 3000 |
| 15 | const B5030_SAVE: i64 = 2000 |
functions
| 17 | func 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 } |
| 18 | func sp_total_by_class(cats: *i64, n: i64, class: i64) -> i64 |
| 23 | func sp_class_pct_bps(cats: *i64, n: i64, class: i64) -> i64 |
| 29 | func sp_class_gap_bps(cats: *i64, n: i64, class: i64, target_bps: i64) -> i64 |
| 34 | func sp_largest_want(cats: *i64, n: i64) -> i64 |
| 48 | func sp_recurring_total(cats: *i64, n: i64) -> i64 called by 1: main |
| 53 | func sp_recurring_want_total(cats: *i64, n: i64) -> i64 |
| 58 | func sp_recurring_want_annual(cats: *i64, n: i64) -> i64 { return sp_recurring_want_total(cats, n) * 12 } |
| 61 | func sp_potential_savings(cats: *i64, n: i64, cut_bps: i64) -> i64 { return sp_total_by_class(cats, n, SP_WANT) * cut_bps / 10000 } |
| 65 | func sp_required_want_cut(target_save: i64, current_save: i64, wants_total: i64) -> i64 called by 1: main |
| 72 | func sp_target_reachable_by_wants(target_save: i64, current_save: i64, wants_total: i64) -> i64 called by 1: main |