/**Begin D:\PDM_UPGRADE\PDM1\CAS_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_BANKJOURNAL_E' AND KSQL_COL_NAME IN ('FRECINITPERIODID')) 
 ALTER TABLE T_CAS_BANKJOURNAL_E ADD (FRECINITPERIODID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_BANKJOURNAL_E' AND KSQL_COL_NAME IN ('FISUSE')) 
 ALTER TABLE T_CAS_BANKJOURNAL_E ADD (FISUSE CHAR(1) DEFAULT '1' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_BANKSTATEMENT' AND KSQL_COL_NAME IN ('FRECINITPERIODID')) 
 ALTER TABLE T_CAS_BANKSTATEMENT ADD (FRECINITPERIODID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_BANKSTATEMENT' AND KSQL_COL_NAME IN ('FISUSE')) 
 ALTER TABLE T_CAS_BANKSTATEMENT ADD (FISUSE CHAR(1) DEFAULT '1' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_CAS_REC_INIT') 
 CREATE TABLE T_CAS_REC_INIT (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FINITPERIODID BIGINT DEFAULT 0 NOT NULL,
FSTARTPERIODID BIGINT DEFAULT 0 NOT NULL,
FCURRENTPERIODID BIGINT DEFAULT 0 NOT NULL,
FISFINISHINIT CHAR(1) DEFAULT '0' NOT NULL,
FBILLSTATUS VARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FSTACURRENCYID BIGINT DEFAULT 0 NOT NULL,
FEXRATETABLEID BIGINT DEFAULT 0 NOT NULL,
FPERIODTYPEID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_CAS_REC_INITCASH') 
 CREATE TABLE T_CAS_REC_INITCASH (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FACCOUNTCASHID BIGINT DEFAULT 0 NOT NULL,
FCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FYEARDEBIT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FYEARCREDIT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBALANCE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBATCHNO NVARCHAR(80) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_CAS_REC_INITBANK') 
 CREATE TABLE T_CAS_REC_INITBANK (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FACCOUNTBANKID BIGINT DEFAULT 0 NOT NULL,
FCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FJOURNALDEBIT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FJOURNALCREDIT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FJOURNALBALANCE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FJOURNALBALANCEADJ DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSTATEMENTDEBIT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSTATEMENTCREDIT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSTATEMENTBALANCE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSTATEMENTBALANCEADJ DECIMAL(23,10) DEFAULT 0 NOT NULL,
FEQUAL CHAR(1) DEFAULT '0' NOT NULL,
FBATCHNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FOPENORGID BIGINT DEFAULT 0 NOT NULL,
FJOURNALSUMBALANCEADJ DECIMAL(23,10) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_CAS_REC_EDC') 
 CREATE TABLE T_CAS_REC_EDC (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FRECPERIODID BIGINT DEFAULT 0 NOT NULL,
FSTARTPERIODID BIGINT DEFAULT 0 NOT NULL,
FCURRENTPERIODID BIGINT DEFAULT 0 NOT NULL,
FBILLSTATUS VARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_CAS_REC_STOPEDCLOG') 
 CREATE TABLE T_CAS_REC_STOPEDCLOG (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FRECPERIODID BIGINT DEFAULT 0 NOT NULL,
FSTARTPERIODID BIGINT DEFAULT 0 NOT NULL,
FCURRENTPERIODID BIGINT DEFAULT 0 NOT NULL,
FBILLSTATUS VARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME
);



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