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
This commit is contained in:
michaelschal committed 2025-09-08 20:01:01 +00:00
1 parent 1470f221de
commit 91031b8c02
2 files changed
+3 -4

No files matched your search

+2 -3
View File
@@ -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(),