-- ====================================================================
-- sales_request_part — 구매요청서/품의서 라인
-- ====================================================================
-- 출처: wace_plm 운영 DB 211.115.91.141:11133/waceplm (PG 16.8)
-- 추출일: 2026-05-15
-- 부모: sales_request_master (doc_type 으로 갈래 분기)
--   PURCHASE_REG          → 구매요청서 라인 (단가/공급업체 입력 후 품의서 생성 대상)
--   PURCHASE_REG_PROPOSAL → 품의서 라인   (PROPOSAL_DATE 가 채워진 사본)
-- ====================================================================

CREATE TABLE IF NOT EXISTS sales_request_part (
    objid                       VARCHAR              NOT NULL,
    sales_bom_qty_objid         VARCHAR,
    part_objid                  VARCHAR,
    sales_request_master_objid  VARCHAR,
    qty                         VARCHAR,
    partner_objid               VARCHAR,
    partner_price               VARCHAR,
    delivery_request_date       VARCHAR,
    writer                      VARCHAR,
    regdate                     TIMESTAMP,
    status                      VARCHAR,
    remark                      VARCHAR,
    order_qty                   VARCHAR,
    org_qty                     VARCHAR,
    spec                        VARCHAR,
    part_name                   VARCHAR,
    use_yn                      VARCHAR(1)           DEFAULT 'Y',
    net_qty                     NUMERIC              DEFAULT 0,
    po_qty                      NUMERIC              DEFAULT 0,
    unit_price                  NUMERIC              DEFAULT 0,
    total_price                 NUMERIC              DEFAULT 0,
    proposal_date               DATE,
    vendor_pm                   VARCHAR(50),
    unit                        VARCHAR(50),
    processing_vendor           VARCHAR(50),
    processing_proposal_date    DATE,
    production_qty              NUMERIC(15,4),
    material_yn                 VARCHAR(1)           DEFAULT 'N',
    currency                    VARCHAR(50),
    CONSTRAINT sales_request_part_pkey PRIMARY KEY (objid)
);

CREATE INDEX IF NOT EXISTS idx_srp_master ON sales_request_part (sales_request_master_objid);
CREATE INDEX IF NOT EXISTS idx_srp_part   ON sales_request_part (part_objid);
