feat: goal-based savings tracking & milestones (#133)#391
Closed
sinatragian wants to merge 2 commits intorohitdash08:mainfrom
Closed
feat: goal-based savings tracking & milestones (#133)#391sinatragian wants to merge 2 commits intorohitdash08:mainfrom
sinatragian wants to merge 2 commits intorohitdash08:mainfrom
Conversation
- SavingsGoal + SavingsMilestone models - Full CRUD: GET/POST/PATCH/DELETE /savings/goals - POST /savings/goals/<id>/deposit (deposit/withdrawal, auto-achievement) - Milestone CRUD + auto-achievement on deposit - Progress percentage + remaining_amount calculated fields - Migration 004_savings_goals.sql - 28 tests covering CRUD, deposits, milestones, auth - docs/savings-goals.md Closes rohitdash08#133
… milestones - Reject amount==0 on POST /deposit with 400 Bad Request (was silent no-op) - After a withdrawal that drops current_amount below target_amount, reset goal.achieved = False so the flag reflects live balance, not history - Same reversal logic for milestones: withdrawal below a milestone threshold resets milestone.achieved = False / achieved_at = None (milestones are treated as live state, not immutable events — comment in code explains the trade-off and how to make them permanent if desired) - Add TestDepositEdgeCases.test_withdrawal_below_target_resets_goal_achieved - Add TestDepositEdgeCases.test_deposit_zero_returns_400 - Add TestMilestones.test_withdrawal_below_milestone_resets_achieved
8 tasks
Author
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.
Adds goal-based savings tracking to fix #133.
New
SavingsGoalandSavingsMilestonemodels with full CRUD under/savings/goals. Deposits updatecurrent_amountand auto-mark milestones as achieved when their threshold is crossed. Goal responses includeprogress_percentandremaining_amount.Migration in
app/db/migrations/004_savings_goals.sql, 31 tests.Review fixes (latest commit)
achievedflags — if a withdrawal dropscurrent_amountbelowtarget_amount,goal.achievedis reset toFalseso it accurately reflects live balance. Same logic for milestones: a withdrawal below a milestone's threshold resetsmilestone.achieved = False/achieved_at = None. Milestones are intentionally treated as live state (re-earnable), not immutable historical events — a comment in the code explains the trade-off and how to make them permanent if preferred.amount == 0→ 400 Bad Request — previously a silent no-op; now returns400with a descriptive error message.TestDepositEdgeCases.test_withdrawal_below_target_resets_goal_achievedTestDepositEdgeCases.test_deposit_zero_returns_400TestMilestones.test_withdrawal_below_milestone_resets_achievedCloses #133