{
  "id": "invoices",
  "label": "Facturación",
  "description": "Facturas emitidas y su seguimiento de pago.",
  "entities": [
    {
      "name": "invoice",
      "label": "Factura",
      "fields": [
        { "name": "invoice_number", "label": "N° factura", "kind": "text", "required": true },
        { "name": "customer_name", "label": "Cliente", "kind": "text", "required": true },
        { "name": "issued_at", "label": "Emitida", "kind": "date", "required": true },
        { "name": "due_at", "label": "Vencimiento", "kind": "date", "required": true },
        { "name": "subtotal", "label": "Subtotal", "kind": "number", "default": "0" },
        { "name": "tax", "label": "Impuestos", "kind": "number", "default": "0" },
        { "name": "total", "label": "Total", "kind": "number", "default": "0" },
        { "name": "amount_paid", "label": "Pagado", "kind": "number", "default": "0" },
        { "name": "status", "label": "Estado", "kind": "text", "required": true, "default": "issued", "help": "draft / issued / partially_paid / paid / overdue / void" },
        { "name": "currency", "label": "Moneda", "kind": "text", "default": "USD" },
        { "name": "reference_order", "label": "Orden referencia", "kind": "text" }
      ]
    }
  ],
  "menu": [
    { "label": "Facturas", "view": "list", "icon": "💳" },
    { "label": "Nueva factura", "view": "form", "icon": "✚" }
  ],
  "views": {
    "list": {
      "kind": "list",
      "title": "Facturas",
      "entity": "invoice",
      "columns": [
        { "field": "invoice_number", "label": "N°", "weight": 1.0 },
        { "field": "customer_name", "label": "Cliente", "weight": 2.0 },
        { "field": "issued_at", "label": "Emitida", "weight": 1.0 },
        { "field": "due_at", "label": "Vence", "weight": 1.0 },
        { "field": "total", "label": "Total", "weight": 1.0 },
        { "field": "amount_paid", "label": "Pagado", "weight": 1.0 },
        { "field": "currency", "label": "Mon.", "weight": 0.5 },
        { "field": "status", "label": "Estado", "weight": 0.9 }
      ],
      "actions": [
        { "kind": "open_view", "view": "form", "label": "✚ Nueva" }
      ],
      "search_in": ["invoice_number", "customer_name", "reference_order"]
    },
    "form": {
      "kind": "form",
      "title": "Nueva factura",
      "entity": "invoice",
      "fields": [
        { "name": "invoice_number", "label": "Número de factura", "kind": "text", "required": true },
        { "name": "customer_name", "label": "Cliente", "kind": "text", "required": true },
        { "name": "issued_at", "label": "Fecha de emisión", "kind": "date", "required": true },
        { "name": "due_at", "label": "Fecha de vencimiento", "kind": "date", "required": true },
        { "name": "subtotal", "label": "Subtotal", "kind": "number", "default": "0" },
        { "name": "tax", "label": "Impuestos", "kind": "number", "default": "0" },
        { "name": "total", "label": "Total", "kind": "number", "default": "0" },
        { "name": "amount_paid", "label": "Pagado", "kind": "number", "default": "0" },
        { "name": "status", "label": "Estado", "kind": "text", "required": true, "default": "issued" },
        { "name": "currency", "label": "Moneda", "kind": "text", "default": "USD" },
        { "name": "reference_order", "label": "Orden de venta referenciada", "kind": "text" }
      ],
      "on_submit": {
        "kind": "seed_entity",
        "entity": "invoice",
        "next_view": "list"
      }
    }
  }
}
