feat: automatización de cotizaciones, contratos, actas y cuentas de cobro con IA
Implementa las 4 fases de la especificación de automatización: módulo de plantillas/tarifas editable por el equipo, generación de PDF (HTML+JS vía Chrome headless) para cotizaciones/contratos/arquitecturas/cuentas de cobro, chat propio en el dashboard reutilizando el mismo motor y tools del bot de Telegram, y nuevas tools del agente para crear estos documentos end-to-end. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
772a4a5656
commit
516220a8a1
@@ -7,6 +7,7 @@ import (
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/sujit-baniya/fiber-boilerplate/pkg/models"
|
||||
"github.com/sujit-baniya/fiber-boilerplate/pkg/services"
|
||||
)
|
||||
|
||||
// ─── Render de vistas ────────────────────────────────────────────────────────
|
||||
@@ -408,12 +409,12 @@ func GetCuentasCobro(c *fiber.Ctx) error {
|
||||
|
||||
func CreateCuentaCobro(c *fiber.Ctx) error {
|
||||
type Req struct {
|
||||
ClienteID uint `json:"cliente_id"`
|
||||
Fecha string `json:"fecha"`
|
||||
Descripcion string `json:"descripcion"`
|
||||
Valor float64 `json:"valor"`
|
||||
FechaVencimiento string `json:"fecha_vencimiento"`
|
||||
Notas string `json:"notas"`
|
||||
ClienteID uint `json:"cliente_id"`
|
||||
Fecha string `json:"fecha"`
|
||||
Descripcion string `json:"descripcion"`
|
||||
Valor float64 `json:"valor"`
|
||||
FechaVencimiento string `json:"fecha_vencimiento"`
|
||||
Notas string `json:"notas"`
|
||||
}
|
||||
var req Req
|
||||
if err := c.BodyParser(&req); err != nil {
|
||||
@@ -452,13 +453,13 @@ func UpdateCuentaCobro(c *fiber.Ctx) error {
|
||||
return c.Status(400).JSON(fiber.Map{"error": "ID inválido"})
|
||||
}
|
||||
type Req struct {
|
||||
Estado string `json:"estado"`
|
||||
FechaPago string `json:"fecha_pago"`
|
||||
TransaccionID *uint `json:"transaccion_id"`
|
||||
Notas string `json:"notas"`
|
||||
FechaVencimiento string `json:"fecha_vencimiento"`
|
||||
Descripcion string `json:"descripcion"`
|
||||
Valor float64 `json:"valor"`
|
||||
Estado string `json:"estado"`
|
||||
FechaPago string `json:"fecha_pago"`
|
||||
TransaccionID *uint `json:"transaccion_id"`
|
||||
Notas string `json:"notas"`
|
||||
FechaVencimiento string `json:"fecha_vencimiento"`
|
||||
Descripcion string `json:"descripcion"`
|
||||
Valor float64 `json:"valor"`
|
||||
}
|
||||
var req Req
|
||||
if err := c.BodyParser(&req); err != nil {
|
||||
@@ -564,10 +565,10 @@ func UpdateCuentaPagar(c *fiber.Ctx) error {
|
||||
return c.Status(400).JSON(fiber.Map{"error": "ID inválido"})
|
||||
}
|
||||
type Req struct {
|
||||
Estado string `json:"estado"`
|
||||
FechaPago string `json:"fecha_pago"`
|
||||
TransaccionID *uint `json:"transaccion_id"`
|
||||
Notas string `json:"notas"`
|
||||
Estado string `json:"estado"`
|
||||
FechaPago string `json:"fecha_pago"`
|
||||
TransaccionID *uint `json:"transaccion_id"`
|
||||
Notas string `json:"notas"`
|
||||
}
|
||||
var req Req
|
||||
if err := c.BodyParser(&req); err != nil {
|
||||
@@ -614,6 +615,21 @@ func MarcarCuentaPagarPagada(c *fiber.Ctx) error {
|
||||
return c.JSON(fiber.Map{"ok": true})
|
||||
}
|
||||
|
||||
// GenerarDocumentoCuentaCobro produce el PDF de solicitud de cuenta de cobro a
|
||||
// partir de la plantilla activa tipo 'cuenta_cobro'.
|
||||
// POST /api/v2/contabilidad/cuentas-cobro/:id/generar-documento
|
||||
func GenerarDocumentoCuentaCobro(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"})
|
||||
}
|
||||
doc, err := services.GenerarDocumentoCuentaCobro(uint(id), generadoPorFromContext(c))
|
||||
if err != nil {
|
||||
return c.Status(400).JSON(fiber.Map{"error": err.Error()})
|
||||
}
|
||||
return c.Status(201).JSON(fiber.Map{"ok": true, "documento": doc})
|
||||
}
|
||||
|
||||
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