diff --git a/server.js b/server.js index 3243e06..090c362 100644 --- a/server.js +++ b/server.js @@ -5173,6 +5173,11 @@ app.post("/budgets/:id/convert", authMiddleware, async (req, res) => { if (bq.rowCount === 0) return res.status(404).json({ok: false}); const budget = bq.rows[0]; + // 🛑 Evitar conversiones duplicadas: si este presupuesto ya se convirtió antes en un servicio, no crear otro + if (budget.status === 'converted' || budget.status === 'paid') { + return res.status(409).json({ ok: false, error: "Este presupuesto ya fue convertido en un servicio anteriormente." }); + } + // 🟢 Saber si ya estaba pagado antes de convertirlo const isAlreadyPaid = budget.status === 'paid';