/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\IFM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IFM_ACCOUNTACCEPT') 
 CREATE TABLE T_IFM_ACCOUNTACCEPT (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(80) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FMODIFYTIME DATETIME,
FCREATETIME DATETIME,
FSOURCEBILLID BIGINT DEFAULT 0 NOT NULL,
FSOURCEBILLTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FAPPLYTIME DATETIME,
FAPPLIER BIGINT DEFAULT 0 NOT NULL,
FBANKID BIGINT DEFAULT 0 NOT NULL,
FOPENDATE DATETIME,
FSHORTNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FISDEFAULTREC CHAR(1) DEFAULT '0' NOT NULL,
FISDEFAULTPAY CHAR(1) DEFAULT '0' NOT NULL,
FMANAGERID BIGINT DEFAULT 0 NOT NULL,
FSTRATEGYID BIGINT DEFAULT 0 NOT NULL,
FISSETBANKINTERFACE CHAR(1) DEFAULT '0' NOT NULL,
FOPENORGID BIGINT DEFAULT 0 NOT NULL,
FBANKACCOUNTNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FENGLISHNAME NVARCHAR(80) DEFAULT ' ' NOT NULL,
FACCTSTYLE NVARCHAR(80) DEFAULT ' ' NOT NULL,
FACCTTYPE NVARCHAR(80) DEFAULT ' ' NOT NULL,
FACCTPROPERTYID BIGINT DEFAULT 0 NOT NULL,
FACCTMANAGEAMT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FISOPENBANK CHAR(1) DEFAULT '0' NOT NULL,
FDEFAULTCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FFINORGTYPE NVARCHAR(80) DEFAULT ' ' NOT NULL,
FMANAGECURRENCYID BIGINT DEFAULT 0 NOT NULL,
FCOMPANYID BIGINT DEFAULT 0 NOT NULL,
FBANKINTERFACE NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSCORGID BIGINT DEFAULT 0 NOT NULL,
FBACKREASON NVARCHAR(500) DEFAULT ' ' NOT NULL,
FSETTLEMENTTYPE BIGINT DEFAULT 0 NOT NULL,
FPAYMODEL NVARCHAR(30) DEFAULT ' ' NOT NULL,
FINTEREST CHAR(1) DEFAULT '0' NOT NULL,
FAGREEMENT CHAR(1) DEFAULT '0' NOT NULL,
FBUSINESSTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FACCOUNTBANKID BIGINT DEFAULT 0 NOT NULL,
FCLOSEDATE DATETIME,
FBUSINESSSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCLOSEREASON NVARCHAR(255) DEFAULT ' ' NOT NULL,
FACCTNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FCOMMENT NVARCHAR(255) DEFAULT ' ' NOT NULL,
FOPENREASON NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IFM_ACCOUNTACCEPT_CUR') 
 CREATE TABLE T_IFM_ACCOUNTACCEPT_CUR (
FPKID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IFM_ACCOUNTACCEPT_L') 
 CREATE TABLE T_IFM_ACCOUNTACCEPT_L (
FPKID NVARCHAR(30) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCLOSEREASON NVARCHAR(255) DEFAULT ' ' NOT NULL,
FACCTNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FCOMMENT NVARCHAR(255) DEFAULT ' ' NOT NULL,
FOPENREASON NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IFM_INNERACCOUNTINIT') 
 CREATE TABLE T_IFM_INNERACCOUNTINIT (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FAUDITDATE DATETIME,
FCREATETIME DATETIME,
FSCORGID BIGINT DEFAULT 0 NOT NULL,
FINNERACCOUNTID BIGINT DEFAULT 0 NOT NULL,
FCURRENCY BIGINT DEFAULT 0 NOT NULL,
FISINIT CHAR(1) DEFAULT '0' NOT NULL,
FAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FAMOUNTDATE DATETIME,
FINTERESTDATESTART DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IFM_INNERACCT_ACC') 
 CREATE TABLE T_IFM_INNERACCT_ACC (
FPKID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IFM_PAYACCEPTANCE') 
 CREATE TABLE T_IFM_PAYACCEPTANCE (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FCREATETIME DATETIME,
FAUDITDATE DATETIME,
FSOURCEBILLTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSOURCEBILLID BIGINT DEFAULT 0 NOT NULL,
FSOURCEBILLNUMBER NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSCORGID BIGINT DEFAULT 0 NOT NULL,
FACCEPTUSERID BIGINT DEFAULT 0 NOT NULL,
FACCEPTDATETIME DATETIME,
FBIZDATE DATETIME,
FEXPECTDATE DATETIME,
FPAYMENTTYPEID BIGINT DEFAULT 0 NOT NULL,
FPAYEETYPEID NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSETTLETTYPEID BIGINT DEFAULT 0 NOT NULL,
FTRANSTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSETTLETNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
FPAYMENTCHANNEL NVARCHAR(30) DEFAULT ' ' NOT NULL,
FISDIFFCUR CHAR(1) DEFAULT '0' NOT NULL,
FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
FAGENTFINORGCATID BIGINT DEFAULT 0 NOT NULL,
FAGENTFINORGID BIGINT DEFAULT 0 NOT NULL,
FAGENTPAYERACCOUNTID BIGINT DEFAULT 0 NOT NULL,
FAGENTPAYERACCNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FACTPAYAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FOPENORGID BIGINT DEFAULT 0 NOT NULL,
FPAYERBANKID BIGINT DEFAULT 0 NOT NULL,
FPAYERACCTBANKID BIGINT DEFAULT 0 NOT NULL,
FPAYEEFORMID NVARCHAR(30) DEFAULT ' ' NOT NULL,
FPAYEEID BIGINT DEFAULT 0 NOT NULL,
FPAYEENAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FPAYEEACCFORMID NVARCHAR(30) DEFAULT ' ' NOT NULL,
FPAYEEACCTBANKID BIGINT DEFAULT 0 NOT NULL,
FPAYEEBANKNUM NVARCHAR(255) DEFAULT ' ' NOT NULL,
FPAYEECURRENCY BIGINT DEFAULT 0 NOT NULL,
FPAYEEBANKID BIGINT DEFAULT 0 NOT NULL,
FPAYEEBANKNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FRECCOUNTRYID BIGINT DEFAULT 0 NOT NULL,
FRECPROVINCE NVARCHAR(80) DEFAULT ' ' NOT NULL,
FRECCITY NVARCHAR(80) DEFAULT ' ' NOT NULL,
FRECACCBANKNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FRECBANKNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
FUSAGE NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IFM_PAYACCEPTANCE_E') 
 CREATE TABLE T_IFM_PAYACCEPTANCE_E (
FID BIGINT DEFAULT 0 NOT NULL,
FISCOMMITBE CHAR(1) DEFAULT '0' NOT NULL,
FBATCHSEQID NVARCHAR(80) DEFAULT ' ' NOT NULL,
FDETAILSEQID NVARCHAR(80) DEFAULT ' ' NOT NULL,
FBANKPAYINGID BIGINT DEFAULT 0 NOT NULL,
FCOMMITBETIME DATETIME,
FBANKPAYSTATUS NVARCHAR(5) DEFAULT ' ' NOT NULL,
FBANKRETURNMSG NVARCHAR(255) DEFAULT ' ' NOT NULL,
FPAYMENTMODE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBANKCHECKFLAG NVARCHAR(80) DEFAULT ' ' NOT NULL,
FISVOUCHER CHAR(1) DEFAULT '0' NOT NULL,
FREASON NVARCHAR(255) DEFAULT ' ' NOT NULL,
FBACKUSERID BIGINT DEFAULT 0 NOT NULL,
FBACKDATE DATETIME,
FENTRUSTORGID BIGINT DEFAULT 0 NOT NULL,
FAPPLYORGID BIGINT DEFAULT 0 NOT NULL,
FITEMPAYEETYPEID NVARCHAR(30) DEFAULT ' ' NOT NULL,
FITEMPAYEEID BIGINT DEFAULT 0 NOT NULL,
FISPERSONPAY CHAR(1) DEFAULT '0' NOT NULL,
FSBILLTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FACTTRADEDATE DATETIME,
FCASHIERID BIGINT DEFAULT 0 NOT NULL,
FPAYDATE DATETIME,
FBIZSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IFM_PAYACCEPTANCEENTRY') 
 CREATE TABLE T_IFM_PAYACCEPTANCEENTRY (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FACTAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FLOCALAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FFUNDFLOWITEMID BIGINT DEFAULT 0 NOT NULL,
FREMARK NVARCHAR(255),
FPAYABLEAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FPAYABLELOCAMOUNT 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(255) 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,
FSETTLEORGID BIGINT DEFAULT 0 NOT NULL,
FPROJECTID BIGINT DEFAULT 0 NOT NULL,
FTAXRATE DECIMAL(19,6) DEFAULT 0 NOT NULL,
FTAXAMT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FCONTRACTNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
FREFUNDAMT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FREFUNDDES NVARCHAR(255)
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IFM_SETTLECENTERINIT') 
 CREATE TABLE T_IFM_SETTLECENTERINIT (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FCREATETIME DATETIME,
FSCORGID BIGINT DEFAULT 0 NOT NULL,
FSCID BIGINT DEFAULT 0 NOT NULL,
FINNERACCINIT CHAR(1) DEFAULT '0' NOT NULL,
FAPPLYFUNDORG CHAR(1) DEFAULT '0' NOT NULL,
FUSESTATUS CHAR(1) DEFAULT '0' NOT NULL,
FSETTCENTERSETTING CHAR(1) DEFAULT '0' NOT NULL,
FACCEPTBUSINESSSETTING CHAR(1) DEFAULT '0' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IFM_TRANSHANDLE') 
 CREATE TABLE T_IFM_TRANSHANDLE (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FCREATETIME DATETIME,
FAUDITDATE DATETIME,
FSOURCEBILLTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSOURCEBILLID BIGINT DEFAULT 0 NOT NULL,
FSOURCEBILLNUMBER NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSCORGID BIGINT DEFAULT 0 NOT NULL,
FACCEPTUSERID BIGINT DEFAULT 0 NOT NULL,
FACCEPTDATETIME DATETIME,
FBIZDATE DATETIME,
FEXPECTDATE DATETIME,
FPAYMENTTYPEID BIGINT DEFAULT 0 NOT NULL,
FPAYEETYPEID NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSETTLETTYPEID BIGINT DEFAULT 0 NOT NULL,
FTRANSTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSETTLETNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
FPAYMENTCHANNEL NVARCHAR(30) DEFAULT ' ' NOT NULL,
FISDIFFCUR CHAR(1) DEFAULT '0' NOT NULL,
FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
FAGENTFINORGCATID BIGINT DEFAULT 0 NOT NULL,
FAGENTFINORGID BIGINT DEFAULT 0 NOT NULL,
FAGENTPAYERACCOUNTID BIGINT DEFAULT 0 NOT NULL,
FAGENTPAYERACCNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FACTPAYAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FOPENORGID BIGINT DEFAULT 0 NOT NULL,
FPAYERBANKID BIGINT DEFAULT 0 NOT NULL,
FPAYERACCTBANKID BIGINT DEFAULT 0 NOT NULL,
FPAYEEFORMID NVARCHAR(30) DEFAULT ' ' NOT NULL,
FPAYEECURRENCY BIGINT DEFAULT 0 NOT NULL,
FPAYEEID BIGINT DEFAULT 0 NOT NULL,
FPAYEENAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FPAYEEACCFORMID NVARCHAR(30) DEFAULT ' ' NOT NULL,
FPAYEEACCTBANKID BIGINT DEFAULT 0 NOT NULL,
FPAYEEBANKNUM NVARCHAR(255) DEFAULT ' ' NOT NULL,
FPAYEEBANKID BIGINT DEFAULT 0 NOT NULL,
FPAYEEBANKNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FRECCOUNTRYID BIGINT DEFAULT 0 NOT NULL,
FRECPROVINCE NVARCHAR(80) DEFAULT ' ' NOT NULL,
FRECCITY NVARCHAR(80) DEFAULT ' ' NOT NULL,
FRECACCBANKNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FRECBANKNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
FUSAGE NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IFM_TRANSHANDLE_E') 
 CREATE TABLE T_IFM_TRANSHANDLE_E (
FID BIGINT DEFAULT 0 NOT NULL,
FISCOMMITBE CHAR(1) DEFAULT '0' NOT NULL,
FBATCHSEQID NVARCHAR(80) DEFAULT ' ' NOT NULL,
FDETAILSEQID NVARCHAR(80) DEFAULT ' ' NOT NULL,
FBANKPAYINGID BIGINT DEFAULT 0 NOT NULL,
FCOMMITBETIME DATETIME,
FBANKPAYSTATUS NVARCHAR(5) DEFAULT ' ' NOT NULL,
FBANKRETURNMSG NVARCHAR(255) DEFAULT ' ' NOT NULL,
FPAYMENTMODE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBANKCHECKFLAG NVARCHAR(80) DEFAULT ' ' NOT NULL,
FISVOUCHER CHAR(1) DEFAULT '0' NOT NULL,
FREASON NVARCHAR(255) DEFAULT ' ' NOT NULL,
FBACKUSERID BIGINT DEFAULT 0 NOT NULL,
FBACKDATE DATETIME,
FENTRUSTORGID BIGINT DEFAULT 0 NOT NULL,
FAPPLYORGID BIGINT DEFAULT 0 NOT NULL,
FITEMPAYEETYPEID NVARCHAR(30) DEFAULT ' ' NOT NULL,
FITEMPAYEEID BIGINT DEFAULT 0 NOT NULL,
FISPERSONPAY CHAR(1) DEFAULT '0' NOT NULL,
FSBILLTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FACTTRADEDATE DATETIME,
FPAIDSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCASHIERID BIGINT DEFAULT 0 NOT NULL,
FPAYDATE DATETIME,
FFAILDESCRIPTION NVARCHAR(500) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IFM_TRANSHANDLEENTRY') 
 CREATE TABLE T_IFM_TRANSHANDLEENTRY (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FACTAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FLOCALAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FFUNDFLOWITEMID BIGINT DEFAULT 0 NOT NULL,
FREMARK NVARCHAR(255),
FPAYABLEAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FPAYABLELOCAMOUNT 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(255) 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,
FSETTLEORGID BIGINT DEFAULT 0 NOT NULL,
FPROJECTID BIGINT DEFAULT 0 NOT NULL,
FTAXRATE DECIMAL(19,6) DEFAULT 0 NOT NULL,
FTAXAMT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FCONTRACTNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
FREFUNDAMT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FREFUNDDES NVARCHAR(255)
);


 EXEC p_AlterColumn 'T_IFM_INNERACCT_L', 'FNAME', 'NVARCHAR(100)', 'NOT NULL', '0100', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_INNERACCT_L' AND KSQL_COL_NAME ='FCLOSEREASON') 
 ALTER TABLE T_IFM_INNERACCT_L ADD (FCLOSEREASON NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_INNERACCT_L' AND KSQL_COL_NAME ='FOPENREASON') 
 ALTER TABLE T_IFM_INNERACCT_L ADD (FOPENREASON NVARCHAR(255) DEFAULT ' ' NOT NULL );
 EXEC p_AlterColumn 'T_IFM_INNERACCT', 'FNAME', 'NVARCHAR(100)', 'NOT NULL', '0100', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_INNERACCT' AND KSQL_COL_NAME ='FINTEREST') 
 ALTER TABLE T_IFM_INNERACCT ADD (FINTEREST CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_INNERACCT' AND KSQL_COL_NAME ='FAGREEMENT') 
 ALTER TABLE T_IFM_INNERACCT ADD (FAGREEMENT CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_INNERACCT' AND KSQL_COL_NAME ='FINTERESTSTARTDATE') 
 ALTER TABLE T_IFM_INNERACCT ADD (FINTERESTSTARTDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_INNERACCT' AND KSQL_COL_NAME ='FPAYMODEL') 
 ALTER TABLE T_IFM_INNERACCT ADD (FPAYMODEL NVARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_INNERACCT' AND KSQL_COL_NAME ='FENGLISHNAME') 
 ALTER TABLE T_IFM_INNERACCT ADD (FENGLISHNAME NVARCHAR(80) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_INNERACCT' AND KSQL_COL_NAME ='FCLOSEDATE') 
 ALTER TABLE T_IFM_INNERACCT ADD (FCLOSEDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_INNERACCT' AND KSQL_COL_NAME ='FMANAGERID') 
 ALTER TABLE T_IFM_INNERACCT ADD (FMANAGERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_INNERACCT' AND KSQL_COL_NAME ='FSETTLEMENTTYPE') 
 ALTER TABLE T_IFM_INNERACCT ADD (FSETTLEMENTTYPE BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_INNERACCT' AND KSQL_COL_NAME ='FISDEFAULTREC') 
 ALTER TABLE T_IFM_INNERACCT ADD (FISDEFAULTREC CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_INNERACCT' AND KSQL_COL_NAME ='FISDEFAULTPAY') 
 ALTER TABLE T_IFM_INNERACCT ADD (FISDEFAULTPAY CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_INNERACCT' AND KSQL_COL_NAME ='FFINORGTYPE') 
 ALTER TABLE T_IFM_INNERACCT ADD (FFINORGTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_INNERACCT' AND KSQL_COL_NAME ='FCLOSEREASON') 
 ALTER TABLE T_IFM_INNERACCT ADD (FCLOSEREASON NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_INNERACCT' AND KSQL_COL_NAME ='FOPENREASON') 
 ALTER TABLE T_IFM_INNERACCT ADD (FOPENREASON NVARCHAR(255) DEFAULT ' ' NOT NULL );

/**End E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\IFM_table.sql **/
