Functional Weave
Code in Rust

payroll.overtime@1.0.1

vectors.json

3,655 bytes · view raw

[
  { "name": "45 hours with time and a half after 40: the half penny rounds up", "args": [2700, { "minor": 1271, "currency": "GBP" }, [{ "fromMinutes": 0, "multiplierBasisPoints": 10000 }, { "fromMinutes": 2400, "multiplierBasisPoints": 15000 }]], "expect": { "lines": [{ "minutes": 2400, "multiplierBasisPoints": 10000, "pay": { "minor": 50840, "currency": "GBP" } }, { "minutes": 300, "multiplierBasisPoints": 15000, "pay": { "minor": 9533, "currency": "GBP" } }], "total": { "minor": 60373, "currency": "GBP" } } },
  { "name": "exactly 40 hours never reaches the overtime band", "args": [2400, { "minor": 1271, "currency": "GBP" }, [{ "fromMinutes": 0, "multiplierBasisPoints": 10000 }, { "fromMinutes": 2400, "multiplierBasisPoints": 15000 }]], "expect": { "lines": [{ "minutes": 2400, "multiplierBasisPoints": 10000, "pay": { "minor": 50840, "currency": "GBP" } }], "total": { "minor": 50840, "currency": "GBP" } } },
  { "name": "three bands: basic, time and a half, double time", "args": [3300, { "minor": 1000, "currency": "GBP" }, [{ "fromMinutes": 0, "multiplierBasisPoints": 10000 }, { "fromMinutes": 2400, "multiplierBasisPoints": 15000 }, { "fromMinutes": 3000, "multiplierBasisPoints": 20000 }]], "expect": { "lines": [{ "minutes": 2400, "multiplierBasisPoints": 10000, "pay": { "minor": 40000, "currency": "GBP" } }, { "minutes": 600, "multiplierBasisPoints": 15000, "pay": { "minor": 15000, "currency": "GBP" } }, { "minutes": 300, "multiplierBasisPoints": 20000, "pay": { "minor": 10000, "currency": "GBP" } }], "total": { "minor": 65000, "currency": "GBP" } } },
  { "name": "37 hours 20 minutes at one rate", "args": [2240, { "minor": 1271, "currency": "GBP" }, [{ "fromMinutes": 0, "multiplierBasisPoints": 10000 }]], "expect": { "lines": [{ "minutes": 2240, "multiplierBasisPoints": 10000, "pay": { "minor": 47451, "currency": "GBP" } }], "total": { "minor": 47451, "currency": "GBP" } } },
  { "name": "no time worked", "args": [0, { "minor": 1271, "currency": "GBP" }, [{ "fromMinutes": 0, "multiplierBasisPoints": 10000 }]], "expect": { "lines": [], "total": { "minor": 0, "currency": "GBP" } } },
  { "name": "one minute into the overtime band", "args": [2401, { "minor": 1200, "currency": "GBP" }, [{ "fromMinutes": 0, "multiplierBasisPoints": 10000 }, { "fromMinutes": 2400, "multiplierBasisPoints": 15000 }]], "expect": { "lines": [{ "minutes": 2400, "multiplierBasisPoints": 10000, "pay": { "minor": 48000, "currency": "GBP" } }, { "minutes": 1, "multiplierBasisPoints": 15000, "pay": { "minor": 30, "currency": "GBP" } }], "total": { "minor": 48030, "currency": "GBP" } } },
  { "name": "bands that do not start at zero are an error", "args": [2700, { "minor": 1271, "currency": "GBP" }, [{ "fromMinutes": 2400, "multiplierBasisPoints": 15000 }]], "expectError": "must start at 0 minutes" },
  { "name": "bands out of order are an error", "args": [2700, { "minor": 1271, "currency": "GBP" }, [{ "fromMinutes": 0, "multiplierBasisPoints": 10000 }, { "fromMinutes": 3000, "multiplierBasisPoints": 20000 }, { "fromMinutes": 2400, "multiplierBasisPoints": 15000 }]], "expectError": "strictly ascending" },
  { "name": "no bands is an error", "args": [2700, { "minor": 1271, "currency": "GBP" }, []], "expectError": "at least one band" },
  { "name": "negative minutes are an error", "args": [-60, { "minor": 1271, "currency": "GBP" }, [{ "fromMinutes": 0, "multiplierBasisPoints": 10000 }]], "expectError": "not negative" },
  { "name": "fractional minutes are an error", "args": [90.5, { "minor": 1271, "currency": "GBP" }, [{ "fromMinutes": 0, "multiplierBasisPoints": 10000 }]], "expectError": "whole number of minutes" }
]