Add new VehicleFinance.fs module for UK vehicle finance products#66
Draft
Copilot wants to merge 3 commits into
Draft
Add new VehicleFinance.fs module for UK vehicle finance products#66Copilot wants to merge 3 commits into
Copilot wants to merge 3 commits into
Conversation
- 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>
Author
Done in commit
|
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a new
src/VehicleFinance.fsmodule modelling the four main UK vehicle finance product structures, together withtests/VehicleFinanceTests.fscontaining 34 tests (all passing).Sub-modules
1.
Pcp— Personal Contract PurchaseMonthly 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 PurchaseFully-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 LeaseRental 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 insuranceExpresses 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
int64<Cent>; interest rates useCalculation.Percent.AnnualInterestRate / 12(nominal annual convention).Apr.calculatewithApr.CalculationMethod.UnitedKingdom 3by default, but is configurable per product.AddOnInsuranceuplift holds the advance constant (what the customer actually receives) while varying the payment stream — this correctly surfaces the cost of the bundled premium.Testing