--THIS FILE IS NEEDED ONLY FOR THE ONLINE UPDATE!!!

--UPDATE FROM 8.6.2.4 TO 8.6.3.0


DROP TABLE VERSION_8_6_2_4;



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


ALTER TABLE WPTS ADD WPTS_REMOTETIMESTAMP DATE;

ALTER TABLE ZDCO ADD ZDCO_FISCAL NUMBER(1);

ALTER TABLE WPSD MODIFY WPSD_ROLE NUMBER(2);

ALTER TABLE SHIS ADD (SHIS_YRCH_COMPSTATUS NUMBER(1));

ALTER TABLE SHIS ADD (SHIS_VIPCODE VARCHAR2(3));

ALTER TABLE SHIS ADD (SHIS_VIPCODE_LONGDESC VARCHAR2(30));

COMMENT ON COLUMN ZFAG.ZFAG_SEND_IFC IS 'Shows if Room Key commands are sent to the IFC for this FA group';

DROP INDEX YRES_RESSTATUS;

DROP INDEX ZFAC_ACTVALIDUNTILNULL;

DROP INDEX ZFAC_ACTVALIDFROMNULL;

DROP INDEX YRES_ACTDEPTIMENULL;

DROP INDEX YRES_ACTARRTIMENULL;

ALTER TABLE WPCA ADD (WPCA_IFCBUSI_LAST_TIME DATE);

COMMENT ON COLUMN WPCA.WPCA_IFCBUSI_LAST_TIME IS 'Timestamp, when ifcbusi loaded last time in this workstation';

ALTER TABLE WPCA ADD (WPCA_IFCBUSI_LAST_VERSION VARCHAR2(10));

COMMENT ON COLUMN WPCA.WPCA_IFCBUSI_LAST_VERSION IS 'Version Number of the last IfcBusi dll';

ALTER TABLE WPCA ADD (WPCA_BARCODEREADERPORT NUMBER(1));

COMMENT ON COLUMN WPCA.WPCA_BARCODEREADERPORT IS 'Barcode Reader COM Port number';

ALTER TABLE WPCA ADD (WPCA_BARCODEREADERBAUD NUMBER(6));

COMMENT ON COLUMN WPCA.WPCA_BARCODEREADERBAUD IS 'Barcode Reader Baud, 1=300 2=1200 3=2400 4=4800 5=9600 6=19200 7=38400 8=57600';

CREATE TABLE CART
(
  CART_ID           NUMBER(30)             NOT NULL,
  CART_NAME         VARCHAR2(100)          NOT NULL,
  CART_TYPE         NUMBER(3),
  CART_PRICE        NUMBER(30,4),
  CART_COUPONTEXT   VARCHAR2(200),
  CART_COUPONDESCR  VARCHAR2(500),
  CART_PAYMENT_ZDCO_ID NUMBER(30),
  CART_DISPLORDER NUMBER(3,0),
  CONSTRAINT CART_PK PRIMARY KEY (CART_ID) USING INDEX TABLESPACE V8INDEX  
)
TABLESPACE V8CONF;

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

COMMENT ON TABLE CART IS 'Certificate articles';

COMMENT ON COLUMN CART.CART_ID IS 'Article ID';

COMMENT ON COLUMN CART.CART_NAME IS 'Article name';

COMMENT ON COLUMN CART.CART_TYPE IS 'Article type (depends on redemption system)';

COMMENT ON COLUMN CART.CART_PRICE IS 'Article price';

COMMENT ON COLUMN CART.CART_COUPONTEXT IS 'Coupon text';

COMMENT ON COLUMN CART.CART_COUPONDESCR IS 'Coupon description';

COMMENT ON COLUMN CART.CART_PAYMENT_ZDCO_ID IS 'Department code for payments';

CREATE TABLE CRVD
(
  CRVD_ID           NUMBER(30)          NOT NULL,
  CRVD_CART_ID      NUMBER(30)          NOT NULL,
  CRVD_ZDCO_ID      NUMBER(30)          NOT NULL,
  CONSTRAINT CRVD_PK PRIMARY KEY (CRVD_ID) USING INDEX TABLESPACE V8INDEX  
)
TABLESPACE V8CONF;

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

COMMENT ON TABLE CRVD IS 'Certificate''s revenue departments';

COMMENT ON COLUMN CRVD.CRVD_ID IS 'Primary key';

COMMENT ON COLUMN CRVD.CRVD_CART_ID IS 'Link to the certificate';

COMMENT ON COLUMN CRVD.CRVD_ZDCO_ID IS 'Link to the department';

CREATE TABLE COUP
(
  COUP_ID             NUMBER(30)            NOT NULL,
  COUP_NUMBER         VARCHAR2(30),
  COUP_DESCRIPTION    VARCHAR2(30),
  COUP_TEXT           VARCHAR2(1000),
  COUP_ISSUE          DATE NOT NULL,
  COUP_VALIDFROM      DATE,
  COUP_VALIDUNTIL     DATE,
  COUP_CLEARINGDATE   DATE,
  COUP_XCMS_ID        NUMBER(30),
  COUP_CART_ID        NUMBER(30),
  COUP_AMOUNT         NUMBER(30,4) NOT NULL,
  COUP_AMOUNTREDEEMED NUMBER(30,4),
  COUP_ISVALUECOUPON  NUMBER(1),
  CONSTRAINT COUP_PK PRIMARY KEY (COUP_ID) USING INDEX TABLESPACE V8INDEX  
)
TABLESPACE V8MAIN;

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

CREATE UNIQUE INDEX COUP_U01 ON COUP (COUP_NUMBER) TABLESPACE V8INDEX;

COMMENT ON TABLE COUP IS 'Gift coupon info';

COMMENT ON COLUMN COUP.COUP_ID IS 'Coupon ID';

