diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 3687c7d..c4a4ead 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -4,11 +4,11 @@ - @@ -794,7 +793,8 @@ - diff --git a/CLAUDE.md b/CLAUDE.md index f1b2667..902346a 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -142,6 +142,15 @@ frontend/ - `BuildingCase` a `bovines` (OneToMany). - Rapport PDF cases : `GET /building_cases/{id}/weights-report` → template Twig, projection depuis `arrivalDate`, gain journalier fixe `1.3 kg/jour`. +### Scanner boucles auriculaires +- Page dédiée `/scan` : scan de codes-barres Code 39/128 (boucles auriculaires bovines) depuis un téléphone Android via Chrome. +- Utilise l'API native `BarcodeDetector` (Shape Detection API, Chrome Android 83+) — pas de lib JS, décodage hardware quasi-instantané. +- **Non supporté sur iOS** (tous les navigateurs iOS utilisent WebKit, qui n'implémente pas `BarcodeDetector`). +- Les 4 premiers caractères du code-barres sont retirés avant enregistrement (`rawValue.slice(4)`). +- Composable `useBarcodeScanner` : caméra arrière, anti-doublon 2s, vibration au scan. +- Le bovin est créé via `POST /bovines` avec `Content-Type: application/ld+json` (nécessaire pour la résolution d'IRI de `buildingCase`). +- Sélection bâtiment → case (filtrées dynamiquement) avant de scanner. + ### Données de référence - `ReceptionType`, `MerchandiseType`, `PelletType`, `Building`, `Supplier` (avec `Address` via join table, `createdBy` → User), `Customer` (avec `Address` via join table, `createdBy` → User), `Truck`, `Carrier`, `Driver`, `Vehicle`. - `Address` : champ `label` nullable (déprécié, retiré du front et du `address:write`), expose `fullAddress` via getter. `countryCode` par défaut `FR` côté front. diff --git a/frontend/services/dto/building-data.ts b/frontend/services/dto/building-data.ts index 60729d4..3f5a9d4 100644 --- a/frontend/services/dto/building-data.ts +++ b/frontend/services/dto/building-data.ts @@ -1,8 +1,10 @@ import type { BuildingLayoutData } from '~/services/dto/building-layout-data' +import type { BuildingCaseData } from '~/services/dto/building-case-data' export interface BuildingData { id: number label: string code: string layouts?: BuildingLayoutData[] | null + buildingCases?: BuildingCaseData[] | null } diff --git a/src/Entity/Building.php b/src/Entity/Building.php index af68257..d1d37eb 100644 --- a/src/Entity/Building.php +++ b/src/Entity/Building.php @@ -53,6 +53,8 @@ class Building * @var Collection */ #[ORM\OneToMany(targetEntity: BuildingCase::class, mappedBy: 'id_building')] + #[Groups(['building:read'])] + #[SerializedName('buildingCases')] private Collection $buildingCases; /** diff --git a/src/Entity/BuildingCase.php b/src/Entity/BuildingCase.php index a3f2dd8..0dd4f85 100644 --- a/src/Entity/BuildingCase.php +++ b/src/Entity/BuildingCase.php @@ -17,6 +17,10 @@ use Symfony\Component\Serializer\Attribute\SerializedName; #[ORM\Entity] #[ApiResource( operations: [ + new Get( + requirements: ['id' => '\d+'], + normalizationContext: ['groups' => ['building:read']], + ), new Get( uriTemplate: '/building_cases/{id}/weights-report', requirements: ['id' => '\d+'],