Skip to content

Add new Savings.fs module for ISA projections, fixed-term deposits and Premium Bonds#67

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/add-savings-module
Draft

Add new Savings.fs module for ISA projections, fixed-term deposits and Premium Bonds#67
Copilot wants to merge 2 commits into
mainfrom
copilot/add-savings-module

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 28, 2026

Adds a new Savings module (src/Savings.fs) covering all three areas from the issue. All monetary values use the library's existing int64<Cent> precision model.

Changes Made

1. Regular savings / ISA projections

  • project returns a month-by-month SavingsProjectionEntry array tracking opening/closing balance, contribution, interest earned, and running totals
  • CompoundingFrequency: Daily, Monthly, Quarterly, Annually
  • TaxWrapper: None, Isa (tax-free label, amounts unchanged), Lisa (25% government bonus applied to each contribution), PensionSalarySacrifice (configurable employer match rate)
  • SavingsRate: Fixed (single rate for the full term) or Stepped (array of { FromMonth; AnnualRate } entries for variable/stepped-rate projections)

2. Fixed-term deposits

  • projectDeposit returns a full per-month DepositProjectionEntry schedule and a DepositMaturityResult
  • InterestPaymentTiming: AtMaturity (interest compounds monthly, paid as a lump sum at the end), Monthly / Annually (simple interest paid out periodically; principal stays fixed)
  • grossToAer / aerToGross — AER ↔ gross rate conversion using the FCA-standard formula AER = (1 + r/n)^n − 1
  • earlyWithdrawal — calculates gross interest to date, a configurable month-count penalty, and the net amount returned to the depositor

3. Premium Bonds expected return (stretch goal)

  • premiumBondsExpectedReturn — expected annual prize income based on the NS&I prize fund rate
  • comparePremiumBonds — returns a PremiumBondsComparison with: expected PB return, equivalent gross rate needed on a taxable account to match after tax, after-tax return on a taxable savings account at the same rate, and cash ISA return

Testing

  • 21 new tests added in tests/SavingsTests.fs covering all sub-modules
  • ✅ All 21 new tests pass
  • ✅ No previously-passing tests broken (219 pre-existing failures in HTML generation code are unrelated and unchanged)

Copy link
Copy Markdown
Owner

@simontreanor simontreanor left a comment

Choose a reason for hiding this comment

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

@copilot continue

Copy link
Copy Markdown
Author

Copilot AI commented Apr 29, 2026

@copilot continue

Done. Commit 4e02b76 adds the full Savings module with:

1. Regular savings / ISA projections (RegularSavings)

  • project — returns a month-by-month SavingsProjectionEntry array
  • Compounding frequencies: Daily, Monthly, Quarterly, Annually
  • Tax wrappers: None, Isa (tax-free label), Lisa (25 % govt bonus per contribution), PensionSalarySacrifice (employer match rate)
  • Rate types: Fixed (single rate) or Stepped (schedule of { FromMonth; AnnualRate } entries)

2. Fixed-term deposits (FixedTermDeposit)

  • projectDeposit — full per-month DepositProjectionEntry schedule + DepositMaturityResult
  • Payment timings: AtMaturity (monthly compounding, lump sum at end), Monthly / Annually (simple interest paid out periodically, principal stays fixed)
  • grossToAer / aerToGross — FCA-consistent AER ↔ gross rate conversion
  • earlyWithdrawal — calculates gross interest, configurable month-count penalty, and net return

3. Premium Bonds (PremiumBonds)

  • premiumBondsExpectedReturn — expected annual prize income
  • comparePremiumBondsPremiumBondsComparison with expected PB return, equivalent gross rate for a taxpayer, after-tax taxable savings return, and cash ISA return

21 new tests added in SavingsTests.fs; all pass. No existing tests broken.

Copilot AI changed the title [WIP] Add new module Savings.fs for ISA projections and deposits Add new Savings.fs module for ISA projections, fixed-term deposits and Premium Bonds Apr 29, 2026
Copilot AI requested a review from simontreanor April 29, 2026 22:34
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.

New module: Savings.fs (ISA projections, fixed-term deposits, Premium Bonds)

2 participants