Fix/budget target client - #217
Merged
Merged
Conversation
Budget targets went out under 'client_id' while the server validates 'targets.*.client_generated_id', so every offline-created budget with targets failed with a 422 and quarantined. Renaming the key alone is not enough: the queued payload is a snapshot, so a target created offline still carries a null id after its own entity syncs, and the server only ever attaches targets by numeric id. The handler now re-resolves targets from local before pushing, defers the push while any target is still unresolved (matching how transactions gate on their category and wallet), and declares budget's dependency on category, wallet and group so those push first. Also fixes getLocalByClientId/getLocalByServerId dropping targets entirely, which would have pushed a budget with its targets cleared.
A PDF export over the server's 100-row cap came back as a helpful 422 telling the user to narrow the range or pick another format, but the app showed a generic unknown error: the datasource skipped the shared error handler, and the JSON error body arrived as bytes so the message extraction never matched. Downloads now route through the handler and byte bodies are decoded before reading the message. The finished export also only opened the share sheet, so dismissing it lost the file with no copy anywhere the user could find. A ready export now offers Save alongside Share; saving goes through the system file picker, which needs no storage permission and confirms with the file name.
Code Review SummaryThis PR addresses synchronization issues with budgets by ensuring that budget targets (categories, wallets) are correctly resolved before syncing to the server. It fixes the payload key for targets and implements a deferred sync mechanism to wait for dependencies. Additionally, it improves the export user experience and error handling for binary responses. 🚀 Key Improvements
💡 Minor Suggestions
|
nfebe
approved these changes
Aug 7, 2026
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.
Description
Fix issues with Target client Id on the budget
Type of Change