Improve handling of numeric input for financial amounts in task management

Update the schema validation for the 'amount' field in the Avoirs component to correctly handle optional, potentially empty numeric inputs, resolving potential runtime errors.

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/KZQgDPI
This commit is contained in:
michaelschal committed 2025-09-08 16:22:52 +00:00
1 parent 3c8ce736cc
commit 558e336188
2 files changed
+4 -1

No files matched your search

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

+4 -1
View File
@@ -71,7 +71,10 @@ 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.preprocess((val) => val === "" ? undefined : val, z.coerce.number().positive().optional()),
amount: z.union([
z.string().length(0).transform(() => undefined),
z.coerce.number().positive()
]).optional(),
comment: z.string().optional(),
commercialProcessed: z.boolean().optional(),
status: z.enum(["En attente de demande", "Demandé", "Reçu"]).optional(),