feat(treasury): policy layer for tax transfers and Amex paydowns (W3) - #401
Open
adme-dev wants to merge 1 commit into
Open
feat(treasury): policy layer for tax transfers and Amex paydowns (W3)#401adme-dev wants to merge 1 commit into
adme-dev wants to merge 1 commit into
Conversation
Kellie's cash-management judgment — weekly NAB Business → NAB Tax transfers with month-varying amounts and a skip-first-Monday rule, and Amex statement paydown tranches — cannot live in Xero (its cashflow tools exclude transfers and card paydowns) and proved unmaintainable as hand-keyed commitment rows. Worse, an internal transfer modelled as a commitment depressed the org-level 13-week forecast: cash moving between our own accounts is not an outflow. - treasury_policies table (migration 377): one config row per policy type per tenant, applied to prod (additive, IF NOT EXISTS). - server/utils/treasuryPolicy.ts: pure derivation of dated lines from config; internal transfers tagged and excluded from org-level outflow, Amex paydowns join weekly outflows. - cashflow-13w: policy lines wired in; policyLines + totalPolicyOutflow exposed for the UI. - GET/PUT /api/cashflow/policies with zod validation per policy type. - Policies seeded from Kellie's 12 Aug sheet (Aug-26 $16k/wk … May-27 $15.5k/wk, skip 1st Monday; Amex $50k 13/8 + $35,327.37 21/8). CUTOVER on deploy: close the two 'Amex — statement payment' commitment rows (notes on the rows say so) — they stay 'expected' so the live forecast keeps the outflow until this code ships. Workstream W3 of .paul/PLAN-2026-08-13-spreadsheet-retirement-platform-work.md. Settings UI for Kellie follows separately (frontend-design pass). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Workstream W3 of the spreadsheet retirement (
.paul/PLAN-2026-08-13-spreadsheet-retirement-platform-work.md, Monday board C-12). Kellie's cash-management judgment — weekly NAB Business → NAB Tax transfers with month-varying amounts and a skip-first-Monday rule, plus Amex statement paydown tranches — can't be represented in Xero (its own cashflow tools exclude transfers and card paydowns). Hand-keying them as commitment rows recreated the spreadsheet's maintenance burden, and modelling an internal transfer as a commitment wrongly depressed the org-level 13-week forecast (cash moving between our own accounts isn't an outflow).What
treasury_policies(migration 377, already applied to prod — additive): one JSONB config row per policy type per tenant.server/utils/treasuryPolicy.ts— pure derivation of dated lines:tax_transfer(per-month weekly amounts, 1-based skip-Monday rules) taggedinternal_transferand excluded from org-level outflow;amex_paydowntranches join weekly outflows as real cash events.cashflow-13w— policy lines wired in;policyLinesandtotalPolicyOutflowexposed for the UI / per-account views.GET/PUT /api/cashflow/policies— zod-validated per policy type.Cutover step on deploy
The two
Amex — statement paymentcommitment rows are stillexpectedso the live forecast keeps that outflow until this ships. Close them when this deploys (theirnotesfield says exactly this); otherwise the week of 17 Aug double-counts ~$35k.Tests
test/server/utils/treasuryPolicy.test.ts— skip rules, per-month amounts, horizon bounds, default fallback, past-tranche exclusion (validated against Kellie's actual Aug/Sep/Oct/Nov Monday patterns).test/server/suite: 4,811 passed.Follow-ups
🤖 Generated with Claude Code