Skip to content

feat: goal-based savings tracking & milestones#941

Open
flaggdavid-source wants to merge 1 commit intorohitdash08:mainfrom
flaggdavid-source:feat/savings-goal-tracking
Open

feat: goal-based savings tracking & milestones#941
flaggdavid-source wants to merge 1 commit intorohitdash08:mainfrom
flaggdavid-source:feat/savings-goal-tracking

Conversation

@flaggdavid-source
Copy link
Copy Markdown

Implementation Summary

Backend Changes

Models (app/models.py):

  • SavingsGoalStatus enum: active → completed / abandoned
  • SavingsGoal: name, target_amount, current_amount, currency, deadline, status
  • SavingsMilestone: goal_id, name, target_amount, reached_at
  • SavingsContribution: goal_id, amount, contributed_at, notes

Schema (app/db/schema.sql):

  • Added savings_goal_status enum type
  • Added savings_goals, savings_milestones, savings_contributions tables with indexes

Service (app/services/savings.py):

  • create_goal() — with auto-milestone creation at 25%/50%/75%/100% thresholds
  • add_contribution() — deposit tracking with auto-completion detection
  • _check_milestones() — marks milestones as reached when current_amount crosses threshold
  • get_goal_progress() — percent complete, remaining amount, days remaining
  • mark_goal_completed() / abandon_goal() — status transitions
  • parse_amount() — Decimal validation for all money inputs

Routes (app/routes/savings.py):

  • POST /savings — create goal with validation
  • GET /savings — list goals with optional status filter
  • GET /savings/<id> — get goal with progress stats
  • PATCH /savings/<id> — update goal (name, target, deadline, status)
  • DELETE /savings/<id> — delete goal with cascading milestones/contributions
  • POST /savings/<id>/contributions — add contribution
  • GET /savings/<id>/contributions — list contributions
  • GET /savings/<id>/milestones — list milestones
  • POST /savings/<id>/complete — manually complete goal
  • POST /savings/<id>/abandon — abandon goal

Tests

21 tests covering:

  • Goal CRUD (create, list, get, update, delete)
  • Input validation (missing name, missing target, negative amounts)
  • Deadline handling
  • Contribution workflow (add, validate, list)
  • Auto-milestone creation (4 milestones per goal)
  • Milestone reach detection on contributions
  • Goal completion (manual and auto on full contribution)
  • Goal abandonment
  • Progress calculation

All 21 savings tests pass. Existing tests remain functional (1 pre-existing failure in auth test unrelated to these changes).

- Add SavingsGoalStatus enum and SavingsGoal, SavingsMilestone, SavingsContribution models
- Add schema tables for savings_goals, savings_milestones, savings_contributions
- Create savings service with create_goal(), add_contribution(), get_goal_progress(), etc.
- Auto-create milestones at 25%/50%/75%/100% thresholds
- Add savings routes with full CRUD + contributions + milestones endpoints
- Add 21 tests covering goal CRUD, validation, contributions, auto-milestones, completion

Closes rohitdash08#133
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.

1 participant