fix: corriger le compteur 'À compléter' - affiche uniquement les factures sans BAP validé ET avec champs manquants
This commit is contained in:
@@ -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) => {
|
const filteredInvoices = invoices?.filter((inv) => {
|
||||||
// Filter by search query
|
// Filter by search query
|
||||||
if (searchQuery) {
|
if (searchQuery) {
|
||||||
@@ -376,7 +384,7 @@ export default function InvoicesBAP() {
|
|||||||
if (statusFilter === "export_error" && inv.exportStatus !== "export_error") return false;
|
if (statusFilter === "export_error" && inv.exportStatus !== "export_error") return false;
|
||||||
if (statusFilter === "bap_validated" && inv.bapValidated !== 1) return false;
|
if (statusFilter === "bap_validated" && inv.bapValidated !== 1) return false;
|
||||||
if (statusFilter === "bap_pending" && 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;
|
return true;
|
||||||
@@ -389,7 +397,7 @@ export default function InvoicesBAP() {
|
|||||||
export_error: invoices?.filter(inv => inv.exportStatus === "export_error").length || 0,
|
export_error: invoices?.filter(inv => inv.exportStatus === "export_error").length || 0,
|
||||||
bap_validated: invoices?.filter(inv => inv.bapValidated === 1).length || 0,
|
bap_validated: invoices?.filter(inv => inv.bapValidated === 1).length || 0,
|
||||||
bap_pending: 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)
|
// Old filter logic (to be removed)
|
||||||
|
|||||||
Reference in New Issue
Block a user