-- ============================================
-- 실사(재고 실물조사) 테이블
-- ============================================

CREATE TABLE IF NOT EXISTS `bag_inventory_inspection` (
  `bis_idx` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  `bis_lg_idx` INT UNSIGNED NOT NULL,
  `bis_work_date` DATE NOT NULL,
  `bis_status` VARCHAR(20) NOT NULL DEFAULT 'selected' COMMENT 'selected/counted/applied',
  `bis_reg_mb_idx` INT UNSIGNED NOT NULL DEFAULT 0,
  `bis_regdate` DATETIME NOT NULL,
  `bis_moddate` DATETIME NULL DEFAULT NULL,
  PRIMARY KEY (`bis_idx`),
  KEY `idx_bis_lg_work` (`bis_lg_idx`, `bis_work_date`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='실사 작업 헤더';

CREATE TABLE IF NOT EXISTS `bag_inventory_inspection_item` (
  `bisi_idx` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  `bisi_bis_idx` INT UNSIGNED NOT NULL,
  `bisi_bag_code` VARCHAR(50) NOT NULL,
  `bisi_bag_name` VARCHAR(100) NOT NULL DEFAULT '',
  `bisi_system_qty` INT NOT NULL DEFAULT 0,
  `bisi_actual_qty` INT NULL DEFAULT NULL,
  `bisi_diff_qty` INT NOT NULL DEFAULT 0,
  `bisi_has_barcode` CHAR(1) NOT NULL DEFAULT 'Y',
  `bisi_apply_yn` CHAR(1) NOT NULL DEFAULT 'N',
  PRIMARY KEY (`bisi_idx`),
  KEY `idx_bisi_bis` (`bisi_bis_idx`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='실사 작업 품목';
