# Suivi d'Intégration POS - Journal de Progression

## Statut Global

| Phase | Nom | Statut | Progression | Date Début | Date Fin |
|-------|-----|--------|-------------|------------|----------|
| 0 | Socle & Infrastructure | A FAIRE | 0% | - | - |
| 1 | Catalogue Produits | A FAIRE | 0% | - | - |
| 2 | Gestion des Stocks | A FAIRE | 0% | - | - |
| 3 | Ventes & Caisse | A FAIRE | 0% | - | - |
| 4 | Clients & Crédit | A FAIRE | 0% | - | - |
| 5 | Commandes & Approvisionnement | A FAIRE | 0% | - | - |
| 6 | Inventaire | A FAIRE | 0% | - | - |
| 7 | Rapports & Statistiques | A FAIRE | 0% | - | - |
| 8 | Remboursements & Annulations | A FAIRE | 0% | - | - |
| 9 | Isolation Média | A FAIRE | 0% | - | - |
| 10 | API Mobile POS | A FAIRE | 0% | - | - |

**Légende :** A FAIRE | EN COURS | TERMINE | BLOQUE

---

## Phase 0 : Socle & Infrastructure

### Entités
| Tâche | Statut | Notes |
|-------|--------|-------|
| PosSettings entity | A FAIRE | |
| PosEmployeeRole entity | A FAIRE | |
| PosAuditLog entity | A FAIRE | |
| Repositories (3) | A FAIRE | |
| Schema update | A FAIRE | |

### Services
| Tâche | Statut | Notes |
|-------|--------|-------|
| PosSettingsService | A FAIRE | |
| PosAuditService | A FAIRE | |
| PosEmployeeService | A FAIRE | |

### Sécurité
| Tâche | Statut | Notes |
|-------|--------|-------|
| Extension CompanyVoter (attributs POS) | A FAIRE | |
| Logique voting POS | A FAIRE | |

### Contrôleurs
| Tâche | Statut | Notes |
|-------|--------|-------|
| PosSettingsController | A FAIRE | |
| PosEmployeeController | A FAIRE | |

### Formulaires
| Tâche | Statut | Notes |
|-------|--------|-------|
| PosSettingsFormType | A FAIRE | |
| PosEmployeeRoleFormType | A FAIRE | |

### Templates
| Tâche | Statut | Notes |
|-------|--------|-------|
| settings/index.html.twig | A FAIRE | |
| employees/index.html.twig | A FAIRE | |
| employees/assign.html.twig | A FAIRE | |
| employees/edit.html.twig | A FAIRE | |

### Navigation & UI
| Tâche | Statut | Notes |
|-------|--------|-------|
| Section POS dans sidebar manager | A FAIRE | |
| Contextes NavigationService | A FAIRE | |
| Stimulus: pos-settings_controller.js | A FAIRE | |

### Validation
| Critère | OK ? |
|---------|------|
| Manager peut activer POS pour sa company | |
| Manager peut configurer les paramètres | |
| Manager peut assigner rôles POS aux employés | |
| Actions tracées dans PosAuditLog | |
| Voter bloque accès aux non-autorisés | |

---

## Phase 1 : Catalogue Produits

### Entités
| Tâche | Statut | Notes |
|-------|--------|-------|
| ProductCategory entity | A FAIRE | |
| Product entity | A FAIRE | |
| ProductVariant entity | A FAIRE | |
| ProductMedia entity | A FAIRE | |
| Barcode entity | A FAIRE | |
| Repositories (5) | A FAIRE | |
| Schema update | A FAIRE | |

### Services
| Tâche | Statut | Notes |
|-------|--------|-------|
| ProductService | A FAIRE | |
| ProductCategoryService | A FAIRE | |
| BarcodeService | A FAIRE | |

### Contrôleurs
| Tâche | Statut | Notes |
|-------|--------|-------|
| ProductController (CRUD + import/export) | A FAIRE | |
| ProductCategoryController (CRUD + tree) | A FAIRE | |

### Formulaires
| Tâche | Statut | Notes |
|-------|--------|-------|
| ProductFormType | A FAIRE | |
| ProductCategoryFormType | A FAIRE | |
| ProductVariantFormType | A FAIRE | |
| ProductImportFormType | A FAIRE | |
| ProductFilterFormType | A FAIRE | |

### Templates
| Tâche | Statut | Notes |
|-------|--------|-------|
| products/index.html.twig | A FAIRE | |
| products/create.html.twig | A FAIRE | |
| products/show.html.twig | A FAIRE | |
| products/edit.html.twig | A FAIRE | |
| products/_product_card.html.twig | A FAIRE | |
| products/import.html.twig | A FAIRE | |
| categories/index.html.twig | A FAIRE | |
| categories/create.html.twig | A FAIRE | |
| categories/edit.html.twig | A FAIRE | |

