--UPDATE FROM 8.13.2.1 TO 8.13.3.0
 	
DROP TABLE VERSION_8_13_2_1;


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

create table zexc (
    zexc_id number(30) not null
   ,zexc_xcms_id number(30) not null
   ,zexc_acc_id number(30) not null   
   ,zexc_zpos_id number(30) not null
   ,zexc_paymentday date not null
   ,zexc_unitprice number(30,4) not null
   ,zexc_foreignprice number(30,4) not null   
   ,zexc_zcur_id number(30) not null
   ,zexc_applied_by number(1) null
   ,constraint zexc_pk primary key (zexc_id) using index tablespace v8index) tablespace v8main;

create sequence seq_zexc increment by 1 start with 1000 nomaxvalue nocycle nocache noorder;

comment on table zexc is 'Auxiliary table storing payments with foreign currency if Currency Exchange Control option is ON';

comment on column zexc.zexc_xcms_id is 'Guest id from xcms';

comment on column zexc.zexc_acc_id is 'Either the reservation id from yres or the FA id from zfac';

comment on column zexc.zexc_zpos_id is 'Zpos record, which holds the complete payment';

comment on column zexc.zexc_paymentday is 'Date of payment';

comment on column zexc.zexc_unitprice is 'payment in local currency';

comment on column zexc.zexc_foreignprice is 'payment using the setup reference currency, if not setup same value like zexc_unitprice';

comment on column zexc.zexc_zcur_id is 'currency id of used currency. Either the reference currency or the local currency';

comment on column zexc.zexc_applied_by is '0 = Currency Exchange, 1 = Payment';

UPDATE WUSS SET WUSS_VALUE='De-identified' WHERE WUSS_NAME='GuestAnonymizationText';


ALTER TABLE ZTDR ADD ztdr_inactive NUMBER(1) DEFAULT 0;

COMMENT ON COLUMN ZTDR.ztdr_inactive IS '1- Inactive, 0- Active';

alter table zfcf add zfcf_original_zinv_id number(30);

comment on column zfcf.zfcf_original_zinv_id is 'Stores original ricevuta zinv_id while issuing credit notes (applicable only for Italian fiscal opertion)';