diff --git a/src/Module/Commercial/Domain/Repository/ClientRepositoryInterface.php b/src/Module/Commercial/Domain/Repository/ClientRepositoryInterface.php index a5c43d7..0f6041f 100644 --- a/src/Module/Commercial/Domain/Repository/ClientRepositoryInterface.php +++ b/src/Module/Commercial/Domain/Repository/ClientRepositoryInterface.php @@ -20,8 +20,9 @@ interface ClientRepositoryInterface * - Tri par defaut : companyName ASC (RG-1.26). * - $search : recherche fuzzy insensible a la casse sur companyName + * lastName + email (metacaracteres LIKE echappes). Ignore si null/vide. - * - $categoryType : restreint aux clients possedant au moins une categorie - * du type donne (code). Ignore si null/vide. + * - $categoryCode : restreint aux clients possedant au moins une categorie + * du code donne (ERP-78 : filtrage par code de Category, plus par type). + * Ignore si null/vide. * * Filtrage centralise ICI (et non dans les providers/controllers) pour que * la liste paginee (ClientProvider) et l'export (ClientExportController) @@ -30,6 +31,6 @@ interface ClientRepositoryInterface public function createListQueryBuilder( bool $includeArchived = false, ?string $search = null, - ?string $categoryType = null, + ?string $categoryCode = null, ): QueryBuilder; } diff --git a/src/Module/Commercial/Infrastructure/ApiPlatform/State/Processor/ClientProcessor.php b/src/Module/Commercial/Infrastructure/ApiPlatform/State/Processor/ClientProcessor.php index f0c5c90..fa1f6c8 100644 --- a/src/Module/Commercial/Infrastructure/ApiPlatform/State/Processor/ClientProcessor.php +++ b/src/Module/Commercial/Infrastructure/ApiPlatform/State/Processor/ClientProcessor.php @@ -457,8 +457,9 @@ final class ClientProcessor implements ProcessorInterface /** * RG-1.03 : distributor et broker mutuellement exclusifs ; un distributor - * doit referencer un client de categorie DISTRIBUTEUR (idem broker -> - * COURTIER). + * doit referencer un client portant la categorie de code DISTRIBUTEUR (idem + * broker -> COURTIER). Depuis ERP-78, le filtrage se fait sur le code de la + * Category (et non plus sur le type, devenu unique CLIENT). */ private function validateDistributorBroker(Client $data): void { @@ -473,7 +474,7 @@ final class ClientProcessor implements ProcessorInterface ); } - if (null !== $distributor && !$this->hasCategoryType($distributor, 'DISTRIBUTEUR')) { + if (null !== $distributor && !$this->hasCategoryCode($distributor, 'DISTRIBUTEUR')) { $this->throwViolation( 'distributor', 'Le distributeur référencé doit être un client de catégorie DISTRIBUTEUR.', @@ -481,7 +482,7 @@ final class ClientProcessor implements ProcessorInterface ); } - if (null !== $broker && !$this->hasCategoryType($broker, 'COURTIER')) { + if (null !== $broker && !$this->hasCategoryCode($broker, 'COURTIER')) { $this->throwViolation( 'broker', 'Le courtier référencé doit être un client de catégorie COURTIER.', @@ -530,13 +531,13 @@ final class ClientProcessor implements ProcessorInterface } /** - * Vrai si au moins une categorie du client porte le type donne. S'appuie - * sur CategoryInterface::getCategoryTypeCode() (pas d'import de Category). + * Vrai si au moins une categorie du client porte le code donne. S'appuie sur + * CategoryInterface::getCode() (pas d'import de Category — regle ABSOLUE n°1). */ - private function hasCategoryType(Client $client, string $typeCode): bool + private function hasCategoryCode(Client $client, string $code): bool { foreach ($client->getCategories() as $category) { - if ($category instanceof CategoryInterface && $category->getCategoryTypeCode() === $typeCode) { + if ($category instanceof CategoryInterface && $category->getCode() === $code) { return true; } } diff --git a/src/Module/Commercial/Infrastructure/ApiPlatform/State/Provider/ClientProvider.php b/src/Module/Commercial/Infrastructure/ApiPlatform/State/Provider/ClientProvider.php index 8d7c640..8125e03 100644 --- a/src/Module/Commercial/Infrastructure/ApiPlatform/State/Provider/ClientProvider.php +++ b/src/Module/Commercial/Infrastructure/ApiPlatform/State/Provider/ClientProvider.php @@ -24,7 +24,7 @@ use Symfony\Component\DependencyInjection\Attribute\Autowire; * exclus au M1) — RG-1.25 ; * - tri par defaut companyName ASC — RG-1.26 ; * - filtres ?search=... (fuzzy companyName + lastName + email) et - * ?categoryType= (clients ayant >= 1 categorie de ce type) ; + * ?categoryCode= (clients ayant >= 1 categorie de ce code — ERP-78) ; * - pagination obligatoire (convention Starseed ERP-72) : Paginator ORM ; * echappatoire ?pagination=false pour alimenter un