fix: marcar pagada en cuentas por pagar sobreescribía datos con ceros
UpdateCuentaPagar actualizaba TODAS las columnas incluyendo entidad_id=0, valor=0, descripcion='' cuando solo se enviaba estado+fecha_pago. Se agrega MarcarCuentaPagarPagada que solo toca estado y fecha_pago, con su endpoint POST /cuentas-pagar/:id/pagar. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
2ee5e2ea83
commit
daf0b2c2a1
@@ -591,6 +591,29 @@ func UpdateCuentaPagar(c *fiber.Ctx) error {
|
||||
return c.JSON(fiber.Map{"ok": true})
|
||||
}
|
||||
|
||||
func MarcarCuentaPagarPagada(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseUint(c.Params("id"), 10, 32)
|
||||
if err != nil {
|
||||
return c.Status(400).JSON(fiber.Map{"error": "ID inválido"})
|
||||
}
|
||||
var req struct {
|
||||
FechaPago string `json:"fecha_pago"`
|
||||
}
|
||||
if err := c.BodyParser(&req); err != nil {
|
||||
return c.Status(400).JSON(fiber.Map{"error": err.Error()})
|
||||
}
|
||||
fecha := time.Now()
|
||||
if req.FechaPago != "" {
|
||||
if parsed, err := time.Parse("2006-01-02", req.FechaPago); err == nil {
|
||||
fecha = parsed
|
||||
}
|
||||
}
|
||||
if err := models.MarcarCuentaPagarPagada(uint(id), fecha); err != nil {
|
||||
return c.Status(500).JSON(fiber.Map{"error": err.Error()})
|
||||
}
|
||||
return c.JSON(fiber.Map{"ok": true})
|
||||
}
|
||||
|
||||
func DeleteCuentaPagar(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseUint(c.Params("id"), 10, 32)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user