COMMENT ON COLUMN COUP.COUP_NUMBER IS 'Complete number of the gift certificate ';

COMMENT ON COLUMN COUP.COUP_DESCRIPTION IS 'gift certificate description';

COMMENT ON COLUMN COUP.COUP_TEXT IS 'Text for the gift certificate ';

COMMENT ON COLUMN COUP.COUP_ISSUE IS 'Date of issue of the gift certificate ';

COMMENT ON COLUMN COUP.COUP_VALIDFROM IS 'Start of date where the gift certificate is valid ';

COMMENT ON COLUMN COUP.COUP_VALIDUNTIL IS 'End of date where the gift certificate is valid ';

COMMENT ON COLUMN COUP.COUP_CLEARINGDATE IS 'Date of clearing ';

COMMENT ON COLUMN COUP.COUP_XCMS_ID IS 'Guest Link';

COMMENT ON COLUMN COUP.COUP_CART_ID IS 'Article Link';

COMMENT ON COLUMN COUP.COUP_AMOUNT IS 'Amount of gift certificates ';

COMMENT ON COLUMN COUP.COUP_AMOUNTREDEEMED IS 'Amount which has been redeemed';

CREATE TABLE CPOS
(
  CPOS_ID           NUMBER(30)          NOT NULL,
  CPOS_COUP_ID      NUMBER(30)          NOT NULL,
  CPOS_ZPOS_ID      NUMBER(30)          NOT NULL,
  CONSTRAINT CPOS_PK PRIMARY KEY (CPOS_ID) USING INDEX TABLESPACE V8INDEX  
)
TABLESPACE V8MAIN;

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

COMMENT ON TABLE CPOS IS 'List of postings linked to the voucher';

COMMENT ON COLUMN CPOS.CPOS_ID IS 'Primary key';

COMMENT ON COLUMN CPOS.CPOS_COUP_ID IS 'Voucher link';

COMMENT ON COLUMN CPOS.CPOS_ZPOS_ID IS 'Posting link';

ALTER TABLE ZRDF ADD (ZRDF_BARCODE VARCHAR2(30));

CREATE UNIQUE INDEX ZRDF_BARCODE ON ZRDF(ZRDF_BARCODE) TABLESPACE V8INDEX;

COMMENT ON COLUMN ZRDF.ZRDF_BARCODE IS 'String associated with barcode (full string will contain global rebate prefix)';

CREATE TABLE CBCC
(
  CBCC_ID      NUMBER(30)                       NOT NULL,
  CBCC_DESC    VARCHAR(30),
  CBCC_ROLE    NUMBER(1)                        NOT NULL,
  CBCC_REGEXP  VARCHAR2(60)                     NOT NULL,
  CBCC_DISPLORDER Number(4),
  constraint CBCC_PK primary key (CBCC_ID) using index tablespace v8index   
)
TABLESPACE V8CONF;

COMMENT ON TABLE CBCC IS 'Barcode prefixes configuration';

COMMENT ON COLUMN CBCC.CBCC_ID IS 'CBCC ID';

COMMENT ON COLUMN CBCC.CBCC_ROLE IS '1 = Voucher 2 = Rebate';

COMMENT ON COLUMN CBCC.CBCC_REGEXP IS 'Regular expression to test';

COMMENT ON COLUMN CBCC.CBCC_DESC IS 'Description';

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

ALTER TABLE WDCG ADD (WDCG_UPLOAD NUMBER(1));

COMMENT ON COLUMN WDCG.WDCG_UPLOAD IS '1 if should be uploaded to master hotel';

ALTER TABLE WDCL ADD (WDCL_WPHS_ID NUMBER(30));

CREATE INDEX WDCL_WPHS_ID ON WDCL(WDCL_WPHS_ID) TABLESPACE V8INDEX;

COMMENT ON COLUMN WDCL.WDCL_WPHS_ID IS 'Hotel where document was created';

COMMENT ON COLUMN XCLR.XCLR_TYPE IS '1-Spouse, 2-next geneneration (descendant), 3-prev gen (predecessor), 4-siblings, 5-partners | for parents should be 3, for children 2';

COMMENT ON COLUMN ZFAG.ZFAG_TYPE IS '0 = Financial Account (Paymaster) | 1 = AR Revenue Charges | 2 = AR Payments | 3 = Foreign Currency Exchange | 4 = for Booth telephone charges paid cash | 5 = Internal Interface Type for POS Accounts or Lost Posting Account, these financial accounts are getting checked in automatically after check out. | 6 = Petty Cash accounts | 7 = Transponder reading | 8 = Deposits, Cancellation and NoShow | 9 = Personal (Staff) Accounts (TI) | 10 = type for Dont close folio | 11= Financial Account for automatic creation';

ALTER TABLE MMOD ADD (MMOD_LINK_GRP_CODES NUMBER(1) NULL);

ALTER TABLE MMOD ADD (MMOD_HTTP_PROVIDER_ID VARCHAR2(20) NULL);

ALTER TABLE MMOD ADD (MMOD_THRESHOLD NUMBER(1) NULL);

COMMENT ON COLUMN MMOD.MMOD_LINK_GRP_CODES IS 'indicates whether the attributes like rate, source, channel, market code for a res should taken from block';

COMMENT ON COLUMN MMOD.MMOD_HTTP_PROVIDER_ID IS 'provider id for HTML submit functionality';

COMMENT ON COLUMN MMOD.MMOD_THRESHOLD IS 'indicates whether inventory upload also use threshold settings of room types';

ALTER TABLE XCED ADD (XCED_LEISUREUSERNAME VARCHAR2(30), XCED_LEISUREPASSWORD VARCHAR2(30));

COMMENT ON COLUMN XCED.XCED_LEISUREUSERNAME IS 'username to login to leisure system';

