Fix
This commit is contained in:
@@ -54,7 +54,7 @@ export function detectTypeEvenement(changements) {
|
||||
// table dédiée, déclenche la régénération automatique de l'échéancier futur.
|
||||
const RevisionSchema = z.object({
|
||||
date_effet: z.string().regex(/^\d{4}-\d{2}-\d{2}$/),
|
||||
nouveau_taux: z.number().positive().optional(),
|
||||
nouveau_taux: z.number().nonnegative().optional(),
|
||||
nouvelle_date_cible: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional(),
|
||||
motif: z.string().trim().min(1, 'Le motif est obligatoire'),
|
||||
}).refine(d => d.nouveau_taux !== undefined || d.nouvelle_date_cible !== undefined, {
|
||||
|
||||
@@ -102,7 +102,9 @@ router.post('/generate', (req, res, next) => {
|
||||
const { investissement_id, replace = true } = req.body;
|
||||
if (!investissement_id) throw new HttpError(400, 'investissement_id required');
|
||||
const inv = assertOwnedInvestissement(Number(investissement_id), req.user.id);
|
||||
if (!inv.taux_interet || !inv.duree_mois) {
|
||||
// taux_interet peut légitimement valoir 0 (ex. révision suite à un arrêt de production) —
|
||||
// ne pas confondre avec "non renseigné" (null/undefined).
|
||||
if (inv.taux_interet == null || !inv.duree_mois) {
|
||||
throw new HttpError(400, 'Investissement requires taux_interet and duree_mois');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user