/**Begin D:\PDM_UPGRADE\PDM1\IFM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_INTOBJECT' AND KSQL_COL_NAME IN ('FLASTPREINTDATE')) 
 ALTER TABLE T_IFM_INTOBJECT ADD (FLASTPREINTDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IFM_CURRENTINTBILL_BANK') 
 CREATE TABLE T_IFM_CURRENTINTBILL_BANK (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(50) 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,
FORGID BIGINT DEFAULT 0 NOT NULL,
FINTERESTDAY DATETIME,
FCOMMENT NVARCHAR(255) DEFAULT ' ' NOT NULL,
FDATASOURCE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBATCHNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FINNERACCTID BIGINT DEFAULT 0 NOT NULL,
FCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FPRINCIPAL DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSETTLECENTERID BIGINT DEFAULT 0 NOT NULL,
FRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRECBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FDEPOSIT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FINTAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FOVERDRAFT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FOVERINTAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FACTUALINSTAMT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FISCHANGED CHAR(1) DEFAULT ' ' NOT NULL,
FWRITEOFFSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FWRITEOFFPREINTBILLID BIGINT DEFAULT 0 NOT NULL,
FBEGINDATE DATETIME,
FBIZTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FINTOBJECTID BIGINT DEFAULT 0 NOT NULL,
FINTSOURCE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FISREVERSE CHAR(1) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IFM_BANKINTBIL_ENTRY') 
 CREATE TABLE T_IFM_BANKINTBIL_ENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FINSTSTARTDATE DATETIME,
FINSTENDDATE DATETIME,
FINSTDAYS BIGINT DEFAULT 0 NOT NULL,
FINSTPRINCIPAL DECIMAL(23,10) DEFAULT 0 NOT NULL,
FINTRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FINSTAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FINSTCTG NVARCHAR(50) DEFAULT ' ' NOT NULL,
FINTTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IFM_INTBILL_BATCH_BANK') 
 CREATE TABLE T_IFM_INTBILL_BATCH_BANK (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(50) 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,
FORGID BIGINT DEFAULT 0 NOT NULL,
FBIZDATE DATETIME,
FBIZTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FINTERESTTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCOMMENT NVARCHAR(255) DEFAULT ' ' NOT NULL,
FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
FPREINTDATE DATETIME,
FOPERATETYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FINTOBJECTID BIGINT DEFAULT 0 NOT NULL,
FINTSOURCE NVARCHAR(30) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IFM_INTBILL_BATCH_ENTRY') 
 CREATE TABLE T_IFM_INTBILL_BATCH_ENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FINTDETAILNUM NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSTARTDATE DATETIME,
FENDDATE DATETIME,
FINTDAYS BIGINT DEFAULT 0 NOT NULL,
FRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FINTERESTAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FINTCOMMENT NVARCHAR(255) DEFAULT ' ' NOT NULL,
FPRINCIPLE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCOMPANYID BIGINT DEFAULT 0 NOT NULL,
FINTTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FINTBILLID BIGINT DEFAULT 0 NOT NULL,
FINNERACCTID BIGINT DEFAULT 0 NOT NULL,
FINTDETAIL_TAG NCLOB,
FINTDETAIL NVARCHAR(255) DEFAULT ' ' NOT NULL,
FACTUALINSTAMT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FINTOBJECTID BIGINT DEFAULT 0 NOT NULL,
FSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL
);


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



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