Olivier Massot před 3 roky
rodič
revize
d96e90fc29

+ 5 - 4
src/Service/Cotisation/Utils.php

@@ -113,18 +113,19 @@ class Utils
 
     /**
      * Retourne dans quelle année de cotisation on est aujourd'hui
+     * @param \DateTime|null $date
      * @return int
      * @throws \Exception
      * @see UtilsTest::testGetCurrentCotisationYear()
      */
-    public function getCurrentCotisationYear(): int {
-        $today = new \DateTime('now');
-        $year = intval($today->format('Y'));
+    public function getCurrentCotisationYear(\DateTime $date = null): int {
+        $date = $date ?? new \DateTime('now');
+        $year = (int)$date->format('Y');
 
         $base_date = new \DateTime($year . '-09-01');
         $dateStart = new \DateTime($year . '-01-01');
 
-        if ($today >= $dateStart && $today <= $base_date) {
+        if ($date >= $dateStart && $date <= $base_date) {
             $cotisationYear = $year;
         } else {
             $cotisationYear = $year + 1;

+ 3 - 4
src/Service/Dolibarr/DolibarrSyncService.php

@@ -711,18 +711,17 @@ class DolibarrSyncService
 
     /**
      * Post-validation of the execution of the operation.
+     * Compare the actual result to the expected one to ensure that the data was correctly updated.
+     *
      * In the case of a validation error, throw an HttpException
      *
      * @param ResponseInterface $response
      * @param BaseRestOperation $operation
      * @throws RuntimeException
      */
-    protected function validateResponse(ResponseInterface $response, BaseRestOperation $operation): void
+    protected function validateResponse(ResponseInterface $response, UpdateOperation | CreateOperation $operation): void
     {
         $updated = $operation->getData();
-        if ($updated === null) {
-            return;
-        }
 
         try {
             $responseData = $response->toArray();