# banking.fees-cap
Applies a monthly cap to the charges raised on an account: charges are taken
in date order until the cap is used up, the charge that crosses the cap is cut
down to what is left, and every later charge in the same period is waived.
Each charge comes back split into `charged` and `waived` (the two always add
up to the amount raised), in the order the caller passed them, with totals.
## Why
The motivating rule is the unarranged overdraft monthly maximum charge: under
the Retail Banking Market Investigation Order 2017 (Competition and Markets
Authority,
https://www.gov.uk/government/publications/retail-banking-market-investigation-order-2017)
each provider sets and publishes a monthly cap on its unarranged overdraft
charges, and must not charge more in a month. The same arithmetic serves any
"no more than X a month" fee promise. **The cap is the caller's figure**: it is
each bank's own published number, not a regulatory constant, so it is an
argument rather than data here.
## Charging periods
A charging period starts on `cycleDay` of each month and runs to the day
before the same day of the next month. `cycleDay` 1 is the calendar month;
statement cycles often start on another day, so 1 to 28 is accepted (29-31 do
not exist in every month, so they are refused rather than guessed at). With
`cycleDay` 15, a charge on 14 March belongs to the period that began on
15 February.
## Order
Charges are capped in date order, and charges on the same date in the order
given, because the cap is reached by whichever charge was raised first. The
result is in input order so it lines up with the caller's list.
## Edge cases
- Zero charges are allowed; negative charges (refunds) are an error, because a
refund is not a charge and should not free up room under the cap.
- A zero cap waives everything.
- Every charge must be in the cap's currency.
- An empty list gives empty totals in the cap's currency.