--ABSN-1162
CREATE TABLE ERP_O_INVOICELINE_TAX
(
  TRANSFER_ID             NUMBER NOT NULL,
  TRANSFER_STATUS         NUMBER DEFAULT 0 NOT NULL,
  BUSINESSUNITCODE        VARCHAR2(6) NOT NULL,
  INVOICEDATE             DATE NOT NULL,
  INVOICENUMBER           NUMBER NOT NULL,
  DELTOCUSTOMERNUMBER     NUMBER,
  DELTOCUSTOMERNAME       VARCHAR2(80),
  INVOICELINENUMBER       NUMBER NOT NULL,
  INVOICELINECODE         VARCHAR2(16) NOT NULL,
  INVOICELINEDESCRIPTION  VARCHAR2(60),
  TAXAMOUNTLAYER_STATE    NUMBER,
  TAXAMOUNTLAYER_CITY     NUMBER,
  TAXAMOUNTLAYER_COUNTY   NUMBER,
  TAXAMOUNTLAYER_DISTRICT NUMBER,
  TAXAMOUNTLAYER_OTHER    NUMBER,
  TOTAL_TAXAMOUNT         NUMBER,
  TAXGROUPCODE            VARCHAR2(6), 
  TAXTYPE                 NUMBER,
  FINALIZATIONTIMESTAMP   DATE,
  INVOICELINE_ID          NUMBER NOT NULL,
  TIMESTAMP               DATE DEFAULT SYSDATE NOT NULL
);
COMMENT ON COLUMN ERP_O_INVOICELINE_TAX.INVOICELINE_ID
  IS 'Unique ABS related ID';
COMMENT ON COLUMN ERP_O_INVOICELINE_TAX.TAXTYPE
  IS 'US:
0 = Not applicable
1 = Sales
2 = Rent
3 = Miscellaneous
EU
0 = Not applicable
1 = Define tax';
COMMENT ON COLUMN ERP_O_INVOICELINE_TAX.DELTOCUSTOMERNUMBER
  IS 'deltocustomer from the corresponding invoiceheader';
CREATE INDEX INDX_ERP_O_INVOICELINE_TAX_1 ON ERP_O_INVOICELINE_TAX (INVOICENUMBER, INVOICELINENUMBER);
ALTER TABLE ERP_O_INVOICELINE_TAX
  ADD CONSTRAINT PK_ERP_O_INVOICELINE_TAX PRIMARY KEY (TRANSFER_ID, INVOICELINE_ID);
ALTER TABLE ERP_O_INVOICELINE_TAX
  ADD CONSTRAINT FK_ERP_O_INVOICELINE_TAX FOREIGN KEY (TRANSFER_ID)
  REFERENCES ERP_O_INVOICEHEADER (TRANSFER_ID) ON DELETE CASCADE;
