mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-15 11:19:43 +02:00
Update how users validate and invalidate task documents
Introduce a new API endpoint for NocoDB verification and integrate cache reconciliation logic for invoices. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 9fcf4b21-eb0c-4e53-a567-e2ce4a6ad869 Replit-Commit-Checkpoint-Type: intermediate_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/9fcf4b21-eb0c-4e53-a567-e2ce4a6ad869/chkBbcP
This commit is contained in:
1 parent
e75a1fb8f3
commit
115090f317
2 files changed
+98
-32
No files matched your search
+51
-32
@@ -1,4 +1,4 @@
|
||||
import { useState } from "react";
|
||||
import { useState, useEffect } from "react";
|
||||
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { Plus, Search, FileText, CheckCircle, AlertCircle, Clock, Edit, Trash2, UserCheck, Send, Upload, XCircle } from "lucide-react";
|
||||
import { useStore } from "@/components/Layout";
|
||||
@@ -362,42 +362,61 @@ 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 handleValidateAvoir = async (avoirId: number) => {
|
||||
try {
|
||||
// Utiliser la route spécifique pour la vérification NocoDB
|
||||
await apiRequest(`/api/avoirs/${avoirId}/nocodb-verification`, 'PUT', {
|
||||
verified: true
|
||||
});
|
||||
|
||||
// Marquer le cache comme réconcilié (permanent)
|
||||
const avoir = avoirs.find(a => a.id === avoirId);
|
||||
if (avoir?.invoiceReference) {
|
||||
try {
|
||||
await apiRequest('/api/cache/mark-reconciled', 'POST', {
|
||||
invoiceReference: avoir.invoiceReference,
|
||||
groupId: avoir.groupId
|
||||
});
|
||||
} catch (cacheError) {
|
||||
console.warn('Cache marking failed but verification succeeded:', cacheError);
|
||||
}
|
||||
}
|
||||
|
||||
// Recharger les avoirs pour voir les changements
|
||||
queryClient.invalidateQueries({ queryKey: ['/api/avoirs'] });
|
||||
|
||||
toast({
|
||||
title: "Avoir validé",
|
||||
description: "L'avoir a été marqué comme validé avec succès",
|
||||
});
|
||||
} catch (error) {
|
||||
toast({
|
||||
title: "Erreur de validation",
|
||||
description: error instanceof Error ? error.message : "Erreur lors de la validation",
|
||||
variant: "destructive",
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
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,
|
||||
}
|
||||
const handleDevalidateAvoir = async (avoirId: number) => {
|
||||
try {
|
||||
// Utiliser la route spécifique pour la vérification NocoDB
|
||||
await apiRequest(`/api/avoirs/${avoirId}/nocodb-verification`, 'PUT', {
|
||||
verified: false
|
||||
});
|
||||
|
||||
// Recharger les avoirs pour voir les changements
|
||||
queryClient.invalidateQueries({ queryKey: ['/api/avoirs'] });
|
||||
|
||||
toast({
|
||||
title: "Avoir dévalidé",
|
||||
description: "L'avoir a été marqué comme non-validé avec succès",
|
||||
});
|
||||
} catch (error) {
|
||||
toast({
|
||||
title: "Erreur de dévalidation",
|
||||
description: error instanceof Error ? error.message : "Erreur lors de la dévalidation",
|
||||
variant: "destructive",
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user