[insight] Goals and rewards: savings goals, ways to save, challenges and medals; v0.6.0 #8

Manually merged
mnovak merged 2 commits from feature/goals-rewards into main 2026-11-07 22:40:41 +01:00
Owner

Savings goals with ways to save, challenges, and medals computed from the ledger, for Fiscus Domi's Savings and Rewards screens. Design: docs/05_goals_rewards.md. Version 0.6.0.

What changes

  • fiscus-ledger::goal and seven events: goal.created, goal.changed, goal.ways_set, goal.saved, goal.closed, challenge.started and challenge.abandoned, with their checks in State::apply.
    • A goal never holds less than nothing, and a closed goal takes no more money. There are at most 20 open goals and at most one way of each kind per goal.
    • The open goals' shares of what's left, and separately of income, add up to at most 1000 ‰.
    • A challenge lasts 1–92 days and is given up once.
    • The serde tags deny unknown fields, so a way or a challenge goal with a field it does not have does not parse.
  • fiscus-insight::goals: per goal, the tank's level, what is needed per month to make its date, the pace and the month it gets there, and this month's split between its ways (fixed, round-ups to the haléř, a share of last month's plan leftover, a share of last month's income). The split is capped at what the goal still needs. There are also "where the money could come from" sources: subscriptions not decided "keep", and categories up on their 3-month average.
  • fiscus-insight::rewards:
    • Medals, from complete periods only:
      • under budget 3+ months running (shared budgets excluded);
      • every plan kept in a month;
      • cancelled and not charged since;
      • a challenge won;
      • a quarter's invoices paid on time;
      • goal milestones ¼ ½ ¾ 1;
      • 3+ months running with money put aside.
    • Challenge outcomes: running, won, lost or abandoned, with each challenge's tank level.
    • Progress toward the medals not yet earned.
  • cancel_kit_in(sub, language): the cancellation email in Czech or English. cancel_kit stays English.
  • Three clippy fixes that the newer toolchain reports in older code: merchant.rs, money.rs and subscriptions.rs. They do not change behaviour.

Self-review

  • Money: integer haléře only. Shares use i128 and floor; "needed per month" rounds up to whole crowns; sums saturate. Nothing near an amount is a float, and the no-float scan still passes.
  • Hostile input: every refusal is a typed reason, and the tests check that a refused event changes no goal and no challenge. A float target, an unknown colour, an unknown way and an extra field are refused at parse.
  • Sharing boundary unchanged: goals and challenges live in the personal log. share.rs still builds only payment.shared, and nothing here touches it.
  • Pure: today is a parameter, and there is no I/O.
  • Limits I accept:
    • The budget medal uses the budget's latest limit for past months, because the ledger keeps no limit history.
    • Round-ups count every spending payment, not only card payments (cash added by hand rounds up too).
  • Tests:
    • fiscus-ledger/tests/goals.rs, 6 tests: goals, ways and shares, closing, challenges, and hostile JSON.
    • fiscus-insight/tests/goals.rs, 8 tests:
      • round-ups;
      • a month's split;
      • the cap;
      • sources;
      • goal and streak medals;
      • budget and plan medals in complete months only;
      • challenges won, lost and given up;
      • the invoice quarter.
    • The Czech cancel letter.
    • cargo test --workspace passes, and cargo clippy --workspace --all-targets is clean.
Savings goals with ways to save, challenges, and medals computed from the ledger, for Fiscus Domi's Savings and Rewards screens. Design: `docs/05_goals_rewards.md`. Version **0.6.0**. ## What changes - **`fiscus-ledger::goal`** and seven events: `goal.created`, `goal.changed`, `goal.ways_set`, `goal.saved`, `goal.closed`, `challenge.started` and `challenge.abandoned`, with their checks in `State::apply`. - A goal never holds less than nothing, and a closed goal takes no more money. There are at most 20 open goals and at most one way of each kind per goal. - The open goals' shares of what's left, and separately of income, add up to at most 1000 ‰. - A challenge lasts 1–92 days and is given up once. - The serde tags deny unknown fields, so a way or a challenge goal with a field it does not have does not parse. - **`fiscus-insight::goals`**: per goal, the tank's level, what is needed per month to make its date, the pace and the month it gets there, and this month's split between its ways (fixed, round-ups to the haléř, a share of last month's plan leftover, a share of last month's income). The split is capped at what the goal still needs. There are also "where the money could come from" sources: subscriptions not decided "keep", and categories up on their 3-month average. - **`fiscus-insight::rewards`**: - **Medals**, from complete periods only: - under budget 3+ months running (shared budgets excluded); - every plan kept in a month; - cancelled and not charged since; - a challenge won; - a quarter's invoices paid on time; - goal milestones ¼ ½ ¾ 1; - 3+ months running with money put aside. - **Challenge outcomes**: running, won, lost or abandoned, with each challenge's tank level. - **Progress** toward the medals not yet earned. - **`cancel_kit_in(sub, language)`**: the cancellation email in Czech or English. `cancel_kit` stays English. - Three clippy fixes that the newer toolchain reports in older code: `merchant.rs`, `money.rs` and `subscriptions.rs`. They do not change behaviour. ## Self-review - **Money:** integer haléře only. Shares use i128 and floor; "needed per month" rounds up to whole crowns; sums saturate. Nothing near an amount is a float, and the no-float scan still passes. - **Hostile input:** every refusal is a typed reason, and the tests check that a refused event changes no goal and no challenge. A float target, an unknown colour, an unknown way and an extra field are refused at parse. - **Sharing boundary unchanged:** goals and challenges live in the personal log. `share.rs` still builds only `payment.shared`, and nothing here touches it. - **Pure:** `today` is a parameter, and there is no I/O. - **Limits I accept:** - The budget medal uses the budget's latest limit for past months, because the ledger keeps no limit history. - Round-ups count every spending payment, not only card payments (cash added by hand rounds up too). - **Tests:** - `fiscus-ledger/tests/goals.rs`, 6 tests: goals, ways and shares, closing, challenges, and hostile JSON. - `fiscus-insight/tests/goals.rs`, 8 tests: - round-ups; - a month's split; - the cap; - sources; - goal and streak medals; - budget and plan medals in complete months only; - challenges won, lost and given up; - the invoice quarter. - The Czech cancel letter. - `cargo test --workspace` passes, and `cargo clippy --workspace --all-targets` is clean.
mnovak added 2 commits 2026-11-07 22:40:16 +01:00
mnovak manually merged commit e9d7ef4239 into main 2026-11-07 22:40:41 +01:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: mnovak/FiscusPublic#8