Fix: Purchases not updating in Ledger — cache invalidation + refresh button #220
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
nidde/parenting-tool!220
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "copilot/fix-purchases-not-updating"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Purchases added/edited/deleted were not reflected in the Ledger due to missing cache invalidation on both the backend and frontend.
Description
Root causes:
PurchaseObserverexisted →BalanceServicecache never cleared on purchase mutationsclearMonth()andclearAll()inledgerStore.tsboth omittedpurchasesByMonth— stale purchase data persisted in localStorage across sessionsFixes:
Backend
PurchaseObserver— clearsBalanceServicemonth cache oncreated/updated/deleted; clears the old month too whendatechanges onupdatedAppServiceProvider::boot()Frontend —
ledgerStore.tsbug fixesclearMonth()now also deletespurchasesByMonth.value[key]clearAll()now also resetspurchasesByMonth.value = {}Frontend — cache propagation
Finance/Purchases/Index.vue:watch(() => props.purchases, ...)callsledgerStore.clearCombinedMonth(year, month)whenever Inertia reloads props after a mutation — ensures the Ledger re-fetches on next openCombinedLedger.vue: added a Refresh Ledger FAB action (mdi-refresh, order 20) that callsledgerStore.clearAll()then re-fetches the active monthType of Change
Testing
4 new unit tests in
tests/Unit/Observers/PurchaseObserverTest.php: created, updated, deleted, and date-change scenarios.Code Quality
CI/CD Checks
Additional Notes
The watcher on
props.purchasesfires only on Inertia-driven prop updates (never on initial mount), so it does not cause spurious cache clears during navigation.Comment
@coderabbitai helpto get the list of available commands and usage tips.