From cc37f4cceb01e177c0e38e54fd9192e7cab70b66 Mon Sep 17 00:00:00 2001 From: michaelschal <35957947-michaelschal@users.noreply.replit.com> Date: Wed, 13 Aug 2025 13:49:08 +0000 Subject: [PATCH] Enable automatic invoice verification upon page load Re-enable automatic invoice verification when the reconciliation page loads, with a delay and cache mechanism to prevent server overload. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 7c468936-2a88-4686-ac0a-84921a45222d Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/7c468936-2a88-4686-ac0a-84921a45222d/h2xHW56 --- client/src/pages/BLReconciliation.tsx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/client/src/pages/BLReconciliation.tsx b/client/src/pages/BLReconciliation.tsx index 135121b..890ba17 100644 --- a/client/src/pages/BLReconciliation.tsx +++ b/client/src/pages/BLReconciliation.tsx @@ -217,7 +217,24 @@ export default function BLReconciliation() { enabled: !!user }); - // Plus de vérification automatique - seulement manuelle via bouton + // VÉRIFICATION AUTOMATIQUE AU CHARGEMENT avec système de cache + useEffect(() => { + if (!deliveriesWithBL.length || !suppliers.length) return; + + console.log('🔄 Déclenchement vérifications automatiques...'); + + deliveriesWithBL.forEach((delivery: any) => { + // Vérifier seulement si on a une référence de facture et pas déjà de résultat + if (delivery.invoiceReference && !verificationResults[delivery.id] && !verifyingDeliveries.has(delivery.id)) { + console.log(`🔍 Vérification auto pour livraison ${delivery.id}:`, delivery.invoiceReference); + + // Délai pour éviter de surcharger le serveur - le cache évitera les appels inutiles + setTimeout(() => { + handleVerifyInvoice(delivery, false); // Pas de force refresh, utilise le cache + }, Math.random() * 1000); // Délai aléatoire entre 0 et 1 seconde + } + }); + }, [deliveriesWithBL, suppliers, verificationResults, verifyingDeliveries]); // Séparer les livraisons par mode de rapprochement const manualReconciliationDeliveries = deliveriesWithBL.filter((delivery: any) => {