How the UAE annual leave calculator is verified

Inputs

InputFieldType
Completed months of service with this employerserviceMonthsnumber
Months worked in this leave year (after the first year)monthsWorkednumber
Days already takendaysTakennumber

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)
Completed MonthscompletedMonths$floor($n(serviceMonths))
Days EntitleddaysEntitled($m := $n(monthsWorked); $m := $m > 12 ? 12 : ($m < 0 ? 0 : $m); completedMonths < 12 ? (completedMonths > $const.minServiceMonths ? completedMonths * $const.daysPerMonthFirstYear : 0) : $round($const.daysPerYear * $m / 12, 1))
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
daysPerYear30
daysPerMonthFirstYear2
minServiceMonths6

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 — U1 a full year of service gives 30

given serviceMonths24
given monthsWorked12
given daysTaken0
expect daysEntitled30

Case 2 — U2 six months or less in the first year gives nothing yet

given serviceMonths6
given monthsWorked12
given daysTaken0
expect daysEntitled0

Case 3 — U3 seven months is two days a month: 14

given serviceMonths7
given monthsWorked12
given daysTaken0
expect daysEntitled14

Case 4 — U4 eleven months is 22 — not eleven twelfths of 30

given serviceMonths11
given monthsWorked12
given daysTaken0
expect daysEntitled22

Case 5 — U5 the first completed year gives the full 30

given serviceMonths12
given monthsWorked12
given daysTaken0
expect daysEntitled30

Case 6 — U6 a final part year of five months is 12.5

given serviceMonths41
given monthsWorked5
given daysTaken0
expect daysEntitled12.5

Case 7 — U7 days taken come off the remainder

given serviceMonths24
given monthsWorked12
given daysTaken12
expect daysRemaining18

Case 8 — U8 taking more than the entitlement never goes negative

given serviceMonths9
given monthsWorked12
given daysTaken40
expect daysRemaining0

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 UAE annual leave calculator

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