/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\BEI_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_BANKPAYINGBILL' AND KSQL_COL_NAME IN ('FPAYERID')) 
 ALTER TABLE T_BEI_BANKPAYINGBILL ADD (FPAYERID BIGINT DEFAULT 0 NOT NULL );
 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_BEI_BANKPAYINGBILL', 'FPAYERNAME', 'NULL', 'NULL', '1001', 'NULL';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BEI_BANKTRANSDOWN_ENTRY') 
 CREATE TABLE T_BEI_BANKTRANSDOWN_ENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBANKRETURNMSG NVARCHAR(255) DEFAULT ' ' NOT NULL,
FREMARK NVARCHAR(255) DEFAULT ' ' NOT NULL,
FBANKCHECKFLAG NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSUBACCT BIGINT DEFAULT 0 NOT NULL,
FTRANSAMT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FSOURCEENTRYID NVARCHAR(80) DEFAULT ' ' NOT NULL,
FISSUCCESS CHAR(1) DEFAULT '0' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BEI_BANKTRANSDOWNBILL') 
 CREATE TABLE T_BEI_BANKTRANSDOWNBILL (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(80) 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,
FAUDITDATE DATETIME,
FMODIFYTIME DATETIME,
FCREATETIME DATETIME,
FORGID BIGINT DEFAULT 0 NOT NULL,
FBIZDATE DATETIME,
FSOURCEBILLID BIGINT DEFAULT 0 NOT NULL,
FCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FLOCAMT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FEXCHANGERATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCOMPANYID BIGINT DEFAULT 0 NOT NULL,
FACCOUNTBANKID BIGINT DEFAULT 0 NOT NULL,
FBANKID BIGINT DEFAULT 0 NOT NULL,
FCOUNT BIGINT DEFAULT 0 NOT NULL,
FACTAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FACTCOUNT BIGINT DEFAULT 0 NOT NULL,
FEXPECTDEALTIME DATETIME,
FISBITBACK CHAR(1) DEFAULT '0' NOT NULL,
FSERIALNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FTRANSBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FPAYSTATE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSUBMITTIME DATETIME,
FISPERSONPAY CHAR(1) DEFAULT '1' NOT NULL,
FISUPDATINGSTATUS CHAR(1) DEFAULT '0' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BEI_BANKTRANSDOWNBILL_L') 
 CREATE TABLE T_BEI_BANKTRANSDOWNBILL_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
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BEI_BANKTRANSUP_ENTRY') 
 CREATE TABLE T_BEI_BANKTRANSUP_ENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBANKRETURNMSG NVARCHAR(255) DEFAULT ' ' NOT NULL,
FREMARK NVARCHAR(255) DEFAULT ' ' NOT NULL,
FBANKCHECKFLAG NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSUBACCT BIGINT DEFAULT 0 NOT NULL,
FTRANSAMT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FSOURCEENTRYID NVARCHAR(80) DEFAULT ' ' NOT NULL,
FISSUCCESS CHAR(1) DEFAULT '0' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BEI_BANKTRANSUPBILL') 
 CREATE TABLE T_BEI_BANKTRANSUPBILL (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(80) 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,
FAUDITDATE DATETIME,
FMODIFYTIME DATETIME,
FCREATETIME DATETIME,
FORGID BIGINT DEFAULT 0 NOT NULL,
FBIZDATE DATETIME,
FSOURCEBILLID BIGINT DEFAULT 0 NOT NULL,
FCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FLOCAMT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FEXCHANGERATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCOMPANYID BIGINT DEFAULT 0 NOT NULL,
FACCOUNTBANKID BIGINT DEFAULT 0 NOT NULL,
FBANKID BIGINT DEFAULT 0 NOT NULL,
FCOUNT BIGINT DEFAULT 0 NOT NULL,
FACTAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FACTCOUNT BIGINT DEFAULT 0 NOT NULL,
FEXPECTDEALTIME DATETIME,
FISBITBACK CHAR(1) DEFAULT '0' NOT NULL,
FSERIALNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FTRANSBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FPAYSTATE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSUBMITTIME DATETIME,
FISPERSONPAY CHAR(1) DEFAULT '1' NOT NULL,
FISUPDATINGSTATUS CHAR(1) DEFAULT '0' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BEI_BANKTRANSUPBILL_L') 
 CREATE TABLE T_BEI_BANKTRANSUPBILL_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
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BEI_UPDATEPAYSTAT') 
 CREATE TABLE T_BEI_UPDATEPAYSTAT (
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,
FAUDITDATE DATETIME,
FMODIFYTIME DATETIME,
FCREATETIME DATETIME,
FORGID BIGINT DEFAULT 0 NOT NULL,
FBIZDATE DATETIME,
FSOURCEBILLID BIGINT DEFAULT 0 NOT NULL,
FCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FLOCAMT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FEXCHANGERATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCOMPANYID BIGINT DEFAULT 0 NOT NULL,
FACCOUNTBANKID BIGINT DEFAULT 0 NOT NULL,
FBANKID BIGINT DEFAULT 0 NOT NULL,
FSOURCEBILLNO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSOURCETYPE NVARCHAR(30) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BEI_UPDATEPAYSTAT_ENTRY') 
 CREATE TABLE T_BEI_UPDATEPAYSTAT_ENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FSUBACCT BIGINT DEFAULT 0 NOT NULL,
FPAYAMT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FSTATUSNEW NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBANKRETURNMSG NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSOURCEENTRYID NVARCHAR(30) DEFAULT ' ' NOT NULL,
FREASON NVARCHAR(255) DEFAULT ' ' NOT NULL,
FPAYSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSOURCESEQ NVARCHAR(30) DEFAULT ' ' NOT NULL,
FOPSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BEI_UPDATEPAYSTAT_L') 
 CREATE TABLE T_BEI_UPDATEPAYSTAT_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
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BEI_UPDATEPAYSTAT_LK') 
 CREATE TABLE T_BEI_UPDATEPAYSTAT_LK (
FID BIGINT DEFAULT 0 NOT NULL,
FPKID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FSTABLEID BIGINT DEFAULT 0 NOT NULL,
FSBILLID BIGINT DEFAULT 0 NOT NULL,
FSID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BEI_UPDATEPAYSTAT_TC') 
 CREATE TABLE T_BEI_UPDATEPAYSTAT_TC (
FID BIGINT DEFAULT 0 NOT NULL,
FTBILLID BIGINT DEFAULT 0 NOT NULL,
FTTABLEID BIGINT DEFAULT 0 NOT NULL,
FTID BIGINT DEFAULT 0 NOT NULL,
FSBILLID BIGINT DEFAULT 0 NOT NULL,
FSTABLEID BIGINT DEFAULT 0 NOT NULL,
FSID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BEI_UPDATEPAYSTAT_WB') 
 CREATE TABLE T_BEI_UPDATEPAYSTAT_WB (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FRULEVERID BIGINT DEFAULT 0 NOT NULL,
FRULEITEMID BIGINT DEFAULT 0 NOT NULL,
FOPERATE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSTABLEID BIGINT DEFAULT 0 NOT NULL,
FSID BIGINT DEFAULT 0 NOT NULL,
FSBILLID BIGINT DEFAULT 0 NOT NULL,
FWRITEVALUE DECIMAL(19,6) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BEI_UPDATEPAYSTAT_ENTRY_LK') 
 CREATE TABLE T_BEI_UPDATEPAYSTAT_ENTRY_LK (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FPKID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FSTABLEID BIGINT DEFAULT 0 NOT NULL,
FSBILLID BIGINT DEFAULT 0 NOT NULL,
FSID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_ELECRECEIPT' AND KSQL_COL_NAME IN ('FBIZTYPE')) 
 ALTER TABLE T_BEI_ELECRECEIPT ADD (FBIZTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_ELECRECEIPT' AND KSQL_COL_NAME IN ('FDETAILID')) 
 ALTER TABLE T_BEI_ELECRECEIPT ADD (FDETAILID NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_ELECRECEIPT' AND KSQL_COL_NAME IN ('FBIZREFNO')) 
 ALTER TABLE T_BEI_ELECRECEIPT ADD (FBIZREFNO NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_ELECRECEIPT' AND KSQL_COL_NAME IN ('FREMARKS')) 
 ALTER TABLE T_BEI_ELECRECEIPT ADD (FREMARKS NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_ELECRECEIPT' AND KSQL_COL_NAME IN ('FBIZTIME')) 
 ALTER TABLE T_BEI_ELECRECEIPT ADD (FBIZTIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_ELECRECEIPT' AND KSQL_COL_NAME IN ('FPRINTCOUNT')) 
 ALTER TABLE T_BEI_ELECRECEIPT ADD (FPRINTCOUNT BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_ELECRECEIPT' AND KSQL_COL_NAME IN ('FDATASOURCE')) 
 ALTER TABLE T_BEI_ELECRECEIPT ADD (FDATASOURCE NVARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_ELECRECEIPT' AND KSQL_COL_NAME IN ('FSORTNO')) 
 ALTER TABLE T_BEI_ELECRECEIPT ADD (FSORTNO NVARCHAR(100) DEFAULT ' ' NOT NULL );
 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_BEI_ELECRECEIPT', 'FBILLSTATUS', 'NULL', 'NULL', '1001', 'NULL';

 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_BEI_ELECRECEIPT', 'FORGID', 'NULL', 'NULL', '1001', 'NULL';

 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_BEI_ELECRECEIPT', 'FSOURCEBILLID', 'NULL', 'NULL', '1001', 'NULL';

 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_BEI_ELECRECEIPT', 'FBUSTYPE', 'NULL', 'NULL', '1001', 'NULL';

 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_BEI_ELECRECEIPT', 'FLOCAMT', 'NULL', 'NULL', '1001', 'NULL';

 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_BEI_ELECRECEIPT', 'FEXCHANGERATE', 'NULL', 'NULL', '1001', 'NULL';

 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_BEI_ELECRECEIPT', 'FSERIALNO', 'NULL', 'NULL', '1001', 'NULL';

 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_BEI_ELECRECEIPT', 'FBIZNUMBER', 'NULL', 'NULL', '1001', 'NULL';


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