Skip to content

Savings calculator: improve reached-goal behavior and goal timing - #185

Merged
jenbreese merged 2 commits into
devfrom
IFDM-172-347
Sep 21, 2026
Merged

jenbreese merged 2 commits into
devfrom
IFDM-172-347

Conversation

@jenbreese

Copy link
Copy Markdown
Collaborator

Summary

This PR improves the Savings calculator’s handling of reached goals, zero-interest calculations, compounding-only growth, partial periods, and year-by-year results.

https://stanfordits.atlassian.net/browse/IFDM-172
https://stanfordits.atlassian.net/browse/IFDM-347

Changes

  • Show the “You’ve already reached this goal” message using the standard warning color.
  • Apply warning styling to both the savings goal and current balance fields.
  • Disable dependent fields and display - when the current balance meets or exceeds the goal.
  • Allow Savings calculations at 0% interest and show the standard amber warning.
  • Display an explanation beneath $0.00 when compounding alone will reach the goal.
  • Stop the year-by-year table when the goal is reached.
  • Display partial final years to one decimal, such as 0.8 or 4.5.
  • Round Time to Goal up to the first contribution period that actually reaches the goal.
  • Allow a smaller final contribution when the regular contribution would exceed the goal.
  • Keep partial-period headline results and breakdown totals consistent.

Human QA scenarios

1. Goal already reached

On the Savings tab, enter:

  • Savings goal: $1,000
  • Current balance: $1,200

Expected:

  • Both fields have amber warning styling.
  • Both show the reached-goal warning.
  • Time, interest, and compounding fields are disabled and display -.
  • Results display -.

2. Zero-interest calculation

Enter:

  • Goal: $12,000
  • Current balance: $0
  • Time: 1 year
  • Interest: 0%
  • Compounding: Monthly

Expected:

  • The 0% message is amber.
  • Calculation remains active.
  • Save each month: $1,000.00
  • Total deposited: $12,000.00
  • Interest earned: $0.00

3. Compounding reaches the goal without contributions

Enter:

  • Goal: $1,000
  • Current balance: $990
  • Time: 10 years
  • Interest: 5%
  • Compounding: Monthly

Expected:

  • Save each month: $0.00
  • Message says the goal will be reached in 3 months.
  • The breakdown stops at the goal rather than continuing for 10 years.
  • Final table row displays approximately year 0.2 and ends at $1,000.00.

4. Partial-year breakdown

Enter a Savings scenario lasting:

  • 4 years
  • 6 months

Expected:

  • The table contains rows for years 1, 2, 3, 4, and 4.5.
  • The final row ends at the savings goal.
  • No rows appear after 4.5.

Also test a ten-month scenario and confirm the final year displays as 0.8.

5. Whole contribution-period timing

On Time to Goal, enter:

  • Goal: $1,000
  • Current balance: $0
  • Contribution: $300
  • Interest: 0%
  • Compounding: Monthly

Expected:

  • Time to goal: 0 years 4 months
  • Total deposited: $1,000.00
  • Interest earned: $0.00
  • The final contribution is effectively $100, rather than another full $300.
  • The breakdown ends at $1,000.00.

6. Partial compounding period

On Savings, enter:

  • Goal: $1,000
  • Current balance: $500
  • Time: 6 months
  • Interest: 10%
  • Compounding: Annually

Expected:

  • Required contribution: approximately $475.60
  • Total deposited: approximately $975.60
  • Interest earned: approximately $24.40
  • The breakdown displays year 0.5.
  • The table and headline results both end at $1,000.00.

Regression checks

  • Change the goal or balance so the reached-goal warning clears; dependent fields should become editable again.
  • Confirm Reset clears warnings, disabled states, inputs, results, and the breakdown.
  • Smoke-test Monthly, Weekly, Quarterly, and Annual compounding.
  • Check light and dark modes.
  • Check keyboard navigation and narrow iframe widths.
  • Confirm switching between all three calculator modes clears prior values and results.

Verification completed

  • yarn lint completes with the existing isOverflow dependency warning.
  • yarn build:local passes.
  • Targeted calculation checks passed for zero interest, positive interest, exact-period boundaries, weekly contributions, partial periods, and normal 12-month savings.

Scope note

The unreproduced review findings numbered #1 and #3 were not changed in this PR.

@jenbreese
jenbreese requested a review from majimmy88 September 17, 2026 23:46

@majimmy88 majimmy88 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jenbreese
jenbreese merged commit 7983436 into dev Sep 21, 2026
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.

2 participants