UPDATE WPSF SET WPSF_FIELDNAME='xcmt_shortdesc' WHERE WPSF_FIELDNAME='xcom_xcmt_id';

ALTER TABLE WACT ADD WACT_FROMMASTER NUMBER(1) DEFAULT 0 NOT NULL;

CREATE TABLE XJET
(
  XJET_ID               NUMBER(30) NOT NULL,
  XJET_OESTAT           VARCHAR2(10),
  XJET_VERSION          VARCHAR2(5),
  XJET_BETRIEBNR        VARCHAR2(10),
  XJET_UVMNR            VARCHAR2(10),
  XJET_NUMBERSLEFT      NUMBER(30),
  XJET_URL              VARCHAR2(120),
  XJET_LOGIN            VARCHAR2(30),
  XJET_PASSWORD         VARCHAR2(30),
  XJET_GASTART_XPAC_ID  NUMBER(30),
  CONSTRAINT XJET_PK PRIMARY KEY (XJET_ID) USING INDEX TABLESPACE V8INDEX    
) TABLESPACE V8CONF;

ALTER TABLE XJET ADD (XJET_GASTTYP_XPAC_ID NUMBER(30));

COMMENT ON TABLE XJET IS 'JetWeb interface configuration table';

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

CREATE TABLE XJNB
(
  XJNB_ID               NUMBER(30)              NOT NULL,
  XJNB_MELDEBLATT_FROM  NUMBER(30)              NOT NULL,
  XJNB_MELDEBLATT_TO    NUMBER(30)              NOT NULL,
  CONSTRAINT XJNB_PK PRIMARY KEY (XJNB_ID) USING INDEX TABLESPACE V8INDEX    
) TABLESPACE V8MAIN;

COMMENT ON TABLE XJNB IS 'JetWeb interface. Allocated registartion card number slots';

COMMENT ON COLUMN XJNB.XJNB_ID IS 'XJNB primary key';

COMMENT ON COLUMN XJNB.XJNB_MELDEBLATT_FROM IS 'Number start';

COMMENT ON COLUMN XJNB.XJNB_MELDEBLATT_TO IS 'number end';

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

CREATE TABLE YMGA (
    YMGA_ID NUMBER(30) NOT NULL
   ,YMGA_YRES_ID NUMBER(30) NOT NULL 
   ,YMGA_XCMS_ID NUMBER(30) NOT NULL
   ,YMGA_XPDA_ID NUMBER(30) NOT NULL
   ,CONSTRAINT YMGA_PK PRIMARY KEY (YMGA_ID) USING INDEX TABLESPACE V8INDEX  ) TABLESPACE V8MAIN ;

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

CREATE INDEX YMGA_YRES_ID ON YMGA(YMGA_YRES_ID) TABLESPACE V8INDEX;

CREATE INDEX YMGA_XCMS_ID ON YMGA(YMGA_XCMS_ID) TABLESPACE V8INDEX;

CREATE INDEX YMGA_XPDA_ID ON YMGA(YMGA_XPDA_ID) TABLESPACE V8INDEX;

ALTER TABLE XPAC ADD XPAC_APPLRESGUEST NUMBER(1) DEFAULT 0 NOT NULL ;

COMMENT ON COLUMN WACT.WACT_FROMMASTER IS ' 1= Downloaded from Master Hotel (only valid for Hotel Connector)';

ALTER TABLE XPMR ADD XPMR_SET NUMBER(1) DEFAULT 0 NOT NULL;

CREATE TABLE ZPO2
(
  ZPO2_ID                     NUMBER(30)        NOT NULL,
  ZPO2_XCMS_ID                NUMBER(30)        NOT NULL,
  ZPO2_YRES_ID                NUMBER(30),
  ZPO2_ZFAC_ID                NUMBER(30),
  ZPO2_ZDCO_ID                NUMBER(30)        NOT NULL,
  ZPO2_ZDC2_ID                NUMBER(30),
  ZPO2_UNITPRICE              NUMBER(30,4)      NOT NULL,
  ZPO2_QUANTITY               NUMBER(10)        NOT NULL,
  ZPO2_DESCRIPT               VARCHAR2(30)      NOT NULL,
  ZPO2_POSTDATE               DATE              NOT NULL,
  ZPO2_PCDATE                 DATE              NOT NULL,
  ZPO2_THIRDPARTYDATE         DATE,
  ZPO2_ZCUR_ID                NUMBER(30),
  ZPO2_EXCHANGERATE           NUMBER(30,4),
  ZPO2_FOREIGNPRICE           NUMBER(30,4),
  ZPO2_ZCAS_ID                NUMBER(30)        NOT NULL,
  ZPO2_USER_XCMS_ID           NUMBER(30),
  ZPO2_ORIGINATED_XCMS_ID     NUMBER(30),
  ZPO2_ORIGINATED_YRES_ID     NUMBER(30),
  ZPO2_ORIGINATED_ZFAC_ID     NUMBER(30),
  ZPO2_ZARR_ID                NUMBER(30),
  ZPO2_COMMENT                VARCHAR2(60),
  ZPO2_ZART_ID                NUMBER(30),
  ZPO2_COVERS                 NUMBER(4),
  ZPO2_TAXLINK_ID             NUMBER(30)        NOT NULL,
  ZPO2_SUMUPID                NUMBER(30),
  ZPO2_INTERNALSPLIT_ZPO2_ID  NUMBER(30)        NOT NULL,
  ZPO2_CDT                    NUMBER(1)         NOT NULL,
  ZPO2_PHONENR                VARCHAR2(30),
  ZPO2_MANUALSPLIT_ID         NUMBER(30),
  ZPO2_PAIDOUT                NUMBER(1),
  ZPO2_ZWIN_ID                NUMBER(30)        NOT NULL,
  ZPO2_ZALL_ID                NUMBER(30),
  ZPO2_IHST_ID                NUMBER(30),
  ZPO2_LEDGERSTATUS           NUMBER(1)         NOT NULL,
  ZPO2_SUMUPAMOUNT            NUMBER(30,4),
  ZPO2_PACK_LOSS              NUMBER(1),
  ZPO2_POSCHECK_NR            VARCHAR2(20),
  ZPO2_GROSSUNITPRICE         NUMBER(30,4),
  ZPO2_GROSSFOREIGNPRICE      NUMBER(30,4),
  ZPO2_ZCHE_ID                NUMBER(30),
  ZPO2_DEPOSIT                NUMBER(1),
  ZPO2_ORGDATE                DATE,
  ZPO2_HIDDEN                 NUMBER(1),
  ZPO2_FOREIGNSUMUPAMOUNT     NUMBER(30,4),
  ZPO2_PROFORMA               NUMBER(30),
  ZPO2_REVERSEEXCHRATE        NUMBER(1),
  ZPO2_ZTCD_ID                NUMBER(30),
  ZPO2_GUEST_XCMS_ID          NUMBER(30),
  ZPO2_INTERNALGROUP_ID       NUMBER(30),
  ZPO2_NOREPRINT              NUMBER(1),
  ZPO2_ZUDD_ID                NUMBER(30),
  ZPO2_MANUALPOST             NUMBER(1)
)
TABLESPACE V8MAIN
PCTUSED    40
PCTFREE    10
INITRANS   1
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             64K
            MINEXTENTS       1
            MAXEXTENTS       505
            PCTINCREASE      50
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
LOGGING 
NOCACHE
NOPARALLEL;

