diff --git a/src/features/grid/components/heatmap-grid.tsx b/src/features/grid/components/heatmap-grid.tsx index 85ccc0e..440b5fa 100644 --- a/src/features/grid/components/heatmap-grid.tsx +++ b/src/features/grid/components/heatmap-grid.tsx @@ -396,10 +396,66 @@ function CellDetailModal({ d, activeMagasin, onClose }: { d: CellDetailData; act Stock fin mois + + {/* + * En « tous magasins », les trois tuiles ci-dessus sont des cumuls. + * Le détail par magasin est justement ce qu'on vient vérifier ici : + * savoir que le stock est de 40 ne dit pas s'il est réparti ou + * entièrement sur un seul site. + */} + {activeMagasin === "TOTAL" && } ); } +/** Détail ventes / entrées / stock du mois, magasin par magasin. */ +function VentilationParMagasin({ d }: { d: CellDetailData }) { + const sites = [...new Set([ + ...Object.keys(d.row.sales12mByStore ?? {}), + ...Object.keys(d.row.stock12mByStore ?? {}), + ])].sort(); + + if (sites.length === 0) return null; + + return ( +
+ + + + + + + + + + + {sites.map((site) => { + const ventes = d.row.sales12mByStore?.[site]?.[d.monthKey] ?? 0; + const entrees = d.row.receptions12mByStore?.[site]?.[d.monthKey] ?? 0; + const stock = d.row.stock12mByStore?.[site]?.[d.monthKey] ?? 0; + return ( + + + + + + + ); + })} + +
MagasinVentesEntréesStock
+ {SITE_LABELS[site]?.nom ?? site} + + {Math.round(ventes).toLocaleString("fr-FR")} + 0 ? "rgb(16,185,129)" : "var(--text-muted)" }}> + {entrees > 0 ? `+${Math.round(entrees).toLocaleString("fr-FR")}` : "—"} + + {Math.round(stock).toLocaleString("fr-FR")} +
+
+ ); +} + // ========================================================================= export function HeatmapGrid({ onSelectionChange, isAdmin }: HeatmapGridProps) {