How the Bangladesh বাৎসরিক ছুটি (annual leave) calculator is verified

Inputs

InputFieldType
Months of continuous service with this employerserviceMonthsnumber
Days you worked in the previous twelve monthsdaysWorkednumber
Where you workestablishmentstring
Adolescent worker (aged 14 to 17)adolescentboolean
Days already taken this leave yeardaysTakennumber

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)
Days EntitleddaysEntitled($per := establishment = 'newspaper' ? $const.newspaperDaysPerLeaveDay : (establishment = 'teaGarden' ? (adolescent ? $const.adolescentTeaDaysPerLeaveDay : $const.adultTeaDaysPerLeaveDay) : ((adolescent and establishment != 'roadTransport') ? $const.adolescentDaysPerLeaveDay : $const.adultDaysPerLeaveDay)); $d := $min([$max([0, $n(daysWorked)]), $const.maxDaysInTwelveMonths]); $n(serviceMonths) >= $const.qualifyingMonths ? $floor($d / $per) : 0)
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
qualifyingMonths12
adultDaysPerLeaveDay18
adultTeaDaysPerLeaveDay22
newspaperDaysPerLeaveDay11
adolescentDaysPerLeaveDay14
adolescentTeaDaysPerLeaveDay18
maxDaysInTwelveMonths366

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 — L1 288 days worked in a shop or factory after two years: 16 days

given serviceMonths24
given daysWorked288
given establishmentshopFactory
given adolescentno
given daysTaken0
expect daysEntitled16
expect daysRemaining16

Case 2 — L2 300 days: still 16, part of 18 days earns nothing

given serviceMonths24
given daysWorked300
given establishmentshopFactory
given adolescentno
given daysTaken0
expect daysEntitled16

Case 3 — L3 tea garden, 286 days: one per 22 = 13

given serviceMonths24
given daysWorked286
given establishmentteaGarden
given adolescentno
given daysTaken0
expect daysEntitled13

Case 4 — L4 newspaper worker, 286 days: one per 11 = 26

given serviceMonths24
given daysWorked286
given establishmentnewspaper
given adolescentno
given daysTaken0
expect daysEntitled26

Case 5 — L5 adolescent in a factory, 280 days: one per 14 = 20

given serviceMonths24
given daysWorked280
given establishmentshopFactory
given adolescentyes
given daysTaken0
expect daysEntitled20

Case 6 — L6 adolescent in a tea garden, 288 days: one per 18 = 16

given serviceMonths24
given daysWorked288
given establishmentteaGarden
given adolescentyes
given daysTaken0
expect daysEntitled16

Case 7 — L7 eleven months of service: no annual leave yet

given serviceMonths11
given daysWorked288
given establishmentshopFactory
given adolescentno
given daysTaken0
expect daysEntitled0

Case 8 — L8 exactly twelve months qualifies

given serviceMonths12
given daysWorked288
given establishmentshopFactory
given adolescentno
given daysTaken0
expect daysEntitled16

Case 9 — L9 days taken come off the remainder

given serviceMonths24
given daysWorked288
given establishmentshopFactory
given adolescentno
given daysTaken5
expect daysRemaining11

Case 10 — L10 the remainder never goes negative

given serviceMonths24
given daysWorked288
given establishmentshopFactory
given adolescentno
given daysTaken30
expect daysRemaining0

Case 11 — L11 adolescent in road transport: s.117(2) lists no rate, the adult 1 per 18 is shown (288 → 16)

given serviceMonths24
given daysWorked288
given establishmentroadTransport
given adolescentyes
given daysTaken0
expect daysEntitled16

Case 12 — L12 adult in road transport, 288 days: 16

given serviceMonths24
given daysWorked288
given establishmentroadTransport
given adolescentno
given daysTaken0
expect daysEntitled16

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 Bangladesh বাৎসরিক ছুটি (annual leave) calculator

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