Functional Weave
Code in Rust

charity.regular-giving-schedule@1.0.0

README.md

1,193 bytes · view raw

# charity.regular-giving-schedule

The dates a regular gift (a Direct Debit, standing order or card
subscription) will be collected: monthly, quarterly or annually on a chosen
day of the month.

- **The first collection** is the first collection day on or after
  `signUpDate + leadDays`. `leadDays` is whatever notice your collection
  method needs (Direct Debit advance notice, a processing cut-off); 0 means
  the sign-up day itself can be the first collection.
- **Short months clamp from the chosen day every time**: a gift on the 31st
  is collected on 30 April, 28 (or 29) February and 31 March again, never
  drifting down to the 28th. Quarterly and annual gifts count their months
  from the first collection. This reuses dates.recurrence (`monthly-on-day`
  every 1, 3 or 12 months) rather than re-implementing it.
- **`endDate` is inclusive** and may cut the list short of `count`; a pledge
  with no end passes `null`.

Dates are ISO strings and are not moved for weekends or bank holidays: banks
move a collection that falls on a non-working day themselves, and a caller who
wants the processing date can pass each date to banking.bacs-processing-date or
dates.add-business-days.