Functional Weave
Code in Python

charity.gift-aid-eligibility@1.0.2

vectors.json

8,636 bytes · view raw

[
  {"name": "£100 with a £25 benefit is exactly at 25% and qualifies", "args": [{"minor": 10000, "currency": "GBP"}, {"minor": 2500, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, true, true, "2026-05-01"], "expect": {"eligible": true, "reasons": [], "benefitLimit": {"minor": 2500, "currency": "GBP"}, "annualBenefitLimit": {"minor": 250000, "currency": "GBP"}}},
  {"name": "£100 with a £25.01 benefit exceeds 25%", "args": [{"minor": 10000, "currency": "GBP"}, {"minor": 2501, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, true, true, "2026-05-01"], "expect": {"eligible": false, "reasons": ["benefit-over-limit"], "benefitLimit": {"minor": 2500, "currency": "GBP"}, "annualBenefitLimit": {"minor": 250000, "currency": "GBP"}}},
  {"name": "£1.01: a 25p benefit is under the unrounded limit of 25.25p", "args": [{"minor": 101, "currency": "GBP"}, {"minor": 25, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, true, true, "2026-05-01"], "expect": {"eligible": true, "reasons": [], "benefitLimit": {"minor": 25, "currency": "GBP"}, "annualBenefitLimit": {"minor": 250000, "currency": "GBP"}}},
  {"name": "£1.01: a 26p benefit is over 25.25p", "args": [{"minor": 101, "currency": "GBP"}, {"minor": 26, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, true, true, "2026-05-01"], "expect": {"eligible": false, "reasons": ["benefit-over-limit"], "benefitLimit": {"minor": 25, "currency": "GBP"}, "annualBenefitLimit": {"minor": 250000, "currency": "GBP"}}},
  {"name": "£2,000 since 2019: £25 plus 5% of £1,900 is £120, and £120 qualifies", "args": [{"minor": 200000, "currency": "GBP"}, {"minor": 12000, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, true, true, "2026-05-01"], "expect": {"eligible": true, "reasons": [], "benefitLimit": {"minor": 12000, "currency": "GBP"}, "annualBenefitLimit": {"minor": 250000, "currency": "GBP"}}},
  {"name": "£2,000 since 2019: £120.01 is over the limit", "args": [{"minor": 200000, "currency": "GBP"}, {"minor": 12001, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, true, true, "2026-05-01"], "expect": {"eligible": false, "reasons": ["benefit-over-limit"], "benefitLimit": {"minor": 12000, "currency": "GBP"}, "annualBenefitLimit": {"minor": 250000, "currency": "GBP"}}},
  {"name": "£50,000: the per-gift limit is £2,520 but a £2,500.01 benefit breaks the £2,500 annual cap", "args": [{"minor": 5000000, "currency": "GBP"}, {"minor": 250001, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, true, true, "2026-05-01"], "expect": {"eligible": false, "reasons": ["annual-benefits-over-limit"], "benefitLimit": {"minor": 252000, "currency": "GBP"}, "annualBenefitLimit": {"minor": 250000, "currency": "GBP"}}},
  {"name": "£50,000 with a £2,500 benefit is exactly at the annual cap and qualifies", "args": [{"minor": 5000000, "currency": "GBP"}, {"minor": 250000, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, true, true, "2026-05-01"], "expect": {"eligible": true, "reasons": [], "benefitLimit": {"minor": 252000, "currency": "GBP"}, "annualBenefitLimit": {"minor": 250000, "currency": "GBP"}}},
  {"name": "earlier benefits this tax year count towards the £2,500", "args": [{"minor": 200000, "currency": "GBP"}, {"minor": 10001, "currency": "GBP"}, {"minor": 240000, "currency": "GBP"}, true, true, "2026-05-01"], "expect": {"eligible": false, "reasons": ["annual-benefits-over-limit"], "benefitLimit": {"minor": 12000, "currency": "GBP"}, "annualBenefitLimit": {"minor": 250000, "currency": "GBP"}}},
  {"name": "no declaration and not enough tax: both reasons, in order", "args": [{"minor": 1000, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, false, false, "2026-05-01"], "expect": {"eligible": false, "reasons": ["no-declaration", "insufficient-tax"], "benefitLimit": {"minor": 250, "currency": "GBP"}, "annualBenefitLimit": {"minor": 250000, "currency": "GBP"}}},
  {"name": "every reason at once", "args": [{"minor": 10000, "currency": "GBP"}, {"minor": 250001, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, false, false, "2026-05-01"], "expect": {"eligible": false, "reasons": ["no-declaration", "insufficient-tax", "benefit-over-limit", "annual-benefits-over-limit"], "benefitLimit": {"minor": 2500, "currency": "GBP"}, "annualBenefitLimit": {"minor": 250000, "currency": "GBP"}}},
  {"name": "before 6 April 2019 a £500 gift had a flat £25 limit, so a £40 benefit failed", "args": [{"minor": 50000, "currency": "GBP"}, {"minor": 4000, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, true, true, "2019-04-05"], "expect": {"eligible": false, "reasons": ["benefit-over-limit"], "benefitLimit": {"minor": 2500, "currency": "GBP"}, "annualBenefitLimit": {"minor": 250000, "currency": "GBP"}}},
  {"name": "from 6 April 2019 the same £500 gift allows £25 plus 5% of £400, £45", "args": [{"minor": 50000, "currency": "GBP"}, {"minor": 4000, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, true, true, "2019-04-06"], "expect": {"eligible": true, "reasons": [], "benefitLimit": {"minor": 4500, "currency": "GBP"}, "annualBenefitLimit": {"minor": 250000, "currency": "GBP"}}},
  {"name": "before 2019 a gift over £1,000 allowed 5% of the whole gift: £100 on £2,000", "args": [{"minor": 200000, "currency": "GBP"}, {"minor": 10000, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, true, true, "2018-06-01"], "expect": {"eligible": true, "reasons": [], "benefitLimit": {"minor": 10000, "currency": "GBP"}, "annualBenefitLimit": {"minor": 250000, "currency": "GBP"}}},
  {"name": "before 2019 exactly £1,000 was still in the £25 band", "args": [{"minor": 100000, "currency": "GBP"}, {"minor": 2501, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, true, true, "2018-06-01"], "expect": {"eligible": false, "reasons": ["benefit-over-limit"], "benefitLimit": {"minor": 2500, "currency": "GBP"}, "annualBenefitLimit": {"minor": 250000, "currency": "GBP"}}},
  {"name": "2010-11: the annual limit was £500", "args": [{"minor": 200000, "currency": "GBP"}, {"minor": 5001, "currency": "GBP"}, {"minor": 45000, "currency": "GBP"}, true, true, "2011-04-05"], "expect": {"eligible": false, "reasons": ["annual-benefits-over-limit"], "benefitLimit": {"minor": 10000, "currency": "GBP"}, "annualBenefitLimit": {"minor": 50000, "currency": "GBP"}}},
  {"name": "6 April 2011: the annual limit became £2,500", "args": [{"minor": 200000, "currency": "GBP"}, {"minor": 5001, "currency": "GBP"}, {"minor": 45000, "currency": "GBP"}, true, true, "2011-04-06"], "expect": {"eligible": true, "reasons": [], "benefitLimit": {"minor": 10000, "currency": "GBP"}, "annualBenefitLimit": {"minor": 250000, "currency": "GBP"}}},
  {"name": "a zero donation is an error", "args": [{"minor": 0, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, true, true, "2026-05-01"], "expectError": "donation must be positive"},
  {"name": "a euro donation is an error", "args": [{"minor": 1000, "currency": "EUR"}, {"minor": 0, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, true, true, "2026-05-01"], "expectError": "Gift Aid amounts must be in GBP, received EUR for donation"},
  {"name": "a negative benefit is an error", "args": [{"minor": 1000, "currency": "GBP"}, {"minor": -1, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, true, true, "2026-05-01"], "expectError": "benefitValue must not be negative"},
  {"name": "negative prior benefits are an error", "args": [{"minor": 1000, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, {"minor": -1, "currency": "GBP"}, true, true, "2026-05-01"], "expectError": "priorBenefitsThisYear must not be negative"},
  {"name": "a date before the rules on file is an error", "args": [{"minor": 1000, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, true, true, "2007-04-05"], "expectError": "no Gift Aid benefit limits on 2007-04-05"},
  {"name": "a malformed date is an error", "args": [{"minor": 1000, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, true, true, "2026-5-1"], "expectError": "onDate must be an ISO date"},
  {"name": "a trailing newline after onDate is not an ISO date", "args": [{"minor": 1000, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, true, true, "2026-09-16\n"], "expectError": "onDate must be an ISO date"},
  {"name": "Arabic-Indic digits in onDate are not an ISO date", "args": [{"minor": 1000, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, true, true, "٢٠٢٦-09-16"], "expectError": "onDate must be an ISO date"}
]