Skip to content

Commit 64e34ec

Browse files
committed
use native
1 parent 0c5c791 commit 64e34ec

File tree

3 files changed

+17
-24
lines changed

3 files changed

+17
-24
lines changed

src/Amortisation.fs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ module Amortisation =
477477
decimal feeTotal * (decimal originalFinalPaymentDay - decimal appliedPaymentDay)
478478
/ decimal originalFinalPaymentDay
479479
|> Cent.round RoundUp
480-
|> Cent.max 0L<Cent>
480+
|> max 0L<Cent>
481481

482482
/// determines any payment due on the day
483483
let calculatePaymentDue si originalPayment rescheduledPayment extraPaymentsBalance interestPortionL minimumPayment =
@@ -498,9 +498,9 @@ module Amortisation =
498498
// if there are no original or rescheduled payments on the day, there is nothing due to pay
499499
| ValueNone, ValueNone -> 0L<Cent>
500500
// payment due should never exceed settlement figure
501-
|> Cent.min (si.PrincipalBalance + si.FeeBalance + interestPortionL)
501+
|> min (si.PrincipalBalance + si.FeeBalance + interestPortionL)
502502
// payment due should never be negative
503-
|> Cent.max 0L<Cent>
503+
|> max 0L<Cent>
504504
// apply minimum payment rules
505505
|> fun payment ->
506506
match minimumPayment with
@@ -762,13 +762,13 @@ module Amortisation =
762762
ap.AppliedCharges |> Array.sumBy _.Total, ap.AppliedCharges
763763

764764
// apportion the charges
765-
let chargesPortion = newChargesTotal + si.ChargesBalance |> Cent.max 0L<Cent>
765+
let chargesPortion = newChargesTotal + si.ChargesBalance |> max 0L<Cent>
766766

767767
// for future days, assume that the payment will be made in full and on schedule, yielding a full net effect and allowing meaningful evaluation of the future schedule
768768
// (e.g. seeing if the schedule will be settled as agreed)
769769
let netEffect =
770770
if appliedPaymentDay > evaluationDay then
771-
Cent.min ap.NetEffect paymentDue
771+
min ap.NetEffect paymentDue
772772
else
773773
ap.NetEffect
774774

@@ -856,7 +856,7 @@ module Amortisation =
856856
match p.Basic.FeeConfig with
857857
| ValueSome feeConfig ->
858858
match feeConfig.FeeAmortisation with
859-
| Fee.FeeAmortisation.AmortiseBeforePrincipal -> Cent.min si.FeeBalance assignable
859+
| Fee.FeeAmortisation.AmortiseBeforePrincipal -> min si.FeeBalance assignable
860860
| Fee.FeeAmortisation.AmortiseProportionately ->
861861
feePercentage p.Basic.Principal feeTotal
862862
|> Percent.toDecimal
@@ -866,8 +866,8 @@ module Amortisation =
866866
else
867867
decimal assignable * m / (1m + m)
868868
|> Cent.round RoundUp
869-
|> Cent.max 0L<Cent>
870-
|> Cent.min si.FeeBalance
869+
|> max 0L<Cent>
870+
|> min si.FeeBalance
871871
| ValueNone -> 0L<Cent>
872872

873873
// determine the value of any fee rebate in the event of settlement, depending on settings
@@ -916,16 +916,16 @@ module Amortisation =
916916
initialStats
917917
appliedPaymentDay
918918
window
919-
|> Cent.max feeRebateIfSettled
920-
|> Cent.min feeTotal
919+
|> max feeRebateIfSettled
920+
|> min feeTotal
921921
| _ -> feeRebateIfSettled
922922

923-
Cent.max 0L<Cent> (si.FeeBalance - feeRebate'), feeRebate'
923+
max 0L<Cent> (si.FeeBalance - feeRebate'), feeRebate'
924924
else
925925
sign feePortion, 0L<Cent>
926926

927927
// apportion the principal
928-
let principalPortion = Cent.max 0L<Cent> (assignable - feePortion')
928+
let principalPortion = max 0L<Cent> (assignable - feePortion')
929929

930930
// calculate the principal balance
931931
let principalBalance = si.PrincipalBalance - sign principalPortion
@@ -1032,7 +1032,7 @@ module Amortisation =
10321032

10331033
let settlementFigure' =
10341034
(balanceTotal, settlementFigure)
1035-
||> if settlementFigure < 0L<Cent> then Cent.max else Cent.min
1035+
||> if settlementFigure < 0L<Cent> then max else min
10361036

10371037
//determine the type of offset day
10381038
let offsetDayType =

src/Calculation.fs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,6 @@ module Calculation =
126126
/// utility functions for base currency unit values
127127
[<RequireQualifiedAccess>]
128128
module Cent =
129-
/// max of two cent values
130-
let max (c1: int64<Cent>) (c2: int64<Cent>) = max (int64 c1) (int64 c2) * 1L<Cent>
131-
/// min of two cent values
132-
let min (c1: int64<Cent>) (c2: int64<Cent>) = min (int64 c1) (int64 c2) * 1L<Cent>
133-
134129
/// derive a rounded cent value from a decimal according to the specified rounding method
135130
let round rounding (m: decimal) =
136131
m |> Rounding.round rounding |> int64 |> (*) 1L<Cent>

src/Quotes.fs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,18 +93,16 @@ module Quotes =
9393
}
9494
// if there is an existing payment on the day and the generated value is positive, apportion the existing payment first (in the order charges->interest->fee->principal), then apportion the generated payment
9595
elif generatedValue >= 0L<Cent> then
96-
let chargesPortion = Cent.min si.ChargesPortion existingPayments
96+
let chargesPortion = min si.ChargesPortion existingPayments
9797

9898
let interestPortion =
99-
Cent.min si.InterestPortion (Cent.max 0L<Cent> (existingPayments - chargesPortion))
99+
min si.InterestPortion (max 0L<Cent> (existingPayments - chargesPortion))
100100

101101
let feePortion =
102-
Cent.min
103-
si.FeePortion
104-
(Cent.max 0L<Cent> (existingPayments - chargesPortion - interestPortion))
102+
min si.FeePortion (max 0L<Cent> (existingPayments - chargesPortion - interestPortion))
105103

106104
let principalPortion =
107-
Cent.max 0L<Cent> (existingPayments - feePortion - chargesPortion - interestPortion)
105+
max 0L<Cent> (existingPayments - feePortion - chargesPortion - interestPortion)
108106

109107
PaymentQuote {
110108
PaymentValue = GeneratedPayment.total si.GeneratedPayment

0 commit comments

Comments
 (0)