COMMENT ON TABLE ZPO2 IS ' Storage for removed postings';

COMMENT ON COLUMN ZPO2.ZPO2_PROFORMA IS 'PROFORMA INVOICE NUMBER';

COMMENT ON COLUMN ZPO2.ZPO2_REVERSEEXCHRATE IS '0 means amount*exchrate=foreignamount. 1 means amount=foreignamount/exchrate. in fact it tells in which direction the exchange rate was entered by the user';

COMMENT ON COLUMN ZPO2.ZPO2_ZTCD_ID IS 'link to the corresponding tax detail';

COMMENT ON COLUMN ZPO2.ZPO2_INTERNALGROUP_ID IS 'Internally used grouping to ease reading and working with excluded taxes';

COMMENT ON COLUMN ZPO2.ZPO2_NOREPRINT IS '0-Posting is not on a vlid folio | 1-The posting is printed on an invoice | 2-Posting is on a void invoice';

COMMENT ON COLUMN ZPO2.ZPO2_MANUALPOST IS '1-posting was made manually';

COMMENT ON COLUMN ZPO2.ZPO2_FOREIGNPRICE IS ' Posted Amount in ForeignPrice';

COMMENT ON COLUMN ZPO2.ZPO2_ZCAS_ID IS ' Cashier Number';

COMMENT ON COLUMN ZPO2.ZPO2_USER_XCMS_ID IS ' UserId of the user who charged this posting.';

COMMENT ON COLUMN ZPO2.ZPO2_ORIGINATED_XCMS_ID IS ' zpo2_ORIGINATED_XCMS_ID is of zpo2';

COMMENT ON COLUMN ZPO2.ZPO2_ORIGINATED_YRES_ID IS ' zpo2_ORIGINATED_YRES_ID is of zpo2';

COMMENT ON COLUMN ZPO2.ZPO2_ORIGINATED_ZFAC_ID IS ' zpo2_ORIGINATED_ZFAC_ID is of zpo2';

COMMENT ON COLUMN ZPO2.ZPO2_ZARR_ID IS ' zpo2_ZARR_ID is of zpo2';

COMMENT ON COLUMN ZPO2.ZPO2_COMMENT IS ' zpo2_COMMENT is of zpo2';

COMMENT ON COLUMN ZPO2.ZPO2_ZART_ID IS ' zpo2_ZART_ID is of zpo2';

COMMENT ON COLUMN ZPO2.ZPO2_COVERS IS ' number of restaurant covers (people)';

COMMENT ON COLUMN ZPO2.ZPO2_TAXLINK_ID IS ' Link Id between related records';

COMMENT ON COLUMN ZPO2.ZPO2_SUMUPID IS ' zpo2_SUMUPID is the link of several postings from rate codes which are set up as weekly or monthly';

COMMENT ON COLUMN ZPO2.ZPO2_INTERNALSPLIT_ZPO2_ID IS ' ID of main zpo2 record for internal split, as for rate code splitting.';

COMMENT ON COLUMN ZPO2.ZPO2_CDT IS ' 1 = debit 	2 = tax 	5 = credit (payment)';

COMMENT ON COLUMN ZPO2.ZPO2_PHONENR IS ' Dialed Phone Number, duplicated information for invoice printing, actual link to call history is handled differently';

COMMENT ON COLUMN ZPO2.ZPO2_MANUALSPLIT_ID IS ' zpo2_MANUALSPLIT_ID is of zpo2';

COMMENT ON COLUMN ZPO2.ZPO2_PAIDOUT IS ' Flag for paid out posting. 1 = true, anything else = false';

COMMENT ON COLUMN ZPO2.ZPO2_ZWIN_ID IS ' zpo2_ZWIN_ID is of zpo2';

COMMENT ON COLUMN ZPO2.ZPO2_ZALL_ID IS ' zpo2_ZALL_ID is of zpo2';

COMMENT ON COLUMN ZPO2.ZPO2_IHST_ID IS ' Link to interface call history table';

COMMENT ON COLUMN ZPO2.ZPO2_LEDGERSTATUS IS ' 0= posting made in the guest ledger;  	1= posting made in the PreArrival ledger;  	2= posting made in the PreArrival ledger and transferred to the guest ledger (at check-in for reservations, manually for fin. acc.);  	3= posting made in the city ledger (accounts receivable) 	4=internal negative payment when city ledger gets paid 	5=advance posting 	6=when advance posting is moved to guest ledger 	7=when advance posting is moved to pre arrival Ledger';

