Bladeren bron

dolibarr sync : minors fixes

Olivier Massot 3 jaren geleden
bovenliggende
commit
e470aed684

+ 1 - 0
src/Enum/Access/FunctionEnum.php

@@ -122,6 +122,7 @@ class FunctionEnum extends Enum
             self::DIRECTOR,
             self::DIRECTOR_ASSISTANT,
             self::SECRETARY,
+            self::ASSISTANT_SECRETARY,
             self::TREASURER,
             self::TREASURER_ASSISTANT,
             self::ADMINISTRATIVE_OFFICER,

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

@@ -465,8 +465,10 @@ class DolibarrSyncService
         foreach ($dolibarrContacts as $contactData) {
             if (
                 !($contactData["array_options"]["options_2iopen_person_id"] ?? null) &&
-                $person->getName() === $contactData["lastname"] &&
-                $person->getGivenName() === $contactData["firstname"]
+                $person->getName() !== null &&
+                $person->getGivenName() !== null &&
+                strtolower($person->getName() ?? '') === strtolower($contactData["lastname"] ?? '') &&
+                strtolower($person->getGivenName() ?? '') === strtolower($contactData["firstname"] ?? '')
             ) {
                 return $contactData;
             }

+ 1 - 1
tests/Service/Dolibarr/DolibarrSyncServiceTest.php

@@ -390,7 +390,7 @@ class DolibarrSyncServiceTest extends TestCase
         // Find by full name (contact already has another person id, it should not be returned)
         $person2 = $this->getMockBuilder(Person::class)->getMock();
         $person2->method('getId')->willReturn(-1);
-        $person2->method('getName')->willReturn('DUPONT');
+        $person2->method('getName')->willReturn('dupont');
         $person2->method('getGivenName')->willReturn('Valerie');
 
         $contact2 = TestableDolibarrSyncService::findDolibarrContactFor($contacts, $person2);