tristan
27f2dcd4c0
fix(commercial) : retrait RG-1.04 (onglet Information facultatif pour tous)
...
L'onglet Information n'est plus obligatoire pour le role metier Commerciale : il devient facultatif pour tous les roles, cote back comme cote front (le front l'etait deja).
- Suppression du validateur ClientInformationCompletenessValidator et de son gating (validateInformationCompleteness / currentUserIsCommerciale) dans ClientProcessor. Security conserve (gating accounting/archive/manage).
- Tests : retrait des 3 tests RG-1.04 (ClientProcessorTest) ; POST Commerciale attendu en 201 et suppression du test dedie (ClientRBACMatrixTest).
- Coherence : commentaires de colonnes BDD (catalogue + migration d'init) passes a « Facultatif », nettoyage des references RG-1.04 (BusinessRoles, RbacSeeder, User, fixtures, front, specs M1, README). Le role metier Commerciale et ses permissions RBAC restent inchanges.
- Pas de migration de schema (colonnes Information deja nullable).
2026-06-08 12:17:16 +02:00
matthieu
56cf492dcc
[ERP-53] Migrer les tables Client + sous-collections + référentiels comptables ( #27 )
...
Auto Tag Develop / tag (push) Failing after 20s
## Contexte
Ticket Lesstime : **#53** (ERP-53) — premier ticket back du M1 (Répertoire clients).
Spec back : `docs/specs/M1-clients/spec-back.md` § 3.2 + § 3.3.
## Implémentation
- Migration Doctrine `migrations/Version20260601000000.php` (12 tables) + fixture `CategoryTypeFixtures`.
- **4 référentiels comptables** seedés : `tva_mode` (3), `payment_delay` (3), `payment_type` (4), `bank` (3).
- **Table `client`** : 31 colonnes (formulaire + Information + Comptabilité + archive + soft-delete + Timestampable/Blamable).
- **4 sous-collections** : `client_category` (M2M), `client_contact`, `client_address`, `client_rib` + **3 jointures** d'adresse (`client_address_site`, `client_address_contact`, `client_address_category`).
- **4 CHECK** : mutex distributor/broker, contact name, address prospect exclusif, billing email conditionnel.
- **1 index partiel unique** : `uq_client_company_name_active` sur `LOWER(company_name) WHERE is_archived=false AND deleted_at IS NULL` (décision Q4 — **pas** d'unicité siren/email).
- **Seed `category_type`** : DISTRIBUTEUR / COURTIER / SECTEUR / AUTRE (`ON CONFLICT (code) DO NOTHING` en migration pour la prod, + fixture idempotente pour dev/test purgés).
- `COMMENT ON COLUMN` sur **chaque** colonne (convention ERP-67, garde-fou vert).
## RG couvertes (niveau BDD)
RG-1.03 (mutex distrib/broker), RG-1.05 (contact name), RG-1.06/07/08 (adresse prospect exclusif), RG-1.11 (billing email), RG-1.16 (unicité company_name — RG-1.15/1.17 supprimées par Q4), RG-1.22 (is_archived + archived_at).
## Écarts assumés vs spec (cf. docblock migration + cahier de test du ticket)
1. **Namespace `migrations/` racine** au lieu de `App\Module\Commercial\…` : vérifié empiriquement que Doctrine 3.9.6 (AlphabeticalComparator → strcmp FQCN) trierait le namespace Commercial **avant** `DoctrineMigrations` → migration client exécutée avant user/category/site → échec FK sur base vide. Le namespace racine garantit l'ordre par timestamp.
2. **DDL aligné Doctrine** : `INT GENERATED BY DEFAULT AS IDENTITY` + `TIMESTAMP(0) WITHOUT TIME ZONE` (et non SERIAL/TIMESTAMPTZ) → forward-compatible avec les entités du ticket 1.1 (schema:update no-op).
3. **Seed `category_type (code, label)` sans `position`** : la table M0 n'a pas de colonne `position` (coquille du pseudo-SQL § 3.3).
> **Note ERP-54** : à l'arrivée des entités Client*, `schema:update` droppera leurs COMMENT + l'index partiel. Prévoir l'ajout au `ColumnCommentsCatalog` + recréation de l'index dans `test-db-setup` (pattern `uq_category_name_type_active`).
## Tests
- `make php-cs-fixer-allow-risky` ✓
- `make db-reset` ✓ + vérifications psql manuelles (8 cas : CHECK, unicité partielle, archivage, siren/email dupliqués, seeds)
- `make test` ✓ — **312 tests OK, 0 régression**
---------
Co-authored-by: Matthieu <contact@malio.fr >
Co-authored-by: Matthieu <mtholot19@gmail.com >
Reviewed-on: #27
Co-authored-by: THOLOT DECHENE Matthieu <matthieu@yuno.malio.fr >
Co-committed-by: THOLOT DECHENE Matthieu <matthieu@yuno.malio.fr >
2026-06-01 15:19:43 +00:00