COMMENT ON COLUMN ZPO2.ZPO2_SUMUPAMOUNT IS ' summed up amount from zpo2_INTERNALSPLIT_ID + Taxes of internal Splits + Allowances. Speeds up invoice printing.';

COMMENT ON COLUMN ZPO2.ZPO2_PACK_LOSS IS ' 3 = allowance consumption 	2 = revenue between value and allowance (overage) 	1 = LOSS (For MINUS loss Postings on package allowances. These records are not taken in calculation for remaining allowance. 	4 = revenue exceeding the allowance (allowance) 	5 = package profit';

COMMENT ON COLUMN ZPO2.ZPO2_POSCHECK_NR IS ' POS Check Number';

COMMENT ON COLUMN ZPO2.ZPO2_GROSSUNITPRICE IS ' zpo2_GROSSUNITPRICE is of zpo2';

COMMENT ON COLUMN ZPO2.ZPO2_GROSSFOREIGNPRICE IS ' zpo2_GROSSFOREIGNPRICE is of zpo2';

COMMENT ON COLUMN ZPO2.ZPO2_ZCHE_ID IS ' Link to ZCHE Guest Check';

COMMENT ON COLUMN ZPO2.ZPO2_DEPOSIT IS ' Filled if posted as revenue or tax department on deposit payment. Implemented for Parameter ''Latin American Deposit Handling''';

COMMENT ON COLUMN ZPO2.ZPO2_ORGDATE IS 'for advance postings';

COMMENT ON COLUMN ZPO2.ZPO2_HIDDEN IS '0 - normal; 1 - do not show on screen; 2 - do not show on reports; 3 - do not show anywhere';

COMMENT ON COLUMN ZPO2.ZPO2_FOREIGNSUMUPAMOUNT IS ' summed up amount in foreign currency from zpo2_INTERNALSPLIT_ID + Taxes of internal Splits + Allowances. Speeds up invoice printing.';

COMMENT ON COLUMN ZPO2.ZPO2_ID IS ' Unique identifier of zpo2';

COMMENT ON COLUMN ZPO2.ZPO2_XCMS_ID IS ' Link to Customer';

COMMENT ON COLUMN ZPO2.ZPO2_YRES_ID IS ' Link to reservation 	Not {not null} for ZFAC postings';

COMMENT ON COLUMN ZPO2.ZPO2_ZFAC_ID IS ' zpo2_ZFAC_ID is of zpo2';

COMMENT ON COLUMN ZPO2.ZPO2_ZDCO_ID IS ' Link to Department Code';

COMMENT ON COLUMN ZPO2.ZPO2_ZDC2_ID IS ' zpo2_ZDC2_ID is of zpo2';

COMMENT ON COLUMN ZPO2.ZPO2_UNITPRICE IS ' Unit Price must be multiplied with zpo2_QUANTITY';

COMMENT ON COLUMN ZPO2.ZPO2_QUANTITY IS ' zpo2_QUANTITY is of zpo2';

COMMENT ON COLUMN ZPO2.ZPO2_DESCRIPT IS ' Description, usually taken from Department Code description. Can be overwritten manually.';

COMMENT ON COLUMN ZPO2.ZPO2_POSTDATE IS ' Posting date (Fidelio date)';

COMMENT ON COLUMN ZPO2.ZPO2_PCDATE IS ' PC Date';

COMMENT ON COLUMN ZPO2.ZPO2_THIRDPARTYDATE IS ' zpo2_THIRDPARTYDATE is of zpo2';

COMMENT ON COLUMN ZPO2.ZPO2_ZCUR_ID IS ' Link to Currency Table';

COMMENT ON COLUMN ZPO2.ZPO2_EXCHANGERATE IS ' Exchange rate value';

CREATE INDEX ZPO2_ZALL_ID ON ZPO2
(ZPO2_ZALL_ID)
LOGGING
TABLESPACE V8INDEX
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             40K
            MINEXTENTS       1
            MAXEXTENTS       505
            PCTINCREASE      50
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;

CREATE INDEX ZPO2_ORIGINATED_YRES_ID ON ZPO2
(ZPO2_ORIGINATED_YRES_ID)
LOGGING
TABLESPACE V8INDEX
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             40K
            MINEXTENTS       1
            MAXEXTENTS       505
            PCTINCREASE      50
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;

CREATE INDEX ZPO2_XCMS_ID ON ZPO2
(ZPO2_XCMS_ID)
LOGGING
TABLESPACE V8INDEX
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             40K
            MINEXTENTS       1
            MAXEXTENTS       505
            PCTINCREASE      50
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;

CREATE INDEX ZPO2_ZCUR_ID ON ZPO2
(ZPO2_ZCUR_ID)
LOGGING
TABLESPACE V8INDEX
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             40K
            MINEXTENTS       1
            MAXEXTENTS       505
            PCTINCREASE      50
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;

CREATE INDEX ZPO2_ZDC2_ID ON ZPO2
(ZPO2_ZDC2_ID)
LOGGING
TABLESPACE V8INDEX
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             40K
            MINEXTENTS       1
            MAXEXTENTS       505
            PCTINCREASE      50
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;

CREATE INDEX ZPO2_ZARR_ID ON ZPO2
(ZPO2_ZARR_ID)
LOGGING
TABLESPACE V8INDEX
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             40K
            MINEXTENTS       1
            MAXEXTENTS       505
            PCTINCREASE      50
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;

CREATE INDEX ZPO2_ZART_ID ON ZPO2
(ZPO2_ZART_ID)
LOGGING
TABLESPACE V8INDEX
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             40K
            MINEXTENTS       1
            MAXEXTENTS       505
            PCTINCREASE      50
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;

