-- =============================================================================
-- XPERT 3PL - Migracion 003
-- Campos adicionales de items necesarios para la carga masiva (CSV) y para
-- tener paridad con los campos base que maneja SAP/XPERT en OITM.
-- =============================================================================

ALTER TABLE `items`
    ADD COLUMN `category` VARCHAR(100) NULL COMMENT 'Rubro/categoria (equivalente a ItmsGrpNam de SAP)' AFTER `description`,
    ADD COLUMN `external_code` VARCHAR(50) NULL COMMENT 'Codigo del item en el sistema propio del cliente (si tiene uno)' AFTER `barcode`,
    ADD COLUMN `shelf_life_days` INT UNSIGNED NULL COMMENT 'Solo aplica si requires_expiry=1' AFTER `requires_serial`,
    ADD COLUMN `min_remaining_shelf_life_days` INT UNSIGNED NULL COMMENT 'Vida util minima remanente aceptada al recibir' AFTER `shelf_life_days`,
    ADD COLUMN `requires_temp_control` TINYINT(1) NOT NULL DEFAULT 0 AFTER `min_remaining_shelf_life_days`,
    ADD COLUMN `min_storage_temp` DECIMAL(5,2) NULL AFTER `requires_temp_control`,
    ADD COLUMN `max_storage_temp` DECIMAL(5,2) NULL AFTER `min_storage_temp`;

ALTER TABLE `items` ADD KEY `idx_items_external_code` (`external_code`);
