From 91031b8c02d675e75c18c4264eeb2c81d6dbc4c1 Mon Sep 17 00:00:00 2001 From: michaelschal <35957947-michaelschal@users.noreply.replit.com> Date: Mon, 8 Sep 2025 20:01:01 +0000 Subject: [PATCH] Allow zero and negative amounts for financial entries Update validation schema for financial entries to permit zero and negative values for amounts, and allow empty values for invoice references. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 9fcf4b21-eb0c-4e53-a567-e2ce4a6ad869 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/9fcf4b21-eb0c-4e53-a567-e2ce4a6ad869/uMhb9Na --- client/src/pages/Avoirs.tsx | 5 ++--- shared/schema.ts | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/client/src/pages/Avoirs.tsx b/client/src/pages/Avoirs.tsx index 1b5416a..a992c66 100644 --- a/client/src/pages/Avoirs.tsx +++ b/client/src/pages/Avoirs.tsx @@ -81,13 +81,12 @@ const avoirSchema = z.object({ z.undefined().transform(() => undefined), z.literal("").transform(() => undefined), z.string().transform((val) => { + if (val.trim() === '') return undefined; // Permettre les champs vides const num = parseFloat(val); if (isNaN(num)) { throw new Error("Montant invalide"); } - if (num <= 0) { - throw new Error("Le montant doit être supérieur à 0"); - } + // Supprimer la restriction > 0 pour permettre zéro et les montants négatifs (avoirs) return num; }) ]).optional(), diff --git a/shared/schema.ts b/shared/schema.ts index f2e0efa..e772088 100644 --- a/shared/schema.ts +++ b/shared/schema.ts @@ -585,7 +585,7 @@ export const insertAvoirSchema = createInsertSchema(avoirs).omit({ processedAt: true, }).extend({ status: z.enum(["En attente de demande", "Demandé", "Reçu"]).default("En attente de demande"), - amount: z.coerce.number().refine(val => val !== 0, "Le montant ne peut pas être zéro").optional(), // Montant optionnel, positif ou négatif (mais pas zéro) + amount: z.coerce.number().optional().nullable(), // Montant optionnel, peut être vide, zéro, positif ou négatif invoiceReference: z.string().optional(), // Référence facture optionnelle comment: z.string().optional(), commercialProcessed: z.boolean().default(false),