Functional Weave
Code in TypeScript

finance.tax.vat-rate@1.2.1

vectors.json

6,674 bytes · view raw

[
  {
    "name": "UK standard rate today",
    "args": [
      "GB",
      "STANDARD",
      "2026-09-16"
    ],
    "expect": {
      "jurisdiction": "GB",
      "category": "STANDARD",
      "basisPoints": 2000,
      "validFrom": "2011-01-04",
      "validTo": null
    }
  },
  {
    "name": "UK standard rate during the 2009 cut",
    "args": [
      "GB",
      "STANDARD",
      "2009-06-01"
    ],
    "expect": {
      "jurisdiction": "GB",
      "category": "STANDARD",
      "basisPoints": 1500,
      "validFrom": "2008-12-01",
      "validTo": "2009-12-31"
    }
  },
  {
    "name": "UK standard rate in 2010",
    "args": [
      "GB",
      "STANDARD",
      "2010-06-01"
    ],
    "expect": {
      "jurisdiction": "GB",
      "category": "STANDARD",
      "basisPoints": 1750,
      "validFrom": "2010-01-01",
      "validTo": "2011-01-03"
    }
  },
  {
    "name": "the day the rate changed",
    "args": [
      "GB",
      "STANDARD",
      "2011-01-04"
    ],
    "expect": {
      "jurisdiction": "GB",
      "category": "STANDARD",
      "basisPoints": 2000,
      "validFrom": "2011-01-04",
      "validTo": null
    }
  },
  {
    "name": "the day before the rate changed",
    "args": [
      "GB",
      "STANDARD",
      "2011-01-03"
    ],
    "expect": {
      "jurisdiction": "GB",
      "category": "STANDARD",
      "basisPoints": 1750,
      "validFrom": "2010-01-01",
      "validTo": "2011-01-03"
    }
  },
  {
    "name": "hospitality during the covid cut",
    "args": [
      "GB",
      "HOSPITALITY",
      "2020-12-25"
    ],
    "expect": {
      "jurisdiction": "GB",
      "category": "HOSPITALITY",
      "basisPoints": 500,
      "validFrom": "2020-07-15",
      "validTo": "2021-09-30"
    }
  },
  {
    "name": "hospitality during the taper",
    "args": [
      "GB",
      "HOSPITALITY",
      "2021-11-01"
    ],
    "expect": {
      "jurisdiction": "GB",
      "category": "HOSPITALITY",
      "basisPoints": 1250,
      "validFrom": "2021-10-01",
      "validTo": "2022-03-31"
    }
  },
  {
    "name": "hospitality back at standard",
    "args": [
      "GB",
      "HOSPITALITY",
      "2026-09-16"
    ],
    "expect": {
      "jurisdiction": "GB",
      "category": "HOSPITALITY",
      "basisPoints": 2000,
      "validFrom": "2022-04-01",
      "validTo": null
    }
  },
  {
    "name": "UK reduced rate",
    "args": [
      "GB",
      "REDUCED",
      "2026-09-16"
    ],
    "expect": {
      "jurisdiction": "GB",
      "category": "REDUCED",
      "basisPoints": 500,
      "validFrom": "1997-09-01",
      "validTo": null
    }
  },
  {
    "name": "UK zero rate",
    "args": [
      "GB",
      "ZERO",
      "2026-09-16"
    ],
    "expect": {
      "jurisdiction": "GB",
      "category": "ZERO",
      "basisPoints": 0,
      "validFrom": "1973-04-01",
      "validTo": null
    }
  },
  {
    "name": "Ireland standard rate",
    "args": [
      "IE",
      "STANDARD",
      "2026-09-16"
    ],
    "expect": {
      "jurisdiction": "IE",
      "category": "STANDARD",
      "basisPoints": 2300,
      "validFrom": "2021-03-01",
      "validTo": null
    }
  },
  {
    "name": "unknown jurisdiction is an error, not a guess",
    "args": [
      "FR",
      "STANDARD",
      "2026-09-16"
    ],
    "expectError": "no VAT rule"
  },
  {
    "name": "a date before the rule existed is an error",
    "args": [
      "GB",
      "STANDARD",
      "1970-01-01"
    ],
    "expectError": "no VAT rule"
  },
  {
    "name": "a malformed date is an error",
    "args": [
      "GB",
      "STANDARD",
      "16/09/2026"
    ],
    "expectError": "ISO date"
  },
  {
    "name": "Irish hospitality during the 9 percent tourism rate",
    "args": [
      "IE",
      "HOSPITALITY",
      "2015-06-01"
    ],
    "expect": {
      "jurisdiction": "IE",
      "category": "HOSPITALITY",
      "basisPoints": 900,
      "validFrom": "2011-07-01",
      "validTo": "2018-12-31"
    }
  },
  {
    "name": "Irish hospitality after the 2019 withdrawal",
    "args": [
      "IE",
      "HOSPITALITY",
      "2019-06-01"
    ],
    "expect": {
      "jurisdiction": "IE",
      "category": "HOSPITALITY",
      "basisPoints": 1350,
      "validFrom": "2019-01-01",
      "validTo": "2020-10-31"
    }
  },
  {
    "name": "Irish hospitality during the covid 9 percent",
    "args": [
      "IE",
      "HOSPITALITY",
      "2021-06-01"
    ],
    "expect": {
      "jurisdiction": "IE",
      "category": "HOSPITALITY",
      "basisPoints": 900,
      "validFrom": "2020-11-01",
      "validTo": "2023-08-31"
    }
  },
  {
    "name": "Irish hospitality today",
    "args": [
      "IE",
      "HOSPITALITY",
      "2026-09-16"
    ],
    "expect": {
      "jurisdiction": "IE",
      "category": "HOSPITALITY",
      "basisPoints": 1350,
      "validFrom": "2023-09-01",
      "validTo": null
    }
  },
  {
    "name": "the day the covid rate ended",
    "args": [
      "IE",
      "HOSPITALITY",
      "2023-08-31"
    ],
    "expect": {
      "jurisdiction": "IE",
      "category": "HOSPITALITY",
      "basisPoints": 900,
      "validFrom": "2020-11-01",
      "validTo": "2023-08-31"
    }
  },
  {
    "name": "Irish standard rate during the 2020-21 cut",
    "args": [
      "IE",
      "STANDARD",
      "2020-12-01"
    ],
    "expect": {
      "jurisdiction": "IE",
      "category": "STANDARD",
      "basisPoints": 2100,
      "validFrom": "2020-09-01",
      "validTo": "2021-02-28"
    }
  },
  {
    "name": "Irish standard rate the day before the cut",
    "args": [
      "IE",
      "STANDARD",
      "2020-08-31"
    ],
    "expect": {
      "jurisdiction": "IE",
      "category": "STANDARD",
      "basisPoints": 2300,
      "validFrom": "2012-01-01",
      "validTo": "2020-08-31"
    }
  },
  {
    "name": "Irish standard rate restored on 1 March 2021",
    "args": [
      "IE",
      "STANDARD",
      "2021-03-01"
    ],
    "expect": {
      "jurisdiction": "IE",
      "category": "STANDARD",
      "basisPoints": 2300,
      "validFrom": "2021-03-01",
      "validTo": null
    }
  },
  {"name": "a date with a trailing newline is an error", "args": ["GB", "STANDARD", "2026-09-16\n"], "expectError": "onDate must be an ISO date (YYYY-MM-DD), received \"2026-09-16\n\""},
  {"name": "a date in Arabic-Indic digits is an error", "args": ["GB", "STANDARD", "٢٠٢٦-٠٩-١٦"], "expectError": "onDate must be an ISO date (YYYY-MM-DD), received \"٢٠٢٦-٠٩-١٦\""},
  {"name": "a malformed date names the parameter as the signature does", "args": ["GB", "STANDARD", "16/09/2026"], "expectError": "onDate must be an ISO date (YYYY-MM-DD), received \"16/09/2026\""}
]