CREATE INDEX ZPO2_ZCHE_ID ON ZPO2
(ZPO2_ZCHE_ID)
LOGGING
TABLESPACE V8INDEX
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             40K
            MINEXTENTS       1
            MAXEXTENTS       505
            PCTINCREASE      50
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;

CREATE INDEX ZPO2_USER_XCMS_ID ON ZPO2
(ZPO2_USER_XCMS_ID)
LOGGING
TABLESPACE V8INDEX
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             40K
            MINEXTENTS       1
            MAXEXTENTS       505
            PCTINCREASE      50
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;

CREATE INDEX ZPO2_MANUALSPLIT_ID ON ZPO2
(ZPO2_MANUALSPLIT_ID)
LOGGING
TABLESPACE V8INDEX
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             40K
            MINEXTENTS       1
            MAXEXTENTS       505
            PCTINCREASE      50
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;

CREATE INDEX ZPO2_PACK_LOSS ON ZPO2
(ZPO2_PACK_LOSS)
LOGGING
TABLESPACE V8INDEX
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             40K
            MINEXTENTS       1
            MAXEXTENTS       505
            PCTINCREASE      50
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;

CREATE INDEX ZPO2_TAXLINK_ID ON ZPO2
(ZPO2_TAXLINK_ID)
LOGGING
TABLESPACE V8INDEX
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             40K
            MINEXTENTS       1
            MAXEXTENTS       505
            PCTINCREASE      50
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;

CREATE INDEX ZPO2_ORIGINATED_ZFAC_ID ON ZPO2
(ZPO2_ORIGINATED_ZFAC_ID)
LOGGING
TABLESPACE V8INDEX
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             40K
            MINEXTENTS       1
            MAXEXTENTS       505
            PCTINCREASE      50
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;

CREATE INDEX ZPO2_ZDCO_ID ON ZPO2
(ZPO2_ZDCO_ID)
LOGGING
TABLESPACE V8INDEX
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             40K
            MINEXTENTS       1
            MAXEXTENTS       505
            PCTINCREASE      50
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;

CREATE INDEX ZPO2_ZCAS_ID ON ZPO2
(ZPO2_ZCAS_ID)
LOGGING
TABLESPACE V8INDEX
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             40K
            MINEXTENTS       1
            MAXEXTENTS       505
            PCTINCREASE      50
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;

CREATE INDEX ZPO2_LEDGERSTATUS ON ZPO2
(ZPO2_LEDGERSTATUS)
LOGGING
TABLESPACE V8INDEX
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             40K
            MINEXTENTS       1
            MAXEXTENTS       505
            PCTINCREASE      50
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;

CREATE INDEX ZPO2_POSTDATE ON ZPO2
(ZPO2_POSTDATE)
LOGGING
TABLESPACE V8INDEX
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             40K
            MINEXTENTS       1
            MAXEXTENTS       505
            PCTINCREASE      50
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;

CREATE INDEX ZPO2_INTERNALSPLIT_ZPO2_ID ON ZPO2
(ZPO2_INTERNALSPLIT_ZPO2_ID)
LOGGING
TABLESPACE V8INDEX
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             40K
            MINEXTENTS       1
            MAXEXTENTS       505
            PCTINCREASE      50
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;

CREATE INDEX ZPO2_ORIGINATED_XCMS_ID ON ZPO2
(ZPO2_ORIGINATED_XCMS_ID)
LOGGING
TABLESPACE V8INDEX
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             40K
            MINEXTENTS       1
            MAXEXTENTS       505
            PCTINCREASE      50
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;

CREATE UNIQUE INDEX ZPO2_PK ON ZPO2
(ZPO2_ID)
NOLOGGING
TABLESPACE V8INDEX
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             40K
            MINEXTENTS       1
            MAXEXTENTS       505
            PCTINCREASE      50
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
PARALLEL ( DEGREE DEFAULT INSTANCES DEFAULT );

CREATE INDEX ZPO2_ZFAC_ID ON ZPO2
(ZPO2_ZFAC_ID)
LOGGING
TABLESPACE V8INDEX
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             40K
            MINEXTENTS       1
            MAXEXTENTS       505
            PCTINCREASE      50
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;

CREATE INDEX ZPO2_ZWIN_ID ON ZPO2
(ZPO2_ZWIN_ID)
LOGGING
TABLESPACE V8INDEX
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             40K
            MINEXTENTS       1
            MAXEXTENTS       505
            PCTINCREASE      50
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;

CREATE INDEX ZPO2_IHST_ID ON ZPO2
(ZPO2_IHST_ID)
LOGGING
TABLESPACE V8INDEX
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             40K
            MINEXTENTS       1
            MAXEXTENTS       505
            PCTINCREASE      50
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;

CREATE INDEX ZPO2_YRES_ID ON ZPO2
(ZPO2_YRES_ID)
LOGGING
TABLESPACE V8INDEX
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             40K
            MINEXTENTS       1
            MAXEXTENTS       505
            PCTINCREASE      50
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;

ALTER TABLE ZPO2 ADD (
  CONSTRAINT ZPO2_PK
 PRIMARY KEY
 (ZPO2_ID)
    USING INDEX 
    TABLESPACE V8INDEX
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          64K
                NEXT             40K
                MINEXTENTS       1
                MAXEXTENTS       505
                PCTINCREASE      50
                FREELISTS        1
                FREELIST GROUPS  1
               ));

CREATE INDEX ZPO2_ZTCD_ID ON ZPO2
(ZPO2_ZTCD_ID)
LOGGING
TABLESPACE V8INDEX
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             40K
            MINEXTENTS       1
            MAXEXTENTS       505
            PCTINCREASE      50
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;

