Functional Weave
Code in TypeScript

payroll.statutory-sick-pay@1.0.1

vectors.json

15,544 bytes · view raw

[
 {
  "name": "two working weeks off in 2025-26: three waiting days, then the daily rate",
  "args": [
   [
    {
     "start": "2025-06-02",
     "end": "2025-06-13"
    }
   ],
   [
    1,
    2,
    3,
    4,
    5
   ],
   {
    "minor": 50000,
    "currency": "GBP"
   }
  ],
  "expect": {
   "total": {
    "minor": 16625,
    "currency": "GBP"
   },
   "paidDays": 7,
   "waitingDays": 3,
   "weeks": [
    {
     "weekStart": "2025-06-01",
     "paidDays": 2,
     "waitingDays": 3,
     "amount": {
      "minor": 4750,
      "currency": "GBP"
     }
    },
    {
     "weekStart": "2025-06-08",
     "paidDays": 5,
     "waitingDays": 0,
     "amount": {
      "minor": 11875,
      "currency": "GBP"
     }
    }
   ],
   "entitlementExhausted": false
  }
 },
 {
  "name": "a three-day spell before April 2026 is not a period of incapacity and pays nothing",
  "args": [
   [
    {
     "start": "2025-06-02",
     "end": "2025-06-04"
    }
   ],
   [
    1,
    2,
    3,
    4,
    5
   ],
   {
    "minor": 50000,
    "currency": "GBP"
   }
  ],
  "expect": {
   "total": {
    "minor": 0,
    "currency": "GBP"
   },
   "paidDays": 0,
   "waitingDays": 0,
   "weeks": [],
   "entitlementExhausted": false
  }
 },
 {
  "name": "the same three-day spell after the 2026 reforms is paid from day one",
  "args": [
   [
    {
     "start": "2026-06-01",
     "end": "2026-06-03"
    }
   ],
   [
    1,
    2,
    3,
    4,
    5
   ],
   {
    "minor": 50000,
    "currency": "GBP"
   }
  ],
  "expect": {
   "total": {
    "minor": 7395,
    "currency": "GBP"
   },
   "paidDays": 3,
   "waitingDays": 0,
   "weeks": [
    {
     "weekStart": "2026-05-31",
     "paidDays": 3,
     "waitingDays": 0,
     "amount": {
      "minor": 7395,
      "currency": "GBP"
     }
    }
   ],
   "entitlementExhausted": false
  }
 },
 {
  "name": "from April 2026 low earners get 80% of earnings, kept exact and rounded up once",
  "args": [
   [
    {
     "start": "2026-06-01",
     "end": "2026-06-01"
    }
   ],
   [
    1,
    2,
    3,
    4,
    5
   ],
   {
    "minor": 12333,
    "currency": "GBP"
   }
  ],
  "expect": {
   "total": {
    "minor": 1974,
    "currency": "GBP"
   },
   "paidDays": 1,
   "waitingDays": 0,
   "weeks": [
    {
     "weekStart": "2026-05-31",
     "paidDays": 1,
     "waitingDays": 0,
     "amount": {
      "minor": 1974,
      "currency": "GBP"
     }
    }
   ],
   "entitlementExhausted": false
  }
 },
 {
  "name": "earnings below the lower earnings limit before April 2026 earn no SSP",
  "args": [
   [
    {
     "start": "2025-06-02",
     "end": "2025-06-13"
    }
   ],
   [
    1,
    2,
    3,
    4,
    5
   ],
   {
    "minor": 12499,
    "currency": "GBP"
   }
  ],
  "expect": {
   "total": {
    "minor": 0,
    "currency": "GBP"
   },
   "paidDays": 0,
   "waitingDays": 0,
   "weeks": [],
   "entitlementExhausted": false
  }
 },
 {
  "name": "a spell 52 days after the last links to it and serves no new waiting days",
  "args": [
   [
    {
     "start": "2025-06-02",
     "end": "2025-06-05"
    },
    {
     "start": "2025-07-28",
     "end": "2025-07-31"
    }
   ],
   [
    1,
    2,
    3,
    4,
    5
   ],
   {
    "minor": 50000,
    "currency": "GBP"
   }
  ],
  "expect": {
   "total": {
    "minor": 11875,
    "currency": "GBP"
   },
   "paidDays": 5,
   "waitingDays": 3,
   "weeks": [
    {
     "weekStart": "2025-06-01",
     "paidDays": 1,
     "waitingDays": 3,
     "amount": {
      "minor": 2375,
      "currency": "GBP"
     }
    },
    {
     "weekStart": "2025-07-27",
     "paidDays": 4,
     "waitingDays": 0,
     "amount": {
      "minor": 9500,
      "currency": "GBP"
     }
    }
   ],
   "entitlementExhausted": false
  }
 },
 {
  "name": "a gap of exactly 8 weeks still links",
  "args": [
   [
    {
     "start": "2025-06-02",
     "end": "2025-06-05"
    },
    {
     "start": "2025-08-01",
     "end": "2025-08-04"
    }
   ],
   [
    1,
    2,
    3,
    4,
    5
   ],
   {
    "minor": 50000,
    "currency": "GBP"
   }
  ],
  "expect": {
   "total": {
    "minor": 7125,
    "currency": "GBP"
   },
   "paidDays": 3,
   "waitingDays": 3,
   "weeks": [
    {
     "weekStart": "2025-06-01",
     "paidDays": 1,
     "waitingDays": 3,
     "amount": {
      "minor": 2375,
      "currency": "GBP"
     }
    },
    {
     "weekStart": "2025-07-27",
     "paidDays": 1,
     "waitingDays": 0,
     "amount": {
      "minor": 2375,
      "currency": "GBP"
     }
    },
    {
     "weekStart": "2025-08-03",
     "paidDays": 1,
     "waitingDays": 0,
     "amount": {
      "minor": 2375,
      "currency": "GBP"
     }
    }
   ],
   "entitlementExhausted": false
  }
 },
 {
  "name": "a gap of 59 days does not link, so waiting days are served again",
  "args": [
   [
    {
     "start": "2025-06-02",
     "end": "2025-06-05"
    },
    {
     "start": "2025-08-04",
     "end": "2025-08-07"
    }
   ],
   [
    1,
    2,
    3,
    4,
    5
   ],
   {
    "minor": 50000,
    "currency": "GBP"
   }
  ],
  "expect": {
   "total": {
    "minor": 4750,
    "currency": "GBP"
   },
   "paidDays": 2,
   "waitingDays": 6,
   "weeks": [
    {
     "weekStart": "2025-06-01",
     "paidDays": 1,
     "waitingDays": 3,
     "amount": {
      "minor": 2375,
      "currency": "GBP"
     }
    },
    {
     "weekStart": "2025-08-03",
     "paidDays": 1,
     "waitingDays": 3,
     "amount": {
      "minor": 2375,
      "currency": "GBP"
     }
    }
   ],
   "entitlementExhausted": false
  }
 },
 {
  "name": "a short spell between two linked ones is ignored before 2026",
  "args": [
   [
    {
     "start": "2025-06-02",
     "end": "2025-06-05"
    },
    {
     "start": "2025-06-10",
     "end": "2025-06-11"
    },
    {
     "start": "2025-07-28",
     "end": "2025-07-31"
    }
   ],
   [
    1,
    2,
    3,
    4,
    5
   ],
   {
    "minor": 50000,
    "currency": "GBP"
   }
  ],
  "expect": {
   "total": {
    "minor": 11875,
    "currency": "GBP"
   },
   "paidDays": 5,
   "waitingDays": 3,
   "weeks": [
    {
     "weekStart": "2025-06-01",
     "paidDays": 1,
     "waitingDays": 3,
     "amount": {
      "minor": 2375,
      "currency": "GBP"
     }
    },
    {
     "weekStart": "2025-07-27",
     "paidDays": 4,
     "waitingDays": 0,
     "amount": {
      "minor": 9500,
      "currency": "GBP"
     }
    }
   ],
   "entitlementExhausted": false
  }
 },
 {
  "name": "a spell across 6 April 2026 serves two old waiting days, then pays at the new rate",
  "args": [
   [
    {
     "start": "2026-04-02",
     "end": "2026-04-10"
    }
   ],
   [
    1,
    2,
    3,
    4,
    5
   ],
   {
    "minor": 50000,
    "currency": "GBP"
   }
  ],
  "expect": {
   "total": {
    "minor": 12325,
    "currency": "GBP"
   },
   "paidDays": 5,
   "waitingDays": 2,
   "weeks": [
    {
     "weekStart": "2026-03-29",
     "paidDays": 0,
     "waitingDays": 2,
     "amount": {
      "minor": 0,
      "currency": "GBP"
     }
    },
    {
     "weekStart": "2026-04-05",
     "paidDays": 5,
     "waitingDays": 0,
     "amount": {
      "minor": 12325,
      "currency": "GBP"
     }
    }
   ],
   "entitlementExhausted": false
  }
 },
 {
  "name": "seven qualifying days a week: one day is a seventh of the week, rounded up",
  "args": [
   [
    {
     "start": "2024-06-03",
     "end": "2024-06-09"
    }
   ],
   [
    1,
    2,
    3,
    4,
    5,
    6,
    7
   ],
   {
    "minor": 50000,
    "currency": "GBP"
   }
  ],
  "expect": {
   "total": {
    "minor": 6672,
    "currency": "GBP"
   },
   "paidDays": 4,
   "waitingDays": 3,
   "weeks": [
    {
     "weekStart": "2024-06-02",
     "paidDays": 3,
     "waitingDays": 3,
     "amount": {
      "minor": 5004,
      "currency": "GBP"
     }
    },
    {
     "weekStart": "2024-06-09",
     "paidDays": 1,
     "waitingDays": 0,
     "amount": {
      "minor": 1668,
      "currency": "GBP"
     }
    }
   ],
   "entitlementExhausted": false
  }
 },
 {
  "name": "2023-24 rate on a Tuesday-and-Thursday pattern: waiting days run into the second week",
  "args": [
   [
    {
     "start": "2023-06-05",
     "end": "2023-06-23"
    }
   ],
   [
    2,
    4
   ],
   {
    "minor": 40000,
    "currency": "GBP"
   }
  ],
  "expect": {
   "total": {
    "minor": 16410,
    "currency": "GBP"
   },
   "paidDays": 3,
   "waitingDays": 3,
   "weeks": [
    {
     "weekStart": "2023-06-04",
     "paidDays": 0,
     "waitingDays": 2,
     "amount": {
      "minor": 0,
      "currency": "GBP"
     }
    },
    {
     "weekStart": "2023-06-11",
     "paidDays": 1,
     "waitingDays": 1,
     "amount": {
      "minor": 5470,
      "currency": "GBP"
     }
    },
    {
     "weekStart": "2023-06-18",
     "paidDays": 2,
     "waitingDays": 0,
     "amount": {
      "minor": 10940,
      "currency": "GBP"
     }
    }
   ],
   "entitlementExhausted": false
  }
 },
 {
  "name": "28 weeks is the most SSP a period of entitlement pays",
  "args": [
   [
    {
     "start": "2026-06-01",
     "end": "2026-12-18"
    }
   ],
   [
    1,
    2,
    3,
    4,
    5
   ],
   {
    "minor": 50000,
    "currency": "GBP"
   }
  ],
  "expect": {
   "total": {
    "minor": 345100,
    "currency": "GBP"
   },
   "paidDays": 140,
   "waitingDays": 0,
   "weeks": [
    {
     "weekStart": "2026-05-31",
     "paidDays": 5,
     "waitingDays": 0,
     "amount": {
      "minor": 12325,
      "currency": "GBP"
     }
    },
    {
     "weekStart": "2026-06-07",
     "paidDays": 5,
     "waitingDays": 0,
     "amount": {
      "minor": 12325,
      "currency": "GBP"
     }
    },
    {
     "weekStart": "2026-06-14",
     "paidDays": 5,
     "waitingDays": 0,
     "amount": {
      "minor": 12325,
      "currency": "GBP"
     }
    },
    {
     "weekStart": "2026-06-21",
     "paidDays": 5,
     "waitingDays": 0,
     "amount": {
      "minor": 12325,
      "currency": "GBP"
     }
    },
    {
     "weekStart": "2026-06-28",
     "paidDays": 5,
     "waitingDays": 0,
     "amount": {
      "minor": 12325,
      "currency": "GBP"
     }
    },
    {
     "weekStart": "2026-07-05",
     "paidDays": 5,
     "waitingDays": 0,
     "amount": {
      "minor": 12325,
      "currency": "GBP"
     }
    },
    {
     "weekStart": "2026-07-12",
     "paidDays": 5,
     "waitingDays": 0,
     "amount": {
      "minor": 12325,
      "currency": "GBP"
     }
    },
    {
     "weekStart": "2026-07-19",
     "paidDays": 5,
     "waitingDays": 0,
     "amount": {
      "minor": 12325,
      "currency": "GBP"
     }
    },
    {
     "weekStart": "2026-07-26",
     "paidDays": 5,
     "waitingDays": 0,
     "amount": {
      "minor": 12325,
      "currency": "GBP"
     }
    },
    {
     "weekStart": "2026-08-02",
     "paidDays": 5,
     "waitingDays": 0,
     "amount": {
      "minor": 12325,
      "currency": "GBP"
     }
    },
    {
     "weekStart": "2026-08-09",
     "paidDays": 5,
     "waitingDays": 0,
     "amount": {
      "minor": 12325,
      "currency": "GBP"
     }
    },
    {
     "weekStart": "2026-08-16",
     "paidDays": 5,
     "waitingDays": 0,
     "amount": {
      "minor": 12325,
      "currency": "GBP"
     }
    },
    {
     "weekStart": "2026-08-23",
     "paidDays": 5,
     "waitingDays": 0,
     "amount": {
      "minor": 12325,
      "currency": "GBP"
     }
    },
    {
     "weekStart": "2026-08-30",
     "paidDays": 5,
     "waitingDays": 0,
     "amount": {
      "minor": 12325,
      "currency": "GBP"
     }
    },
    {
     "weekStart": "2026-09-06",
     "paidDays": 5,
     "waitingDays": 0,
     "amount": {
      "minor": 12325,
      "currency": "GBP"
     }
    },
    {
     "weekStart": "2026-09-13",
     "paidDays": 5,
     "waitingDays": 0,
     "amount": {
      "minor": 12325,
      "currency": "GBP"
     }
    },
    {
     "weekStart": "2026-09-20",
     "paidDays": 5,
     "waitingDays": 0,
     "amount": {
      "minor": 12325,
      "currency": "GBP"
     }
    },
    {
     "weekStart": "2026-09-27",
     "paidDays": 5,
     "waitingDays": 0,
     "amount": {
      "minor": 12325,
      "currency": "GBP"
     }
    },
    {
     "weekStart": "2026-10-04",
     "paidDays": 5,
     "waitingDays": 0,
     "amount": {
      "minor": 12325,
      "currency": "GBP"
     }
    },
    {
     "weekStart": "2026-10-11",
     "paidDays": 5,
     "waitingDays": 0,
     "amount": {
      "minor": 12325,
      "currency": "GBP"
     }
    },
    {
     "weekStart": "2026-10-18",
     "paidDays": 5,
     "waitingDays": 0,
     "amount": {
      "minor": 12325,
      "currency": "GBP"
     }
    },
    {
     "weekStart": "2026-10-25",
     "paidDays": 5,
     "waitingDays": 0,
     "amount": {
      "minor": 12325,
      "currency": "GBP"
     }
    },
    {
     "weekStart": "2026-11-01",
     "paidDays": 5,
     "waitingDays": 0,
     "amount": {
      "minor": 12325,
      "currency": "GBP"
     }
    },
    {
     "weekStart": "2026-11-08",
     "paidDays": 5,
     "waitingDays": 0,
     "amount": {
      "minor": 12325,
      "currency": "GBP"
     }
    },
    {
     "weekStart": "2026-11-15",
     "paidDays": 5,
     "waitingDays": 0,
     "amount": {
      "minor": 12325,
      "currency": "GBP"
     }
    },
    {
     "weekStart": "2026-11-22",
     "paidDays": 5,
     "waitingDays": 0,
     "amount": {
      "minor": 12325,
      "currency": "GBP"
     }
    },
    {
     "weekStart": "2026-11-29",
     "paidDays": 5,
     "waitingDays": 0,
     "amount": {
      "minor": 12325,
      "currency": "GBP"
     }
    },
    {
     "weekStart": "2026-12-06",
     "paidDays": 5,
     "waitingDays": 0,
     "amount": {
      "minor": 12325,
      "currency": "GBP"
     }
    }
   ],
   "entitlementExhausted": true
  }
 },
 {
  "name": "no qualifying days is an error",
  "args": [
   [
    {
     "start": "2025-06-02",
     "end": "2025-06-13"
    }
   ],
   [],
   {
    "minor": 50000,
    "currency": "GBP"
   }
  ],
  "expectError": "at least one qualifying day"
 },
 {
  "name": "a weekday outside 1-7 is an error",
  "args": [
   [
    {
     "start": "2025-06-02",
     "end": "2025-06-13"
    }
   ],
   [
    0,
    1
   ],
   {
    "minor": 50000,
    "currency": "GBP"
   }
  ],
  "expectError": "qualifying weekdays must be 1 (Monday) to 7 (Sunday)"
 },
 {
  "name": "a period that ends before it starts is an error",
  "args": [
   [
    {
     "start": "2025-06-13",
     "end": "2025-06-02"
    }
   ],
   [
    1,
    2,
    3,
    4,
    5
   ],
   {
    "minor": 50000,
    "currency": "GBP"
   }
  ],
  "expectError": "ends before it starts"
 },
 {
  "name": "overlapping periods are an error",
  "args": [
   [
    {
     "start": "2025-06-02",
     "end": "2025-06-13"
    },
    {
     "start": "2025-06-10",
     "end": "2025-06-20"
    }
   ],
   [
    1,
    2,
    3,
    4,
    5
   ],
   {
    "minor": 50000,
    "currency": "GBP"
   }
  ],
  "expectError": "must be in date order and must not overlap"
 },
 {
  "name": "sickness before the rules this capability carries is an error",
  "args": [
   [
    {
     "start": "2020-06-01",
     "end": "2020-06-12"
    }
   ],
   [
    1,
    2,
    3,
    4,
    5
   ],
   {
    "minor": 50000,
    "currency": "GBP"
   }
  ],
  "expectError": "no SSP rule for 2020-06-01"
 },
 {
  "name": "negative earnings are an error",
  "args": [
   [
    {
     "start": "2025-06-02",
     "end": "2025-06-13"
    }
   ],
   [
    1,
    2,
    3,
    4,
    5
   ],
   {
    "minor": -1,
    "currency": "GBP"
   }
  ],
  "expectError": "must not be negative"
 }
]