diff --git a/attached_assets/image_1757348664830.png b/attached_assets/image_1757348664830.png new file mode 100644 index 0000000..72bbc3c Binary files /dev/null and b/attached_assets/image_1757348664830.png differ diff --git a/client/src/pages/Avoirs.tsx b/client/src/pages/Avoirs.tsx index 10eab00..6442371 100644 --- a/client/src/pages/Avoirs.tsx +++ b/client/src/pages/Avoirs.tsx @@ -71,10 +71,19 @@ const avoirSchema = z.object({ supplierId: z.coerce.number().min(1, "Veuillez sélectionner un fournisseur"), groupId: z.coerce.number().min(1, "Veuillez sélectionner un magasin"), invoiceReference: z.string().optional(), - amount: z.union([ - z.string().length(0).transform(() => undefined), - z.coerce.number().positive() - ]).optional(), + amount: z.string().transform((val) => { + if (val === "" || val === null || val === undefined) { + return undefined; + } + 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"); + } + return num; + }).optional(), comment: z.string().optional(), commercialProcessed: z.boolean().optional(), status: z.enum(["En attente de demande", "Demandé", "Reçu"]).optional(),