Add flex-budget context to get_budgets (flex bucket + section totals)#77
Open
asreynolds1000 wants to merge 1 commit into
Open
Add flex-budget context to get_budgets (flex bucket + section totals)#77asreynolds1000 wants to merge 1 commit into
asreynolds1000 wants to merge 1 commit into
Conversation
Under Monarch's "Fixed & Flexible" budgeting the real flexible budget is a
single flex-bucket total that the per-category flex sub-budgets do NOT sum to,
so the per-category planned amounts alone can't convey the actual flexible
budget. Analyzing flex categories against their sub-budgets is misleading.
get_budgets now also returns, alongside the existing category rows:
- flex_bucket: per-month flex-bucket planned/actual/remaining
(budgetData.monthlyAmountsForFlexExpense)
- section_totals: per-month Fixed / Non-Monthly / Flexible / overall rollups
the way Monarch computes the budget (budgetData.totalsByMonth)
Both fields live on budgetData and don't touch the guarded category-group
fields (budgetVariability/rolloverPeriod), so the existing account-compatibility
constraint is preserved. Return shape becomes
{categories, flex_bucket, section_totals}; docstring updated. Adds tests for
both new formatters and asserts the query requests the flex fields.
Co-Authored-By: Claude Opus 4.8 <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.
What & why
Under Monarch's Fixed & Flexible budgeting mode, the real flexible budget is a single flex-bucket total (
budgetData.monthlyAmountsForFlexExpense) that the individual flex category sub-budgets do not sum to. Todayget_budgetsonly returns per-categoryplanned/actual, so any analysis of flexible spending compares against sub-budgets that aren't the real budget — which is misleading (you can be "under" on every flex category while the flex bucket is blown).Change
get_budgetsnow returns, alongside the existing category rows:flex_bucket— per-month flex-bucketplanned/actual/remaining.section_totals— per-month Fixed / Non-Monthly / Flexible / total_expenses / income rollups, the way Monarch computes the budget (total budget = Fixed + Non-Monthly + Flex bucket).Both come from fields on
budgetData(monthlyAmountsForFlexExpense,totalsByMonth). They deliberately do not touch the guarded category-group fields (budgetVariability/rolloverPeriod) that some accounts reject — the existing compatibility guard and its test are preserved.Return shape
Changes from a bare list to
{ "categories": [...], "flex_bucket": [...], "section_totals": [...] }. For category-based (non-flex) budgets,flex_bucket/section_totalscome back empty andcategoriesis unchanged.Tests
format_flex_bucketandformat_section_totals.budgetVariability/rolloverPeriod).Verified live against a Fixed & Flex account: the flex bucket and Fixed/Non-Monthly/Flexible section totals return correctly per month.
🤖 Generated with Claude Code