/**Begin D:\pdm\PDM_UPGRADE\pdm1\SIM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SIM_INV_APPLY') 
 CREATE TABLE T_SIM_INV_APPLY (
FID BIGINT DEFAULT 0 NOT NULL,
FEPINFO BIGINT DEFAULT 0 NOT NULL,
FINVOICETYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FREMAINQUANTITY BIGINT DEFAULT 0 NOT NULL,
FAVAILABLEQUANTITY BIGINT DEFAULT 0 NOT NULL,
FAPPLYPURCHASEQUANTITY BIGINT DEFAULT 0 NOT NULL,
FCONDUCTOR BIGINT DEFAULT 0 NOT NULL,
FORG BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SIM_INV_APPLY_LOG') 
 CREATE TABLE T_SIM_INV_APPLY_LOG (
FID BIGINT DEFAULT 0 NOT NULL,
FEQINFO BIGINT DEFAULT 0 NOT NULL,
FINVOICETYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FAPPLYTYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FAGENT VARCHAR(50) DEFAULT ' ' NOT NULL,
FCONDUCTOR BIGINT DEFAULT 0 NOT NULL,
FDEALTIME DATETIME,
FAPPLYPURCHASEQUANTITY BIGINT DEFAULT 0 NOT NULL,
FORG BIGINT DEFAULT 0 NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SIM_INV_APPLY_DETAIL') 
 CREATE TABLE T_SIM_INV_APPLY_DETAIL (
FID BIGINT DEFAULT 0 NOT NULL,
FEPINFO BIGINT DEFAULT 0 NOT NULL,
FINVOICETYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FAPPLYPURCHASEQUANTITY BIGINT DEFAULT 0 NOT NULL,
FAGENT VARCHAR(25) DEFAULT ' ' NOT NULL,
FCONDUCTOR BIGINT DEFAULT 0 NOT NULL,
FDEALTIME DATETIME,
FAPPLYDATE DATETIME,
FDEALSTATE VARCHAR(30) DEFAULT ' ' NOT NULL,
FINVOICECODE VARCHAR(30) DEFAULT ' ' NOT NULL,
FSTARTNUMBER VARCHAR(30) DEFAULT ' ' NOT NULL,
FENDNUMBER VARCHAR(30) DEFAULT ' ' NOT NULL,
FINVOICEQUANTITY BIGINT DEFAULT 0 NOT NULL,
FDEALMESSAGE VARCHAR(200) DEFAULT ' ' NOT NULL,
FDEALWITHTIME DATETIME,
FPREAPPNUMBER VARCHAR(30) DEFAULT ' ' NOT NULL,
FAPPLYSTATE VARCHAR(30) DEFAULT ' ' NOT NULL,
FORG BIGINT DEFAULT 0 NOT NULL,
FRESULTASKFLAG VARCHAR(4) DEFAULT ' ' NOT NULL,
FREMARK NVARCHAR(200) DEFAULT ' ' NOT NULL,
FSYCNID VARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SIM_VATINVOICE_ITEM') 
 CREATE TABLE T_SIM_VATINVOICE_ITEM (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FSPMC BIGINT DEFAULT 0 NOT NULL,
FGOODSCODE VARCHAR(50) DEFAULT ' ' NOT NULL,
FSPECIFICATION VARCHAR(50) DEFAULT ' ' NOT NULL,
FUNIT VARCHAR(50) DEFAULT ' ' NOT NULL,
FNUM DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNITPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FZEROTAXMARK VARCHAR(8) DEFAULT ' ' NOT NULL,
FTAXPREMARK VARCHAR(16) DEFAULT ' ' NOT NULL,
FZZSTSGL VARCHAR(2000) DEFAULT ' ' NOT NULL,
FZXBM VARCHAR(128) DEFAULT ' ' NOT NULL,
FTAXFLAG VARCHAR(8) DEFAULT ' ' NOT NULL,
FSIMPLEGOODSNAME VARCHAR(50) DEFAULT ' ' NOT NULL,
FUSERINPUTGOODSNAME VARCHAR(128) DEFAULT ' ' NOT NULL,
FGOODSNAME VARCHAR(128) DEFAULT ' ' NOT NULL,
FTAXRATE VARCHAR(30) DEFAULT ' ' NOT NULL,
FROWTYPE VARCHAR(30) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SIM_DRAWER_SETTING') 
 CREATE TABLE T_SIM_DRAWER_SETTING (
FID BIGINT DEFAULT 0 NOT NULL,
FTAXNO VARCHAR(50) DEFAULT ' ' NOT NULL,
FDRAWER VARCHAR(50) DEFAULT ' ' NOT NULL,
FPAYEE VARCHAR(50) DEFAULT ' ' NOT NULL,
FREVIEWER VARCHAR(50) DEFAULT ' ' NOT NULL,
FDRAWERID VARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SIM_INVOICE_SUM_DATA') 
 CREATE TABLE T_SIM_INVOICE_SUM_DATA (
FID BIGINT DEFAULT 0 NOT NULL,
FORGFIELD BIGINT DEFAULT 0 NOT NULL,
FINVOICENUMBER BIGINT DEFAULT 0 NOT NULL,
FINVENTORYNUM BIGINT DEFAULT 0 NOT NULL,
FBLUEINVOICEAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBLUEINVOICENUM BIGINT DEFAULT 0 NOT NULL,
FBLUEINVOICETAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREDINVOICENUM BIGINT DEFAULT 0 NOT NULL,
FREDINVOICEAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREDINVOICETAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCREATEDATE DATETIME,
FDATADATE DATETIME,
FINVOICEAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSTATISTICSTYPE VARCHAR(8) DEFAULT ' ' NOT NULL,
FTAXRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCANCELINVOICENUM BIGINT DEFAULT 0 NOT NULL,
FCANCELINVOICEAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCANCELINVOICETAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FINVOICETAX DECIMAL(23,10) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SIM_INVOICE_SETTING') 
 CREATE TABLE T_SIM_INVOICE_SETTING (
FID BIGINT DEFAULT 0 NOT NULL,
FINVOICEADDR NVARCHAR(100) DEFAULT ' ' NOT NULL,
FPHONE VARCHAR(50) DEFAULT ' ' NOT NULL,
FOPENUSERBANK NVARCHAR(100) DEFAULT ' ' NOT NULL,
FBANKACCOUNT VARCHAR(50) DEFAULT ' ' NOT NULL,
FTAXNO VARCHAR(50) DEFAULT ' ' NOT NULL,
FISCHECK VARCHAR(8) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SIM_VATINVOICE') 
 CREATE TABLE T_SIM_VATINVOICE (
FID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FINVOICECODE VARCHAR(50) DEFAULT ' ' NOT NULL,
FINVOICENO VARCHAR(50) DEFAULT ' ' NOT NULL,
FCHECKCODE VARCHAR(50) DEFAULT ' ' NOT NULL,
FISSUETIME DATETIME,
FINVOICETYPE VARCHAR(8) DEFAULT ' ' NOT NULL,
FBUYERTYPE VARCHAR(8) DEFAULT ' ' NOT NULL,
FINVOICESTATUS VARCHAR(8) DEFAULT ' ' NOT NULL,
FINVENTORYMARK VARCHAR(8) DEFAULT ' ' NOT NULL,
FORIGINALINVOICECODE VARCHAR(50) DEFAULT ' ' NOT NULL,
FORIGINALINVOICENO VARCHAR(50) DEFAULT ' ' NOT NULL,
FORIGINALISSUETIME DATETIME,
FORIGINALINVOICETYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FORDERNO VARCHAR(50) DEFAULT ' ' NOT NULL,
FBUYERNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FBUYERTAXNO VARCHAR(50) DEFAULT ' ' NOT NULL,
FBUYERADDR NVARCHAR(100) DEFAULT ' ' NOT NULL,
FBUYERTELNO VARCHAR(50) DEFAULT ' ' NOT NULL,
FBUYERBANK NVARCHAR(100) DEFAULT ' ' NOT NULL,
FBUYERBANKACC VARCHAR(50) DEFAULT ' ' NOT NULL,
FTOTALAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FINVOICEAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTOTALTAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSALERADDR NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSALERTELNO VARCHAR(50) DEFAULT ' ' NOT NULL,
FSALERBANK NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSALERBANKACC VARCHAR(50) DEFAULT ' ' NOT NULL,
FPAYEE VARCHAR(50) DEFAULT ' ' NOT NULL,
FREVIEWER VARCHAR(50) DEFAULT ' ' NOT NULL,
FDRAWER VARCHAR(50) DEFAULT ' ' NOT NULL,
FSPECIALTYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FORGID VARCHAR(50) DEFAULT ' ' NOT NULL,
FSALERNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSALERTAXNO VARCHAR(50) DEFAULT ' ' NOT NULL,
FREMARK VARCHAR(512) DEFAULT ' ' NOT NULL,
FDEDUCTION DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBUYEREMAIL VARCHAR(50) DEFAULT ' ' NOT NULL,
FBUYERPHONE VARCHAR(50) DEFAULT ' ' NOT NULL,
FHSBZ VARCHAR(8) DEFAULT ' ' NOT NULL,
FTAXEDTYPE VARCHAR(8) DEFAULT ' ' NOT NULL,
FISSUETYPE VARCHAR(8) DEFAULT ' ' NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SIM_VATINVOICE_E') 
 CREATE TABLE T_SIM_VATINVOICE_E (
FID BIGINT DEFAULT 0 NOT NULL,
FBUYERTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FINVENTORYMARK NVARCHAR(50) DEFAULT ' ' NOT NULL,
FRESULT NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDATAHASH NVARCHAR(50) DEFAULT ' ' NOT NULL,
FINVALIDER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FINVALIDDATE DATETIME,
FPUSHTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPUSHSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FOFDSTATUS NVARCHAR(8) DEFAULT ' ' NOT NULL,
FUPLOADMARK NVARCHAR(8) DEFAULT ' ' NOT NULL,
FCONTRASTSTATUS NVARCHAR(8) DEFAULT ' ' NOT NULL,
FFILEURL VARCHAR(200) DEFAULT ' ' NOT NULL,
FISSUESOURCE VARCHAR(60) DEFAULT ' ' NOT NULL,
FSNAPSHOTURL VARCHAR(200) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SIM_RED_INFO') 
 CREATE TABLE T_SIM_RED_INFO (
FID BIGINT DEFAULT 0 NOT NULL,
FINFOCODE NVARCHAR(32) DEFAULT ' ' NOT NULL,
FORIGINALINVOICECODE NVARCHAR(20) DEFAULT ' ' NOT NULL,
FORIGINALINVOICENO NVARCHAR(15) DEFAULT ' ' NOT NULL,
FINVOICETYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSALERTAXNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSALERNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSALERADDR NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSALERTELNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSALERBANK NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSALERBANKACC NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBUYERNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FBUYERTAXNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBUYERADDR NVARCHAR(100) DEFAULT ' ' NOT NULL,
FBUYERTELNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBUYERBANK NVARCHAR(100) DEFAULT ' ' NOT NULL,
FBUYERBANKACC NVARCHAR(50) DEFAULT ' ' NOT NULL,
FINVOICEAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTOTALTAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTOTALAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCREATER BIGINT DEFAULT 0 NOT NULL,
FMODIFIER BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FAPPLICANT NVARCHAR(30) DEFAULT ' ' NOT NULL,
FINFOSOURCE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FAGENT NVARCHAR(50) DEFAULT ' ' NOT NULL,
FORG BIGINT DEFAULT 0 NOT NULL,
FSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSTATUSDESCRIBE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FINFOSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FAPPLYREASON NVARCHAR(30) DEFAULT ' ' NOT NULL,
FORIGINALISSUETIME DATETIME,
FMAINTAXRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FORIGINALDEDUCTION DECIMAL(23,10) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SIM_RED_INFO_ITEM') 
 CREATE TABLE T_SIM_RED_INFO_ITEM (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FSIMPLEGOODSNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FGOODSNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSPECIFICATION NVARCHAR(50) DEFAULT ' ' NOT NULL,
FUNIT NVARCHAR(50) DEFAULT ' ' NOT NULL,
FNUM DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNITPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAXRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FGOODSCODE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FTAXPREMARK NVARCHAR(2) DEFAULT ' ' NOT NULL,
FZZSTSGL NVARCHAR(500) DEFAULT ' ' NOT NULL,
FTAXFLAG NVARCHAR(2) DEFAULT ' ' NOT NULL,
FZEROTAXMARK NVARCHAR(2) DEFAULT ' ' NOT NULL,
FROWTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL
);



/**End D:\pdm\PDM_UPGRADE\pdm1\SIM_table.sql **/
