How the China 带薪年休假 (paid annual leave) calculator is verified

Inputs

InputFieldType
Cumulative years worked (any employer)serviceYearsnumber
Days already taken this yeardaysTakennumber

The formula

Each derived value below is computed by the Valem engine from the expression shown, in this order. Nothing else runs — there is no hidden code path.

Derived valueFieldFormula (JSONata)
Days EntitleddaysEntitled($y := $n(serviceYears); $y >= $const.longServiceYears ? $const.daysLong : ($y >= $const.midServiceYears ? $const.daysMid : ($y >= $const.minServiceYears ? $const.daysShort : 0)))
Days RemainingdaysRemaining($r := daysEntitled - $n(daysTaken); $r < 0 ? 0 : $round($r, 1))

Rates and thresholds

The expressions above read these as $const. They are the figures the annual refresh replaces, so they live as data rather than being written into the formulas — which is what makes a year-on-year change a one-line diff instead of an edit to arithmetic.

ConstantValue
minServiceYears1
midServiceYears10
longServiceYears20
daysShort5
daysMid10
daysLong15

Test vectors (8)

Every case is executed against this model on each build, by the Java engine and independently by a JavaScript one. A mismatch of a single cent fails the build, so the page cannot ship advertising a figure the model no longer produces.

Case 1 — L2 one full year: 5 days

given serviceYears1
given daysTaken0
expect daysEntitled5

Case 2 — L1 under a year of work: no annual leave yet

given serviceYears0
given daysTaken0
expect daysEntitled0

Case 3 — L3 nine years is still the 5-day band (“不满10年”)

given serviceYears9
given daysTaken0
expect daysEntitled5

Case 4 — L4 ten years steps to 10 days (“已满10年”)

given serviceYears10
given daysTaken0
expect daysEntitled10

Case 5 — L5 nineteen years: still 10

given serviceYears19
given daysTaken0
expect daysEntitled10

Case 6 — L6 twenty years and beyond: 15, the ceiling

given serviceYears30
given daysTaken0
expect daysEntitled15

Case 7 — L7 days taken come off the remainder and it never goes negative

given serviceYears12
given daysTaken14
expect daysEntitled10
expect daysRemaining0

Case 8 — L8 days taken below the entitlement leave the balance

given serviceYears25
given daysTaken4
expect daysRemaining11

Sources

Check it yourself — and reuse it

The whole model as JSON — inputs, outputs, formulas, vectors and sources in one re-runnable document.

This model is published under CC BY 4.0: use it, adapt it, build on it, with attribution. The licence covers the model — the expression of each rule and the arrangement of the catalog. The rates and thresholds are law, and nobody licenses those; the sources above are where they come from.

← Back to the China 带薪年休假 (paid annual leave) calculator

Built with Valem — a live, verifiable calculator you can fork and embed.