code wiki / (root) / nx_money_situation.nx

nx_money_situation.nx

buildroot/runtime/nx_money_situation.nx

5201 B83 linesdepth 3pulls 3 transitivereach 1 importersview sourcekind librarytopic money
docsdependenciesstructsconstsfunctions

about

nx_money_situation.nx -- the FOUNDATION of the comprehensive money system: a person's whole financial SITUATION (income, expenses, debts, assets, goals) + the derived metrics every module reads so advice is "optimal for THEIR situation", not generic. Integer-exact (cents / basis-points). Composes nx_debt_strategy (debts layout + underwater check). The keystone is sit_priority(): given the WHOLE picture it routes to the right focus -- relief, emergency fund, debt, or invest -- the decision the operator asked for. license_tier: ORIGINAL

dependencies 2 imports · 1 importers

nx_syscalls.nx nx_debt_strategy.nx nx_money_situation.nx nx_money_situation_gate.nx

imports: nx_syscalls.nxnx_debt_strategy.nx

imported by: nx_money_situation_gate.nx

structs

none

consts

8const SIT_MAGIC_10000: i64 = 10000
11const SIT_INCOME_GROSS: i64 = 0 // monthly gross income cents
12const SIT_INCOME_NET: i64 = 1 // monthly after-tax income cents
13const SIT_EXPENSES_ESSENTIAL: i64 = 2 // monthly essentials cents (housing/food/utilities/transport/insurance)
14const SIT_SPEND_DISCRETIONARY: i64 = 3 // monthly discretionary spend cents
15const SIT_CASH: i64 = 4 // liquid cash/savings cents
16const SIT_RETIREMENT: i64 = 5 // retirement assets cents
17const SIT_OTHER_ASSETS: i64 = 6 // other assets cents
18const SIT_DEPENDENTS: i64 = 7 // number of dependents
19const SIT_EMPLOYED: i64 = 8 // 1 = employed, 0 = not
20const SIT_EFUND_TARGET_MONTHS: i64 = 9 // desired emergency fund, in months of essentials
21const SIT_FIELDS: i64 = 16
24const DTI_HEALTHY_BPS: i64 = 3600 // back-end DTI < 36% = healthy (conventional-mortgage guideline)
25const DTI_STRESSED_BPS: i64 = 4300 // 36-43% stretched; > 43% exceeds the CFPB ability-to-repay QM limit
26const EFUND_MIN_MONTHS: i64 = 3 // 3-6 months of essentials = standard emergency fund floor

functions

29func sit_total_debt(debts: *i64, ndebts: i64) -> i64 { var s: i64 = 0; var i: i64 = 0; while i < ndebts { s = s + debts[i*DS_FIELDS+0]; i = i + 1 } return s }
30func sit_total_min(debts: *i64, ndebts: i64) -> i64 { var s: i64 = 0; var i: i64 = 0; while i < ndebts { s = s + debts[i*DS_FIELDS+2]; i = i + 1 } return s }
31func sit_total_assets(sit: *i64) -> i64 { return sit[SIT_CASH] + sit[SIT_RETIREMENT] + sit[SIT_OTHER_ASSETS] }
called by 1: sit_net_worth
32func sit_net_worth(sit: *i64, debts: *i64, ndebts: i64) -> i64 { return sit_total_assets(sit) - sit_total_debt(debts, ndebts) }
called by 1: main calls 2: sit_total_assetssit_total_debt
36func sit_monthly_surplus(sit: *i64, debts: *i64, ndebts: i64) -> i64
40func sit_max_debt_paydown(sit: *i64, debts: *i64, ndebts: i64) -> i64
called by 2: sit_prioritymain calls 1: sit_total_min
47func sit_dti_bps(sit: *i64, debts: *i64, ndebts: i64) -> i64
called by 2: sit_dti_statusmain calls 1: sit_total_min
51func sit_savings_rate_bps(sit: *i64, debts: *i64, ndebts: i64) -> i64
57func sit_efund_months_x100(sit: *i64) -> i64 { // months of essentials covered by cash, x100
called by 2: sit_prioritymain
61func sit_efund_target_cents(sit: *i64) -> i64 { return sit[SIT_EFUND_TARGET_MONTHS] * sit[SIT_EXPENSES_ESSENTIAL] }
called by 1: sit_efund_gap_cents
62func sit_efund_gap_cents(sit: *i64) -> i64 { let g: i64 = sit_efund_target_cents(sit) - sit[SIT_CASH]; if g < 0 { return 0 } return g }
65func sit_dti_status(sit: *i64, debts: *i64, ndebts: i64) -> i64
called by 1: main calls 1: sit_dti_bps
77func sit_priority(sit: *i64, debts: *i64, ndebts: i64) -> i64