mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-11 17:27:31 +02:00
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:
1 parent
1470f221de
commit
91031b8c02
2 files changed
+3
-4
No files matched your search
@@ -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(),
|
||||
|
||||
+1
-1
@@ -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),
|
||||
|
||||
Reference in new issue
Block a user