Skip to content

Commit

Permalink
minor display tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
simontreanor committed Oct 3, 2024
1 parent 3bde0a7 commit ef557d9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/Formatting.fs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ module Formatting =
let outputToFile' fileName append content =
outputToFile $"{__SOURCE_DIRECTORY__}/../io/{fileName}" append content

let internal regexMetadata = Regex(@"metadata = map \[.*?\]")
let internal regexMetadata = Regex(@"(metadata = )?map \[.*?\]")
let internal regexObject = Regex(@"[{}]")
let internal regexType = Regex(@"(scheduled payment type|actual payment status) = ")
let internal regexSimple = Regex(@"\( simple (.+?)\)")
Expand Down
17 changes: 9 additions & 8 deletions src/PaymentSchedule.fs
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,18 @@ module PaymentSchedule =
open ValueOptionCE

/// an originally scheduled payment, including the original simple interest and contractual interest calculations
[<Struct>]
[<Struct; StructuredFormatDisplay("{Html}")>]
type OriginalPayment =
{
/// the original payment amount
Amount: int64<Cent>
Value: int64<Cent>
/// the original simple interest
SimpleInterest: int64<Cent>
/// the contractually calculated interest
ContractualInterest: decimal<Cent>
}

member x.Html =
formatCent x.Value

/// any original or rescheduled payment, affecting how any payment due is calculated
[<StructuredFormatDisplay("{Html}")>]
Expand All @@ -45,7 +46,7 @@ module PaymentSchedule =
| _, ValueSome r ->
r
| ValueSome o, ValueNone ->
o.Amount
o.Value
| ValueNone, ValueNone ->
0L<Cent>
|> fun t ->
Expand All @@ -68,16 +69,16 @@ module PaymentSchedule =
/// a quick convenient method to create a basic scheduled payment
static member Quick originalAmount rescheduledAmount =
{ ScheduledPayment.DefaultValue with
Original = originalAmount |> ValueOption.map(fun oa -> { Amount = oa; SimpleInterest = 0L<Cent>; ContractualInterest = 0m<Cent> })
Original = originalAmount |> ValueOption.map(fun oa -> { Value = oa; SimpleInterest = 0L<Cent>; ContractualInterest = 0m<Cent> })
Rescheduled = rescheduledAmount
}
/// HTML formatting to display the scheduled payment in a concise way
member x.Html =
match x.Original, x.Rescheduled with
| ValueSome o, ValueSome r ->
$"""<s>{formatCent o.Amount}</s>&nbsp;{formatCent r}"""
$"""<s>{formatCent o.Value}</s>&nbsp;{formatCent r}"""
| ValueSome o, ValueNone ->
$"original {formatCent o.Amount}"
$"original {formatCent o.Value}"
| ValueNone, ValueSome r ->
$"rescheduled {formatCent r}"
| ValueNone, ValueNone ->
Expand Down Expand Up @@ -540,7 +541,7 @@ module PaymentSchedule =
si.ScheduledPayment
|> ValueOption.map(fun p ->
{ p with
Original = if p.Rescheduled.IsNone then p.Original |> ValueOption.map(fun o -> { o with Amount = o.Amount + si.PrincipalBalance }) else p.Original
Original = if p.Rescheduled.IsNone then p.Original |> ValueOption.map(fun o -> { o with Value = o.Value + si.PrincipalBalance }) else p.Original
Rescheduled = if p.Rescheduled.IsSome then p.Rescheduled |> ValueOption.map(fun r -> r + si.PrincipalBalance) else p.Rescheduled
}
)
Expand Down
2 changes: 1 addition & 1 deletion src/Rescheduling.fs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ module Rescheduling =
match rp.FeeHandling with
| Fee.FeeHandling.CarryOverAsIs ->
{ sp.FeeConfig with
FeeTypes = [| Fee.CustomFee ("Rolled-Over Fee", Amount.Simple feesPortion) |]
FeeTypes = [| Fee.CustomFee ("Rollover Fee", Amount.Simple feesPortion) |]
SettlementRefund =
if feesRefundIfSettled = 0L<Cent> then
Fee.SettlementRefund.None
Expand Down

0 comments on commit ef557d9

Please sign in to comment.