From 9bcddcf1ea403c82b2ec4b4525b3a4224cc17ea3 Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Wed, 13 May 2026 22:05:20 -0500 Subject: [PATCH] up --- pkg/models/notificacion_log.go | 8 +++++--- pkg/services/renovacion_service.go | 1 + resources/views/renovaciones/contratos.html | 9 ++++++++- rest/controllers/contrato_controller.go | 14 ++++++++++++++ 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/pkg/models/notificacion_log.go b/pkg/models/notificacion_log.go index b4ebc90..be1853f 100644 --- a/pkg/models/notificacion_log.go +++ b/pkg/models/notificacion_log.go @@ -21,6 +21,7 @@ type NotificacionLog struct { Asunto string `json:"asunto" gorm:"column:asunto"` PreviewHTML string `json:"preview_html" gorm:"column:preview_html;type:text"` Pasarela string `json:"pasarela" gorm:"column:pasarela;type:varchar(20)"` // bold | dlocal | (vacío para correos de aviso) + EnlacePago string `json:"enlace_pago" gorm:"column:enlace_pago;type:text"` // URL del link de pago generado en este envío } func (NotificacionLog) TableName() string { return "notificaciones_log" } @@ -74,9 +75,10 @@ func CreateNotificacionLog(n NotificacionLog) (*NotificacionLog, error) { func UpdateNotificacionLog(n NotificacionLog) error { return app.Http.Database.DB.Model(&n).Updates(map[string]interface{}{ - "estado": n.Estado, - "error_msg": n.ErrorMsg, - "pasarela": n.Pasarela, + "estado": n.Estado, + "error_msg": n.ErrorMsg, + "pasarela": n.Pasarela, + "enlace_pago": n.EnlacePago, }).Error } diff --git a/pkg/services/renovacion_service.go b/pkg/services/renovacion_service.go index 2f0a78e..dd79a1f 100644 --- a/pkg/services/renovacion_service.go +++ b/pkg/services/renovacion_service.go @@ -232,6 +232,7 @@ func EnviarNotificacionGrupo(regla *models.NotificacionRegla, cliente *models.Cl Asunto: p.Asunto, PreviewHTML: html, Pasarela: pasarela, + EnlacePago: enlacePago, } savedLog, err := models.CreateNotificacionLog(logEntry) if err != nil { diff --git a/resources/views/renovaciones/contratos.html b/resources/views/renovaciones/contratos.html index 4700653..f421702 100644 --- a/resources/views/renovaciones/contratos.html +++ b/resources/views/renovaciones/contratos.html @@ -229,7 +229,14 @@

- + + Fallido
diff --git a/rest/controllers/contrato_controller.go b/rest/controllers/contrato_controller.go index 675b97c..adabd8b 100644 --- a/rest/controllers/contrato_controller.go +++ b/rest/controllers/contrato_controller.go @@ -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), })