mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-11 17:27:31 +02:00
Fix issue preventing delivery reconciliation status from displaying
Update BLReconciliation page logic to correctly trigger invoice verification for displaying reconciliation status. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 1e4433b5-47ab-464c-b663-fea2e53367dd Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: 7bb63bc1-fa5b-4888-baf3-17f792c47530 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/1e4433b5-47ab-464c-b663-fea2e53367dd/lCj0xbO
This commit is contained in:
1 parent
feb433c645
commit
55c010c2f6
2 files changed
+35
-15
No files matched your search
Binary file not shown.
|
After Width: | Height: | Size: 146 KiB |
@@ -386,22 +386,42 @@ export default function BLReconciliation() {
|
||||
// CAS SPÉCIAL : Livraisons réconciliées (✅) avec cellules vides
|
||||
// Si reconciled=true ET (cellules vides) ET blNumber existe → auto-remplir
|
||||
deliveriesWithBL.forEach((delivery: any) => {
|
||||
if (!delivery.reconciled) return; // Ignorer les livraisons non réconciliées
|
||||
|
||||
const hasEmptyCells = !delivery.invoiceReference || !delivery.invoiceAmount || !delivery.dueDate;
|
||||
const hasBLNumber = delivery.blNumber?.trim();
|
||||
const notAlreadyAutoVerified = !autoVerifiedDeliveries.has(delivery.id);
|
||||
const notCurrentlyVerifying = !verifyingDeliveries.has(delivery.id);
|
||||
|
||||
if (hasEmptyCells && hasBLNumber && notAlreadyAutoVerified && notCurrentlyVerifying) {
|
||||
// Livraison réconciliée avec cellules vides → vérifier pour auto-remplir (UNE SEULE FOIS)
|
||||
if (import.meta.env.DEV) {
|
||||
console.log(`🔄 Livraison réconciliée #${delivery.id} avec cellules vides, auto-vérification (première tentative)...`);
|
||||
if (delivery.reconciled) {
|
||||
const hasEmptyCells = !delivery.invoiceReference || !delivery.invoiceAmount || !delivery.dueDate;
|
||||
const hasBLNumber = delivery.blNumber?.trim();
|
||||
const notAlreadyAutoVerified = !autoVerifiedDeliveries.has(delivery.id);
|
||||
const notCurrentlyVerifying = !verifyingDeliveries.has(delivery.id);
|
||||
|
||||
if (hasEmptyCells && hasBLNumber && notAlreadyAutoVerified && notCurrentlyVerifying) {
|
||||
// Livraison réconciliée avec cellules vides → vérifier pour auto-remplir (UNE SEULE FOIS)
|
||||
if (import.meta.env.DEV) {
|
||||
console.log(`🔄 Livraison réconciliée #${delivery.id} avec cellules vides, auto-vérification (première tentative)...`);
|
||||
}
|
||||
// Marquer comme auto-vérifiée AVANT de lancer pour éviter les doublons
|
||||
setAutoVerifiedDeliveries(prev => new Set(prev).add(delivery.id));
|
||||
// Lancer la vérification sans délai
|
||||
handleVerifyInvoice(delivery, false);
|
||||
}
|
||||
// Marquer comme auto-vérifiée AVANT de lancer pour éviter les doublons
|
||||
setAutoVerifiedDeliveries(prev => new Set(prev).add(delivery.id));
|
||||
// Lancer la vérification sans délai
|
||||
handleVerifyInvoice(delivery, false);
|
||||
return; // Autres livraisons réconciliées = AUCUNE vérification nécessaire
|
||||
}
|
||||
|
||||
// VÉRIFICATION AUTOMATIQUE pour afficher les coches (UNE SEULE FOIS au chargement)
|
||||
// Vérifier seulement les livraisons NON réconciliées qui n'ont PAS encore été vérifiées
|
||||
const hasVerifiableData = delivery.invoiceReference || delivery.blNumber;
|
||||
const notAlreadyProcessed = !verificationResults[delivery.id] && !verifyingDeliveries.has(delivery.id);
|
||||
|
||||
if (hasVerifiableData && notAlreadyProcessed) {
|
||||
if (import.meta.env.DEV) {
|
||||
console.log(`🔍 Vérification initiale pour affichage coche ${delivery.id}:`, {
|
||||
invoiceRef: delivery.invoiceReference,
|
||||
blNumber: delivery.blNumber
|
||||
});
|
||||
}
|
||||
|
||||
// Délai pour éviter de surcharger le serveur
|
||||
setTimeout(() => {
|
||||
handleVerifyInvoice(delivery, false);
|
||||
}, Math.random() * 1000);
|
||||
}
|
||||
});
|
||||
}, [deliveriesWithBL, suppliers, verificationResults, verifyingDeliveries]);
|
||||
|
||||
Reference in new issue
Block a user