{
  "id": "inventory_movements",
  "label": "Inventario",
  "description": "Movimientos de stock: entradas, salidas, ajustes.",
  "entities": [
    {
      "name": "stock_movement",
      "label": "Movimiento",
      "fields": [
        { "name": "occurred_at", "label": "Fecha", "kind": "date", "required": true },
        { "name": "movement_type", "label": "Tipo", "kind": "text", "required": true, "help": "in / out / adjustment" },
        { "name": "product_sku", "label": "SKU producto", "kind": "text", "required": true },
        { "name": "quantity", "label": "Cantidad", "kind": "number", "required": true },
        { "name": "unit_cost", "label": "Costo unitario", "kind": "number", "default": "0" },
        { "name": "reason", "label": "Motivo", "kind": "text", "help": "Compra, venta, merma, ajuste por inventario..." },
        { "name": "reference", "label": "Doc. referencia", "kind": "text", "help": "Factura, orden, conteo..." }
      ]
    }
  ],
  "menu": [
    { "label": "Movimientos", "view": "list", "icon": "📊" },
    { "label": "Registrar", "view": "form", "icon": "✚" }
  ],
  "views": {
    "list": {
      "kind": "list",
      "title": "Movimientos de stock",
      "entity": "stock_movement",
      "columns": [
        { "field": "occurred_at", "label": "Fecha", "weight": 1.0 },
        { "field": "movement_type", "label": "Tipo", "weight": 0.7 },
        { "field": "product_sku", "label": "SKU", "weight": 1.0 },
        { "field": "quantity", "label": "Cantidad", "weight": 0.8 },
        { "field": "unit_cost", "label": "Costo", "weight": 0.8 },
        { "field": "reason", "label": "Motivo", "weight": 1.5 },
        { "field": "reference", "label": "Ref.", "weight": 1.0 }
      ],
      "actions": [
        { "kind": "open_view", "view": "form", "label": "✚ Registrar" }
      ],
      "search_in": ["product_sku", "reason", "reference"]
    },
    "form": {
      "kind": "form",
      "title": "Registrar movimiento",
      "entity": "stock_movement",
      "fields": [
        { "name": "occurred_at", "label": "Fecha", "kind": "date", "required": true },
        { "name": "movement_type", "label": "Tipo (in/out/adjustment)", "kind": "text", "required": true, "default": "in" },
        { "name": "product_sku", "label": "SKU producto", "kind": "text", "required": true },
        { "name": "quantity", "label": "Cantidad", "kind": "number", "required": true },
        { "name": "unit_cost", "label": "Costo unitario", "kind": "number", "default": "0" },
        { "name": "reason", "label": "Motivo", "kind": "text" },
        { "name": "reference", "label": "Documento de referencia", "kind": "text" }
      ],
      "on_submit": {
        "kind": "seed_entity",
        "entity": "stock_movement",
        "next_view": "list"
      }
    }
  }
}
