Skip to content

Fix budgets for categories missing from snapshots - #416

Merged
otherworld-dev merged 1 commit into
otherworld-dev:devfrom
almeidandres:fix/missing-budget-snapshot-category
Oct 3, 2026
Merged

otherworld-dev merged 1 commit into
otherworld-dev:devfrom
almeidandres:fix/missing-budget-snapshot-category

Conversation

@almeidandres

Copy link
Copy Markdown

Problem

A category excluded when a monthly budget snapshot was created has no row in that snapshot. Re-enabling the category and setting its budget then returns “No budget snapshot found for this category and month”.

Fix

Insert a snapshot row when the month already contains snapshot rows but the requested owned category does not. The new row uses the submitted values and falls back to the category's effective budget for omitted fields. Existing rows remain unchanged.

Checks

  • CategoryServiceTest: 66 tests, 158 assertions
  • Regression test for adding a missing category to an existing snapshot month
  • PHP CS Fixer: no changes needed
  • Psalm: no errors in CategoryService.php

otherworld-dev added a commit that referenced this pull request Oct 3, 2026
The fix in #416 added the missing row with its own fallbacks for the amount
and period, which differed from resolveEffectiveBudget(), so a period-only
save could turn an earlier "no budget" into the category's default, and a
NULL period was stored as the category's own rather than monthly. The row
now starts from resolveEffectiveBudget() and the change is applied to it
like any other row.

Two quick saves that both find no row no longer show the user a unique
index error, as the second updates the row the first one added, and an
unknown category keeps the readable "No budget snapshot found" message
rather than the mapper's SQL. A save with nothing to change is refused
instead of writing a row. The changelog now gives the real cause, a
category created after the adjustment was made.
otherworld-dev added a commit that referenced this pull request Oct 3, 2026
@otherworld-dev
otherworld-dev merged commit a11b924 into otherworld-dev:dev Oct 3, 2026
13 checks passed
@otherworld-dev

Copy link
Copy Markdown
Owner

Merged with a few changes on top. The new row now starts from the budget the page was already showing for that month, so a period-only save keeps an earlier "no budget" instead of picking up the category's default. Two quick saves that both miss the row no longer show the user the unique index error, and an unknown category keeps the "No budget snapshot found" message rather than the SQL from the mapper. I also reworded the changelog, the adjustment copies every category including excluded ones, so the missing row only happens for a category created after the adjustment was made. Thanks for the fix and the test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants