diff --git a/client/src/pages/InvoicesBAP.tsx b/client/src/pages/InvoicesBAP.tsx index c207afa..ef68320 100644 --- a/client/src/pages/InvoicesBAP.tsx +++ b/client/src/pages/InvoicesBAP.tsx @@ -236,9 +236,11 @@ export default function InvoicesBAP() { const handleSelectAll = (checked: boolean) => { if (checked) { - // Select all invoices (no restriction) - const allIds = (filteredInvoices || []).map(inv => inv.id); - setSelectedIds(allIds); + // Select only exportable invoices + const exportableIds = (filteredInvoices || []) + .filter(inv => isEligibleForExport(inv)) + .map(inv => inv.id); + setSelectedIds(exportableIds); } else { setSelectedIds([]); } @@ -291,7 +293,17 @@ export default function InvoicesBAP() { }; const isEligibleForExport = (invoice: any) => { - return (invoice.qualityScore || 0) === 100; + // Une facture BAP est exportable si : + // 1. Score = 100% + // 2. Type d'achat rempli + // 3. Service concerné rempli + // 4. Ventilation comptable remplie + return ( + (invoice.qualityScore || 0) === 100 && + invoice.typeAchat && + invoice.serviceConcerne && + invoice.ventilationComptable + ); }; const hasOnlyEligibleSelected = selectedIds.length > 0 && selectedIds.every(id => { @@ -322,12 +334,11 @@ export default function InvoicesBAP() {