Encoding French Employment Law in JavaScript: Severance Calculator
Employment law is inherently complex. In France, calculating severance pay involves navigating multiple legal texts, collective bargaining agreements, and edge cases that would make any engineer's head spin.
We built a calculator that translates legal requirements into executable code. The challenge: making law work like software.
The Legal Foundation
French severance law is spread across:
- French Labor Code (Articles L1234-1 to L1234-9) — Base rules
- 12+ Collective bargaining agreements — Sectoral variations
- Case law (jurisprudence) — Court interpretations
- European directives — Minimum standards
Each adds conditions. Each has exceptions. Each can override the previous tier.
The Base Formula
Legally, severance depends on:
- Seniority — Must have at least 8 days of effective work
- Dismissal reason — For "real and serious cause" (yes) vs. gross misconduct (no)
- Average salary — Previous 12 months of work
- Tenure brackets — Different rates apply at 2, 5, 10+ years
Simplified formula:
Severance = (Average Monthly Salary) × (Tenure Factor)
Where Tenure Factor =
- 0 if < 2 years
- 1/4 month if 2-5 years
- 1/2 month if 5-10 years
- 2/3 month if 10+ years
The Complexity Layers
Layer 1: Eligibility Rules
Not everyone gets severance. Excluded reasons include gross misconduct, serious misconduct, resignation, temp contract end, and probation termination.
Layer 2: Salary Calculation
This is where most implementations fail. The legal definition of "severance salary" includes base salary, 13th-month bonuses, profit-sharing, and sales commissions—but excludes exceptional bonuses, expense reimbursements, meal vouchers, and company cars.
The reference period: Exactly 12 months of effective work immediately before dismissal.
Layer 3: Tenure Calculation
Counting years of service should be simple. It isn't. What counts: all days worked, unpaid leave, sick leave, maternity/parental leave. What doesn't: time between contracts, unpaid suspension.
Layer 4: Collective Bargaining Variations
Most collective agreements offer better terms than the legal minimum.
Example: Retail sector collective agreement
1-2 years: 1 month's salary
2-5 years: 1 month's salary
5-10 years: 1.5 months' salary
10+ years: 2 months' salary
Example: Healthcare collective agreement
1-2 years: 0.5 months' salary
2-5 years: 1 month's salary
5-10 years: 2 months' salary
10+ years: 3 months' salary
The Hard Edge Cases
Case 1: Part-Time to Full-Time Transition
If an employee transitioned from 20 hours/week to 39 hours/week mid-career, how do you calculate severance?
Answer: Pro-rata. Weight each period by hours worked.
Case 2: Commission-Based Employees
For sales staff, commissions can be volatile. The law says to use "normal earned remuneration."
Answer: Use a 3-year lookback to establish "normal" commission level. Use median (less affected by outliers) rather than mean.
Case 3: Undocumented Overtime
Some roles involve chronic unpaid overtime. Courts have ruled this counts as part of "normal" salary.
Answer: Document it and add it to the severance base.
Testing Against Real Law
You can't ship a severance calculator without validation against actual legal requirements.
Our test suite includes 63 test cases, each cross-referenced to a specific legal article:
Test case: SMIC worker, 3 years, economic dismissal, retail agreement
- Expected: 1 month salary (retail agreement: 3 years = 1 month)
Test case: Executive, 12 years, legal minimum
- Expected: 5000 × 2/3 = 3333.33 EUR (legal cap at 2/3)
Handling Opacity
The hardest part: employees often don't know their own salary structure.
Most French payslips don't clearly separate recurring vs. exceptional elements. Our solution:
- Upload payslips (PDF parsing)
- Auto-extract salary components
- Flag uncertain items for user confirmation
- Explain which items are included in severance calculation
Results
- 12 collective agreements supported
- 47 test cases per agreement
- 3 lawyers validated the implementation
- 250+ calculations processed monthly
Key Lessons
- Law is logic. Frame it as decision trees + formulas. Version it like code.
- Context matters. The same fact ("3 years employment") has different legal weight depending on sector and dismissal reason.
- Transparency builds trust. Show your work. Employees want to understand why they got X euros, not Y.
- Edge cases are features. Handling pro-rata, undocumented overtime, and commission volatility is what separates useful from toy.
Try the calculator at indemnite-licenciement.fr.
Have you encoded complex legal rules into software? What was your biggest surprise? Drop a comment—I'd love to hear from other engineers building compliance tools.
Top comments (0)