How the Iceland orlof calculator is verified

Inputs

InputFieldType
Months worked in the leave year (1 May – 30 April)monthsWorkednumber
Orlofsdagar 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)
Counted MonthscountedMonths($m := $clampFloorCap($n(monthsWorked), 0, $const.monthsPerYear); $whole := $floor($m); $frac := $m - $whole; $frac >= $const.halfMonthThreshold ? $whole + 1 : $whole)
Orlofsdagar EntitledorlofsdagarEntitledcountedMonths * $const.daysPerWorkedMonth
Weeks Of LeaveweeksOfLeave($d := orlofsdagarEntitled; $plain := $const.freeSaturdays * $const.workingDaysPerWeek; $d <= $plain ? $round($d / $const.workingDaysPerWeek, 2) : $round($const.freeSaturdays + ($d - $plain) / ($const.workingDaysPerWeek + 1), 2))
Days EntitleddaysEntitledorlofsdagarEntitled
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
daysPerWorkedMonth2
halfMonthThreshold0.5
freeSaturdays5
monthsPerYear12
workingDaysPerWeek5

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 — N1 a full leave year is 24 orlofsdagar, which is 4,8 Monday-to-Friday weeks

given monthsWorked12
given daysTaken0
expect countedMonths12
expect orlofsdagarEntitled24
expect weeksOfLeave4.8
expect daysEntitled24

Case 2 — N2 six months earns half of it

given monthsWorked6
given daysTaken0
expect orlofsdagarEntitled12
expect daysEntitled12

Case 3 — N3 half a month rounds UP to a whole month

given monthsWorked7.5
given daysTaken0
expect countedMonths8
expect orlofsdagarEntitled16

Case 4 — N4 just under half a month counts for nothing

given monthsWorked7.4
given daysTaken0
expect countedMonths7
expect orlofsdagarEntitled14

Case 5 — N5 the threshold is AT a half, so exactly .5 rounds up

given monthsWorked0.5
given daysTaken0
expect countedMonths1
expect orlofsdagarEntitled2

Case 6 — N6 under half a month in total earns nothing at all

given monthsWorked0.4
given daysTaken0
expect countedMonths0
expect daysEntitled0

Case 7 — N7 days already taken come off the remainder

given monthsWorked12
given daysTaken10
expect daysRemaining14

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

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 Iceland orlof calculator

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