/*order 502396*/    
      /*
      CHANGE REPORT for Table INVOICELINEDETAIL
          - Adding column CORRECTIONTYPE_ID
          - Adding index XIF10INVOICELINEDETAIL
          - Adding index XIF3INVOICELINEDETAIL
      ACTION is ALTER or modify Table INVOICELINEDETAIL
      */

ALTER TABLE INVOICELINEDETAIL ADD (CORRECTIONTYPE_ID    NUMBER NULL);

CREATE INDEX XIF10INVOICELINEDETAIL ON INVOICELINEDETAIL
(
       CORRECTIONTYPE_ID              ASC
);

ALTER TABLE INVOICELINEDETAIL
       ADD  ( CONSTRAINT INVOICELINEDETAIL_CORRECTIONTY
              FOREIGN KEY (CORRECTIONTYPE_ID)
                             REFERENCES INVOICECORRECTIONTYPE ) ;

--------COSTCENTERHISTINVDATA
ALTER TABLE COSTCENTERHISTINVDATA ADD (ORIGIN NUMBER DEFAULT 0 NOT NULL);

COMMENT ON COLUMN COSTCENTERHISTINVDATA.ORIGIN IS '0 = Initial invoice
1 = Correction invoice';

DROP INDEX XAK1COSTCENTERHISTINVDATA;

CREATE UNIQUE INDEX XAK1COSTCENTERHISTINVDATA ON COSTCENTERHISTINVDATA
(
  INVOICEHEADER_ID		ASC,
  DISTRIBUTIONPOINT_LINK_ID	ASC,
  PRODUCT_LINK_ID		ASC,
  SIZEDEFINITION_LINK_ID	ASC,
  FINISHINGMETHOD_ID		ASC,
  DELIVERYSCHEME_ID		ASC,
  ORIGIN                        ASC
);
