{
  "id": "sales_orders",
  "label": "Ventas",
  "description": "Órdenes de venta y sus líneas.",
  "entities": [
    {
      "name": "sales_order",
      "label": "Orden de venta",
      "fields": [
        { "name": "order_number", "label": "Número", "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" },
        { "name": "status", "label": "Estado", "kind": "text", "required": true, "default": "draft", "help": "draft / confirmed / shipped / closed / cancelled" },
        { "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": "notes", "label": "Notas", "kind": "multiline" }
      ]
    }
  ],
  "menu": [
    { "label": "Órdenes", "view": "list", "icon": "🧾" },
    { "label": "Nueva orden", "view": "form", "icon": "✚" }
  ],
  "views": {
    "list": {
      "kind": "list",
      "title": "Órdenes de venta",
      "entity": "sales_order",
      "columns": [
        { "field": "order_number", "label": "N°", "weight": 0.8 },
        { "field": "customer_name", "label": "Cliente", "weight": 2.0 },
        { "field": "issued_at", "label": "Emitida", "weight": 1.0 },
        { "field": "status", "label": "Estado", "weight": 0.8 },
        { "field": "total", "label": "Total", "weight": 1.0 }
      ],
      "actions": [
        { "kind": "open_view", "view": "form", "label": "✚ Nueva orden" }
      ],
      "search_in": ["order_number", "customer_name"]
    },
    "form": {
      "kind": "form",
      "title": "Nueva orden de venta",
      "entity": "sales_order",
      "fields": [
        { "name": "order_number", "label": "Número de orden", "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" },
        { "name": "status", "label": "Estado", "kind": "text", "required": true, "default": "draft" },
        { "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": "notes", "label": "Notas", "kind": "multiline" }
      ],
      "on_submit": {
        "kind": "seed_entity",
        "entity": "sales_order",
        "next_view": "list"
      }
    }
  }
}
