Skip to content

Add Apr.CalculationMethod.Disabled for non-APR products#52

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/add-aprmethod-disabled-case
Draft

Add Apr.CalculationMethod.Disabled for non-APR products#52
Copilot wants to merge 2 commits into
mainfrom
copilot/add-aprmethod-disabled-case

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 28, 2026

Zero-interest products (salary advances, BNPL) have no meaningful APR, but the current CalculationMethod DU had no way to express this — requiring a misleading placeholder.

Changes

  • src/Apr.fs

    • Added | Disabled case to CalculationMethod with doc comment
    • Html member returns "n/a" for Disabled
    • calculate returns Solution.Impossible (rather than throwing or returning zero)
    • toPercent made exhaustive — UnitedStatesRule and Disabled both explicitly yield precision 0
  • tests/AprDisabledTests.fs (new): 4 tests covering calculate, toPercent, and Html for Disabled

Usage

let interestConfig = {
    Method = Interest.Method.None
    StandardRate = Interest.Rate.Zero
    Cap = Interest.Cap.zero
    Rounding = RoundDown
    AprMethod = Apr.CalculationMethod.Disabled  // clearly opt out of APR
}

// calculate returns Solution.Impossible; toPercent returns Percent 0m
Apr.calculate Apr.CalculationMethod.Disabled principal startDate transfers
// => Solution.Impossible

Copilot AI linked an issue Apr 28, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Add AprMethod.Disabled for non-APR products Add Apr.CalculationMethod.Disabled for non-APR products Apr 28, 2026
Copilot AI requested a review from simontreanor April 28, 2026 22:51
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.

Apr.fs: add AprMethod.Disabled for non-APR products

2 participants