Functional Weave
Code in Rust

insurance.mid-term-adjustment@1.0.0

README.md

1,716 bytes · view raw

# insurance.mid-term-adjustment

The additional premium (AP) or return premium (RP) when a policy is changed
part-way through its term: a driver added, a car swapped, cover reduced.

## How it is worked out

Give it the full-term premium before the change and the full-term premium
the policy would cost with the change (as your rating engine quotes it), the
term dates and the date the change takes effect. The difference is pro-rated
on the days left:

    premiumChange = (newPremium - oldPremium) x remainingDays / totalDays

with one rounding, in the caller's mode. Pro-rating the old and the new
premium separately and subtracting rounds twice and can be a penny out (the
vectors have one such case: 60.16, not 60.17).

`expiryDate` is exclusive (a year from 2026-01-01 ends 2027-01-01), and the
days left are `expiryDate - changeDate`, so a change on the inception date is
the whole difference and a change on the expiry date is nothing. Leap years
count their 366 days.

## The admin fee

`adminFee` is added to what is due whichever way the premium moves, which is
how most UK insurers and brokers apply an MTA fee: on a return premium the
fee is deducted from the refund, and if the fee is larger the policyholder
still pays the difference (`amountDue` positive while `kind` is `return`).
Pass zero when no fee is charged. The fee is kept separate from the premium
change because it is usually not premium: IPT (`insurance.ipt`) applies to
`premiumChange`, and to the fee only when the insurer charges it as part of
the premium.

## Not covered here

Short-period loadings on MTAs, minimum additional premiums and "no refund
below X" rules are insurer-specific terms of business; apply them to the
result.