{
  "module": "inventory",
  "morphisms": [
    {
      "name": "recibir_stock",
      "inputs": [
        { "role": "stock", "entity": "Stock" }
      ],
      "reads":  ["stock.cantidad", "stock.sku_id"],
      "writes": ["stock.cantidad", "MovimientoStock"],
      "depends_on": [],
      "script": "morphisms/recibir_stock.rhai"
    },
    {
      "name": "transferir_stock",
      "inputs": [
        { "role": "source", "entity": "Stock" },
        { "role": "dest",   "entity": "Stock" }
      ],
      "reads":  ["source.cantidad", "source.sku_id", "dest.cantidad", "dest.sku_id"],
      "writes": ["source.cantidad", "dest.cantidad", "TransferenciaStock"],
      "invariants": {
        "conserve": [
          { "entity": "Stock", "field": "cantidad", "group_by": "sku_id" }
        ]
      },
      "depends_on": [],
      "script": "morphisms/transferir_stock.rhai"
    }
  ]
}
