-- 구매리스트 테이블 생성
CREATE TABLE IF NOT EXISTS PURCHASE_LIST (
	OBJID VARCHAR(50) PRIMARY KEY,
	SALES_REQUEST_MASTER_OBJID VARCHAR(50),
	PART_NO VARCHAR(100),
	PART_NAME VARCHAR(200),
	QTY VARCHAR(50),
	ITEM_QTY VARCHAR(50),
	FILE_3D VARCHAR(200),
	FILE_2D VARCHAR(200),
	FILE_PDF VARCHAR(200),
	MATERIAL VARCHAR(200),
	HEAT_TREATMENT_HARDNESS VARCHAR(100),
	HEAT_TREATMENT_METHOD VARCHAR(100),
	SURFACE_TREATMENT VARCHAR(100),
	SUPPLIER VARCHAR(200),
	CATEGORY_NAME VARCHAR(100),
	SUPPLY_TYPE VARCHAR(50),
	RAW_MATERIAL VARCHAR(200),
	SIZE VARCHAR(100),
	RAW_MATERIAL_PART_NO VARCHAR(100),
	RAW_MATERIAL_REQUIRED_QTY VARCHAR(50),
	RAW_MATERIAL_ORDER_QTY VARCHAR(50),
	ITEM_QTY2 VARCHAR(50),
	PRODUCTION_QTY VARCHAR(50),
	PROCESSING_COMPANY VARCHAR(200),
	PROCESSING_DELIVERY_DATE DATE,
	GRINDING_DELIVERY_DATE DATE,
	USE_YN VARCHAR(1) DEFAULT 'Y',
	NET_QTY VARCHAR(50),
	ORDER_QTY VARCHAR(50),
	SUPPLIER2 VARCHAR(200),
	UNIT_PRICE VARCHAR(50),
	TOTAL_PRICE VARCHAR(50),
	PROPOSAL_DATE DATE,
	WRITER VARCHAR(50),
	REGDATE TIMESTAMP DEFAULT NOW()
);

-- 인덱스 생성
CREATE INDEX IF NOT EXISTS idx_purchase_list_sales_request ON PURCHASE_LIST(SALES_REQUEST_MASTER_OBJID);

-- 컬럼 설명
COMMENT ON TABLE PURCHASE_LIST IS '구매리스트';
COMMENT ON COLUMN PURCHASE_LIST.OBJID IS 'OBJID';
COMMENT ON COLUMN PURCHASE_LIST.SALES_REQUEST_MASTER_OBJID IS '구매요청서 OBJID';
COMMENT ON COLUMN PURCHASE_LIST.PART_NO IS '품번';
COMMENT ON COLUMN PURCHASE_LIST.PART_NAME IS '품명';
COMMENT ON COLUMN PURCHASE_LIST.QTY IS '수량';
COMMENT ON COLUMN PURCHASE_LIST.ITEM_QTY IS '항목수량';
COMMENT ON COLUMN PURCHASE_LIST.FILE_3D IS '3D';
COMMENT ON COLUMN PURCHASE_LIST.FILE_2D IS '2D';
COMMENT ON COLUMN PURCHASE_LIST.FILE_PDF IS 'PDF';
COMMENT ON COLUMN PURCHASE_LIST.MATERIAL IS '재료';
COMMENT ON COLUMN PURCHASE_LIST.HEAT_TREATMENT_HARDNESS IS '열처리경도';
COMMENT ON COLUMN PURCHASE_LIST.HEAT_TREATMENT_METHOD IS '열처리방법';
COMMENT ON COLUMN PURCHASE_LIST.SURFACE_TREATMENT IS '표면처리';
COMMENT ON COLUMN PURCHASE_LIST.SUPPLIER IS '공급업체';
COMMENT ON COLUMN PURCHASE_LIST.CATEGORY_NAME IS '범주이름';
COMMENT ON COLUMN PURCHASE_LIST.SUPPLY_TYPE IS '지급/사급';
COMMENT ON COLUMN PURCHASE_LIST.RAW_MATERIAL IS '소재';
COMMENT ON COLUMN PURCHASE_LIST.SIZE IS '사이즈';
COMMENT ON COLUMN PURCHASE_LIST.RAW_MATERIAL_PART_NO IS '소재품번';
COMMENT ON COLUMN PURCHASE_LIST.RAW_MATERIAL_REQUIRED_QTY IS '소재소요량';
COMMENT ON COLUMN PURCHASE_LIST.RAW_MATERIAL_ORDER_QTY IS '소재발주수량';
COMMENT ON COLUMN PURCHASE_LIST.ITEM_QTY2 IS '항목수량';
COMMENT ON COLUMN PURCHASE_LIST.PRODUCTION_QTY IS '제작수량';
COMMENT ON COLUMN PURCHASE_LIST.PROCESSING_COMPANY IS '가공업체';
COMMENT ON COLUMN PURCHASE_LIST.PROCESSING_DELIVERY_DATE IS '가공납기';
COMMENT ON COLUMN PURCHASE_LIST.GRINDING_DELIVERY_DATE IS '연삭납기';
COMMENT ON COLUMN PURCHASE_LIST.USE_YN IS '사용여부';
COMMENT ON COLUMN PURCHASE_LIST.NET_QTY IS '정미수량';
COMMENT ON COLUMN PURCHASE_LIST.ORDER_QTY IS '발주수량';
COMMENT ON COLUMN PURCHASE_LIST.SUPPLIER2 IS '공급업체';
COMMENT ON COLUMN PURCHASE_LIST.UNIT_PRICE IS '단가';
COMMENT ON COLUMN PURCHASE_LIST.TOTAL_PRICE IS '총단가';
COMMENT ON COLUMN PURCHASE_LIST.PROPOSAL_DATE IS '품의서작성일';
COMMENT ON COLUMN PURCHASE_LIST.WRITER IS '작성자';
COMMENT ON COLUMN PURCHASE_LIST.REGDATE IS '등록일';

