--ABS-133356
CREATE TABLE ERP_U_CUSTSPECIALCHARGEPRICE
( TRANSFER_ID        NUMBER NOT NULL,
  TRANSFER_STATUS    NUMBER DEFAULT 0 NOT NULL CONSTRAINT CHK_ERP_U_CUSTSPECIALCHARGEPRICE_V1 CHECK (TRANSFER_STATUS IN (-1,0,1)),
  CUSTOMERNUMBER     NUMBER NOT NULL,
  SPECIALCHARGECODE  VARCHAR2(6) NOT NULL, 
  PRICE              NUMBER(11,6) NULL, 
  STARTDATEPRICE     DATE NOT NULL, 
  PERCENTAGE         NUMBER NULL, 
  TIMESTAMP          DATE DEFAULT SYSDATE NOT NULL);
ALTER TABLE ERP_U_CUSTSPECIALCHARGEPRICE
 ADD CONSTRAINT XPKERP_U_CUSTSPECIALCHARGEPRICE PRIMARY KEY (TRANSFER_ID);
CREATE INDEX XIE1_ERP_U_CUSTSPECIALCHARGEPRICE ON ERP_U_CUSTSPECIALCHARGEPRICE(TRANSFER_STATUS);
CREATE INDEX XIE2_ERP_U_CUSTSPECIALCHARGEPRICE ON ERP_U_CUSTSPECIALCHARGEPRICE(CUSTOMERNUMBER, SPECIALCHARGECODE);
COMMENT ON COLUMN ERP_U_CUSTSPECIALCHARGEPRICE.TRANSFER_STATUS
  IS '0 = ready to be read, 1 = read correctly';

CREATE TABLE ERP_U_CUSTSPECIALCHARGEPRICE_LOG
(
  TRANSFER_ID     NUMBER NOT NULL,
  TRANSFER_STATUS NUMBER DEFAULT 0 NOT NULL  CONSTRAINT CHK_ERP_U_CUSTSPECIALCHARGEPRICE_LOG_V1 CHECK (TRANSFER_STATUS IN (-1,0,1)),
  TEXT            VARCHAR2(1000) NULL,
  PROCESS_STATUS  NUMBER DEFAULT 0 NOT NULL,
  TIMESTAMP       DATE DEFAULT SYSDATE NOT NULL
);
ALTER TABLE ERP_U_CUSTSPECIALCHARGEPRICE_LOG
  ADD CONSTRAINT XPKERP_U_CUSTSPECIALCHARGEPRICE_LOG PRIMARY KEY (TRANSFER_ID);
ALTER TABLE ERP_U_CUSTSPECIALCHARGEPRICE_LOG
  ADD CONSTRAINT FK_ERP_U_CUSTSPECIALCHARGEPRICE_LOG FOREIGN KEY (TRANSFER_ID)
  REFERENCES ERP_U_CUSTSPECIALCHARGEPRICE(TRANSFER_ID) ON DELETE CASCADE;
COMMENT ON COLUMN ERP_U_CUSTSPECIALCHARGEPRICE_LOG.TRANSFER_STATUS
  IS '0 = ready to be read, 1 = read correctly';
COMMENT ON COLUMN ERP_U_CUSTSPECIALCHARGEPRICE_LOG.PROCESS_STATUS
  IS '0 = processed correctly, 1 = process stopped with errors';  


CREATE TABLE ERP_U_CUSTEMBLEMLINEPRICE
( TRANSFER_ID        NUMBER NOT NULL,
  TRANSFER_STATUS    NUMBER DEFAULT 0 NOT NULL CONSTRAINT CHK_ERP_U_CUSTEBLEMLINEPRICE_V1 CHECK (TRANSFER_STATUS IN (-1,0,1)),
  CUSTOMERNUMBER     NUMBER NOT NULL,
  EMBLEMTEMPLATECODE VARCHAR2(6) NOT NULL,
  EMBLEMTYPE         NUMBER NOT NULL,
  PRODUCTCODE        VARCHAR2(12) NULL,
  SIZECODE           VARCHAR2(12) NOT NULL,
  FABRICCODE         VARCHAR2(12) NOT NULL,
  TEXTCOLOR          VARCHAR2(12) NULL,
  BORDERCOLOR        VARCHAR2(12) NULL,
  BACKGROUNDCOLOR    VARCHAR2(12) NULL,
  PLACEMENT          VARCHAR2(6) NULL,
  EMBLEMFONT         VARCHAR2(30) NULL,
  PRICE              NUMBER(11,6) NOT NULL, 
  STARTDATEPRICE     DATE NOT NULL, 
  TIMESTAMP          DATE DEFAULT SYSDATE NOT NULL);
ALTER TABLE ERP_U_CUSTEMBLEMLINEPRICE
 ADD CONSTRAINT XPKERP_U_CUSTEBLEMLINEPRICE PRIMARY KEY (TRANSFER_ID);
CREATE INDEX XIE1_ERP_U_CUSTEBLEMLINEPRICE ON ERP_U_CUSTEMBLEMLINEPRICE(TRANSFER_STATUS);
CREATE INDEX XIE2_ERP_U_CUSTEBLEMLINEPRICE ON ERP_U_CUSTEMBLEMLINEPRICE(CUSTOMERNUMBER,EMBLEMTEMPLATECODE,EMBLEMTYPE,PRODUCTCODE,SIZECODE,FABRICCODE);
COMMENT ON COLUMN ERP_U_CUSTEMBLEMLINEPRICE.TRANSFER_STATUS
  IS '0 = ready to be read, 1 = read correctly';

CREATE TABLE ERP_U_CUSTEMBLEMLINEPRICE_LOG
(
  TRANSFER_ID     NUMBER NOT NULL,
  TRANSFER_STATUS NUMBER DEFAULT 0 NOT NULL  CONSTRAINT CHK_ERP_U_CUSTEBLEMLINEPRICE_LOG_V1 CHECK (TRANSFER_STATUS IN (-1,0,1)),
  TEXT            VARCHAR2(1000) NULL,
  PROCESS_STATUS  NUMBER DEFAULT 0 NOT NULL,
  TIMESTAMP       DATE DEFAULT SYSDATE NOT NULL
);
ALTER TABLE ERP_U_CUSTEMBLEMLINEPRICE_LOG
  ADD CONSTRAINT XPKERP_U_CUSTEBLEMLINEPRICE_LOG PRIMARY KEY (TRANSFER_ID);
ALTER TABLE ERP_U_CUSTEMBLEMLINEPRICE_LOG
  ADD CONSTRAINT FK_ERP_U_CUSTEBLEMLINEPRICE_LOG FOREIGN KEY (TRANSFER_ID)
  REFERENCES ERP_U_CUSTEMBLEMLINEPRICE(TRANSFER_ID) ON DELETE CASCADE;
COMMENT ON COLUMN ERP_U_CUSTEMBLEMLINEPRICE_LOG.TRANSFER_STATUS
  IS '0 = ready to be read, 1 = read correctly';
COMMENT ON COLUMN ERP_U_CUSTEMBLEMLINEPRICE_LOG.PROCESS_STATUS
  IS '0 = processed correctly, 1 = process stopped with errors';  