### Stimulus
| Tâche | Statut | Notes |
|-------|--------|-------|
| pos-product-form_controller.js | A FAIRE | |
| pos-product-image_controller.js | A FAIRE | |
| pos-category-tree_controller.js | A FAIRE | |
| pos-product-variant_controller.js | A FAIRE | |
| pos-barcode_controller.js | A FAIRE | |

### Validation
| Critère | OK ? |
|---------|------|
| CRUD catégories hiérarchiques (3 niveaux) | |
| CRUD produits avec filtres et pagination | |
| Variantes (taille, couleur) | |
| Upload multi-images via Media | |
| Codes-barres génération + scan | |
| Import/Export CSV | |
| Vues table et grille | |
| Isolation par company | |

---

## Phase 2 : Gestion des Stocks

### Entités
| Tâche | Statut | Notes |
|-------|--------|-------|
| StockMovement entity | A FAIRE | |
| Supplier entity | A FAIRE | |
| SupplierProduct entity | A FAIRE | |
| Repositories (3) | A FAIRE | |
| Schema update | A FAIRE | |

### Services
| Tâche | Statut | Notes |
|-------|--------|-------|
| StockService | A FAIRE | |

### Contrôleurs
| Tâche | Statut | Notes |
|-------|--------|-------|
| StockController (manager) | A FAIRE | |
| SupplierController (manager) | A FAIRE | |
| StockReceptionController (employer) | A FAIRE | |

### Commandes
| Tâche | Statut | Notes |
|-------|--------|-------|
| PosStockAlertCommand | A FAIRE | |

### Validation
| Critère | OK ? |
|---------|------|
| Entrée/sortie/ajustement stock | |
| Stock dénormalisé sur Product | |
| Alertes visuelles stock bas/critique | |
| CRUD fournisseurs | |
| Commande CLI alertes email | |
| Employer magasinier réceptionne stock | |

---

## Phase 3 : Ventes & Caisse

### Entités
| Tâche | Statut | Notes |
|-------|--------|-------|
| Sale entity | A FAIRE | |
| SaleLine entity | A FAIRE | |
| Payment entity | A FAIRE | |
| Register entity | A FAIRE | |
| RegisterSession entity | A FAIRE | |
| CashMovement entity | A FAIRE | |
| Repositories (6) | A FAIRE | |
| Schema update | A FAIRE | |

### Services
| Tâche | Statut | Notes |
|-------|--------|-------|
| SaleService | A FAIRE | |
| PaymentService | A FAIRE | |
| RegisterService | A FAIRE | |
| ReceiptService | A FAIRE | |

### Contrôleurs
| Tâche | Statut | Notes |
|-------|--------|-------|
| SaleController (manager) | A FAIRE | |
| RegisterController (manager) | A FAIRE | |
| CashierController (employer) | A FAIRE | |

### Stimulus (critiques)
| Tâche | Statut | Notes |
|-------|--------|-------|
| pos-cashier_controller.js | A FAIRE | Le plus complexe |
| pos-payment_controller.js | A FAIRE | |
| pos-receipt_controller.js | A FAIRE | |
| pos-product-search_controller.js | A FAIRE | |

### Validation
| Critère | OK ? |
|---------|------|
| Interface caissier fonctionnelle | |
| Recherche produit (nom, SKU, barcode) | |
| Panier avec quantités | |
| Calcul TVA et remises | |
| Multi-paiement | |
| Rendu de monnaie | |
| Ouverture/fermeture caisse | |
| Impression ticket | |
| Stock décrémenté auto | |
| Historique ventes manager | |

---

## Phase 4 : Clients & Crédit

### Entités
| Tâche | Statut | Notes |
|-------|--------|-------|
| Customer entity | A FAIRE | |
| CustomerCredit entity | A FAIRE | |
| Repositories (2) | A FAIRE | |
| Schema update | A FAIRE | |

### Services
| Tâche | Statut | Notes |
|-------|--------|-------|
| CustomerService | A FAIRE | |

### Contrôleurs
| Tâche | Statut | Notes |
|-------|--------|-------|
| CustomerController (manager) | A FAIRE | |

### Intégration Caisse
| Tâche | Statut | Notes |
|-------|--------|-------|
| Sélection client dans caisse | A FAIRE | |
| Paiement par crédit | A FAIRE | |
| Points fidélité | A FAIRE | |

### Validation
| Critère | OK ? |
|---------|------|
| CRUD clients | |
| Vente à crédit | |
| Suivi solde crédit | |
| Paiements de dette | |
| Liste débiteurs | |
| Points fidélité (si activé) | |
| Historique achats par client | |

---

## Phase 5 : Commandes & Approvisionnement

### Entités
| Tâche | Statut | Notes |
|-------|--------|-------|
| PurchaseOrder entity | A FAIRE | |
| PurchaseOrderLine entity | A FAIRE | |
| Repositories (2) | A FAIRE | |
| Schema update | A FAIRE | |

### Services
| Tâche | Statut | Notes |
|-------|--------|-------|
| PurchaseOrderService | A FAIRE | |

