Functional Weave
Code in TypeScript

insurance.age-banding@1.0.0

README.md

1,137 bytes · view raw

# insurance.age-banding

The policyholder's (or driver's) age on the inception date, and the band of a
rating table it falls in: "17-20", "21-24", "70+".

## Age

Completed years on `inceptionDate`, by `dates.age`: a birthday on the
inception date counts, and a 29 February birthday ages on 1 March in other
years (UK law), so someone born on 29 February 2004 is still 20 on
28 February 2025. The date is always passed in: insurers rate on the age at
inception or renewal, never on the day the code runs, and a mid-term change
is usually rated on the age at the start of the term.

## Bands

The band table is the insurer's, so it is an argument. Each band is
inclusive at both ends in whole years; the last may have no upper limit
(`maxAge` null). The table is checked first: youngest first, no overlaps,
and only the last band open-ended. Gaps are allowed, and an age that falls
in a gap, or below the first band, is an error naming the age rather than
being put in the nearest band, because a quote for someone the table does
not cover should stop, not be priced.

Look the label up in a factor table with `insurance.rating-factors`.