Kaynağa Gözat

switch dolibarr client to prospect on organization deletion

Olivier Massot 11 ay önce
ebeveyn
işleme
835f5ffed2

+ 6 - 5
src/Service/Dolibarr/DolibarrApiService.php

@@ -214,16 +214,17 @@ class DolibarrApiService extends ApiRequestService
      * @throws JsonException
      * @throws TransportExceptionInterface
      */
-    public function deleteDolibarrSociety(int $organizationId): void
+    public function switchSocietyToProspect(int $organizationId): void
     {
-        SecurityUtils::preventIfNotLocalhost();
-
         $socId = $this->getSociety($organizationId)['id'];
 
-        $res = $this->delete("thirdparties/$socId");
+        $res = $this->put(
+            "thirdparties/$socId",
+            ["client" => 2],
+        );
 
         if ($res->getStatusCode() !== 200) {
-            throw new HttpException($res->getStatusCode(), 'Error while deleting the organization from Dolibarr');
+            throw new HttpException($res->getStatusCode(), 'Error while updating the society in Dolibarr');
         }
     }
 }

+ 4 - 4
src/Service/Organization/OrganizationFactory.php

@@ -644,9 +644,9 @@ class OrganizationFactory
         }
 
         try {
-            $this->deleteDolibarrSociety($organization);
+            $this->switchSocietyToProspect($organization);
         } catch (\Exception $e) {
-            $this->logger->critical("An error happened while deleting the Dolibarr society, please proceed manually.");
+            $this->logger->critical("An error happened while updating the Dolibarr society, please proceed manually.");
             $this->logger->debug($e);
             $withError = true;
         }
@@ -731,9 +731,9 @@ class OrganizationFactory
 //        $this->typo3Service->deleteSite($organization->getId());
     }
 
-    protected function deleteDolibarrSociety(Organization $organization): void
+    protected function switchSocietyToProspect(Organization $organization): void
     {
-        $this->dolibarrApiService->deleteDolibarrSociety($organization->getId());
+        $this->dolibarrApiService->switchSocietyToProspect($organization->getId());
     }
 
     protected function deleteLocalDirectories(Organization $organization): void