Skip to Content
MAFA Group · Odoo 17

Payroll that was off by half a day, every month

Four parts of the system each decided what counted as a working day. We replaced them with one classifier everything reads from.

Led by Umar · ~28,000 LOC
Odoo 17 Python OWL

The problem a client brought us

“Payroll is wrong. Not by much — half a day, for a handful of people, every month — and we can't find the bug.”

Before and after

Four places deciding what a working day is

  • Payslip engine
  • Attendance dashboard
  • Monthly report
  • Leave module

One definition everyone calls

Canonical day classifier

What we found and built

The bug wasn't arithmetic. Four separate parts of the system — the payslip engine, the attendance dashboard, the monthly report, and the leave module — each independently decided what counted as a working day. An employee with a half-day of attendance and a half-day of leave got credited for both.

We replaced all four with one canonical day classifier everything else now reads from — fractional payable-day accounting, a Saudi-labour-law overtime engine, and a redesigned payroll report suite, backed by 19 automated tests.

Result

The discrepancy stopped. It's now the largest, most heavily tested module in the codebase.

The pattern behind it

One definition everyone calls

When several parts of a system each decide the same fact, they eventually disagree. We don't add a fourth opinion — we collapse the disagreement into one definition and make everything else read from it.

How we think about problems

Recognise any of this?

Most of our work starts with a message that sounds a lot like this one did.