How the Brazil férias calculator is verified

Inputs

InputFieldType
Months completed in this período aquisitivomonthsWorkednumber
Unjustified absences (faltas) in the periodunjustifiedAbsencesnumber
Days you work per weekdaysPerWeeknumber
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)
Band Days CorridosbandDaysCorridos($a := $n(unjustifiedAbsences); $a <= $const.absenceLimit5 ? $const.bandDaysTo5Absences : ($a <= $const.absenceLimit14 ? $const.bandDaysTo14Absences : ($a <= $const.absenceLimit23 ? $const.bandDaysTo23Absences : ($a <= $const.absenceLimit32 ? $const.bandDaysTo32Absences : 0))))
Days Corridos EntitleddaysCorridosEntitled($m := $clampFloorCap($n(monthsWorked), 0, $const.acquisitionMonths); $m >= $const.acquisitionMonths ? bandDaysCorridos : 0)
Days EntitleddaysEntitled$round(daysCorridosEntitled / $const.daysPerCalendarWeek * $n(daysPerWeek), 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
acquisitionMonths12
bandDaysTo5Absences30
bandDaysTo14Absences24
bandDaysTo23Absences18
bandDaysTo32Absences12
absenceLimit55
absenceLimit1414
absenceLimit2323
absenceLimit3232
daysPerCalendarWeek7

Test vectors (12)

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 clean year is 30 dias corridos, about 21.4 working days on a five-day week

given monthsWorked12
given unjustifiedAbsences0
given daysPerWeek5
given daysTaken0
expect bandDaysCorridos30
expect daysEntitled21.4

Case 2 — N2 five absences is still band I, because the article says 'not more than five'

given monthsWorked12
given unjustifiedAbsences5
given daysPerWeek5
given daysTaken0
expect bandDaysCorridos30

Case 3 — N3 the sixth absence costs six days of leave at once

given monthsWorked12
given unjustifiedAbsences6
given daysPerWeek5
given daysTaken0
expect bandDaysCorridos24
expect daysEntitled17.1

Case 4 — N4 the seventh costs nothing further — the band is flat to fourteen

given monthsWorked12
given unjustifiedAbsences14
given daysPerWeek5
given daysTaken0
expect bandDaysCorridos24

Case 5 — N5 fifteen absences drops to 18 corridos

given monthsWorked12
given unjustifiedAbsences15
given daysPerWeek5
given daysTaken0
expect bandDaysCorridos18
expect daysEntitled12.9

Case 6 — N6 twenty-four drops to the lowest band, 12 corridos or about 8.6 working days

given monthsWorked12
given unjustifiedAbsences24
given daysPerWeek5
given daysTaken0
expect bandDaysCorridos12
expect daysEntitled8.6

Case 7 — N7 thirty-two is the last banded value

given monthsWorked12
given unjustifiedAbsences32
given daysPerWeek5
given daysTaken0
expect bandDaysCorridos12

Case 8 — N8 above thirty-two art. 130 supplies no band at all

given monthsWorked12
given unjustifiedAbsences33
given daysPerWeek5
given daysTaken0
expect bandDaysCorridos0
expect daysEntitled0

Case 9 — N9 the right is acquired AFTER twelve months, so eleven earns nothing

given monthsWorked11
given unjustifiedAbsences0
given daysPerWeek5
given daysTaken0
expect daysCorridosEntitled0
expect daysEntitled0

Case 10 — N10 a six-day week gets more working days out of the same 30 corridos

given monthsWorked12
given unjustifiedAbsences0
given daysPerWeek6
given daysTaken0
expect daysEntitled25.7

Case 11 — N11 days already taken come off the remainder

given monthsWorked12
given unjustifiedAbsences0
given daysPerWeek5
given daysTaken10
expect daysRemaining11.4

Case 12 — N12 taking more than the entitlement never goes negative

given monthsWorked12
given unjustifiedAbsences24
given daysPerWeek5
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 Brazil férias calculator

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