mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-11 17:27:31 +02:00
Update delivery reconciliation to correctly handle invoice data and fix date field
Correctly applies invoice reference, amount, and due date to delivery updates. Modifies the `dueDate` field in the schema to `timestamp` and resolves the "column 'due_date' does not exist" error in PostgreSQL. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 1e4433b5-47ab-464c-b663-fea2e53367dd Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: a35a1a31-82b0-453f-aa10-f67eb24aaae3 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/1e4433b5-47ab-464c-b663-fea2e53367dd/Tx7N1IN
This commit is contained in:
1 parent
01c629c3e0
commit
e328993329
3 files changed
+215
-6
No files matched your search
+204
@@ -0,0 +1,204 @@
|
||||
ns
|
||||
|
||||
|
||||
|
||||
|
||||
errorMessage: null,
|
||||
|
||||
invoiceReference: '981644',
|
||||
|
||||
supplierName: 'Polyflame',
|
||||
|
||||
fromCache: true,
|
||||
|
||||
permanent: false
|
||||
|
||||
}
|
||||
|
||||
POST /api/deliveries/343/verify-invoice 200 in 256ms
|
||||
|
||||
🔍 Recherche NocoDB: { tableId: 'mrr733dfb8wtt9b', column: 'Numero_BL' }
|
||||
|
||||
🔍 Recherche NocoDB: { tableId: 'mrr733dfb8wtt9b', column: 'Numero_BL' }
|
||||
|
||||
💾 [CACHE] Tentative sauvegarde: {
|
||||
|
||||
invoiceReference: '197771',
|
||||
|
||||
groupId: 1,
|
||||
|
||||
cacheKey: '1_197771',
|
||||
|
||||
exists: true,
|
||||
|
||||
isReconciled: false,
|
||||
|
||||
cacheType: 'temporaire 6h (trouvé)',
|
||||
|
||||
expiresAt: '2025-11-03T23:21:35.673Z'
|
||||
|
||||
}
|
||||
|
||||
💾 [CACHE] Tentative sauvegarde: {
|
||||
|
||||
invoiceReference: '197771',
|
||||
|
||||
groupId: 1,
|
||||
|
||||
cacheKey: '1_197771',
|
||||
|
||||
exists: true,
|
||||
|
||||
isReconciled: false,
|
||||
|
||||
cacheType: 'temporaire 6h (trouvé)',
|
||||
|
||||
expiresAt: '2025-11-03T23:21:35.675Z'
|
||||
|
||||
}
|
||||
|
||||
✅ [CACHE] Résultat sauvé en cache: {
|
||||
|
||||
␍ id: 31803,
|
||||
|
||||
invoiceReference: '197771',
|
||||
|
||||
groupId: 1,
|
||||
|
||||
exists: true,
|
||||
|
||||
isReconciled: false,
|
||||
|
||||
cacheType: 'temporaire 6h (trouvé)',
|
||||
|
||||
cacheKey: '1_197771'
|
||||
|
||||
}
|
||||
|
||||
📅 Date d'échéance récupérée et normalisée: 2025-11-29 (original: 2025-11-29)
|
||||
|
||||
✅ [CACHE] Résultat sauvé en cache: {
|
||||
|
||||
␍ id: 31803,
|
||||
|
||||
invoiceReference: '197771',
|
||||
|
||||
groupId: 1,
|
||||
|
||||
exists: true,
|
||||
|
||||
isReconciled: false,
|
||||
|
||||
cacheType: 'temporaire 6h (trouvé)',
|
||||
|
||||
cacheKey: '1_197771'
|
||||
|
||||
}
|
||||
|
||||
📅 Date d'échéance récupérée et normalisée: 2025-11-29 (original: 2025-11-29)
|
||||
|
||||
Error updating delivery: error: column "due_date" does not exist
|
||||
|
||||
at /app/node_modules/pg-pool/index.js:45:11
|
||||
|
||||
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
|
||||
|
||||
at async file:///app/node_modules/drizzle-orm/node-postgres/session.js:83:22
|
||||
|
||||
at async DatabaseStorage.updateDelivery (file:///app/dist/index.js:2142:28)
|
||||
|
||||
at async file:///app/dist/index.js:14714:31 {
|
||||
|
||||
length: 174,
|
||||
|
||||
severity: 'ERROR',
|
||||
|
||||
code: '42703',
|
||||
|
||||
detail: undefined,
|
||||
|
||||
hint: 'Perhaps you meant to reference the column "deliveries.dueDate".',
|
||||
|
||||
position: '310',
|
||||
|
||||
internalPosition: undefined,
|
||||
|
||||
internalQuery: undefined,
|
||||
|
||||
where: undefined,
|
||||
|
||||
schema: undefined,
|
||||
|
||||
table: undefined,
|
||||
|
||||
column: undefined,
|
||||
|
||||
dataType: undefined,
|
||||
|
||||
constraint: undefined,
|
||||
|
||||
file: 'parse_relation.c',
|
||||
|
||||
line: '3665',
|
||||
|
||||
routine: 'errorMissingColumn'
|
||||
|
||||
}
|
||||
|
||||
PUT /api/deliveries/427 500 in 307ms
|
||||
|
||||
Error updating delivery: error: column "due_date" does not exist
|
||||
|
||||
at /app/node_modules/pg-pool/index.js:45:11
|
||||
|
||||
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
|
||||
|
||||
at async file:///app/node_modules/drizzle-orm/node-postgres/session.js:83:22
|
||||
|
||||
at async DatabaseStorage.updateDelivery (file:///app/dist/index.js:2142:28)
|
||||
|
||||
at async file:///app/dist/index.js:14714:31 {
|
||||
|
||||
length: 174,
|
||||
|
||||
severity: 'ERROR',
|
||||
|
||||
code: '42703',
|
||||
|
||||
detail: undefined,
|
||||
|
||||
hint: 'Perhaps you meant to reference the column "deliveries.dueDate".',
|
||||
|
||||
position: '310',
|
||||
|
||||
internalPosition: undefined,
|
||||
|
||||
internalQuery: undefined,
|
||||
|
||||
where: undefined,
|
||||
|
||||
schema: undefined,
|
||||
|
||||
table: undefined,
|
||||
|
||||
column: undefined,
|
||||
|
||||
dataType: undefined,
|
||||
|
||||
constraint: undefined,
|
||||
|
||||
file: 'parse_relation.c',
|
||||
|
||||
line: '3665',
|
||||
|
||||
routine: 'errorMissingColumn'
|
||||
|
||||
}
|
||||
|
||||
PUT /api/deliveries/427 500 in 330ms
|
||||
|
||||
HEAD /api/health 200 in 1ms
|
||||
|
||||
HEAD /api/health 200 in 1ms
|
||||
|
||||
HEAD /api/health 200 in 1ms
|
||||
@@ -158,31 +158,36 @@ export default function BLReconciliation() {
|
||||
// Auto-remplir les champs dans la livraison via API
|
||||
const updateData: any = {};
|
||||
|
||||
// Ajouter la référence de facture si trouvée et pas déjà renseignée
|
||||
// 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;
|
||||
}
|
||||
|
||||
// Toujours mettre à jour le montant si disponible
|
||||
if (result.invoiceAmount) {
|
||||
// TOUJOURS mettre à jour le montant si disponible (peu importe le matchType)
|
||||
if (result.invoiceAmount !== undefined && result.invoiceAmount !== null) {
|
||||
updateData.invoiceAmount = result.invoiceAmount;
|
||||
}
|
||||
|
||||
// Toujours mettre à jour la date d'échéance si disponible
|
||||
// TOUJOURS mettre à jour la date d'échéance si disponible (peu importe le matchType)
|
||||
if (result.dueDate) {
|
||||
updateData.dueDate = result.dueDate;
|
||||
}
|
||||
|
||||
console.log('📝 Données à 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) {
|
||||
apiRequest(`/api/deliveries/${variables.deliveryId}`, "PUT", updateData)
|
||||
.then(() => {
|
||||
console.log('✅ Données sauvegardées avec succès');
|
||||
queryClient.invalidateQueries({ queryKey: ['/api/deliveries/bl'] });
|
||||
queryClient.invalidateQueries({ queryKey: ['/api/deliveries'] });
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Erreur auto-remplissage:', error);
|
||||
console.error('❌ Erreur auto-remplissage:', error);
|
||||
});
|
||||
} else {
|
||||
console.log('⚠️ Aucune donnée à sauvegarder');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -119,7 +119,7 @@ export const deliveries = pgTable("deliveries", {
|
||||
blAmount: decimal("bl_amount", { precision: 10, scale: 2 }), // Montant BL
|
||||
invoiceReference: varchar("invoice_reference"), // Référence facture
|
||||
invoiceAmount: decimal("invoice_amount", { precision: 10, scale: 2 }), // Montant facture
|
||||
dueDate: date("due_date"), // Date d'échéance de paiement (récupérée depuis NocoDB)
|
||||
dueDate: timestamp("dueDate"), // Date d'échéance de paiement (récupérée depuis NocoDB)
|
||||
reconciled: boolean("reconciled").default(false), // Rapprochement effectué
|
||||
validatedAt: timestamp("validated_at"), // Date de validation de la livraison
|
||||
// Champs pour le contrôle des livraisons (fournisseurs nécessitant un contrôle)
|
||||
|
||||
Reference in new issue
Block a user