--ABS-117568
----------- ERP_I_PAIDAMOUNT -----------
CREATE TABLE ERP_I_PAIDAMOUNT
( TRANSFER_ID             NUMBER NOT NULL,
  TRANSFER_STATUS         NUMBER DEFAULT 0 NOT NULL,
  INVOICEHEADER_ID        NUMBER NOT NULL,
  PAIDAMOUNT              NUMBER(28,6) NOT NULL,
  TIMESTAMP               DATE DEFAULT SYSDATE NOT NULL);
ALTER TABLE ERP_I_PAIDAMOUNT
  ADD CONSTRAINT PK_ERP_I_PAIDAMOUNT PRIMARY KEY (TRANSFER_ID);

----------- ERP_I_PAIDAMOUNT_LOG -----------
CREATE TABLE ERP_I_PAIDAMOUNT_LOG
( TRANSFER_ID     NUMBER NOT NULL,
  TRANSFER_STATUS NUMBER NOT NULL CONSTRAINT CHK_ERP_I_PAIDAMOUNT_TS CHECK (TRANSFER_STATUS IN (-1,0,1)),
  TEXT            VARCHAR2(1000) NULL,
  PROCESS_STATUS  NUMBER NOT NULL,
  TIMESTAMP       DATE DEFAULT SYSDATE NOT NULL);
COMMENT ON COLUMN ERP_I_PAIDAMOUNT_LOG.TRANSFER_STATUS
  IS '-1 = staging, 0 = ready to be read, 1 = read correctly';
COMMENT ON COLUMN ERP_I_PAIDAMOUNT_LOG.PROCESS_STATUS
  IS '0 = processed correctly, 1 = process stopped with errors';
ALTER TABLE ERP_I_PAIDAMOUNT_LOG
  ADD CONSTRAINT PK_ERP_I_PAIDAMOUNT_LOG PRIMARY KEY (TRANSFER_ID);
ALTER TABLE ERP_I_PAIDAMOUNT_LOG
  ADD CONSTRAINT FK_ERP_I_PAIDAMOUNT_LOG FOREIGN KEY (TRANSFER_ID)
  REFERENCES ERP_I_PAIDAMOUNT (TRANSFER_ID) ON DELETE CASCADE;
  
--UPDATE ERP_O_INVOICEHEADER ADD INVOICESERIES
ALTER TABLE ERP_O_INVOICEHEADER ADD (INVOICESERIES VARCHAR2(6));