Functional Weave
Code in TypeScript

charity.gasds@1.0.2

vectors.json

8,718 bytes · view raw

[
  {"name": "£10,000 collected, plenty of Gift Aid: capped at £8,000, a £2,000 top-up", "args": [{"minor": 1000000, "currency": "GBP"}, {"minor": 200000, "currency": "GBP"}, [], "2026-06-01"], "expect": {"eligibleDonations": {"minor": 800000, "currency": "GBP"}, "topUp": {"minor": 200000, "currency": "GBP"}, "maximumDonations": {"minor": 800000, "currency": "GBP"}, "specifiedAmount": {"minor": 800000, "currency": "GBP"}, "smallDonationLimit": {"minor": 3000, "currency": "GBP"}, "usedCommunityBuildings": false}},
  {"name": "the matching rule: £100 of Gift Aid donations allows £1,000 of small donations, a £250 top-up", "args": [{"minor": 500000, "currency": "GBP"}, {"minor": 10000, "currency": "GBP"}, [], "2026-06-01"], "expect": {"eligibleDonations": {"minor": 100000, "currency": "GBP"}, "topUp": {"minor": 25000, "currency": "GBP"}, "maximumDonations": {"minor": 100000, "currency": "GBP"}, "specifiedAmount": {"minor": 800000, "currency": "GBP"}, "smallDonationLimit": {"minor": 3000, "currency": "GBP"}, "usedCommunityBuildings": false}},
  {"name": "under both limits: the whole £4,000 earns £1,000", "args": [{"minor": 400000, "currency": "GBP"}, {"minor": 1000000, "currency": "GBP"}, [], "2026-06-01"], "expect": {"eligibleDonations": {"minor": 400000, "currency": "GBP"}, "topUp": {"minor": 100000, "currency": "GBP"}, "maximumDonations": {"minor": 800000, "currency": "GBP"}, "specifiedAmount": {"minor": 800000, "currency": "GBP"}, "smallDonationLimit": {"minor": 3000, "currency": "GBP"}, "usedCommunityBuildings": false}},
  {"name": "no Gift Aid claimed in the year: no top-up at all", "args": [{"minor": 400000, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, [], "2026-06-01"], "expect": {"eligibleDonations": {"minor": 0, "currency": "GBP"}, "topUp": {"minor": 0, "currency": "GBP"}, "maximumDonations": {"minor": 0, "currency": "GBP"}, "specifiedAmount": {"minor": 800000, "currency": "GBP"}, "smallDonationLimit": {"minor": 3000, "currency": "GBP"}, "usedCommunityBuildings": false}},
  {"name": "two community buildings: £8,000 (capped from £9,000) plus £3,000 raises the limit to £11,000", "args": [{"minor": 2000000, "currency": "GBP"}, {"minor": 500000, "currency": "GBP"}, [{"minor": 900000, "currency": "GBP"}, {"minor": 300000, "currency": "GBP"}], "2026-06-01"], "expect": {"eligibleDonations": {"minor": 1100000, "currency": "GBP"}, "topUp": {"minor": 275000, "currency": "GBP"}, "maximumDonations": {"minor": 1100000, "currency": "GBP"}, "specifiedAmount": {"minor": 1100000, "currency": "GBP"}, "smallDonationLimit": {"minor": 3000, "currency": "GBP"}, "usedCommunityBuildings": true}},
  {"name": "two community buildings worth less than £8,000 together: the ordinary £8,000 is better", "args": [{"minor": 1000000, "currency": "GBP"}, {"minor": 1000000, "currency": "GBP"}, [{"minor": 300000, "currency": "GBP"}, {"minor": 200000, "currency": "GBP"}], "2026-06-01"], "expect": {"eligibleDonations": {"minor": 800000, "currency": "GBP"}, "topUp": {"minor": 200000, "currency": "GBP"}, "maximumDonations": {"minor": 800000, "currency": "GBP"}, "specifiedAmount": {"minor": 800000, "currency": "GBP"}, "smallDonationLimit": {"minor": 3000, "currency": "GBP"}, "usedCommunityBuildings": false}},
  {"name": "one community building alone does not change the limit", "args": [{"minor": 1000000, "currency": "GBP"}, {"minor": 1000000, "currency": "GBP"}, [{"minor": 900000, "currency": "GBP"}], "2026-06-01"], "expect": {"eligibleDonations": {"minor": 800000, "currency": "GBP"}, "topUp": {"minor": 200000, "currency": "GBP"}, "maximumDonations": {"minor": 800000, "currency": "GBP"}, "specifiedAmount": {"minor": 800000, "currency": "GBP"}, "smallDonationLimit": {"minor": 3000, "currency": "GBP"}, "usedCommunityBuildings": false}},
  {"name": "community buildings do not lift the matching rule", "args": [{"minor": 2000000, "currency": "GBP"}, {"minor": 50000, "currency": "GBP"}, [{"minor": 900000, "currency": "GBP"}, {"minor": 900000, "currency": "GBP"}], "2026-06-01"], "expect": {"eligibleDonations": {"minor": 500000, "currency": "GBP"}, "topUp": {"minor": 125000, "currency": "GBP"}, "maximumDonations": {"minor": 500000, "currency": "GBP"}, "specifiedAmount": {"minor": 1600000, "currency": "GBP"}, "smallDonationLimit": {"minor": 3000, "currency": "GBP"}, "usedCommunityBuildings": true}},
  {"name": "£10.01 of small donations: 250.25p rounded down", "args": [{"minor": 1001, "currency": "GBP"}, {"minor": 100000, "currency": "GBP"}, [], "2026-06-01"], "expect": {"eligibleDonations": {"minor": 1001, "currency": "GBP"}, "topUp": {"minor": 250, "currency": "GBP"}, "maximumDonations": {"minor": 800000, "currency": "GBP"}, "specifiedAmount": {"minor": 800000, "currency": "GBP"}, "smallDonationLimit": {"minor": 3000, "currency": "GBP"}, "usedCommunityBuildings": false}},
  {"name": "2015-16: the limit was £5,000", "args": [{"minor": 1000000, "currency": "GBP"}, {"minor": 1000000, "currency": "GBP"}, [], "2016-04-05"], "expect": {"eligibleDonations": {"minor": 500000, "currency": "GBP"}, "topUp": {"minor": 125000, "currency": "GBP"}, "maximumDonations": {"minor": 500000, "currency": "GBP"}, "specifiedAmount": {"minor": 500000, "currency": "GBP"}, "smallDonationLimit": {"minor": 2000, "currency": "GBP"}, "usedCommunityBuildings": false}},
  {"name": "6 April 2016: the limit became £8,000, small donations still £20", "args": [{"minor": 1000000, "currency": "GBP"}, {"minor": 1000000, "currency": "GBP"}, [], "2016-04-06"], "expect": {"eligibleDonations": {"minor": 800000, "currency": "GBP"}, "topUp": {"minor": 200000, "currency": "GBP"}, "maximumDonations": {"minor": 800000, "currency": "GBP"}, "specifiedAmount": {"minor": 800000, "currency": "GBP"}, "smallDonationLimit": {"minor": 2000, "currency": "GBP"}, "usedCommunityBuildings": false}},
  {"name": "5 April 2019: small donations were £20 or less", "args": [{"minor": 100000, "currency": "GBP"}, {"minor": 100000, "currency": "GBP"}, [], "2019-04-05"], "expect": {"eligibleDonations": {"minor": 100000, "currency": "GBP"}, "topUp": {"minor": 25000, "currency": "GBP"}, "maximumDonations": {"minor": 800000, "currency": "GBP"}, "specifiedAmount": {"minor": 800000, "currency": "GBP"}, "smallDonationLimit": {"minor": 2000, "currency": "GBP"}, "usedCommunityBuildings": false}},
  {"name": "6 April 2019: small donations became £30 or less", "args": [{"minor": 100000, "currency": "GBP"}, {"minor": 100000, "currency": "GBP"}, [], "2019-04-06"], "expect": {"eligibleDonations": {"minor": 100000, "currency": "GBP"}, "topUp": {"minor": 25000, "currency": "GBP"}, "maximumDonations": {"minor": 800000, "currency": "GBP"}, "specifiedAmount": {"minor": 800000, "currency": "GBP"}, "smallDonationLimit": {"minor": 3000, "currency": "GBP"}, "usedCommunityBuildings": false}},
  {"name": "community buildings before 2017-18 are an error", "args": [{"minor": 1000000, "currency": "GBP"}, {"minor": 1000000, "currency": "GBP"}, [{"minor": 500000, "currency": "GBP"}, {"minor": 500000, "currency": "GBP"}], "2016-06-01"], "expectError": "community building claims before 6 April 2017 are not supported"},
  {"name": "community building donations above the total are an error", "args": [{"minor": 500000, "currency": "GBP"}, {"minor": 1000000, "currency": "GBP"}, [{"minor": 400000, "currency": "GBP"}, {"minor": 200000, "currency": "GBP"}], "2026-06-01"], "expectError": "communityBuildingDonations total 600000, more than smallDonations of 500000"},
  {"name": "negative small donations are an error", "args": [{"minor": -1, "currency": "GBP"}, {"minor": 1000000, "currency": "GBP"}, [], "2026-06-01"], "expectError": "smallDonations must not be negative"},
  {"name": "euros are an error", "args": [{"minor": 1000, "currency": "EUR"}, {"minor": 1000000, "currency": "GBP"}, [], "2026-06-01"], "expectError": "GASDS amounts must be in GBP, received EUR for smallDonations"},
  {"name": "a year before the scheme is an error", "args": [{"minor": 1000, "currency": "GBP"}, {"minor": 1000, "currency": "GBP"}, [], "2013-04-05"], "expectError": "no GASDS limits on 2013-04-05"},
  {"name": "a malformed date is an error", "args": [{"minor": 1000, "currency": "GBP"}, {"minor": 1000, "currency": "GBP"}, [], "2026"], "expectError": "onDate must be an ISO date"},
  {"name": "a trailing newline after onDate is not an ISO date", "args": [{"minor": 1000, "currency": "GBP"}, {"minor": 1000, "currency": "GBP"}, [], "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": 1000, "currency": "GBP"}, [], "٢٠٢٦-09-16"], "expectError": "onDate must be an ISO date"}
]