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),