Functional Weave
Code in Python

charity.payroll-giving@1.0.0

vectors.json

5,382 bytes · view raw

[
  {"name": "basic rate: £100 given from £3,000 saves £20 of PAYE, costing £80", "args": ["1257L", "monthly", 1, {"minor": 300000, "currency": "GBP"}, {"minor": 10000, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, "2026-04-25"], "expect": {"taxablePay": {"minor": 290000, "currency": "GBP"}, "taxWithoutGiving": {"minor": 39020, "currency": "GBP"}, "taxWithGiving": {"minor": 37020, "currency": "GBP"}, "taxSaved": {"minor": 2000, "currency": "GBP"}, "netCost": {"minor": 8000, "currency": "GBP"}}},
  {"name": "£5 given saves exactly £1", "args": ["1257L", "monthly", 1, {"minor": 300000, "currency": "GBP"}, {"minor": 500, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, "2026-04-25"], "expect": {"taxablePay": {"minor": 299500, "currency": "GBP"}, "taxWithoutGiving": {"minor": 39020, "currency": "GBP"}, "taxWithGiving": {"minor": 38920, "currency": "GBP"}, "taxSaved": {"minor": 100, "currency": "GBP"}, "netCost": {"minor": 400, "currency": "GBP"}}},
  {"name": "50p given saves nothing: PAYE rounds taxable pay down to whole pounds (naive 20% says 10p)", "args": ["1257L", "monthly", 1, {"minor": 300000, "currency": "GBP"}, {"minor": 50, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, "2026-04-25"], "expect": {"taxablePay": {"minor": 299950, "currency": "GBP"}, "taxWithoutGiving": {"minor": 39020, "currency": "GBP"}, "taxWithGiving": {"minor": 39020, "currency": "GBP"}, "taxSaved": {"minor": 0, "currency": "GBP"}, "netCost": {"minor": 50, "currency": "GBP"}}},
  {"name": "higher rate: £200 given from £5,000 saves £80", "args": ["1257L", "monthly", 1, {"minor": 500000, "currency": "GBP"}, {"minor": 20000, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, "2026-04-25"], "expect": {"taxablePay": {"minor": 480000, "currency": "GBP"}, "taxWithoutGiving": {"minor": 95206, "currency": "GBP"}, "taxWithGiving": {"minor": 87206, "currency": "GBP"}, "taxSaved": {"minor": 8000, "currency": "GBP"}, "netCost": {"minor": 12000, "currency": "GBP"}}},
  {"name": "Scottish intermediate rate: £100 saves £21", "args": ["S1257L", "monthly", 1, {"minor": 300000, "currency": "GBP"}, {"minor": 10000, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, "2026-04-25"], "expect": {"taxablePay": {"minor": 290000, "currency": "GBP"}, "taxWithoutGiving": {"minor": 39227, "currency": "GBP"}, "taxWithGiving": {"minor": 37127, "currency": "GBP"}, "taxSaved": {"minor": 2100, "currency": "GBP"}, "netCost": {"minor": 7900, "currency": "GBP"}}},
  {"name": "cumulative month 6: £100 saves £20 against tax to date", "args": ["1257L", "monthly", 6, {"minor": 300000, "currency": "GBP"}, {"minor": 10000, "currency": "GBP"}, {"minor": 1500000, "currency": "GBP"}, {"minor": 195160, "currency": "GBP"}, "2026-09-25"], "expect": {"taxablePay": {"minor": 290000, "currency": "GBP"}, "taxWithoutGiving": {"minor": 39040, "currency": "GBP"}, "taxWithGiving": {"minor": 37040, "currency": "GBP"}, "taxSaved": {"minor": 2000, "currency": "GBP"}, "netCost": {"minor": 8000, "currency": "GBP"}}},
  {"name": "no donation: nothing saved", "args": ["1257L", "monthly", 1, {"minor": 300000, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, "2026-04-25"], "expect": {"taxablePay": {"minor": 300000, "currency": "GBP"}, "taxWithoutGiving": {"minor": 39020, "currency": "GBP"}, "taxWithGiving": {"minor": 39020, "currency": "GBP"}, "taxSaved": {"minor": 0, "currency": "GBP"}, "netCost": {"minor": 0, "currency": "GBP"}}},
  {"name": "pay under the allowance: the donation saves no tax at all", "args": ["1257L", "monthly", 1, {"minor": 100000, "currency": "GBP"}, {"minor": 100000, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, "2026-04-25"], "expect": {"taxablePay": {"minor": 0, "currency": "GBP"}, "taxWithoutGiving": {"minor": 0, "currency": "GBP"}, "taxWithGiving": {"minor": 0, "currency": "GBP"}, "taxSaved": {"minor": 0, "currency": "GBP"}, "netCost": {"minor": 100000, "currency": "GBP"}}},
  {"name": "a donation above pay is an error", "args": ["1257L", "monthly", 1, {"minor": 10000, "currency": "GBP"}, {"minor": 10001, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, "2026-04-25"], "expectError": "donation of 10001 is more than pay of 10000"},
  {"name": "a negative donation is an error", "args": ["1257L", "monthly", 1, {"minor": 10000, "currency": "GBP"}, {"minor": -1, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, "2026-04-25"], "expectError": "donation must not be negative"},
  {"name": "a euro donation is an error", "args": ["1257L", "monthly", 1, {"minor": 10000, "currency": "GBP"}, {"minor": 100, "currency": "EUR"}, {"minor": 0, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, "2026-04-25"], "expectError": "payroll amounts must be in GBP, received EUR for donation"},
  {"name": "a bad period is refused by payroll.income-tax", "args": ["1257L", "monthly", 13, {"minor": 300000, "currency": "GBP"}, {"minor": 100, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, "2026-04-25"], "expectError": "period 13 is not a tax period for monthly pay"}
]