/*ORDER 502303*/
      
      /*
      ACTION is CREATE Table FREEOFCHARGEADJUSTMENT
      */

CREATE SEQUENCE SEQ_FREEOFCHARGEADJUSTMENT
START WITH 1
INCREMENT BY 1;

CREATE TABLE FREEOFCHARGEADJUSTMENT (
       FREEOFCHARGEADJUSTMENT_ID NUMBER NOT NULL,
       PRODUCTLISTPERDISTRIBPOINT_ID NUMBER NOT NULL,
       ADJUSTMENTDATE       DATE DEFAULT TO_DATE('31-12-2099','DD-MM-YYYY') NOT NULL,
       QUANTITY             NUMBER DEFAULT 1 NOT NULL,
       REMARK               VARCHAR2(60) NULL,
       SYSTEMUSER_ID        NUMBER NOT NULL,
       TIMESTAMP            DATE NOT NULL
);

CREATE UNIQUE INDEX XAK1FREEOFCHARGEADJUSTMENT ON FREEOFCHARGEADJUSTMENT
(
       PRODUCTLISTPERDISTRIBPOINT_ID  ,
       ADJUSTMENTDATE                 
);

CREATE INDEX XIF1FREEOFCHARGEADJUSTMENT ON FREEOFCHARGEADJUSTMENT
(
       PRODUCTLISTPERDISTRIBPOINT_ID  ASC
);


ALTER TABLE FREEOFCHARGEADJUSTMENT
       ADD  ( CONSTRAINT XPKFREEOFCHARGEADJUSTMENT PRIMARY KEY (
              FREEOFCHARGEADJUSTMENT_ID) ) ;

      
      /*
      ACTION is CREATE Table TEMPORARYRENTSTOP
      */

CREATE SEQUENCE SEQ_TEMPORARYRENTSTOP
START WITH 1
INCREMENT BY 1;

CREATE TABLE TEMPORARYRENTSTOP (
       TEMPORARYRENTSTOP_ID NUMBER NOT NULL,
       STANDARDDELIVERYLINE_ID NUMBER NOT NULL,
       TEMPORARYSTOPSTARTWEEK NUMBER DEFAULT 0 NOT NULL,
       TEMPORARYSTOPENDWEEK NUMBER DEFAULT 0 NOT NULL,
       TEMPSTOPSTARTWEEKFORYEAR NUMBER DEFAULT 0 NOT NULL,
       TEMPSTOPENDWEEKFORYEAR NUMBER DEFAULT 0 NOT NULL,
       TEMPORARYSTOPSTARTYEAR NUMBER DEFAULT 0 NOT NULL,
       TEMPORARYSTOPENDYEAR NUMBER DEFAULT 0 NOT NULL,
       STARTDATE            DATE NULL,
       ENDDATE              DATE NULL,
       SYSTEMUSER_ID        NUMBER NOT NULL,
       TIMESTAMP            DATE NOT NULL
);

CREATE INDEX XIF1TEMPORARYRENTSTOP ON TEMPORARYRENTSTOP
(
       STANDARDDELIVERYLINE_ID        ASC
);


ALTER TABLE TEMPORARYRENTSTOP
       ADD  ( CONSTRAINT XPKTEMPORARYRENTSTOP PRIMARY KEY (
              TEMPORARYRENTSTOP_ID) ) ;

      
      /*
      CHANGE REPORT for Table PRODUCTLISTPERDISTRIBPOINT
          - Adding column CONTRACTPERIOD
          - Adding column PROLONGATIONPERIOD
          - Adding column CANCELADVANCEPERIOD
          - Adding column FREEQTYFREQUENCY
          - Changing column definition of FREEQTYFREQUENCY
      ACTION is ALTER or modify Table PRODUCTLISTPERDISTRIBPOINT
      */

ALTER TABLE PRODUCTLISTPERDISTRIBPOINT ADD (CONTRACTPERIOD       NUMBER DEFAULT 
    0 NOT NULL);


ALTER TABLE PRODUCTLISTPERDISTRIBPOINT ADD (PROLONGATIONPERIOD   NUMBER DEFAULT 
    0 NOT NULL);


ALTER TABLE PRODUCTLISTPERDISTRIBPOINT ADD (CANCELADVANCEPERIOD  NUMBER DEFAULT 
    0 NOT NULL);


ALTER TABLE PRODUCTLISTPERDISTRIBPOINT ADD (FREEQTYFREQUENCY     NUMBER DEFAULT 
    0 NOT NULL);

COMMENT ON COLUMN PRODUCTLISTPERDISTRIBPOINT.FREEQTYFREQUENCY IS '0 = Per Week / Month / 4 Weeks
1 = Per Invoice';

ALTER TABLE FREEOFCHARGEADJUSTMENT
       ADD  ( CONSTRAINT FREEOFCHARGEADJUSTMENT_PRODUCT
              FOREIGN KEY (PRODUCTLISTPERDISTRIBPOINT_ID)
                             REFERENCES PRODUCTLISTPERDISTRIBPOINT ) ;


ALTER TABLE TEMPORARYRENTSTOP
       ADD  ( CONSTRAINT TEMPORARYRENTSTOP_STANDARDDELI
              FOREIGN KEY (STANDARDDELIVERYLINE_ID)
                             REFERENCES STANDARDDELIVERYLINE ) ;





