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:
Lizandro GD
2026-08-03 00:45:58 +00:00
co-authored by Claude Sonnet 5
parent 772a4a5656
commit 516220a8a1
32 changed files with 2272 additions and 132 deletions
@@ -0,0 +1,56 @@
package controllers
import (
"math"
"strconv"
"github.com/gofiber/fiber/v2"
"github.com/sujit-baniya/fiber-boilerplate/pkg/models"
"github.com/sujit-baniya/fiber-boilerplate/pkg/services"
)
// GetArquitecturas lista los patrones de arquitectura de referencia.
func GetArquitecturas(c *fiber.Ctx) error {
page, _ := strconv.Atoi(c.Query("page", "1"))
limit, _ := strconv.Atoi(c.Query("limit", "20"))
if page < 1 {
page = 1
}
offset := (page - 1) * limit
records, total, err := models.GetAllArquitecturas(limit, offset, c.Query("search"), c.Query("solo_referencias") == "true")
if err != nil {
return c.Status(500).JSON(fiber.Map{"error": err.Error()})
}
return c.JSON(fiber.Map{
"registros": records,
"total": total,
"totalPages": int(math.Ceil(float64(total) / float64(limit))),
"page": page,
})
}
type crearArquitecturaRequest struct {
Requerimiento string `json:"requerimiento"`
Propuesta string `json:"propuesta"`
Nombre string `json:"nombre"`
ClienteID uint `json:"cliente_id"`
GuardarComoReferencia bool `json:"guardar_como_referencia"`
}
// CreateArquitectura genera el PDF de una propuesta técnica.
// POST /api/v2/arquitecturas
func CreateArquitectura(c *fiber.Ctx) error {
var req crearArquitecturaRequest
if err := c.BodyParser(&req); err != nil {
return c.Status(400).JSON(fiber.Map{"error": err.Error()})
}
var clienteID *uint
if req.ClienteID != 0 {
clienteID = &req.ClienteID
}
doc, err := services.GenerarArquitectura(req.Requerimiento, req.Propuesta, req.Nombre, clienteID, req.GuardarComoReferencia, 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})
}