CREATE INDEX ZPO2_GUEST_XCMS_ID ON ZPO2
(ZPO2_GUEST_XCMS_ID)
LOGGING
TABLESPACE V8INDEX
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             40K
            MINEXTENTS       1
            MAXEXTENTS       505
            PCTINCREASE      50
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;

CREATE INDEX ZPO2_INTERNALGROUP_ID ON ZPO2
(ZPO2_INTERNALGROUP_ID)
LOGGING
TABLESPACE V8INDEX
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             40K
            MINEXTENTS       1
            MAXEXTENTS       505
            PCTINCREASE      50
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;

CREATE INDEX ZPO2_ZUDD_ID ON ZPO2
(ZPO2_ZUDD_ID)
LOGGING
TABLESPACE V8INDEX
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             40K
            MINEXTENTS       1
            MAXEXTENTS       505
            PCTINCREASE      50
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;

CREATE INDEX ZPO2_POSCHECK_NR ON ZPO2
(ZPO2_POSCHECK_NR)
LOGGING
TABLESPACE V8INDEX
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             40K
            MINEXTENTS       1
            MAXEXTENTS       505
            PCTINCREASE      50
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;

ALTER TABLE ZINV ADD ZINV_CORRECTING_ZINV_ID NUMBER(30);

CREATE INDEX ZINV_CORRECTING_ZINV_ID ON ZINV(ZINV_CORRECTING_ZINV_ID) TABLESPACE V8INDEX;

COMMENT ON COLUMN ZINV.ZINV_CORRECTING_ZINV_ID IS 'invoice has been corrected with a correction invoice, which id stored here';

COMMENT ON COLUMN ZINV.ZINV_ROLE IS ' 0 or null = regular invoice |	1 = Deposit Folio | 2 = City Ledger Folio (not yet implemented) | 3 = Credit Note, 31=Faktura Korekta (polish credit note)| 10 = Fattura Riepilogativa (used for Italy)';

CREATE TABLE ZINK (
	ZINK_ID NUMBER(30) NOT NULL,
	ZINK_ZINV_ID NUMBER(30) NOT NULL,
	ZINK_OLD_ZTXC_ID0 NUMBER(30) NULL,
	ZINK_OLD_NET0 NUMBER(30,4) NULL,
	ZINK_OLD_TAX0 NUMBER(30,4) NULL,
	ZINK_OLD_ZTXC_ID1 NUMBER(30) NULL,
	ZINK_OLD_NET1 NUMBER(30,4) NULL,
	ZINK_OLD_TAX1 NUMBER(30,4) NULL,
	ZINK_OLD_ZTXC_ID2 NUMBER(30) NULL,
	ZINK_OLD_NET2 NUMBER(30,4) NULL,
	ZINK_OLD_TAX2 NUMBER(30,4) NULL,
	ZINK_OLD_ZTXC_ID3 NUMBER(30) NULL,
	ZINK_OLD_NET3 NUMBER(30,4) NULL,
	ZINK_OLD_TAX3 NUMBER(30,4) NULL,
	ZINK_OLD_ZTXC_ID4 NUMBER(30) NULL,
	ZINK_OLD_NET4 NUMBER(30,4) NULL,
	ZINK_OLD_TAX4 NUMBER(30,4) NULL,
	ZINK_OLD_ZTXC_ID5 NUMBER(30) NULL,
	ZINK_OLD_NET5 NUMBER(30,4) NULL,
	ZINK_OLD_TAX5 NUMBER(30,4) NULL,
	ZINK_OLD_ZTXC_ID6 NUMBER(30) NULL,
	ZINK_OLD_NET6 NUMBER(30,4) NULL,
	ZINK_OLD_TAX6 NUMBER(30,4) NULL,
	ZINK_OLD_ZTXC_ID7 NUMBER(30) NULL,
	ZINK_OLD_NET7 NUMBER(30,4) NULL,
	ZINK_OLD_TAX7 NUMBER(30,4) NULL,
	ZINK_OLD_ZTXC_ID8 NUMBER(30) NULL,
	ZINK_OLD_NET8 NUMBER(30,4) NULL,
	ZINK_OLD_TAX8 NUMBER(30,4) NULL,
	ZINK_OLD_ZTXC_ID9 NUMBER(30) NULL,
	ZINK_OLD_NET9 NUMBER(30,4) NULL,
	ZINK_OLD_TAX9 NUMBER(30,4) NULL,
	ZINK_ZTXC_ID0 NUMBER(30) NULL,
	ZINK_NET0 NUMBER(30,4) NULL,
	ZINK_TAX0 NUMBER(30,4) NULL,
	ZINK_ZTXC_ID1 NUMBER(30) NULL,
	ZINK_NET1 NUMBER(30,4) NULL,
	ZINK_TAX1 NUMBER(30,4) NULL,
	ZINK_ZTXC_ID2 NUMBER(30) NULL,
	ZINK_NET2 NUMBER(30,4) NULL,
	ZINK_TAX2 NUMBER(30,4) NULL,
	ZINK_ZTXC_ID3 NUMBER(30) NULL,
	ZINK_NET3 NUMBER(30,4) NULL,
	ZINK_TAX3 NUMBER(30,4) NULL,
	ZINK_ZTXC_ID4 NUMBER(30) NULL,
	ZINK_NET4 NUMBER(30,4) NULL,
	ZINK_TAX4 NUMBER(30,4) NULL,
	ZINK_ZTXC_ID5 NUMBER(30) NULL,
	ZINK_NET5 NUMBER(30,4) NULL,
	ZINK_TAX5 NUMBER(30,4) NULL,
	ZINK_ZTXC_ID6 NUMBER(30) NULL,
	ZINK_NET6 NUMBER(30,4) NULL,
	ZINK_TAX6 NUMBER(30,4) NULL,
	ZINK_ZTXC_ID7 NUMBER(30) NULL,
	ZINK_NET7 NUMBER(30,4) NULL,
	ZINK_TAX7 NUMBER(30,4) NULL,
	ZINK_ZTXC_ID8 NUMBER(30) NULL,
	ZINK_NET8 NUMBER(30,4) NULL,
	ZINK_TAX8 NUMBER(30,4) NULL,
	ZINK_ZTXC_ID9 NUMBER(30) NULL,
	ZINK_NET9 NUMBER(30,4) NULL,
	ZINK_TAX9 NUMBER(30,4) NULL,
	ZINK_DATE DATE NULL,
	ZINK_REASON VARCHAR2(200) NOT NULL,
	CONSTRAINT ZINK_PK PRIMARY KEY (ZINK_ID) USING INDEX TABLESPACE V8INDEX  ) TABLESPACE V8MAIN ;

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

