diff --git a/client/src/pages/InvoicesBAP.tsx b/client/src/pages/InvoicesBAP.tsx index 397c306..5def1a4 100644 --- a/client/src/pages/InvoicesBAP.tsx +++ b/client/src/pages/InvoicesBAP.tsx @@ -350,6 +350,14 @@ export default function InvoicesBAP() { ); }; + // "À compléter" = BAP non validé ET au moins un champ obligatoire manquant + const isToComplete = (invoice: any) => { + return ( + invoice.bapValidated !== 1 && + (!invoice.serviceConcerne || !invoice.typeAchat || !invoice.ventilationComptable) + ); + }; + const filteredInvoices = invoices?.filter((inv) => { // Filter by search query if (searchQuery) { @@ -376,7 +384,7 @@ export default function InvoicesBAP() { if (statusFilter === "export_error" && inv.exportStatus !== "export_error") return false; if (statusFilter === "bap_validated" && inv.bapValidated !== 1) return false; if (statusFilter === "bap_pending" && inv.bapValidated === 1) return false; - if (statusFilter === "to_complete" && isEligibleForBAPValidation(inv)) return false; + if (statusFilter === "to_complete" && !isToComplete(inv)) return false; } return true; @@ -389,7 +397,7 @@ export default function InvoicesBAP() { 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 => !isEligibleForBAPValidation(inv)).length || 0, + to_complete: invoices?.filter(inv => isToComplete(inv)).length || 0, }; // Old filter logic (to be removed)