mirror of
https://github.com/R0m1k3/CollectFlow.git
synced 2026-10-11 17:26:32 +02:00
Merge: vrais 12 mois via COMP dérivé
This commit is contained in:
2 files changed
+14
-4
No files matched your search
@@ -379,7 +379,7 @@ function NetworkMonthlyModal({ row, onClose }: { row: ProductRow; onClose: () =>
|
|||||||
{row.libelle1}
|
{row.libelle1}
|
||||||
</DialogTitle>
|
</DialogTitle>
|
||||||
<p className="text-[12px] mt-0.5" style={{ color: "var(--text-muted)" }}>
|
<p className="text-[12px] mt-0.5" style={{ color: "var(--text-muted)" }}>
|
||||||
Ventes réseau · 12 derniers mois
|
Ventes réseau · {labels.length > 0 ? `${labels.length} derniers mois` : "12 derniers mois"}
|
||||||
{row.nbMagasinsReseau != null && <> · <span className="font-semibold" style={{ color: "var(--text-secondary)" }}>{row.nbMagasinsReseau} magasins</span></>}
|
{row.nbMagasinsReseau != null && <> · <span className="font-semibold" style={{ color: "var(--text-secondary)" }}>{row.nbMagasinsReseau} magasins</span></>}
|
||||||
{pct != null && (
|
{pct != null && (
|
||||||
<> · <span className="font-bold" style={{ color }}>
|
<> · <span className="font-bold" style={{ color }}>
|
||||||
|
|||||||
@@ -443,12 +443,22 @@ export async function fetchNetworkMetricsPlaywright(
|
|||||||
const got = await timed("cube", "batch", () => fetchMonthCube((code, mois, ca, qte, nbMag, caMag, marge, qteComp) => {
|
const got = await timed("cube", "batch", () => fetchMonthCube((code, mois, ca, qte, nbMag, caMag, marge, qteComp) => {
|
||||||
if (!code || code === "-") return;
|
if (!code || code === "-") return;
|
||||||
out.push([code, ca, qte, nbMag, caMag, marge]);
|
out.push([code, ca, qte, nbMag, caMag, marge]);
|
||||||
// 12 mois glissants : mois de l'année N → Quantité N, mois N-1 → Quantité COMP.
|
// 12 mois glissants. Le cube ne renvoie que les mois de l'année N
|
||||||
|
// (les mesures "N" sont nulles ailleurs → lignes supprimées).
|
||||||
|
// "Quantité COMP" = comparable N-1 : à la ligne Mois=YYYYMM elle
|
||||||
|
// donne la quantité du MÊME mois l'année précédente. On dérive donc
|
||||||
|
// deux points par ligne : YYYY-MM (N) et (YYYY-1)-MM (N-1).
|
||||||
const mm = normMois(mois);
|
const mm = normMois(mois);
|
||||||
const y = parseInt(mm.slice(0, 4), 10);
|
const y = parseInt(mm.slice(0, 4), 10);
|
||||||
const qtyMonth = y === yearN ? qte : qteComp;
|
|
||||||
(monthlyByCode[code] ??= {});
|
(monthlyByCode[code] ??= {});
|
||||||
monthlyByCode[code][mm] = (monthlyByCode[code][mm] ?? 0) + qtyMonth;
|
if (y === yearN) {
|
||||||
|
monthlyByCode[code][mm] = (monthlyByCode[code][mm] ?? 0) + qte;
|
||||||
|
const mmPrev = String(y - 1) + mm.slice(4); // "2026-03" → "2025-03"
|
||||||
|
monthlyByCode[code][mmPrev] = (monthlyByCode[code][mmPrev] ?? 0) + qteComp;
|
||||||
|
} else {
|
||||||
|
// Ligne d'une autre année (cas non observé) : on prend la mesure N.
|
||||||
|
monthlyByCode[code][mm] = (monthlyByCode[code][mm] ?? 0) + qte;
|
||||||
|
}
|
||||||
}, timings, () => { code15Retries++; }), timings);
|
}, timings, () => { code15Retries++; }), timings);
|
||||||
aggBatches++;
|
aggBatches++;
|
||||||
aggCode15Retries += code15Retries;
|
aggCode15Retries += code15Retries;
|
||||||
|
|||||||
Reference in new issue
Block a user