Merge pull request #411 from R0m1k3/1.1

Fix issue with empty amount fields not saving correctly
This commit is contained in:
LogiFlow authored and GitHub committed 2025-09-08 22:32:34 +02:00
commit a9c0af8eeb
2 files changed
+10 -1

No files matched your search

Binary file not shown.

After

Width:  |  Height:  |  Size: 301 KiB

+10 -1
View File
@@ -2506,7 +2506,16 @@ export async function registerRoutes(app: Express): Promise<Server> {
const validatedData = insertAvoirSchema.partial().parse(req.body);
console.log('💰 PUT Avoir - Validated data:', JSON.stringify(validatedData, null, 2));
const updatedAvoir = await storage.updateAvoir(id, validatedData);
// ✅ FIX: Convertir undefined en null pour les champs optionnels (important pour PostgreSQL)
const dataForDb: any = {
...validatedData,
amount: validatedData.amount === undefined ? null : validatedData.amount,
invoiceReference: validatedData.invoiceReference === undefined ? null : validatedData.invoiceReference,
comment: validatedData.comment === undefined ? null : validatedData.comment,
};
console.log('💰 PUT Avoir - Data for DB (undefined → null):', JSON.stringify(dataForDb, null, 2));
const updatedAvoir = await storage.updateAvoir(id, dataForDb);
console.log('✅ Avoir updated:', id, 'by user:', user.id);
// 🎯 WEBHOOK QUAND STATUT PASSE À "Reçu"