Loading
fix(payfit): read absence dates as PayFit lists them
Problem
- The leave synchronisation fails on the absence format that PayFit documents. Half days are not seen, and a push retry can create the same absence twice.
- A leave imported from PayFit cannot be cancelled in Dokos, even when the connection is disabled or deleted (since !3289 (merged)).
Root cause
- PayFit lists
startDateandendDateas{date, moment}objects (reference). The code expected a plain date and a separatestartMoment/endMoment.getdate()then returnedNone. The test fixtures had the same wrong format, so the tests passed. - The cancellation was refused for every leave that comes from PayFit, without a check of the connection.
Fix
PayfitClient.list_absencessplits both ends into plain fields. The fixtures now use the documented format.- The cancellation is refused only while the connection is enabled with leave synchronisation.
If the synchronisation is enabled again and PayFit still lists the absence inside the synchronised period, the leave is imported again.
Tests
- New tests for the format conversion and for the cancellation with an inactive synchronisation.
- Not run locally: the shared test site was busy. This MR relies on the pipeline.
- Not tested with a real PayFit account.
The two fixes are separate commits. The first bug is also in the absences.py of v5. The second one is only on develop.