-- ABS-63328
CREATE TABLE INVOICELINETAXEXPORT
( INVOICELINE_ID   NUMBER NOT NULL,
  INVOICEHEADER_ID NUMBER NOT NULL,
  LINENUMBER       NUMBER(6,0) NOT NULL,
  SYSTEMUSER_ID    NUMBER NOT NULL,
  TIMESTAMP        DATE NOT NULL);

COMMENT ON COLUMN INVOICELINETAXEXPORT.LINENUMBER
  IS 'Between 1..999999. Always start numbering at 1 per invoice';

ALTER TABLE INVOICELINETAXEXPORT
  ADD CONSTRAINT XPKINVOICELINETAXEXPORT PRIMARY KEY (INVOICELINE_ID);
  
CREATE UNIQUE INDEX XAK1INVOICELINETAXEXPORT ON INVOICELINETAXEXPORT (INVOICEHEADER_ID ASC, LINENUMBER ASC);

CREATE INDEX XIF1INVOICELINETAXEXPORT ON INVOICELINETAXEXPORT (INVOICEHEADER_ID ASC);

ALTER TABLE INVOICELINETAXEXPORT
  ADD CONSTRAINT INVOICELINETAXEXPORT_IL FOREIGN KEY (INVOICELINE_ID)
  REFERENCES INVOICELINE (INVOICELINE_ID) ON DELETE CASCADE;
ALTER TABLE INVOICELINETAXEXPORT
  ADD CONSTRAINT INVOICELINETAXEXPORT_IH FOREIGN KEY (INVOICEHEADER_ID)
  REFERENCES INVOICEHEADER (INVOICEHEADER_ID) ON DELETE CASCADE;
