How the Malta leave tal-vaganzi calculator is verified

Inputs

InputFieldType
Your average weekly hoursweeklyHoursnumber
Hours in your working dayhoursPerDaynumber
Months employed in this calendar yearmonthsWorkednumber
Public holidays falling on a Saturday, Sunday or your rest dayholidaysOnRestDaysnumber
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 HoursbaseHours(($const.statutoryWeeks * $const.basisWeeklyHours + $const.extraStatutoryHours) * $n(weeklyHours) / $const.basisWeeklyHours)
Extra HoursextraHours$n(holidaysOnRestDays) * $n(hoursPerDay)
Entitlement HoursentitlementHours($m := $clampFloorCap($n(monthsWorked), 0, $const.monthsPerYear); baseHours * $m / $const.monthsPerYear + extraHours)
Days EntitleddaysEntitled$round(entitlementHours / $n(hoursPerDay), 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
statutoryWeeks4
extraStatutoryHours32
basisWeeklyHours40
basisDailyHours8
monthsPerYear12

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 four weeks and thirty-two hours on a forty-hour week is 192 hours, or 24 days

given weeklyHours40
given hoursPerDay8
given monthsWorked12
given holidaysOnRestDays0
given daysTaken0
expect baseHours192
expect entitlementHours192
expect daysEntitled24

Case 2 — N2 a twenty-hour week halves the hours, and the days stay 24 on a four-hour day

given weeklyHours20
given hoursPerDay4
given monthsWorked12
given holidaysOnRestDays0
given daysTaken0
expect baseHours96
expect daysEntitled24

Case 3 — N3 a longer week raises the hours entitlement in proportion

given weeklyHours45
given hoursPerDay9
given monthsWorked12
given holidaysOnRestDays0
given daysTaken0
expect baseHours216
expect daysEntitled24

Case 4 — N4 three weekend public holidays add three days

given weeklyHours40
given hoursPerDay8
given monthsWorked12
given holidaysOnRestDays3
given daysTaken0
expect extraHours24
expect entitlementHours216
expect daysEntitled27

Case 5 — N5 half a year of employment halves the base, under reg. 8(4)

given weeklyHours40
given hoursPerDay8
given monthsWorked6
given holidaysOnRestDays0
given daysTaken0
expect entitlementHours96
expect daysEntitled12

Case 6 — N6 the weekend-holiday days are added whole, not pro-rated

given weeklyHours40
given hoursPerDay8
given monthsWorked6
given holidaysOnRestDays2
given daysTaken0
expect entitlementHours112
expect daysEntitled14

Case 7 — N7 no months employed still leaves any weekend-holiday days

given weeklyHours40
given hoursPerDay8
given monthsWorked0
given holidaysOnRestDays0
given daysTaken0
expect daysEntitled0

Case 8 — N8 days already taken come off the remainder

given weeklyHours40
given hoursPerDay8
given monthsWorked12
given holidaysOnRestDays0
given daysTaken10
expect daysRemaining14

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

given weeklyHours40
given hoursPerDay8
given monthsWorked12
given holidaysOnRestDays0
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 Malta leave tal-vaganzi calculator

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