/**Begin D:\d_desk\pdm\PDM_UPGRADE_1.1\PDM_UPGRADE\pdm1\SIM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SIM_BILL_TRANS') 
 CREATE TABLE T_SIM_BILL_TRANS (
FID BIGINT DEFAULT 0 NOT NULL,
FCONFIRMBILLNO NVARCHAR(100) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SIM_BILL_TRANS_ITEM') 
 CREATE TABLE T_SIM_BILL_TRANS_ITEM (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FGOODSITEMSID BIGINT DEFAULT 0 NOT NULL,
FNUM DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SIM_BILL_TRANS_RELAX') 
 CREATE TABLE T_SIM_BILL_TRANS_RELAX (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLID BIGINT DEFAULT 0 NOT NULL,
FCONFIRMBILLID BIGINT DEFAULT 0 NOT NULL,
FCHANGEDATE DATETIME,
FCHANGESTATE NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SIM_CONFIRM_BILL') 
 CREATE TABLE T_SIM_CONFIRM_BILL (
FID BIGINT DEFAULT 0 NOT NULL,
FCONFIRMBILLNO NVARCHAR(100) DEFAULT ' ' NOT NULL,
FOLDINVOICEAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FINVOICEAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTOTALAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBILLTAXRATE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBILLDATE DATETIME,
FCONFIRMBILLSTATE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBUYERNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FBUYERTAXNO NVARCHAR(100) DEFAULT ' ' NOT NULL,
FBUYERADDR NVARCHAR(100) DEFAULT ' ' NOT NULL,
FBUYERBANK NVARCHAR(100) DEFAULT ' ' NOT NULL,
FBUYERPROPERTY NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBUYERPERSONNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FBUYERPHONE NVARCHAR(100) DEFAULT ' ' NOT NULL,
FBUYEREMAIL NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSALERBANK NVARCHAR(100) DEFAULT ' ' NOT NULL,
FINVOICETYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FPAYEE NVARCHAR(100) DEFAULT ' ' NOT NULL,
FREVIEWER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCONTRACTNO NVARCHAR(100) DEFAULT ' ' NOT NULL,
FCONTRACTDATE DATETIME,
FCONTRACTAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPURCHASERNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FPURCHASERCONTACT NVARCHAR(100) DEFAULT ' ' NOT NULL,
FPURCHASERPHONE NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSUPPLIERNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSUPPLIERCONTACT NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSUPPLIERPHONE NVARCHAR(100) DEFAULT ' ' NOT NULL,
FBILLEXTRAFIELD1 NVARCHAR(200) DEFAULT ' ' NOT NULL,
FBILLEXTRAFIELD2 NVARCHAR(200) DEFAULT ' ' NOT NULL,
FBILLNATURE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME,
FTOTALTAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FORIGINALINVOICECODE NVARCHAR(20) DEFAULT ' ' NOT NULL,
FORIGINALINVOICENO NVARCHAR(15) DEFAULT ' ' NOT NULL,
FJQBH NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSPLITRULE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FHSBZ NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SIM_CONFIRM_BILL_ITEM') 
 CREATE TABLE T_SIM_CONFIRM_BILL_ITEM (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 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,
FTAXUNITPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDEDUCTION DECIMAL(23,10) DEFAULT 0 NOT NULL,
FROWTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FGOODSCODE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTAXRATE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FGOODSSIMPLENAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FREMARK NVARCHAR(200) DEFAULT ' ' NOT NULL,
FEXTRAFIELD NVARCHAR(200) DEFAULT ' ' NOT NULL,
FSPBM NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTAXPREMARK NVARCHAR(50) DEFAULT ' ' NOT NULL,
FZZSTSGL NVARCHAR(200) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SIM_ORIGINAL_BILL') 
 CREATE TABLE T_SIM_ORIGINAL_BILL (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBILLDATE DATETIME,
FOLDTOTALAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FINVOICEAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTOTALAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBILLTAXRATE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCONFIRMAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCONFIRMSTATE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FVALIDSTATE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSPLIT NVARCHAR(30) DEFAULT ' ' NOT NULL,
FPRIORITY NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBILLCONTAINTAX NVARCHAR(30) DEFAULT ' ' NOT NULL,
FTAXATIONSTYLE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBILLPROPERTIES NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBILLREMARK NVARCHAR(90) DEFAULT ' ' NOT NULL,
FBUYERNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBUYERTAXNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBUYERADDR NVARCHAR(100) DEFAULT ' ' NOT NULL,
FBUYERBANK NVARCHAR(100) DEFAULT ' ' NOT NULL,
FBUYERPERSONNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBUYERPHONE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBUYEREMAIL NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBUYERPROPERTY NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSALERBANK NVARCHAR(100) DEFAULT ' ' NOT NULL,
FINVOICETYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FPAYEE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FREVIEWER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCONTRACTNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPURCHASERNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPURCHASERCONTACT NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCONTRACTDATE DATETIME,
FCONTRACTAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPURCHASERPHONE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSUPPLIERNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSUPPLIERCONTACT NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSUPPLIERPHONE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FHSBZ NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SIM_ORIGINAL_BILL_ITEM') 
 CREATE TABLE T_SIM_ORIGINAL_BILL_ITEM (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FGOODSNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FGOODSNO NVARCHAR(50) 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,
FTAXUNITPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAXRATE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FTAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDEDUCTION DECIMAL(23,10) DEFAULT 0 NOT NULL,
FROWTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FGOODSCODE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FGOODSSIMPLENAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FPOLICYCONTANTS NVARCHAR(200) DEFAULT ' ' NOT NULL,
FREMARK NVARCHAR(200) DEFAULT ' ' NOT NULL,
FEXTRAFIELD NVARCHAR(200) DEFAULT ' ' NOT NULL,
FREMAINVALIDNUM DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREMAINVALIDAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSPBM NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDISCOUNTAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDISCOUNTRATE DECIMAL(23,10) DEFAULT 0 NOT NULL
);



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