mirror of
https://github.com/we-promise/sure.git
synced 2026-05-30 15:59:02 +00:00
Adds a standalone Savings goals feature: a piggy-bank style tracker that lets a family set a target, link one or more Depository accounts as funding sources, and log manual contributions over time. Supersedes #1569 (closed) — same intent, redesigned per reviewer + Discord feedback. What this adds: - New `/savings_goals` sidebar entry (piggy-bank icon) with index, show, state-filtered tabs (all/active/paused/completed/archived), and a 2-step modal stepper for creation (Identity → Review). - Multi-account funding via a `SavingsGoalAccount` join: a goal requires ≥1 linked Depository account (checking/savings/HSA/CD/money-market), and all linked accounts must share the goal's currency. - Tracker balance model: goal balance = SUM(contributions.amount). No auto-flow from account balances. Contributions are pure logical records and don't move money between accounts. - Manual contributions modal scoped to the goal's linked accounts. Initial contributions seeded at creation can't be deleted; manual ones can. - AASM lifecycle: active / paused / completed / archived. Hard-delete only after archive. - Status pills (On track / Behind / Reached / No date) derived from pace vs target_date. - AI Assistant tool `create_savings_goal` lets the sidebar chat create a goal end-to-end from a natural-language prompt; soft errors carry the available-accounts list back to the LLM (mirrors the existing `import_bank_statement` pattern). - Family-scoped throughout (`Current.family`-only access, account family-scoping enforced both in controllers and the AI tool). - Demo data seed wires up 4 sample goals across the Depository accounts. Intentionally out of scope (separate PRs / v1.1): - Auto-fund from budget surplus + Sidekiq cron + budget-show card. - Dashboard "Savings goals" widget. - "Behind pace" projection chart on the detail page. - `evaluate_savings_goal_feasibility` LLM tool (level-setting before create_savings_goal). - Spend-less goals inside Budgets. - Family-member-private goals (deferred investigation).
44 lines
1.5 KiB
Plaintext
44 lines
1.5 KiB
Plaintext
<%# locals: (savings_goal:) %>
|
|
|
|
<% if savings_goal.errors.any? %>
|
|
<%= render "shared/form_errors", model: savings_goal %>
|
|
<% end %>
|
|
|
|
<%= styled_form_with model: savings_goal,
|
|
url: savings_goal_path(savings_goal),
|
|
method: :patch,
|
|
class: "space-y-3" do |f| %>
|
|
<%= f.text_field :name,
|
|
label: t("savings_goals.form_stepper.step1.fields.name"),
|
|
required: true,
|
|
autofocus: true %>
|
|
|
|
<%= f.money_field :target_amount,
|
|
label: t("savings_goals.form_stepper.step1.fields.target_amount"),
|
|
required: true %>
|
|
|
|
<%= f.date_field :target_date,
|
|
label: t("savings_goals.form_stepper.step1.fields.target_date") %>
|
|
|
|
<div>
|
|
<span class="block text-sm text-secondary mb-2"><%= t("savings_goals.form_stepper.step1.fields.color") %></span>
|
|
<div class="flex flex-wrap gap-2">
|
|
<% SavingsGoal::COLORS.each do |c| %>
|
|
<label class="relative">
|
|
<%= f.radio_button :color, c, class: "sr-only peer" %>
|
|
<div class="w-6 h-6 rounded-full cursor-pointer peer-checked:ring-2 peer-checked:ring-offset-2 peer-checked:ring-gray-500"
|
|
style="background-color: <%= c %>"></div>
|
|
</label>
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
|
|
<%= f.text_area :notes,
|
|
label: t("savings_goals.form_stepper.step1.fields.notes"),
|
|
rows: 2 %>
|
|
|
|
<div class="flex justify-end pt-2">
|
|
<%= f.submit t("savings_goals.edit.save") %>
|
|
</div>
|
|
<% end %>
|