Skip to content

Add new VehicleFinance.fs module for UK vehicle finance products#66

Draft
Copilot wants to merge 3 commits into
mainfrom
copilot/add-vehicle-finance-module
Draft

Add new VehicleFinance.fs module for UK vehicle finance products#66
Copilot wants to merge 3 commits into
mainfrom
copilot/add-vehicle-finance-module

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 28, 2026

Adds a new src/VehicleFinance.fs module modelling the four main UK vehicle finance product structures, together with tests/VehicleFinanceTests.fs containing 34 tests (all passing).

Sub-modules

1. Pcp — Personal Contract Purchase

Monthly payment derived from vehicle price, deposit, Guaranteed Future Value (GFV), nominal annual rate, and term using the standard PMT formula with a balloon. APR is calculated via the UK FCA method, combining the GFV balloon with the final monthly cashflow.

2. HirePurchase — Hire Purchase

Fully-amortising annuity schedule. Supports an optional nominal option-to-purchase fee, which is combined with the final monthly payment in the APR calculation.

3. FinanceLease — Finance Lease

Rental schedule with independently configurable residual value. No automatic title transfer. The residual is treated as a separate APR cashflow placed after the final rental, reflecting end-of-lease settlement.

4. AddOnInsurance — PPI / GAP add-on insurance

Expresses the implied APR uplift from bundled Payment Protection Insurance (PPI) or Guaranteed Asset Protection (GAP) premiums. The base APR (advance vs. base payments) is compared against the true APR (same advance vs. insurance-inflated payments), making the true cost transparent to the borrower.

Design notes

  • All monetary values use int64<Cent>; interest rates use Calculation.Percent.
  • Monthly rate = AnnualInterestRate / 12 (nominal annual convention).
  • APR is computed via Apr.calculate with Apr.CalculationMethod.UnitedKingdom 3 by default, but is configurable per product.
  • The AddOnInsurance uplift holds the advance constant (what the customer actually receives) while varying the payment stream — this correctly surfaces the cost of the bundled premium.

Testing

  • 34 new tests covering structural invariants, edge cases (zero rate, zero GFV/residual, zero premium), cross-product consistency (PCP with zero GFV = HP; Finance Lease with zero residual = HP), and APR properties.
  • Pre-existing 219 test failures are 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

Copilot AI and others added 2 commits April 29, 2026 22:35
- Add src/VehicleFinance.fs with four sub-modules:
  - Pcp: PCP monthly payment via PMT formula with GFV balloon, APR via UK FCA method
  - HirePurchase: fully-amortising annuity with optional option-to-purchase fee
  - FinanceLease: rental schedule with independently configurable residual value
  - AddOnInsurance: APR uplift from bundled PPI / GAP premiums
- Register VehicleFinance.fs in src/FSharp.Finance.Personal.fsproj
- Add tests/VehicleFinanceTests.fs with 34 tests covering all four sub-modules
- Register VehicleFinanceTests.fs in tests/FSharp.Finance.Personal.Tests.fsproj

Agent-Logs-Url: https://github.com/simontreanor/FSharp.Finance.Personal/sessions/0544183d-cec8-4c10-bffa-9510e8922ef9

Co-authored-by: simontreanor <4550815+simontreanor@users.noreply.github.com>
…ual after final rental

- PCP: combine GFV balloon with the final monthly payment (single end-of-term cashflow)
- HP: combine OTP fee with the final monthly payment
- Finance Lease: keep residual as a separate cashflow one month after the final rental,
  avoiding Newton-Raphson divergence caused by the large balloon amount

Agent-Logs-Url: https://github.com/simontreanor/FSharp.Finance.Personal/sessions/0544183d-cec8-4c10-bffa-9510e8922ef9

Co-authored-by: simontreanor <4550815+simontreanor@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented Apr 29, 2026

@copilot continue

Done in commit 1bec339. I've added src/VehicleFinance.fs with four sub-modules and tests/VehicleFinanceTests.fs with 34 tests (all passing):

  • Pcp – PCP monthly payment via PMT formula with a GFV balloon; APR uses the GFV combined into the final cashflow per UK FCA methodology
  • HirePurchase – Fully-amortising annuity; optional option-to-purchase fee combined with the final payment in the APR
  • FinanceLease – Rental schedule with independently configurable residual value; residual placed as a separate APR cashflow after the final rental
  • AddOnInsurance – Expresses the implied APR uplift from bundled PPI/GAP by comparing the base APR (advance vs. base payments) against the true APR (same advance vs. insurance-inflated payments)

Copilot AI changed the title [WIP] Add new VehicleFinance.fs module for UK vehicle finance products Add new VehicleFinance.fs module for UK vehicle finance products Apr 29, 2026
Copilot AI requested a review from simontreanor April 29, 2026 22:41
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: VehicleFinance.fs (PCP, HP, finance lease, add-on insurance)

2 participants