-- Table to store planned MO quantity per BOM
-- Used by productionrules module to prefill MO qty during creation
-- Decouples BOM header qty (pack count) from actual planned production qty
-- job_number: indexed for efficient MAX queries (O(1) vs O(n) label parsing)

CREATE TABLE llx_prod_bom_mo_qty (
  rowid           INT AUTO_INCREMENT PRIMARY KEY,
  fk_bom          INT NOT NULL,
  qty_to_produce  DOUBLE NOT NULL DEFAULT 1.0,
  job_number      INT NULL,
  entity          INT NOT NULL DEFAULT 1,
  created_at      DATETIME,
  KEY idx_fk_bom (fk_bom),
  KEY idx_entity (entity),
  KEY idx_job_entity (job_number, entity)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
