Functional Weave
Code in TypeScript

charity.reclaim-batch@1.0.1

README.md

3,117 bytes · view raw

# charity.reclaim-batch

Turn a period's donation records into the figures of a Gift Aid repayment
claim: the schedule lines, the total of eligible donations and the tax to
reclaim, plus every donation left out and why.

For each donation, in input order:

- outside `periodStart`..`periodEnd` (inclusive): excluded, `outside-period`;
- zero or negative (a refund, a reversal): excluded, `not-positive`;
- no Gift Aid declaration: excluded, `no-declaration`;
- no donor (anonymous): excluded, `no-donor`;
- otherwise it is on the claim.

Eligible donations become **donor lines**, one per donor with the donor's
total, count and last donation date (the schedule asks for the date of the
last donation in a series), ordered by donor id. With `aggregateSmall`,
donations of **£20 or less** go instead onto **aggregated lines** of up to
**£1,000** each, filled in date order (ties by donation id), as Charities
Online allows; each line's date is its last donation's. A donor's larger gifts
stay on their donor line.

The tax is Gift Aid (charity.gift-aid) on the eligible total of **each tax
year** in the period, rounded down once per year: a claim that crosses 5
April 2008 uses 22% before and 20% after, and pennies are not lost by
rounding every gift. Ordering is fixed throughout, so the same records always
give the same claim.

## Decisions and limits

- The aggregation limits are one row of data (`maxDonation` 2000p,
  `maxLineTotal` 100000p) with **no effective dates**: they are HMRC's
  administrative rule for Charities Online rather than law, and HMRC has not
  published the date they took effect, so there is nothing honest to put in a
  `validFrom`. It is kept as data so a change is a data release. Note that
  GOV.UK's schedule spreadsheet page also describes aggregated donations in
  passing as "multiple donations under £30", while its own detailed section
  and the Charities Online page both say "£20 or less"; this follows the
  detailed rule.
- Donor ids sort by plain string order (ordinal, not locale): use ASCII ids.
- It does not check benefits (charity.gift-aid-eligibility), the
  sponsored-event rule (sponsorship under £500 per sponsor listed under the
  participant), the four-year time limit, or visitor-attraction admissions,
  which may not be aggregated.

## Sources

- GOV.UK, "Claim tax back on donations using Charities Online" ("add
  together small donations of £20 or less, up to a total of £1,000 per
  entry"), https://www.gov.uk/guidance/claim-tax-back-on-donations-using-charities-online
- GOV.UK, "Schedule spreadsheet to claim back tax on Gift Aid donations"
  ("donations of £20 or less from different donors ... cannot be higher than
  £1,000"; date of the last donation), https://www.gov.uk/guidance/schedule-spreadsheet-to-claim-back-tax-on-gift-aid-donations
- Basic rates: see charity.gift-aid.

## Notices

Contains public sector information licensed under the Open Government
Licence v3.0 (https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/).

1.0.1 adds its attribution notices (NOTICE). The code and the tests are unchanged.