--UPDATE FROM 8.8.4.2 TO 8.8.4.3


DROP TABLE VERSION_8_8_4_2;



/*  VERSION_8_8_4_3  */
CREATE TABLE VERSION_8_8_4_3 (
	 DUMMY	NUMBER	    NULL
)
;


ALTER TABLE SMBD ADD SMBD_WPHS_ID NUMBER(30);

ALTER TABLE SMBD ADD SMBD_PARTNER_ID NUMBER(30);

ALTER TABLE SMBD ADD SMBD_IMPORTED NUMBER(1);

ALTER TABLE ZBCF ADD ZBCF_CARDROLE NUMBER(1) DEFAULT 0 NOT NULL;

COMMENT ON COLUMN ZBCF.ZBCF_CARDROLE IS '0=rules for guest card linked to reservation 1=rules for bookers card';

INSERT INTO ZBCF SELECT SEQ_ZBCF.NEXTVAL, ZBCF_XMTY_ID, ZBCF_STAYPERADULT, ZBCF_FIRSTSTAYPERADULT, ZBCF_NIGHTPERADULT, ZBCF_RATECODESTAYPERADULT, ZBCF_RATECODEFIRSTSTAYPERADULT, ZBCF_RATECODENIGHTPERADULT, ZBCF_ROOMTYPESTAYPERADULT, ZBCF_ROOMTYPEFIRSTSTAYPERADULT, ZBCF_ROOMTYPENIGHTPERADULT, 1 FROM ZBCF WHERE ZBCF_CARDROLE=0;

COMMIT;

ALTER TABLE WMAI MODIFY WMAI_TO VARCHAR2(2000); 

ALTER TABLE WMAI MODIFY WMAI_CC VARCHAR2(2000);

ALTER TABLE WMAI MODIFY WMAI_BCC VARCHAR2(2000);

ALTER TABLE YPAC ADD YPAC_SUBSTRACTINCLUDEDPACKAGE NUMBER(1);

COMMENT ON COLUMN YPAC.YPAC_SUBSTRACTINCLUDEDPACKAGE IS 'substract included packages from base. ypac_perctobase adds addtorate packages only';

ALTER TABLE YPRR ADD YPRR_MINARRIVAL NUMBER (3); 

COMMENT ON COLUMN YPRR.YPRR_MINARRIVAL IS 'minimum days in advance';

ALTER TABLE YPRR ADD YPRR_MAXARRIVAL NUMBER (3); 

COMMENT ON COLUMN YPRR.YPRR_MAXARRIVAL IS 'maximum days in advance';

ALTER TABLE YPRR ADD YPRR_YPFR_ID NUMBER (30);

COMMENT ON COLUMN YPRR.YPRR_YPFR_ID IS 'Nights frequency';

ALTER TABLE YPRR ADD YPRR_XCAC_ID NUMBER (30);

COMMENT ON COLUMN YPRR.YPRR_XCAC_ID IS 'xcac_id=0 = no pax control,  xcac_id=-1 = ADULT Control, xcac_id>0 xcac_id Child control ';

ALTER TABLE YPRR ADD YPRR_EB_PERCENTAGE NUMBER(1);

COMMENT ON COLUMN YPRR.YPRR_EB_PERCENTAGE IS 'Percentage can be chosen also for daily and stay promotions';

COMMENT ON COLUMN YPRR.YPRR_EB_CALCMETHOD IS '1: OBSOLETE NOT USED (was Percentage), 2:Night  3: Stay 4: Frequency ';

COMMENT ON COLUMN YPRR.YPRR_RULE IS 'Discount Types: 0 - Free Nights, 1 - Percentage/Fix Amount';

COMMENT ON COLUMN YPRR.YPRR_EB_POSTDAY IS '0: Obsolete NOT USED (was Percentage Calculation), 1: Evenly Spread, 2:First Day  3: Last Day';

COMMENT ON COLUMN YPRR.YPRR_VALUE IS 'Percentage/Fix Amount or Number of Nights for free, depends on Discount Type';

COMMENT ON COLUMN YPRR.YPRR_MINDAY IS 'Minimum Nights for Rule to apply';

COMMENT ON COLUMN YPRR.YPRR_MAXDAY IS 'Maximum Nights for Rule to apply, if MAXDAY=0 every Reservation that has equal or more Nights, the Rule applies';

UPDATE YPRR SET YPRR_EB_PERCENTAGE=1, YPRR_EB_CALCMETHOD=2 WHERE YPRR_EB_CALCMETHOD=1;

UPDATE YPRR SET YPRR_EB_POSTDAY=-1 WHERE YPRR_EB_CALCMETHOD=2 AND YPRR_EB_POSTDAY=1; 

UPDATE YPRR SET YPRR_MINARRIVAL=YPRR_MINDAY, YPRR_MAXARRIVAL=YPRR_MAXDAY WHERE YPRR_RULE=1 AND (YPRR_MINARRIVAL IS NULL OR YPRR_MAXARRIVAL IS NULL);

UPDATE YPRR SET YPRR_MINDAY=0, YPRR_MAXDAY=0 WHERE YPRR_RULE=1 AND (YPRR_MINARRIVAL=YPRR_MINDAY AND YPRR_MAXARRIVAL=YPRR_MAXDAY);

ALTER TABLE YCRT MODIFY YCRT_WEEKSTARTVALUE NUMBER(2);

CREATE TABLE YMSP (
   YMSP_ID NUMBER(30) NOT NULL
  ,YMSP_MASTER_YPAC_ID NUMBER(30) NOT NULL
  ,YMSP_SUB_YPAC_ID NUMBER(30) NOT NULL
  ,CONSTRAINT YMSP_PK PRIMARY KEY (YMSP_ID) USING INDEX TABLESPACE V8INDEX 
) TABLESPACE V8CONF;  

CREATE SEQUENCE SEQ_YMSP INCREMENT BY 1 START WITH 1000 NOMAXVALUE NOCYCLE NOCACHE NOORDER;

COMMENT ON TABLE YMSP IS 'master sub package link';
