feat(logistique) : pesée pont bascule stub + DSD + endpoint (ERP-184) #134

Merged
matthieu merged 1 commits from feat/erp-184-pesee-pont-bascule into develop 2026-06-18 12:47:07 +00:00
Owner

ERP-184 (M5 · 1.4) — Pesée pont bascule (stub + DSD + endpoint)

Spec : docs/specs/M5-tickets-pesee/spec-back.md (§ 2.6, § 2.7, § 4.2). Prérequis : ERP-182/183.

Contenu

  • WeighbridgeReaderInterface (contrat domaine) + RandomWeighbridgeReader : stub du pont (aucune liaison matérielle), poids aléatoire ∈ [10000,50000] kg (RG-5.06). Driver réel = hors périmètre (HP-M5-02), substituable derrière l'interface.
  • WeighbridgeUnavailableException (domaine pure) → traduite en HTTP 503 par le Processor.
  • DsdAllocator : compteur DSD par site (weighbridge_dsd_counter), incrément sous verrou ligne SELECT ... FOR UPDATE en transaction (RG-5.04). AUTO et MANUAL = dernier + 1.
  • Endpoint POST /api/weighbridge_readings : ressource virtuelle WeighbridgeReadingResource + WeighbridgeReadingProcessor (pas de controller, statut 200).
    • {mode: AUTO}{weight, dsd, mode} (site courant via CurrentSiteProviderInterface).
    • {mode: MANUAL, weight, manualNumber}{weight, dsd, manualNumber, mode}.
    • Pont indisponible → 503 « Pont bascule indisponible — passez en pesée manuelle ».
    • Sécurité is_granted('logistique.weighing_tickets.manage').
  • Le dsd renvoyé est prévisionnel : attribution autoritaire refaite à la création du ticket (ERP-185).

Tests (make test 811 tests OK)

  • WeighbridgeReaderStubTest : poids borné [10000,50000], DSD délégué.
  • DsdAllocatorTest : incrément séquentiel + isolation par site (DBAL réel).
  • WeighbridgeReadingProcessorTest : AUTO / MANUAL / 503 / 400 (sans site courant).
  • WeighbridgeReadingApiTest : RBAC (403 sans manage), AUTO/MANUAL 200, 422 (mode invalide / poids manquant en manuel).
  • make php-cs-fixer-allow-risky

Note : l'appel curl manuel via nginx est bloqué par un 405 nginx sur POST /login_check (config proxy dev, indépendante de cette feature) ; le bout-en-bout est couvert par WeighbridgeReadingApiTest (vrai kernel, auth /login_check).

## ERP-184 (M5 · 1.4) — Pesée pont bascule (stub + DSD + endpoint) Spec : `docs/specs/M5-tickets-pesee/spec-back.md` (§ 2.6, § 2.7, § 4.2). Prérequis : ERP-182/183. ### Contenu - **`WeighbridgeReaderInterface`** (contrat domaine) + **`RandomWeighbridgeReader`** : stub du pont (aucune liaison matérielle), poids aléatoire ∈ [10000,50000] kg (RG-5.06). Driver réel = hors périmètre (HP-M5-02), substituable derrière l'interface. - **`WeighbridgeUnavailableException`** (domaine pure) → traduite en **HTTP 503** par le Processor. - **`DsdAllocator`** : compteur DSD **par site** (`weighbridge_dsd_counter`), incrément sous **verrou ligne `SELECT ... FOR UPDATE`** en transaction (RG-5.04). AUTO et MANUAL = `dernier + 1`. - **Endpoint `POST /api/weighbridge_readings`** : ressource virtuelle `WeighbridgeReadingResource` + `WeighbridgeReadingProcessor` (**pas de controller**, statut 200). - `{mode: AUTO}` → `{weight, dsd, mode}` (site courant via `CurrentSiteProviderInterface`). - `{mode: MANUAL, weight, manualNumber}` → `{weight, dsd, manualNumber, mode}`. - Pont indisponible → **503** « Pont bascule indisponible — passez en pesée manuelle ». - Sécurité `is_granted('logistique.weighing_tickets.manage')`. - Le `dsd` renvoyé est **prévisionnel** : attribution autoritaire refaite à la création du ticket (ERP-185). ### Tests (`make test` ✅ 811 tests OK) - `WeighbridgeReaderStubTest` : poids borné [10000,50000], DSD délégué. - `DsdAllocatorTest` : incrément séquentiel + isolation par site (DBAL réel). - `WeighbridgeReadingProcessorTest` : AUTO / MANUAL / 503 / 400 (sans site courant). - `WeighbridgeReadingApiTest` : RBAC (403 sans `manage`), AUTO/MANUAL 200, 422 (mode invalide / poids manquant en manuel). - `make php-cs-fixer-allow-risky` ✅ > Note : l'appel curl manuel via nginx est bloqué par un 405 nginx sur `POST /login_check` (config proxy dev, indépendante de cette feature) ; le bout-en-bout est couvert par `WeighbridgeReadingApiTest` (vrai kernel, auth `/login_check`).
matthieu added the backM5-Ticket-peseetype/feat labels 2026-06-17 16:11:10 +00:00
matthieu changed target branch from feat/erp-183-entite-weighingticket to develop 2026-06-18 12:47:05 +00:00
matthieu added 1 commit 2026-06-18 12:47:05 +00:00
- WeighbridgeReaderInterface (contrat) + RandomWeighbridgeReader (stub,
  poids aléatoire ∈ [10000,50000] kg, RG-5.06) + WeighbridgeUnavailableException
- DsdAllocator : compteur DSD par site (weighbridge_dsd_counter) incrémenté
  sous verrou ligne SELECT ... FOR UPDATE (RG-5.04, § 2.7)
- endpoint POST /api/weighbridge_readings : ressource virtuelle
  WeighbridgeReadingResource + WeighbridgeReadingProcessor (pas de controller)
  - AUTO -> {weight, dsd, mode} ; MANUAL -> {weight, dsd, manualNumber, mode}
  - WeighbridgeUnavailableException -> HTTP 503 explicite (RG-5.06)
  - site courant via CurrentSiteProviderInterface (contrat Sites)
  - is_granted('logistique.weighing_tickets.manage')
- dsd renvoyé prévisionnel : attribution autoritaire refaite à la création
  du ticket (ERP-185)
- tests : WeighbridgeReaderStubTest, DsdAllocatorTest, processor (503/400),
  WeighbridgeReadingApiTest (RBAC + AUTO/MANUAL + 422)
matthieu merged commit 1ffa38282a into develop 2026-06-18 12:47:07 +00:00
matthieu deleted branch feat/erp-184-pesee-pont-bascule 2026-06-18 12:47:07 +00:00
Sign in to join this conversation.