From 382ac51943d976e51e9bd6593e117c61165d6798 Mon Sep 17 00:00:00 2001 From: Manus Date: Tue, 5 May 2026 10:44:18 -0400 Subject: [PATCH] =?UTF-8?q?fix:=20compteurs=20statusCounts=20respectent=20?= =?UTF-8?q?le=20filtre=20de=20p=C3=A9riode=20(coh=C3=A9rence=20avec=20la?= =?UTF-8?q?=20liste=20affich=C3=A9e)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/pages/InvoicesBAP.tsx | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/client/src/pages/InvoicesBAP.tsx b/client/src/pages/InvoicesBAP.tsx index 5def1a4..0187713 100644 --- a/client/src/pages/InvoicesBAP.tsx +++ b/client/src/pages/InvoicesBAP.tsx @@ -390,14 +390,26 @@ export default function InvoicesBAP() { return true; }); + // Factures filtrées par période uniquement (sans filtre de statut) pour les compteurs + const invoicesInPeriod = invoices?.filter((inv) => { + if (selectedYear === "all") return true; + const invDate = inv.invoiceDate ? new Date(inv.invoiceDate) : null; + const fallbackDate = inv.createdAt ? new Date(inv.createdAt) : null; + const dateToUse = invDate || fallbackDate; + if (!dateToUse) return false; + if (dateToUse.getFullYear() !== parseInt(selectedYear)) return false; + if (selectedMonth !== "all" && (dateToUse.getMonth() + 1) !== parseInt(selectedMonth)) return false; + return true; + }) || []; + const statusCounts = { - all: invoices?.length || 0, - exported: invoices?.filter(inv => inv.exportStatus === "exported").length || 0, - not_exported: invoices?.filter(inv => inv.exportStatus === "not_exported").length || 0, - export_error: invoices?.filter(inv => inv.exportStatus === "export_error").length || 0, - bap_validated: invoices?.filter(inv => inv.bapValidated === 1).length || 0, - bap_pending: invoices?.filter(inv => inv.bapValidated !== 1).length || 0, - to_complete: invoices?.filter(inv => isToComplete(inv)).length || 0, + all: invoicesInPeriod.length, + exported: invoicesInPeriod.filter(inv => inv.exportStatus === "exported").length, + not_exported: invoicesInPeriod.filter(inv => inv.exportStatus === "not_exported").length, + export_error: invoicesInPeriod.filter(inv => inv.exportStatus === "export_error").length, + bap_validated: invoicesInPeriod.filter(inv => inv.bapValidated === 1).length, + bap_pending: invoicesInPeriod.filter(inv => inv.bapValidated !== 1).length, + to_complete: invoicesInPeriod.filter(inv => isToComplete(inv)).length, }; // Old filter logic (to be removed)