COMMENT ON TABLE ZINK IS 'Table for special polish invoice correction report';

CREATE INDEX ZINK_ZINV_ID ON ZINK(ZINK_ZINV_ID) TABLESPACE V8INDEX;

CREATE TABLE ZADR (
	ZADR_ID NUMBER(30,0) NOT NULL,
	ZADR_ZINV_ID NUMBER(30,0) NOT NULL,
	ZADR_XADR_ID NUMBER(30,0) NOT NULL,
	ZADR_XATY_ID NUMBER(30,0),
	ZADR_XCOU_ID NUMBER(30,0),
	ZADR_XSTA_ID NUMBER(30,0),
	ZADR_ZIP VARCHAR2(15),
	ZADR_STREET1 VARCHAR2(60) ,
	ZADR_STREET2 VARCHAR2(60) ,
	ZADR_STREET3 VARCHAR2(60) ,
	ZADR_CITY VARCHAR2(30),
	ZADR_VAT_NUMBER VARCHAR2(30),
	ZADR_NAME1 VARCHAR2(35),
	ZADR_NAME2 VARCHAR2(35),
	ZADR_NAME3 VARCHAR2(35),
	CONSTRAINT ZADR_PK PRIMARY KEY (ZADR_ID) USING INDEX TABLESPACE V8INDEX  ) TABLESPACE V8MAIN ; 

COMMENT ON TABLE ZADR  IS 'Copy of the data on the moment of printing folio (Polish legal requirements)';

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

CREATE UNIQUE INDEX ZADR_ZINV_ID ON ZADR(ZADR_ZINV_ID) TABLESPACE V8INDEX;

CREATE INDEX ZADR_XADR_ID ON ZADR(ZADR_XADR_ID) TABLESPACE V8INDEX;

CREATE INDEX ZADR_XATY_ID ON ZADR(ZADR_XATY_ID) TABLESPACE V8INDEX;

CREATE INDEX ZADR_XCOU_ID ON ZADR(ZADR_XCOU_ID) TABLESPACE V8INDEX;

CREATE INDEX ZADR_XSTA_ID ON ZADR(ZADR_XSTA_ID) TABLESPACE V8INDEX;

CREATE TABLE ZNCR (
	ZNCR_ID NUMBER(30,0),
	ZNCR_ZINB_ID NUMBER(30,0),
	ZNCR_NUMBER NUMBER(30), 
	ZNCR_BEFORE VARCHAR2(1000),
	ZNCR_AFTER VARCHAR2(1000),
	ZNCR_REASON VARCHAR2(200),
	CONSTRAINT ZNCR_PK PRIMARY KEY (ZNCR_ID) USING INDEX TABLESPACE V8INDEX  ) TABLESPACE V8MAIN ; 

COMMENT ON TABLE ZNCR  IS 'Nota correction details (Polish legal requirements)';

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

CREATE UNIQUE INDEX ZNCR_ZINB_ID ON ZNCR(ZNCR_ZINB_ID) TABLESPACE V8INDEX;

CREATE TABLE WRCG (
     WRCG_ID NUMBER(30) NOT NULL
    ,WRCG_NAME VARCHAR2(50) NOT NULL 
	,CONSTRAINT WRCG_PK PRIMARY KEY (WRCG_ID) USING INDEX TABLESPACE V8INDEX  ) TABLESPACE V8MAIN ;

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

CREATE UNIQUE INDEX WRCG_NAME ON WRCG(WRCG_NAME) TABLESPACE V8INDEX;

CREATE TABLE WRCT (
    WRCT_ID NUMBER(30) NOT NULL
   ,WRCT_TASK NUMBER(3) NOT NULL
   ,WRCT_WRCG_ID NUMBER(30) NOT NULL
   ,CONSTRAINT WRCT_PK PRIMARY KEY (WRCT_ID) USING INDEX TABLESPACE V8INDEX  ) TABLESPACE V8MAIN ; 

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

CREATE UNIQUE INDEX WRCT_TASK ON WRCT(WRCT_TASK) TABLESPACE V8INDEX;

CREATE INDEX WRCT_WRCG_ID ON WRCT(WRCT_WRCG_ID) TABLESPACE V8INDEX;

COMMENT ON COLUMN ZINN.zinn_type IS ' 1 = Invoices  2 = User definable number cycles  3 = Currency Exchange (ZFAG_TYPE 3)  4 = Autonumber for Booth telephone charges paid cash  11 = Autonumber ZFAG_TYPE 1 (AR Postings)  12 = Autonumber ZFAG_TYPE 2 (AR Payments)  13 = Void Invoice  14 = Fattura (for Italy)  15 = Nota di Credito (for Italy or Credit Note for Greece or Portugal)  16 = Proforma  17 = Fattura and Nota di Credito (for Italy)  18 = Nota Korekta (for Poland)  21 = Registration Cards  31 = Automatic FA Numbers (zfac_autonumber)  32 = Lost and Found  33 = Police Export  34 = Tourist Export  35 = JetWeb Interface';
