--ABS-133498
CREATE TABLE ERP_I_CONTRACTSPECIALCHARGE
( TRANSFER_ID        NUMBER NOT NULL,
  TRANSFER_STATUS    NUMBER DEFAULT 0 NOT NULL CONSTRAINT CHK_ERP_I_CONTSPECIALCHARGECUST_V1 CHECK (TRANSFER_STATUS IN (-1,0,1)),
  CONTRACTCODE       VARCHAR2(15) NOT NULL,
  SPECIALCHARGECODE  VARCHAR2(6) NOT NULL, 
  CUSTOMERNUMBER     NUMBER NULL,
  TIMESTAMP          DATE DEFAULT SYSDATE NOT NULL);
ALTER TABLE ERP_I_CONTRACTSPECIALCHARGE
 ADD CONSTRAINT XPKERP_I_CONTRACTSPECIALCHARGE PRIMARY KEY (TRANSFER_ID);
CREATE INDEX XIE1_ERP_I_CONTRACTSPECIALCHARGE ON ERP_I_CONTRACTSPECIALCHARGE(TRANSFER_STATUS);
CREATE INDEX XIE2_ERP_I_CONTRACTSPECIALCHARGE ON ERP_I_CONTRACTSPECIALCHARGE(CONTRACTCODE, SPECIALCHARGECODE);
COMMENT ON COLUMN ERP_I_CONTRACTSPECIALCHARGE.TRANSFER_STATUS
  IS '0 = ready to be read, 1 = read correctly';

CREATE TABLE ERP_I_CONTRACTSPECIALCHARGE_LOG
(
  TRANSFER_ID     NUMBER NOT NULL,
  TRANSFER_STATUS NUMBER DEFAULT 0 NOT NULL  CONSTRAINT CHK_ERP_I_CONTSPECCHARGECUST_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_I_CONTRACTSPECIALCHARGE_LOG
  ADD CONSTRAINT XPKERP_I_CONTRACTSPECIALCHARGE_LOG PRIMARY KEY (TRANSFER_ID);
ALTER TABLE ERP_I_CONTRACTSPECIALCHARGE_LOG
  ADD CONSTRAINT FK_ERP_I_CONTRACTSPECIALCHARGE_LOG FOREIGN KEY (TRANSFER_ID)
  REFERENCES ERP_I_CONTRACTSPECIALCHARGE(TRANSFER_ID) ON DELETE CASCADE;
COMMENT ON COLUMN ERP_I_CONTRACTSPECIALCHARGE_LOG.TRANSFER_STATUS
  IS '0 = ready to be read, 1 = read correctly';
COMMENT ON COLUMN ERP_I_CONTRACTSPECIALCHARGE_LOG.PROCESS_STATUS
  IS '0 = processed correctly, 1 = process stopped with errors';
