feat: agente - agregar listar_facturas + campos agente en AI Config create/update

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro GD
2026-07-13 18:31:15 +00:00
co-authored by Claude Sonnet 4.6
parent 33cfe4fdb0
commit 5c81939bbf
2 changed files with 70 additions and 31 deletions
+31
View File
@@ -130,6 +130,14 @@ func agentTools() []agentTool {
"uuid": str("UUID de la aplicación"),
}, []string{"config_id", "uuid"})),
// ── Facturas ─────────────────────────────────────────────────────────
tool("listar_facturas", "Lista facturas. Puede filtrar por estado: pendiente, pagada, vencida, cancelada.",
obj(map[string]agentToolParam{
"page": num("Página (default 1)"),
"search": str("Búsqueda por número, cliente o descripción"),
"estado": agentToolParam{Type: "string", Description: "pendiente | pagada | vencida | cancelada", Enum: []string{"pendiente", "pagada", "vencida", "cancelada", ""}},
}, nil)),
// ── Clientes ─────────────────────────────────────────────────────────
tool("listar_clientes", "Lista clientes con paginación y búsqueda.",
obj(map[string]agentToolParam{
@@ -360,6 +368,29 @@ func runTool(name string, a map[string]interface{}) (interface{}, error) {
return coolifyAppAction(getInt("config_id", 0), getStr("uuid"), "start")
// ── Clientes ───────────────────────────────────────────────────────────
case "listar_facturas":
page := getInt("page", 1)
search := getStr("search")
estado := getStr("estado")
limit := 10
offset := (page - 1) * limit
all, total, err := models.GetAllFacturas(limit, offset, search)
if err != nil {
return nil, err
}
// Filtrar por estado si se especificó
items := all
if estado != "" {
items = nil
for _, f := range all {
if f.Estado == estado {
items = append(items, f)
}
}
total = int64(len(items))
}
return map[string]interface{}{"items": items, "total": total, "page": page}, nil
case "listar_clientes":
page := getInt("page", 1)
search := getStr("search")