fix(payfit): read absence dates as PayFit lists them

Problem

  1. 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.
  2. A leave imported from PayFit cannot be cancelled in Dokos, even when the connection is disabled or deleted (since !3289 (merged)).

Root cause

  1. PayFit lists startDate and endDate as {date, moment} objects (reference). The code expected a plain date and a separate startMoment / endMoment. getdate() then returned None. The test fixtures had the same wrong format, so the tests passed.
  2. The cancellation was refused for every leave that comes from PayFit, without a check of the connection.

Fix

  1. PayfitClient.list_absences splits both ends into plain fields. The fixtures now use the documented format.
  2. 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.

Merge request reports

Loading
Loading