/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\SIM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SIM_ORIGINAL_BILL_E' AND KSQL_COL_NAME ='FSPECIALTYPE') 
 ALTER TABLE T_SIM_ORIGINAL_BILL_E ADD (FSPECIALTYPE VARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SIM_CONFIRM_BILL_E') 
 CREATE TABLE T_SIM_CONFIRM_BILL_E (
FID BIGINT DEFAULT 0 NOT NULL,
FSPECIALTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SIM_RED_INFO' AND KSQL_COL_NAME ='FSPECIALTYPE') 
 ALTER TABLE T_SIM_RED_INFO ADD (FSPECIALTYPE VARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SIM_VATINVOICE_E' AND KSQL_COL_NAME ='ABOLISHTYPE') 
 ALTER TABLE T_SIM_VATINVOICE_E ADD (ABOLISHTYPE VARCHAR(5) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SIM_VATINVOICE_E' AND KSQL_COL_NAME ='FABOLISHTYPE') 
 ALTER TABLE T_SIM_VATINVOICE_E ADD (FABOLISHTYPE VARCHAR(5) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SIM_REDINFO_WF') 
 CREATE TABLE T_SIM_REDINFO_WF (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FAPPLYDATE DATETIME,
FAPPLYNUM BIGINT DEFAULT 0 NOT NULL,
FALLFTOTALAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FALLTOTALTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FALLTOTALPRICEANDTAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAPPLYREASON NVARCHAR(50) DEFAULT ' ' NOT NULL,
FAPPLYER BIGINT DEFAULT 0 NOT NULL,
FORG BIGINT DEFAULT 0 NOT NULL,
FBILLSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FREBACKREASON NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SIM_REDINFO_WF_ITEM') 
 CREATE TABLE T_SIM_REDINFO_WF_ITEM (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FINFOSERIALNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FAPPLICANT NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSALERNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSALERTAXNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBUYERNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FBUYERTAXNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FINVOICEAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FINVOICETYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME,
FHSBZ NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDECIMALFIELD DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTOTALAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FORIGINALINVOICECODE NVARCHAR(20) DEFAULT ' ' NOT NULL,
FORIGINALINVOICENO NVARCHAR(20) DEFAULT ' ' NOT NULL,
FORIGINALISSUETIME DATETIME,
FINFOSOURCE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FREMAINREDAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL
);



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