feat(api): budget and report filters for the transactions index

Merged
BH
5d ago
+507-64

Budget clients need transaction drill-downs that reconcile with the budget line they opened. This adds budget/report filters to GET /api/v1/transactions and makes the web budget category list and API budget list use the same eligibility rules as the income statement totals.

Behavior

ParameterBehavior
budget_idLists the visible budget's reportable transactions using its income statement's period scope, account IDs and shared row conditions. Pending, future-dated, excluded, tax-advantaged and internal investment-movement rows are omitted. Investment contributions follow the family's spending setting.
exclude_split_parentsApplies Entry.excluding_split_parents.
excludedFilters the entry's excluded flag on ordinary transaction lists. Budget lists already exclude flagged entries.

Budget visibility is enforced before listing rows. Results are additionally restricted to accounts the caller can access: a personal-budget share alone does not grant access to its underlying accounts, so a viewer with partial account access can see a smaller sum than the owner's budget total.

IncomeStatement::Totals and the drill-down share the normal budget row conditions; the legacy include_trades: false totals behavior is preserved. BudgetCategoriesController#show uses the same reportable rows, so the web list receives the fix too.

BaseController#boolean_filter_param(key, required:) serves transactions, rules and security filters. It accepts true/false/1/0 with case/space normalization and rejects invalid or empty values with 422. Budget IDs and dates are parsed before the index's broad rescue so invalid filters produce 404/422. API documentation and OpenAPI are updated.

Validation

  • Full Rails suite: 19,025 tests, 115,540 assertions, 0 failures, 0 errors, 9 skips.
  • Executable API documentation and OpenAPI regeneration: 487 examples, 0 failures, 89 existing documentation-only pending examples.
  • The reviewer reproduction returns 40, matching the budget actual, while omitting pending 11, HSA 22, transfer-labelled 33 and a finance-excluded shared-account 44. Another regression covers future-dated rows in the current month.
  • Totals equivalence tests cover the legacy option matrix; account visibility and boolean parsing regressions pass.
  • Changed Ruby lint passes. Brakeman reports 0 errors and 0 security warnings.

The final base-only update includes main ac19725d8 (the merged mobile splits feature and carried-forward security-price fixes). Another 380 importer/price/transaction regressions and all 487 API documentation examples pass on that integration.