/**Begin D:\PDM_UPGRADE\PDM1\CAS_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_CAS_RECBILLCHANG') 
 CREATE TABLE T_CAS_RECBILLCHANG (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FBILLSTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FMODIFYTIME DATETIME,
FCREATETIME DATETIME,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FBIZDATE DATETIME,
FRECEIVINGTYPEID BIGINT DEFAULT 0 NOT NULL,
FPAYERTYPEID VARCHAR(30) DEFAULT ' ' NOT NULL,
FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
FPAYEEBANKID BIGINT DEFAULT 0 NOT NULL,
FACTRECAMT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FEXCHANGERATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLOCALAMT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FPAYERNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FPAYERBANKNUM NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSETTLETTYPEID BIGINT DEFAULT 0 NOT NULL,
FSETTLETNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
FPAYERID BIGINT DEFAULT 0 NOT NULL,
FPAYERFORMID VARCHAR(30) DEFAULT ' ' NOT NULL,
FPAYERACCFORMID VARCHAR(30) DEFAULT ' ' NOT NULL,
FPAYERACCTBANKID BIGINT DEFAULT 0 NOT NULL,
FBIZTYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FCASHIERID BIGINT DEFAULT 0 NOT NULL,
FPAYEEDATE DATETIME,
FPAYERBANKID BIGINT DEFAULT 0 NOT NULL,
FACCOUNTCASH BIGINT DEFAULT 0 NOT NULL,
FSOURCEBILLID BIGINT DEFAULT 0 NOT NULL,
FFUNDFLOWITEM BIGINT DEFAULT 0 NOT NULL,
FCLERK BIGINT DEFAULT 0 NOT NULL,
FPAYEEACCTBANKID BIGINT DEFAULT 0 NOT NULL,
FPAYERBANKNAME VARCHAR(255) DEFAULT ' ' NOT NULL,
FCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FBASECURRENCYID BIGINT DEFAULT 0 NOT NULL,
FBANKCHECKFLAG VARCHAR(80) DEFAULT ' ' NOT NULL,
FISAGENT CHAR(1) DEFAULT ' ' NOT NULL,
FISVOUCHER CHAR(1) DEFAULT ' ' NOT NULL,
FPAYMENTMODE VARCHAR(30) DEFAULT ' ' NOT NULL,
FISARCHIVE CHAR(1) DEFAULT ' ' NOT NULL,
FSOURCEBILLNUMBER NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSOURCEBILLTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FOPENORGID BIGINT DEFAULT 0 NOT NULL,
FACTPAYACCOUNTID BIGINT DEFAULT 0 NOT NULL,
FACTRECAMTSOUR DECIMAL(19,6) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_CAS_RECBILLCHANG_E') 
 CREATE TABLE T_CAS_RECBILLCHANG_E (
FID BIGINT DEFAULT 0 NOT NULL,
FREFUNDBATCHSEQID VARCHAR(80) DEFAULT ' ' NOT NULL,
FISREFUND CHAR(1) DEFAULT '0' NOT NULL,
FISFULLREFUND CHAR(1) DEFAULT '0' NOT NULL,
FEXRATEDATE DATETIME,
FEXRATETABLEID BIGINT DEFAULT 0 NOT NULL,
FVOUCHERNUM NVARCHAR(50) DEFAULT ' ' NOT NULL,
FITEMPAYERTYPEID VARCHAR(30) DEFAULT ' ' NOT NULL,
FFEE DECIMAL(19,6) DEFAULT 0 NOT NULL,
FITEMPAYERID BIGINT DEFAULT 0 NOT NULL,
FIMAGENUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCHGRESON NVARCHAR(255) DEFAULT ' ' NOT NULL,
FBBILLSTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
FBBIZDATE DATETIME,
FBRECEIVINGTYPE BIGINT DEFAULT 0 NOT NULL,
FBPAYERTYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FBPAYERNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FBSETTLETNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBSETTLETYPE BIGINT DEFAULT 0 NOT NULL,
FBPAYERBANKNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FBPAYBANKNO NVARCHAR(255) DEFAULT ' ' NOT NULL,
FBFEE DECIMAL(19,6) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_CAS_RECBILLCHANGENTRY') 
 CREATE TABLE T_CAS_RECBILLCHANGENTRY (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FACTAMT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FLOCALAMT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FFUNDFLOWITEMID BIGINT DEFAULT 0 NOT NULL,
FREMARK NVARCHAR(255),
FREALRECCOMPANY BIGINT DEFAULT 0 NOT NULL,
FRECEIVABLEAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FRECEIVABLELOCAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FDISCOUNTAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FDISCOUNTLOCAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FCOREBILLTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCOREBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FCOREBILLENTRYSEQ INT DEFAULT 0 NOT NULL,
FUNSETTLEDAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FLOCKAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FUNLOCKAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FSETTLEDAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FSOURCEBILLID BIGINT DEFAULT 0 NOT NULL,
FSOURCEBILLENTRYID BIGINT DEFAULT 0 NOT NULL,
FEXPENSEITEMID BIGINT DEFAULT 0 NOT NULL,
FPROJECTID BIGINT DEFAULT 0 NOT NULL,
FSETTLEORGID BIGINT DEFAULT 0 NOT NULL,
FCONTRACTNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
FFEE DECIMAL(19,6) DEFAULT 0 NOT NULL,
FCOREBILLID NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_CAS_RECBILLCHANGBENTRY') 
 CREATE TABLE T_CAS_RECBILLCHANGBENTRY (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FBACTAMT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FBLOCALAMT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FBFUNDFLOWITEMID BIGINT DEFAULT 0 NOT NULL,
FBREMARK NVARCHAR(255),
FBREALRECCOMPANY BIGINT DEFAULT 0 NOT NULL,
FBRECEIVABLEAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FBRECEIVABLELOCAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FBDISCOUNTAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FBDISCOUNTLOCAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FBMATERIALID BIGINT DEFAULT 0 NOT NULL,
FBCOREBILLTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBCOREBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FBCOREBILLENTRYSEQ INT DEFAULT 0 NOT NULL,
FBUNSETTLEDAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FBLOCKAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FBUNLOCKAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FBSETTLEDAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FBSOURCEBILLID BIGINT DEFAULT 0 NOT NULL,
FBSOURCEBILLENTRYID BIGINT DEFAULT 0 NOT NULL,
FBEXPENSEITEMID BIGINT DEFAULT 0 NOT NULL,
FBPROJECTID BIGINT DEFAULT 0 NOT NULL,
FBSETTLEORGID BIGINT DEFAULT 0 NOT NULL,
FBCONTRACTNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBFEE DECIMAL(19,6) DEFAULT 0 NOT NULL,
FBCOREBILLID NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_CAS_RECCHGSETTLEENTRY') 
 CREATE TABLE T_CAS_RECCHGSETTLEENTRY (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FRECAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FCATEGORYID BIGINT DEFAULT 0 NOT NULL,
FSETTLEREMARK NVARCHAR(255) DEFAULT ' ' NOT NULL
);



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