This commit is contained in:
Lizandro Guarnizo
2026-05-13 22:05:20 -05:00
parent 381425b7e6
commit 9bcddcf1ea
4 changed files with 28 additions and 4 deletions
+14
View File
@@ -248,6 +248,7 @@ func GetHistorialContrato(c *fiber.Ctx) error {
Icono string `json:"icono"`
Titulo string `json:"titulo"`
Detalle string `json:"detalle"`
Enlace string `json:"enlace"` // URL de pago generada en este envío (opcional)
Estado string `json:"estado"` // ok | error | info
FechaISO string `json:"fecha"`
}
@@ -264,6 +265,18 @@ func GetHistorialContrato(c *fiber.Ctx) error {
FechaISO: contrato.CreatedAt.Format(time.RFC3339),
})
// Evento: pago confirmado (directo del contrato, siempre visible si se pagó)
if contrato.PagoConfirmado && contrato.FechaPago != nil {
timeline = append(timeline, Evento{
Tipo: "pago",
Icono: "currency",
Titulo: "Pago confirmado",
Detalle: "Nuevo vencimiento: " + contrato.FechaVencimiento.Format("02/01/2006"),
Estado: "ok",
FechaISO: contrato.FechaPago.Format(time.RFC3339),
})
}
// Evento: renovaciones (updated_at con estado renovado — heurístico por estado)
if contrato.Estado == "renovado" {
timeline = append(timeline, Evento{
@@ -297,6 +310,7 @@ func GetHistorialContrato(c *fiber.Ctx) error {
Icono: "mail",
Titulo: "Notificación enviada" + reglaLabel,
Detalle: detalle,
Enlace: n.EnlacePago,
Estado: estado,
FechaISO: n.CreatedAt.Format(time.RFC3339),
})