Update invoice reconciliation to fix display issues

Introduce detailed logging and data type conversions in invoice verification service and client-side reconciliation page to address discrepancies in displayed invoice amounts and due dates.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 1e4433b5-47ab-464c-b663-fea2e53367dd
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: 41ed310d-8033-46c7-bb26-e56560b56490
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/1e4433b5-47ab-464c-b663-fea2e53367dd/gTQvEeF
This commit is contained in:
michaelschal committed 2025-11-04 05:30:12 +00:00
1 parent fc6661551a
commit c669c4eba9
3 files changed
+33 -2

No files matched your search

+22 -1
View File
@@ -156,25 +156,46 @@ export default function BLReconciliation() {
// Auto-remplissage si facture trouvée (référence facture OU numéro BL)
if (result.exists) {
console.log('🔍 DEBUG - Résultat complet de vérification:', {
deliveryId: variables.deliveryId,
exists: result.exists,
matchType: result.matchType,
invoiceReference: result.invoiceReference,
invoiceAmount: result.invoiceAmount,
dueDate: result.dueDate,
hasInvoiceRef: !!result.invoiceReference,
hasAmount: result.invoiceAmount !== undefined && result.invoiceAmount !== null,
hasDueDate: !!result.dueDate
});
// Auto-remplir les champs dans la livraison via API
const updateData: any = {};
// Ajouter la référence de facture SEULEMENT si trouvée via BL (pas déjà renseignée)
if (result.invoiceReference && result.matchType === 'bl_number') {
updateData.invoiceReference = result.invoiceReference;
console.log('✅ Ajout invoiceReference:', result.invoiceReference);
} else {
console.log('⚠️ Pas d\'ajout invoiceReference:', { hasRef: !!result.invoiceReference, matchType: result.matchType });
}
// TOUJOURS mettre à jour le montant si disponible (peu importe le matchType)
if (result.invoiceAmount !== undefined && result.invoiceAmount !== null) {
updateData.invoiceAmount = result.invoiceAmount;
console.log('✅ Ajout invoiceAmount:', result.invoiceAmount);
} else {
console.log('⚠️ Pas d\'ajout invoiceAmount:', { amount: result.invoiceAmount });
}
// TOUJOURS mettre à jour la date d'échéance si disponible (peu importe le matchType)
if (result.dueDate) {
updateData.dueDate = result.dueDate;
console.log('✅ Ajout dueDate:', result.dueDate);
} else {
console.log('⚠️ Pas d\'ajout dueDate:', { dueDate: result.dueDate });
}
console.log('📝 Données à sauvegarder:', { deliveryId: variables.deliveryId, updateData, matchType: result.matchType });
console.log('📝 Données finales à sauvegarder:', { deliveryId: variables.deliveryId, updateData, matchType: result.matchType });
// Ne faire l'appel que si on a des données à mettre à jour
if (Object.keys(updateData).length > 0) {
+9 -1
View File
@@ -35,7 +35,9 @@ export class InvoiceVerificationService {
console.log('🛡️ [CACHE] PERMANENT - Facture validée avec coche verte, AUCUNE vérification:', {
invoiceReference,
groupId,
exists: cached.exists
exists: cached.exists,
invoiceAmount: cached.invoiceAmount,
dueDate: cached.dueDate
});
return {
exists: cached.exists,
@@ -43,6 +45,8 @@ export class InvoiceVerificationService {
errorMessage: cached.errorMessage,
invoiceReference: cached.invoiceReference,
supplierName: cached.supplierName,
invoiceAmount: cached.invoiceAmount ? parseFloat(cached.invoiceAmount) : undefined,
dueDate: cached.dueDate ? new Date(cached.dueDate).toISOString() : null,
fromCache: true,
permanent: true
};
@@ -57,6 +61,8 @@ export class InvoiceVerificationService {
errorMessage: cached.errorMessage,
invoiceReference: cached.invoiceReference,
supplierName: cached.supplierName,
invoiceAmount: cached.invoiceAmount ? parseFloat(cached.invoiceAmount) : undefined,
dueDate: cached.dueDate ? new Date(cached.dueDate).toISOString() : null,
fromCache: true,
permanent: false
};
@@ -115,6 +121,8 @@ export class InvoiceVerificationService {
groupId,
invoiceReference,
supplierName: supplierName || null,
invoiceAmount: result.invoiceAmount || null,
dueDate: result.dueDate ? new Date(result.dueDate) : null,
exists: result.exists,
matchType: result.matchType,
errorMessage: result.errorMessage || null,
+2
View File
@@ -173,6 +173,8 @@ export const invoiceVerificationCache = pgTable("invoice_verification_cache", {
groupId: integer("group_id").notNull(),
invoiceReference: varchar("invoice_reference", { length: 255 }).notNull(),
supplierName: varchar("supplier_name", { length: 255 }),
invoiceAmount: decimal("invoice_amount", { precision: 10, scale: 2 }), // Montant de la facture
dueDate: timestamp("due_date"), // Date d'échéance
exists: boolean("exists").notNull(),
matchType: varchar("match_type", { length: 50 }).notNull(),
errorMessage: text("error_message"),