/**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_PRODUCT') 
 CREATE TABLE T_IFM_PRODUCT (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FDISABLERID BIGINT DEFAULT 0 NOT NULL,
FENABLERID BIGINT DEFAULT 0 NOT NULL,
FENABLEDATE DATETIME,
FDISABLEDATE DATETIME,
FSERVICECATEGORY NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FCATEGORY NVARCHAR(30) DEFAULT ' ' NOT NULL,
FEFFECTIVEDATE DATETIME,
FINTERESTRATEDAYS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FINITDEPOSITLIMIT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FCONVERTUNIT NVARCHAR(30) DEFAULT ' ' NOT NULL,
FPRODUCTTERMID BIGINT DEFAULT 0 NOT NULL,
FFLOATRATE CHAR(1) DEFAULT '0' NOT NULL,
FFLOATDIRECTION NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBENCHMARK BIGINT DEFAULT 0 NOT NULL,
FFLOATPOINTS BIGINT DEFAULT 0 NOT NULL,
FPRICE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPRICENUM DECIMAL(23,10) DEFAULT 0 NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCOMMENT NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IFM_PRODUCT_ENTRY') 
 CREATE TABLE T_IFM_PRODUCT_ENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FEFFECTIVEDATE DATETIME,
FINTERESTRATEDAYS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FINITDEPOSITLIMIT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FCONVERTUNIT NVARCHAR(30) DEFAULT ' ' NOT NULL,
FPRICE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBENCHMARK BIGINT DEFAULT 0 NOT NULL,
FFLOATDIRECTION NVARCHAR(30) DEFAULT ' ' NOT NULL,
FFLOATPOINTS BIGINT DEFAULT 0 NOT NULL,
FFLOATRATE CHAR(1) DEFAULT '0' NOT NULL,
FPRICENUM DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCOMMENT NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IFM_PRODUCT_ENTRY_L') 
 CREATE TABLE T_IFM_PRODUCT_ENTRY_L (
FPKID NVARCHAR(80) DEFAULT ' ' NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCOMMENT NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IFM_PRODUCT_L') 
 CREATE TABLE T_IFM_PRODUCT_L (
FPKID NVARCHAR(80) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCOMMENT NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IFM_RECTRANSBILL') 
 CREATE TABLE T_IFM_RECTRANSBILL (
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(100) DEFAULT ' ' NOT NULL,
FSCORGID BIGINT DEFAULT 0 NOT NULL,
FTRANSTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBIZDATE DATETIME,
FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
FCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FPAYEEORGID BIGINT DEFAULT 0 NOT NULL,
FPAYEEBANKID BIGINT DEFAULT 0 NOT NULL,
FPAYEEACCTBANKID BIGINT DEFAULT 0 NOT NULL,
FACTRECAMT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FPACCOUNTBANKID BIGINT DEFAULT 0 NOT NULL,
FPAYERNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FPAYERBANKACCNUM NVARCHAR(100) DEFAULT ' ' NOT NULL,
FPAYERBANKID BIGINT DEFAULT 0 NOT NULL,
FPAYERBANKNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FPAYERTYPEID NVARCHAR(30) DEFAULT ' ' NOT NULL,
FPAYERID BIGINT DEFAULT 0 NOT NULL,
FPAYERFORMID NVARCHAR(30) DEFAULT ' ' NOT NULL,
FPAYERACCFORMID NVARCHAR(30) DEFAULT ' ' NOT NULL,
FPAYERACCTBANKID BIGINT DEFAULT 0 NOT NULL,
FITEMPAYERTYPEID NVARCHAR(30) DEFAULT ' ' NOT NULL,
FITEMPAYERID BIGINT DEFAULT 0 NOT NULL,
FPAYERNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSETTLETYPEID BIGINT DEFAULT 0 NOT NULL,
FSETTLENUMBER NVARCHAR(100) DEFAULT ' ' NOT NULL,
FOPENORGID BIGINT DEFAULT 0 NOT NULL,
FPAYEEDATE DATETIME,
FISVOUCHER CHAR(1) DEFAULT '0' NOT NULL,
FVOUCHERNUM NVARCHAR(100) DEFAULT ' ' NOT NULL,
FBANKCHECKFLAG NVARCHAR(100) DEFAULT ' ' NOT NULL,
FPAIDSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FACTTRADEDATE DATETIME,
FSOURCEBILLENTRYID BIGINT DEFAULT 0 NOT NULL
);


 EXEC p_AlterColumn 'T_IFM_ACCOUNTACCEPT', 'FISDEFAULTREC', 'CHAR(1)', 'NOT NULL', '0001', '''0''';

 EXEC p_AlterColumn 'T_IFM_ACCOUNTACCEPT', 'FISDEFAULTPAY', 'CHAR(1)', 'NOT NULL', '0001', '''0''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_TRANSHANDLE_E' AND KSQL_COL_NAME ='FPACCOUNTBANKID') 
 ALTER TABLE T_IFM_TRANSHANDLE_E ADD (FPACCOUNTBANKID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_TRANSHANDLE_E' AND KSQL_COL_NAME ='FSOURCEBILLENTRYID') 
 ALTER TABLE T_IFM_TRANSHANDLE_E ADD (FSOURCEBILLENTRYID BIGINT DEFAULT 0 NOT NULL );

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