mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-11 17:27:31 +02:00
Enable clearing of invoice fields and fix delivery date display
Update data transformation and validation logic in server routes to allow null values for invoice reference, amount, and due date. This addresses issues where users could not clear these fields and ensures the due date is correctly displayed. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 1e4433b5-47ab-464c-b663-fea2e53367dd Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: 693eaffa-e5f9-48b1-8bb4-034d4f47e3f4 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:
1 parent
d0747e39bb
commit
478ad4eb5b
3 files changed
+273
-11
No files matched your search
+206
@@ -0,0 +1,206 @@
|
||||
|
||||
|
||||
|
||||
|
||||
GET /api/deliveries 200 in 16975ms
|
||||
|
||||
🔗 PRODUCTION: getDeliveries() récupéré 195 livraisons avec relations
|
||||
|
||||
Deliveries returned: 195 items
|
||||
|
||||
GET /api/deliveries 200 in 17283ms
|
||||
|
||||
🔗 PRODUCTION: getDeliveries() récupéré 195 livraisons avec relations
|
||||
|
||||
Deliveries returned: 195 items
|
||||
|
||||
GET /api/deliveries 200 in 17249ms
|
||||
|
||||
🔗 PRODUCTION: getDeliveries() récupéré 195 livraisons avec relations
|
||||
|
||||
Deliveries returned: 195 items
|
||||
|
||||
GET /api/deliveries 200 in 17353ms
|
||||
|
||||
🔗 PRODUCTION: getDeliveries() récupéré 195 livraisons avec relations
|
||||
|
||||
Deliveries returned: 195 items
|
||||
|
||||
GET /api/deliveries 200 in 17284ms
|
||||
|
||||
🔗 PRODUCTION: getDeliveries() récupéré 195 livraisons avec relations
|
||||
|
||||
Deliveries returned: 195 items
|
||||
|
||||
GET /api/deliveries 200 in 17188ms
|
||||
|
||||
🔗 PRODUCTION: getDeliveries() récupéré 195 livraisons avec relations
|
||||
|
||||
Deliveries returned: 195 items
|
||||
|
||||
GET /api/deliveries 200 in 17045ms
|
||||
|
||||
🔗 PRODUCTION: getOrder #256 found 1 associated deliveries
|
||||
|
||||
✅ PRODUCTION: getDelivery #427 found associated order #256 with status: delivered
|
||||
|
||||
🔗 PRODUCTION: getDeliveries() récupéré 195 livraisons avec relations
|
||||
|
||||
Deliveries returned: 195 items
|
||||
|
||||
🔄 Updating delivery: {
|
||||
|
||||
id: 427,
|
||||
|
||||
|
||||
|
||||
{
|
||||
|
||||
blNumber: '197771',
|
||||
|
||||
blAmount: '695.66',
|
||||
|
||||
invoiceReference: null,
|
||||
|
||||
invoiceAmount: null
|
||||
|
||||
},
|
||||
|
||||
user: 'admin_local'
|
||||
|
||||
}
|
||||
|
||||
GET /api/deliveries 200 in 17076ms
|
||||
|
||||
✅ Delivery updated successfully: {
|
||||
|
||||
id: 427,
|
||||
|
||||
updatedDelivery: {
|
||||
|
||||
␍ id: 427,
|
||||
|
||||
orderId: 256,
|
||||
|
||||
supplierId: 7,
|
||||
|
||||
groupId: 1,
|
||||
|
||||
scheduledDate: '2025-10-31',
|
||||
|
||||
deliveredDate: 2025-10-31T08:32:15.684Z,
|
||||
|
||||
quantity: 1,
|
||||
|
||||
unit: 'palettes',
|
||||
|
||||
status: 'delivered',
|
||||
|
||||
notes: null,
|
||||
|
||||
blNumber: '197771',
|
||||
|
||||
blAmount: '695.66',
|
||||
|
||||
invoiceReference: null,
|
||||
|
||||
invoiceAmount: null,
|
||||
|
||||
dueDate: null,
|
||||
|
||||
reconciled: false,
|
||||
|
||||
validatedAt: null,
|
||||
|
||||
controlValidated: false,
|
||||
|
||||
controlValidatedBy: null,
|
||||
|
||||
controlValidatedAt: null,
|
||||
|
||||
createdBy: '_1754943032954',
|
||||
|
||||
createdAt: 2025-10-30T08:47:43.018Z,
|
||||
|
||||
updatedAt: 2025-11-04T05:51:30.924Z
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
PUT /api/deliveries/427 200 in 17189ms
|
||||
|
||||
Deliveries API called with: {
|
||||
|
||||
startDate: undefined,
|
||||
|
||||
endDate: undefined,
|
||||
|
||||
storeId: '1',
|
||||
|
||||
withBL: undefined,
|
||||
|
||||
userRole: 'admin'
|
||||
|
||||
}
|
||||
|
||||
🔍 Admin deliveries filtering by store: { storeId: '1', groupIds: [ 1 ], role: 'admin' }
|
||||
|
||||
Fetching all deliveries
|
||||
|
||||
🔗 PRODUCTION: getDeliveries() récupéré 195 livraisons avec relations
|
||||
|
||||
Deliveries returned: 195 items
|
||||
|
||||
GET /api/deliveries 200 in 158ms
|
||||
|
||||
Deliveries API called with: {
|
||||
|
||||
startDate: undefined,
|
||||
|
||||
endDate: undefined,
|
||||
|
||||
storeId: '1',
|
||||
|
||||
withBL: undefined,
|
||||
|
||||
userRole: 'admin'
|
||||
|
||||
}
|
||||
|
||||
🔍 Admin deliveries filtering by store: { storeId: '1', groupIds: [ 1 ], role: 'admin' }
|
||||
|
||||
Fetching all deliveries
|
||||
|
||||
🔗 PRODUCTION: getDeliveries() récupéré 195 livraisons avec relations
|
||||
|
||||
Deliveries returned: 195 items
|
||||
|
||||
GET /api/deliveries 304 in 147ms
|
||||
|
||||
Deliveries API called with: {
|
||||
|
||||
startDate: undefined,
|
||||
|
||||
endDate: undefined,
|
||||
|
||||
storeId: '1',
|
||||
|
||||
withBL: undefined,
|
||||
|
||||
userRole: 'admin'
|
||||
|
||||
}
|
||||
|
||||
🔍 Admin deliveries filtering by store: { storeId: '1', groupIds: [ 1 ], role: 'admin' }
|
||||
|
||||
Fetching all deliveries
|
||||
|
||||
🔗 PRODUCTION: getDeliveries() récupéré 195 livraisons avec relations
|
||||
|
||||
Deliveries returned: 195 items
|
||||
|
||||
GET /api/deliveries 304 in 139ms
|
||||
|
||||
HEAD /api/health 200 in 1ms
|
||||
|
||||
+66
-10
@@ -1401,20 +1401,40 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
// Transform data types before validation
|
||||
const transformedData = { ...req.body };
|
||||
|
||||
// Convert decimal amounts to strings (schema expects string for decimal fields)
|
||||
if (transformedData.blAmount !== undefined && transformedData.blAmount !== null) {
|
||||
transformedData.blAmount = transformedData.blAmount.toString();
|
||||
// Convert decimal amounts to strings or null (schema expects string for decimal fields)
|
||||
if (transformedData.blAmount !== undefined) {
|
||||
transformedData.blAmount = (transformedData.blAmount === null || transformedData.blAmount === '')
|
||||
? null
|
||||
: transformedData.blAmount.toString();
|
||||
}
|
||||
if (transformedData.invoiceAmount !== undefined && transformedData.invoiceAmount !== null) {
|
||||
transformedData.invoiceAmount = transformedData.invoiceAmount.toString();
|
||||
if (transformedData.invoiceAmount !== undefined) {
|
||||
transformedData.invoiceAmount = (transformedData.invoiceAmount === null || transformedData.invoiceAmount === '')
|
||||
? null
|
||||
: transformedData.invoiceAmount.toString();
|
||||
}
|
||||
|
||||
// Convert timestamp fields to Date objects (schema expects Date for timestamp fields)
|
||||
if (transformedData.validatedAt && typeof transformedData.validatedAt === 'string') {
|
||||
transformedData.validatedAt = new Date(transformedData.validatedAt);
|
||||
// Convert text fields - allow null for clearing
|
||||
if (transformedData.invoiceReference !== undefined) {
|
||||
transformedData.invoiceReference = (transformedData.invoiceReference === '')
|
||||
? null
|
||||
: transformedData.invoiceReference;
|
||||
}
|
||||
if (transformedData.dueDate && typeof transformedData.dueDate === 'string') {
|
||||
transformedData.dueDate = new Date(transformedData.dueDate);
|
||||
if (transformedData.blNumber !== undefined) {
|
||||
transformedData.blNumber = (transformedData.blNumber === '')
|
||||
? null
|
||||
: transformedData.blNumber;
|
||||
}
|
||||
|
||||
// Convert timestamp fields to Date objects or null (schema expects Date for timestamp fields)
|
||||
if (transformedData.validatedAt !== undefined) {
|
||||
transformedData.validatedAt = (transformedData.validatedAt === null || transformedData.validatedAt === '')
|
||||
? null
|
||||
: new Date(transformedData.validatedAt);
|
||||
}
|
||||
if (transformedData.dueDate !== undefined) {
|
||||
transformedData.dueDate = (transformedData.dueDate === null || transformedData.dueDate === '')
|
||||
? null
|
||||
: new Date(transformedData.dueDate);
|
||||
}
|
||||
|
||||
const data = insertDeliverySchema.partial().parse(transformedData);
|
||||
@@ -1859,6 +1879,42 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
}
|
||||
|
||||
console.log('✅ Résultat vérification:', result);
|
||||
|
||||
// CRITICAL FIX: Sauvegarder les données dans la table deliveries après vérification réussie
|
||||
if (result.exists && (result.invoiceAmount !== undefined || result.dueDate !== undefined || result.invoiceReference !== undefined)) {
|
||||
try {
|
||||
const updateData: any = {};
|
||||
|
||||
// Ajouter la référence facture si trouvée
|
||||
if (result.invoiceReference) {
|
||||
updateData.invoiceReference = result.invoiceReference;
|
||||
}
|
||||
|
||||
// Ajouter le montant facture si trouvé
|
||||
if (result.invoiceAmount !== undefined && result.invoiceAmount !== null) {
|
||||
updateData.invoiceAmount = result.invoiceAmount.toString();
|
||||
}
|
||||
|
||||
// Ajouter l'échéance si trouvée
|
||||
if (result.dueDate) {
|
||||
const normalizedDateString = normalizeDateString(result.dueDate);
|
||||
if (normalizedDateString) {
|
||||
updateData.dueDate = new Date(normalizedDateString);
|
||||
console.log(`✅ Sauvegarde échéance dans deliveries: ${normalizedDateString}`);
|
||||
}
|
||||
}
|
||||
|
||||
// Mettre à jour la livraison si on a des données
|
||||
if (Object.keys(updateData).length > 0) {
|
||||
await storage.updateDelivery(deliveryId, updateData);
|
||||
console.log(`✅ Livraison #${deliveryId} mise à jour avec:`, updateData);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('❌ Erreur sauvegarde données vérification:', error);
|
||||
// Ne pas bloquer la réponse, juste logger l'erreur
|
||||
}
|
||||
}
|
||||
|
||||
res.json(result);
|
||||
} catch (error) {
|
||||
console.error("Error verifying invoice:", error);
|
||||
|
||||
+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: timestamp("dueDate"), // Date d'échéance de paiement (récupérée depuis NocoDB)
|
||||
dueDate: timestamp("due_date"), // 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