mirror of
https://github.com/we-promise/sure.git
synced 2026-05-30 07:49:01 +00:00
Functional data-entry surface on the (still preview) /retirement page. The polished combined-page UI is PR4; this ships plain forms + lists so a preview user can populate a plan end to end. - RetirementScoped concern: tier-1 preview gate + tier-2 family killswitch + per-owner plan bootstrap (Goal::Retirement.for_owner find-or-creates, so children always have a parent). RetirementController now uses it. - Nested controllers under Retirement::: PensionSources (full CRUD), Statements (new/create + soft-delete destroy — append-only audit), Adjustments (full CRUD), Buckets (replace-all account selection, same-family filtered). All scoped to the current user's own plan, so cross-user access is impossible by construction. - Routes nested under `resource :retirement` via `scope module:`. - Views: show page rewritten into management sections (sources, adjustments, bucket checkboxes, statement journal) + plain styled_form_with forms. Money carries privacy-sensitive. - Goal gains a target_amount_required? hook (true); Goal::Retirement overrides it false — the forecast owns the target (PR3), so a plan can exist before any target is set. - EN locale for the new surface. 111 controller+model tests green. Note: delete uses Turbo confirm for now; PR4 swaps in the skinned DS::Dialog per the design.
51 lines
1.2 KiB
Ruby
51 lines
1.2 KiB
Ruby
class Retirement::PensionSourcesController < ApplicationController
|
|
include RetirementScoped
|
|
|
|
before_action :set_source, only: %i[edit update destroy]
|
|
|
|
def new
|
|
@source = @plan.pension_sources.new(
|
|
kind: "state", country: "DE", pension_system: "de_grv",
|
|
tax_treatment: "de_renten", payout_shape: "monthly_for_life",
|
|
start_age: 67, currency: Current.family.primary_currency_code
|
|
)
|
|
end
|
|
|
|
def create
|
|
@source = @plan.pension_sources.new(source_params)
|
|
if @source.save
|
|
redirect_to retirement_path, notice: t(".created")
|
|
else
|
|
render :new, status: :unprocessable_entity
|
|
end
|
|
end
|
|
|
|
def edit; end
|
|
|
|
def update
|
|
if @source.update(source_params)
|
|
redirect_to retirement_path, notice: t(".updated")
|
|
else
|
|
render :edit, status: :unprocessable_entity
|
|
end
|
|
end
|
|
|
|
def destroy
|
|
@source.destroy!
|
|
redirect_to retirement_path, notice: t(".deleted")
|
|
end
|
|
|
|
private
|
|
def set_source
|
|
@source = @plan.pension_sources.find(params[:id])
|
|
end
|
|
|
|
def source_params
|
|
params.require(:pension_source).permit(
|
|
:name, :kind, :country, :pension_system, :tax_treatment,
|
|
:payout_shape, :start_age, :end_age, :amount, :currency,
|
|
:effective_rate_override
|
|
)
|
|
end
|
|
end
|