/**Begin D:\PDM_UPGRADE\PDM1\CAS_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_CAS_PAYAPPLYBILL_BL') 
 CREATE TABLE T_CAS_PAYAPPLYBILL_BL (
FPKID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_CAS_PAYINFOENTRY') 
 CREATE TABLE T_CAS_PAYINFOENTRY (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FSETTLEMENTTYPEID BIGINT DEFAULT 0 NOT NULL,
FREMARK NVARCHAR(255) DEFAULT ' ' NOT NULL,
FPAYERACCBANKID BIGINT DEFAULT 0 NOT NULL,
FBALANCE DECIMAL(19,6) DEFAULT 0 NOT NULL,
FPAYMENTCHANNEL NVARCHAR(50) DEFAULT ' ' NOT NULL,
FEXPECTDATE DATETIME,
FPAYEEAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FPAYEETYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPAYEE BIGINT DEFAULT 0 NOT NULL,
FPAYEENAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FRECACCBANKNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPAYEEACCBANKNUM NVARCHAR(255) DEFAULT ' ' NOT NULL,
FPAYEEBANK BIGINT DEFAULT 0 NOT NULL,
FRECBANKNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FUSAGE NVARCHAR(255) DEFAULT ' ' NOT NULL,
FPRIORITY NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPAYSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSTATUSEXPLAIN NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPAYDATE DATETIME,
FPAYBILLNO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FPAIDAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FLOCKEDAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FPAYEEID BIGINT DEFAULT 0 NOT NULL,
FPAYERBANKID BIGINT DEFAULT 0 NOT NULL,
FSETTLETNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_CAS_BUSINESSENTRY') 
 CREATE TABLE T_CAS_BUSINESSENTRY (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FBUSREMARK NVARCHAR(512) DEFAULT ' ' NOT NULL,
FCONTRACTNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMATERIELFIELD BIGINT DEFAULT 0 NOT NULL,
FEXPENSEITEMID BIGINT DEFAULT 0 NOT NULL,
FPROJECTID BIGINT DEFAULT 0 NOT NULL,
FBUSPAYEEAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_PAYAPPLYBILL' AND KSQL_COL_NAME IN ('FPLANPAYDATE')) 
 ALTER TABLE T_CAS_PAYAPPLYBILL ADD (FPLANPAYDATE DATETIME );

/**End D:\PDM_UPGRADE\PDM1\CAS_table.sql **/
