US trucking · Case study · 2 min read
Driver pay that adds up
Truck drivers are paid every week from the loads they haul. We fixed payslips that printed one thing and totalled another, and built a tool that finds pay that went missing on the way.
- Type
- Payroll fix and audit tool
- Built with
- Laravel, MariaDB
- Our part
- The fix, the reconcile tool and the investigation behind both
The problem
Drivers are paid weekly from the loads they hauled, minus deductions such as an advance paid back in instalments. A payslip listed the advance as a line, but the total left it out, so the net pay on the PDF and the spreadsheet came out higher than on the screen. The screen was right. The driver gets the download.
And the download was a file saved when the week was generated, so a number fixed on screen did nothing for the payslip already sent.
What we built
- One list for every number. The deduction lines, the total and the record of what was repaid now all come from the same list of instalments. A payslip can't disagree with itself any more, and generating a week again gives the same result.
- A reconcile tool. Extra pay, such as a cancellation fee or detention, has to travel from the load into the driver's pay record before payroll sees it. The tool compares the two for every load and lists each mismatch, with the driver's pay week and whether that week was already paid. By default it only reports. Told to fix, it corrects the load's pay record and adds the difference as a correction in a week that's still open, instead of reopening one that was paid. Running it twice never books the same load twice.
The hard part
The first fix was wrong. It made generating a week repeatable, and the payslip still disagreed. The real cause was two calculations of the same deduction, one for the lines and one for the total. They agreed until an instalment was marked as repaid; then the total dropped it while the line kept printing it.
The second was a rule, not a bug. A paid week is history: change it and the payslip a driver already has becomes wrong. So corrections go forward, as new entries, and the old week stays as it was.
Where it is now
Live. The first run of the reconcile tool found 41 loads whose pay record didn't match the fees on the load, every one from before a fix in July. Nothing has drifted since. The bigger version, where every change to pay is its own entry in a ledger, is designed and not built yet.