diff --git a/client/src/pages/Avoirs.tsx b/client/src/pages/Avoirs.tsx index 32d2ff5..4219efb 100644 --- a/client/src/pages/Avoirs.tsx +++ b/client/src/pages/Avoirs.tsx @@ -355,6 +355,47 @@ export default function Avoirs() { } }; + // Handle validation/devalidation + const handleValidateAvoir = (avoirId: number) => { + const avoir = avoirs.find(a => a.id === avoirId); + if (avoir) { + editAvoirMutation.mutate({ + id: avoirId, + data: { + supplierId: avoir.supplierId, + groupId: avoir.groupId, + invoiceReference: avoir.invoiceReference || "", + amount: avoir.amount, + comment: avoir.comment || "", + commercialProcessed: avoir.commercialProcessed, + status: avoir.status as "En attente de demande" | "Demandé" | "Reçu", + nocodbVerified: true, + nocodbVerifiedAt: new Date(), + } + }); + } + }; + + const handleDevalidateAvoir = (avoirId: number) => { + const avoir = avoirs.find(a => a.id === avoirId); + if (avoir) { + editAvoirMutation.mutate({ + id: avoirId, + data: { + supplierId: avoir.supplierId, + groupId: avoir.groupId, + invoiceReference: avoir.invoiceReference || "", + amount: avoir.amount, + comment: avoir.comment || "", + commercialProcessed: avoir.commercialProcessed, + status: avoir.status as "En attente de demande" | "Demandé" | "Reçu", + nocodbVerified: false, + nocodbVerifiedAt: null, + } + }); + } + }; + // 🔍 FONCTION DE VÉRIFICATION DE FACTURE (comme rapprochement) const verifyAvoirInvoiceMutation = useMutation({ mutationFn: async ({ avoirId, invoiceReference, forceRefresh }: { avoirId: number; invoiceReference?: string; forceRefresh?: boolean }) => { @@ -947,7 +988,7 @@ export default function Avoirs() { const canEditDelete = ['admin', 'directeur'].includes((user as any)?.role); return ( -