How the Estonia põhipuhkus calculator is verified

Inputs

InputFieldType
Calendar days of the year you were employedcalendarDaysWorkednumber
Calendar days in the yeardaysInYearnumber
You are a minor, or have partial or no capacity for workextendedEntitlementboolean
Calendar 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)
Base DaysbaseDays(extendedEntitlement = true ? $const.baseDaysExtended : $const.baseDaysStandard)
Days EntitleddaysEntitled($dw := $clampFloorCap($n(calendarDaysWorked), 0, $n(daysInYear)); $round(baseDays / $n(daysInYear) * $dw, 2))
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
baseDaysStandard28
baseDaysExtended35

Test vectors (9)

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 year is 28 calendar days

given calendarDaysWorked365
given daysInYear365
given extendedEntitlementno
given daysTaken0
expect baseDays28
expect daysEntitled28

Case 2 — A1 the authority's own example, first half: 28 ÷ 365 × 181 (it prints ~13,89; the stated arithmetic gives 13,8849, so 13,88 at two decimals)

given calendarDaysWorked181
given daysInYear365
given extendedEntitlementno
given daysTaken0
expect daysEntitled13.88

Case 3 — A2 the authority's own example, second half: 35 ÷ 365 × 184 = 17,64 exactly as printed

given calendarDaysWorked184
given daysInYear365
given extendedEntitlementyes
given daysTaken0
expect daysEntitled17.64

Case 4 — N2 the extended entitlement over a full year is 35

given calendarDaysWorked365
given daysInYear365
given extendedEntitlementyes
given daysTaken0
expect baseDays35
expect daysEntitled35

Case 5 — N3 half a year is half the entitlement

given calendarDaysWorked182.5
given daysInYear365
given extendedEntitlementno
given daysTaken0
expect daysEntitled14

Case 6 — N4 a leap year divides by 366

given calendarDaysWorked366
given daysInYear366
given extendedEntitlementno
given daysTaken0
expect daysEntitled28

Case 7 — N5 no days employed earns nothing

given calendarDaysWorked0
given daysInYear365
given extendedEntitlementno
given daysTaken0
expect daysEntitled0

Case 8 — N6 days already taken come off the remainder

given calendarDaysWorked365
given daysInYear365
given extendedEntitlementno
given daysTaken10
expect daysRemaining18

Case 9 — N7 taking more than the entitlement never goes negative

given calendarDaysWorked365
given daysInYear365
given extendedEntitlementno
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 Estonia põhipuhkus calculator

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