Save income distribution to bucket balances #19

Closed
opened 2026-03-21 16:26:07 +01:00 by myrmidex · 0 comments
Owner

Problem

The income distribution preview (#12) shows how income would spread across buckets, but there's no way to persist the result. After the user distributes money in their bank accounts, they need to click Save to update bucket balances so the next preview reflects current fill levels.

Approach

Add a "Save Distribution" button to the preview results. On click, send the allocation data to a new endpoint that updates each bucket's starting_amount by adding the allocated amount.

Keep it simple: no Draw or Inflow records, just update starting_amount directly. Ledger entries are a future concern.

Scope

Backend:

  • New endpoint: POST /scenarios/{scenario}/projections/apply (or similar)
  • Request validation: accepts the same amount as the preview, re-runs allocateInflow() to compute allocations server-side (don't trust client-sent allocation amounts)
  • Updates each bucket's starting_amount += allocated_amount
  • Returns updated bucket data

Frontend:

  • Add "Save Distribution" button to IncomeDistributionPreview component, visible only when preview results are shown
  • On save: POST to apply endpoint, reload bucket data, reset preview
  • Loading/success/error states

Acceptance criteria

  • User previews $3000 income → sees distribution → clicks Save
  • Each bucket's starting_amount increases by its allocated amount
  • Bucket cards on the page reflect updated balances after save
  • Next preview with the same amount shows different results (buckets partially filled)
  • No Draw or Inflow records created
## Problem The income distribution preview (#12) shows how income would spread across buckets, but there's no way to persist the result. After the user distributes money in their bank accounts, they need to click Save to update bucket balances so the next preview reflects current fill levels. ## Approach Add a "Save Distribution" button to the preview results. On click, send the allocation data to a new endpoint that updates each bucket's `starting_amount` by adding the allocated amount. Keep it simple: no Draw or Inflow records, just update `starting_amount` directly. Ledger entries are a future concern. ## Scope **Backend:** - New endpoint: `POST /scenarios/{scenario}/projections/apply` (or similar) - Request validation: accepts the same `amount` as the preview, re-runs `allocateInflow()` to compute allocations server-side (don't trust client-sent allocation amounts) - Updates each bucket's `starting_amount += allocated_amount` - Returns updated bucket data **Frontend:** - Add "Save Distribution" button to `IncomeDistributionPreview` component, visible only when preview results are shown - On save: POST to apply endpoint, reload bucket data, reset preview - Loading/success/error states ## Acceptance criteria - User previews $3000 income → sees distribution → clicks Save - Each bucket's `starting_amount` increases by its allocated amount - Bucket cards on the page reflect updated balances after save - Next preview with the same amount shows different results (buckets partially filled) - No Draw or Inflow records created
myrmidex added this to the v0.2.0 milestone 2026-03-21 16:26:07 +01:00
myrmidex added the
enhancement
label 2026-03-21 16:26:07 +01:00
myrmidex self-assigned this 2026-03-21 16:26:08 +01:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lvl0/buckets#19
No description provided.