6f9bb68170
Auto Tag Develop / tag (push) Successful in 7s
## ERP-92 — Tests PHPUnit M2 fournisseurs (#521) Suite fonctionnelle M2 assertant sur le **corps JSON** (jamais les annotations), jumelle de la suite clients M1. ### Couverture - **Contrat de sérialisation** (`SupplierSerializationContractTest`) : 4 régressions M1 re-testées — RIB gaté **absent** pour la Commerciale, booléens `triageProvider`/`isArchived` présents, embed `categories[].code/name`, embed `sites[].name/postalCode` (objet, pas IRI) — + enveloppe AP4 (`member`/`totalItems`/`view`, archivés exclus) + suppression du contact inline. - **Matrice RBAC réelle** (`app:seed-rbac`, pas de mock) : bureau/compta/commerciale/usine 200/403, gating `accounting` par **omission de clé**, mode strict PATCH (RG-2.16). - **Matrice RG-2.03 → RG-2.17** (création, normalisation RG-2.12, catégorie FOURNISSEUR RG-2.10, unicité RG-2.11, archivage RG-2.14/2.15, RG-2.07/2.08 compta, sous-ressources RG-2.04/2.05/2.06/2.09). - **Anti N+1 liste** : nombre de requêtes constant entre 2 et 4 fournisseurs. **Audit** Supplier + RIB (`iban`/`bic` dans le diff). ### Fix de contrat (découvert par la DoD) Les référentiels comptables (`TvaMode`/`PaymentType`/`PaymentDelay`/`Bank`) ne portaient que `client:read:accounting` (M1) → sur un fournisseur ils sortaient en **IRI nu**. Ajout de `supplier:read:accounting` → objet `{id, code, label}` embarqué (additif, zéro impact M1). Sans ce fix, #95/#96 auraient été développés contre un contrat faux. ### Infra `makefile` : `test-db-setup` recrée l'index partiel `uq_supplier_company_name_active` (droppé par `schema:update` comme celui du client — oubli M2). ### DoD ✅ § 4.0.bis : réponses JSON **réelles** (liste + détail admin/commerciale) collées. Front #93→#96 peuvent démarrer. ### Vérifs - `make test` : **574 tests OK** (suite complète verte) - `make php-cs-fixer-allow-risky` : 0 correction --------- Co-authored-by: Matthieu <contact@malio.fr> Reviewed-on: #71 Co-authored-by: THOLOT DECHENE Matthieu <matthieu@yuno.malio.fr> Co-committed-by: THOLOT DECHENE Matthieu <matthieu@yuno.malio.fr>
107 lines
3.2 KiB
PHP
107 lines
3.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Module\Commercial\Domain\Entity;
|
|
|
|
use ApiPlatform\Metadata\ApiResource;
|
|
use ApiPlatform\Metadata\Get;
|
|
use ApiPlatform\Metadata\GetCollection;
|
|
use App\Module\Commercial\Infrastructure\Doctrine\DoctrinePaymentDelayRepository;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Symfony\Component\Serializer\Attribute\Groups;
|
|
|
|
/**
|
|
* Delai de reglement applique a un client (15 jours, 30 jours, a reception) :
|
|
* referentiel statique seede par la migration M1 et re-seede en dev/test par
|
|
* CommercialReferentialFixtures.
|
|
*
|
|
* Lecture seule au M1 (HP-M2-2) : GetCollection + Get uniquement (ERP-56),
|
|
* permission commercial.clients.view ; POST/PATCH/DELETE -> 405. Pas de
|
|
* Timestampable/Blamable (referentiel statique whiteliste dans
|
|
* EntitiesAreTimestampableBlamableTest::EXCLUDED). Le groupe
|
|
* `client:read:accounting` permet l'embarquement dans la reponse Client ;
|
|
* `supplier:read:accounting` dans la reponse Fournisseur (M2, ERP-92 — § 4.0).
|
|
*/
|
|
#[ApiResource(
|
|
operations: [
|
|
new GetCollection(
|
|
security: "is_granted('commercial.clients.view') or is_granted('commercial.suppliers.view')",
|
|
normalizationContext: ['groups' => ['payment_delay:read']],
|
|
// Tri par defaut spec M1 § 4.7 : position ASC puis label ASC.
|
|
order: ['position' => 'ASC', 'label' => 'ASC'],
|
|
// ERP-72 : pagination serveur + toggle ?pagination=false (cf. TvaMode).
|
|
paginationClientEnabled: true,
|
|
),
|
|
new Get(
|
|
security: "is_granted('commercial.clients.view') or is_granted('commercial.suppliers.view')",
|
|
normalizationContext: ['groups' => ['payment_delay:read']],
|
|
),
|
|
],
|
|
security: "is_granted('commercial.clients.view') or is_granted('commercial.suppliers.view')",
|
|
)]
|
|
#[ORM\Entity(repositoryClass: DoctrinePaymentDelayRepository::class)]
|
|
#[ORM\Table(name: 'payment_delay')]
|
|
#[ORM\UniqueConstraint(name: 'uq_payment_delay_code', columns: ['code'])]
|
|
class PaymentDelay
|
|
{
|
|
#[ORM\Id]
|
|
#[ORM\GeneratedValue]
|
|
#[ORM\Column]
|
|
#[Groups(['payment_delay:read', 'client:read:accounting', 'supplier:read:accounting'])]
|
|
private ?int $id = null;
|
|
|
|
#[ORM\Column(length: 30)]
|
|
#[Groups(['payment_delay:read', 'client:read:accounting', 'supplier:read:accounting'])]
|
|
private ?string $code = null;
|
|
|
|
#[ORM\Column(length: 120)]
|
|
#[Groups(['payment_delay:read', 'client:read:accounting', 'supplier:read:accounting'])]
|
|
private ?string $label = null;
|
|
|
|
#[ORM\Column(options: ['default' => 0])]
|
|
#[Groups(['payment_delay:read'])]
|
|
private int $position = 0;
|
|
|
|
public function getId(): ?int
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function getCode(): ?string
|
|
{
|
|
return $this->code;
|
|
}
|
|
|
|
public function setCode(string $code): static
|
|
{
|
|
$this->code = $code;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getLabel(): ?string
|
|
{
|
|
return $this->label;
|
|
}
|
|
|
|
public function setLabel(string $label): static
|
|
{
|
|
$this->label = $label;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getPosition(): int
|
|
{
|
|
return $this->position;
|
|
}
|
|
|
|
public function setPosition(int $position): static
|
|
{
|
|
$this->position = $position;
|
|
|
|
return $this;
|
|
}
|
|
}
|