### Validation
| Critère | OK ? |
|---------|------|
| Création bon de commande | |
| Workflow statuts | |
| Réception partielle/totale | |
| Stock mis à jour à réception | |
| PDF bon de commande | |
| Suggestions réapprovisionnement | |

---

## Phase 6 : Inventaire

### Entités
| Tâche | Statut | Notes |
|-------|--------|-------|
| Inventory entity | A FAIRE | |
| InventoryLine entity | A FAIRE | |
| Repositories (2) | A FAIRE | |
| Schema update | A FAIRE | |

### Services
| Tâche | Statut | Notes |
|-------|--------|-------|
| InventoryService | A FAIRE | |

### Validation
| Critère | OK ? |
|---------|------|
| Création inventaire (total/partiel) | |
| Pré-remplissage stock théorique | |
| Saisie comptages | |
| Calcul écarts | |
| Validation manager → ajuste stock | |
| Rapport inventaire | |

---

## Phase 7 : Rapports & Statistiques

### Services
| Tâche | Statut | Notes |
|-------|--------|-------|
| PosReportService | A FAIRE | |

### Contrôleurs
| Tâche | Statut | Notes |
|-------|--------|-------|
| PosDashboardController | A FAIRE | |
| PosReportController | A FAIRE | |

### Commandes
| Tâche | Statut | Notes |
|-------|--------|-------|
| PosDailyReportCommand | A FAIRE | |

### Validation
| Critère | OK ? |
|---------|------|
| Dashboard POS temps réel | |
| Rapports ventes par période | |
| Top produits/catégories/vendeurs | |
| Répartition paiements | |
| Rapport marges | |
| Export PDF et Excel | |
| Rapport quotidien email | |

---

## Phase 8 : Remboursements & Annulations

### Entités
| Tâche | Statut | Notes |
|-------|--------|-------|
| Refund entity | A FAIRE | |
| Repository | A FAIRE | |
| Schema update | A FAIRE | |

### Validation
| Critère | OK ? |
|---------|------|
| Demande remboursement total/partiel | |
| Approbation manager (si requis) | |
| Restock automatique | |
| Traçabilité audit | |

---

## Phase 9 : Isolation Média

### Travaux
| Tâche | Statut | Notes |
|-------|--------|-------|
| CompanyMediaPathService | A FAIRE | |
| Nouveaux types Media POS | A FAIRE | |
| Refactoring MediaService | A FAIRE | |
| Vérification accès renforcée | A FAIRE | |
| Commande migration fichiers | A FAIRE | |
| Tests d'isolation | A FAIRE | |

### Validation
| Critère | OK ? |
|---------|------|
| Stockage par company/{uuid}/ | |
| Path traversal bloqué | |
| Manager ne voit que sa company | |
| Quota stockage respecté | |
| Migration fichiers existants | |

---

## Phase 10 : API Mobile POS

### Endpoints
| Tâche | Statut | Notes |
|-------|--------|-------|
| POST /api/pos/sales | A FAIRE | |
| GET /api/pos/products/search | A FAIRE | |
| GET /api/pos/products/{barcode} | A FAIRE | |
| POST /api/pos/register/open | A FAIRE | |
| POST /api/pos/register/close | A FAIRE | |
| GET /api/pos/dashboard | A FAIRE | |
| GET /api/pos/customers/search | A FAIRE | |
| POST /api/pos/stock/receive | A FAIRE | |

### Validation
| Critère | OK ? |
|---------|------|
| Documentation OpenAPI/Swagger | |
| Auth JWT fonctionnelle | |
| Isolation company | |
| Tests API | |

---

## Journal des Modifications

| Date | Phase | Description | Auteur |
|------|-------|-------------|--------|
| 2026-03-31 | - | Création de la documentation POS | - |
| | | | |

---

## Notes & Décisions

### Décisions d'Architecture
1. **Prefix `pos_`** pour toutes les tables BDD → évite les conflits avec les entités existantes
2. **Entités dans `src/Entity/Pos/`** → namespace séparé pour organisation claire
3. **Soft-delete** sur Product, Customer, Supplier, ProductCategory → préserve l'historique
4. **Append-only** sur StockMovement, PosAuditLog, CustomerCredit → intégrité audit
5. **Dénormalisation** : stock sur Product, totaux sur Customer/Supplier → performance
6. **UUID** sur les entités principales → compatibilité API et références externes

### Risques Identifiés
1. **Performance caisse** : l'interface caissier doit être ultra-rapide → optimiser les requêtes, envisager cache
2. **Concurrence stock** : deux caissiers peuvent vendre le même produit simultanément → verrouillage optimiste
3. **Volume de données** : PosAuditLog et StockMovement vont croître vite → prévoir archivage
4. **Hors-ligne** : si le réseau tombe, la caisse doit pouvoir fonctionner → localStorage + sync

### Questions Ouvertes
- Gestion multi-dépôts par company ? (Phase future)
- Intégration comptable (export vers logiciel compta) ?
- Codes-barres : lecteur USB ou caméra smartphone ?
- Programme fidélité : simple points ou paliers/récompenses ?
