feat(commercial) : types d'adresse Courtier et Distributeur (ERP-119)
Ajoute deux types d'adresse autonomes (exclusifs, comme la Prospection) : - back : colonnes is_broker / is_distributor sur client_address (migration modulaire, append + 2 CHECK miroir d'exclusivite + COMMENT ON COLUMN), proprietes ClientAddress (getters Groups + SerializedName), Callback validateExclusiveAddressTypes, validateAddressTypeRequired etendue, catalogue des commentaires SQL mis a jour. - front : type AddressType (+broker/distributor), drapeaux, mappers, option du select Type d'adresse, labels i18n, payloads create/edit et lecture. - tests back (acceptation + exclusivite + contrat de serialisation) et front.
This commit is contained in:
@@ -351,6 +351,88 @@ final class ClientAddressTest extends AbstractCommercialApiTestCase
|
||||
self::assertSame('Le type d\'adresse est obligatoire.', $byPath['isProspect']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Nouveaux types d'adresse (ERP-119) : Courtier et Distributeur sont acceptes
|
||||
* comme types autonomes (avec site + categorie). is_broker / is_distributor.
|
||||
*/
|
||||
public function testBrokerAddressAccepted(): void
|
||||
{
|
||||
$this->skipIfSitesModuleDisabled();
|
||||
$client = $this->createAdminClient();
|
||||
$seed = $this->seedClient('Address Broker Type');
|
||||
$category = $this->createCategory('SECTEUR');
|
||||
|
||||
$client->request('POST', '/api/clients/'.$seed->getId().'/addresses', [
|
||||
'headers' => ['Content-Type' => self::LD],
|
||||
'json' => [
|
||||
'isBroker' => true,
|
||||
'postalCode' => '86100',
|
||||
'city' => 'Châtellerault',
|
||||
'street' => '1 rue du Test',
|
||||
'sites' => [$this->firstSiteIri()],
|
||||
'categories' => ['/api/categories/'.$category->getId()],
|
||||
],
|
||||
]);
|
||||
|
||||
self::assertResponseStatusCodeSame(201);
|
||||
}
|
||||
|
||||
public function testDistributorAddressAccepted(): void
|
||||
{
|
||||
$this->skipIfSitesModuleDisabled();
|
||||
$client = $this->createAdminClient();
|
||||
$seed = $this->seedClient('Address Distributor Type');
|
||||
$category = $this->createCategory('SECTEUR');
|
||||
|
||||
$client->request('POST', '/api/clients/'.$seed->getId().'/addresses', [
|
||||
'headers' => ['Content-Type' => self::LD],
|
||||
'json' => [
|
||||
'isDistributor' => true,
|
||||
'postalCode' => '86100',
|
||||
'city' => 'Châtellerault',
|
||||
'street' => '1 rue du Test',
|
||||
'sites' => [$this->firstSiteIri()],
|
||||
'categories' => ['/api/categories/'.$category->getId()],
|
||||
],
|
||||
]);
|
||||
|
||||
self::assertResponseStatusCodeSame(201);
|
||||
}
|
||||
|
||||
/**
|
||||
* Courtier / Distributeur sont des types AUTONOMES exclusifs : les combiner avec
|
||||
* un autre usage (ici Livraison) -> 422, violation sur isProspect (mappee sous le
|
||||
* select Type d'adresse). Miroir applicatif du CHECK chk_client_address_broker_exclusive.
|
||||
*/
|
||||
public function testExclusiveAddressTypeRejected(): void
|
||||
{
|
||||
$this->skipIfSitesModuleDisabled();
|
||||
$client = $this->createAdminClient();
|
||||
$seed = $this->seedClient('Address Broker Mix');
|
||||
$category = $this->createCategory('SECTEUR');
|
||||
|
||||
$body = $client->request('POST', '/api/clients/'.$seed->getId().'/addresses', [
|
||||
'headers' => ['Content-Type' => self::LD, 'Accept' => self::LD],
|
||||
'json' => [
|
||||
'isBroker' => true,
|
||||
'isDelivery' => true,
|
||||
'postalCode' => '86100',
|
||||
'city' => 'Châtellerault',
|
||||
'street' => '1 rue du Test',
|
||||
'sites' => [$this->firstSiteIri()],
|
||||
'categories' => ['/api/categories/'.$category->getId()],
|
||||
],
|
||||
])->toArray(false);
|
||||
|
||||
self::assertResponseStatusCodeSame(422);
|
||||
$byPath = [];
|
||||
foreach ($body['violations'] ?? [] as $v) {
|
||||
$byPath[$v['propertyPath']] = $v['message'];
|
||||
}
|
||||
self::assertArrayHasKey('isProspect', $byPath);
|
||||
self::assertSame('Une adresse Courtier ne peut pas avoir d\'autre type.', $byPath['isProspect']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne l'IRI du premier site seede (fixtures Sites).
|
||||
*/
|
||||
|
||||
@@ -59,12 +59,18 @@ final class ClientSerializationContractTest extends AbstractCommercialApiTestCas
|
||||
self::assertArrayHasKey('isProspect', $address);
|
||||
self::assertArrayHasKey('isDelivery', $address);
|
||||
self::assertArrayHasKey('isBilling', $address);
|
||||
// Memes garanties pour les types Courtier / Distributeur (ERP-119, meme
|
||||
// pattern getter + SerializedName).
|
||||
self::assertArrayHasKey('isBroker', $address);
|
||||
self::assertArrayHasKey('isDistributor', $address);
|
||||
|
||||
// L'adresse seedee est livraison + facturation (prospect exclusif, RG-1.06).
|
||||
// Prouve qu'un booleen `true` est bien serialise (le bug masquait meme les true).
|
||||
self::assertFalse($address['isProspect']);
|
||||
self::assertTrue($address['isDelivery']);
|
||||
self::assertTrue($address['isBilling']);
|
||||
self::assertFalse($address['isBroker']);
|
||||
self::assertFalse($address['isDistributor']);
|
||||
}
|
||||
|
||||
// === #80 — Gating des RIB par accounting.view ===
|
||||
|
||||
Reference in New Issue
Block a user