/**Begin D:\pdm\PDM_UPGRADE_1.1\PDM_UPGRADE\pdm1\SIM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SIM_MATCH_BILL') 
 CREATE TABLE T_SIM_MATCH_BILL (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(50) 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,
FBUYERTAXNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBUYERNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSALERTAXNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSALERNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMATCHAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMATCHTAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMATCHTOTALAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMATCHINVOICENUM BIGINT DEFAULT 0 NOT NULL,
FAPPLYAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAPPLYTAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAPPLYTOTALAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FINVOICETYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPAYEE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FREVIEWER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDRAWER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBUYERPHONE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBUYEREMAIL NVARCHAR(100) DEFAULT ' ' NOT NULL,
FREMARK NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSYSTEMSOURCE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMATCHRULE BIGINT DEFAULT 0 NOT NULL,
FMATCHTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FREDREASON NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMATCHSTATUS VARCHAR(20) DEFAULT ' ' NOT NULL,
FBUYERPROPERTY VARCHAR(20) DEFAULT ' ' NOT NULL,
FBUYERADDR NVARCHAR(200) DEFAULT ' ' NOT NULL,
FBUYERTEL NVARCHAR(100) DEFAULT ' ' NOT NULL,
FBUYERBANK NVARCHAR(200) DEFAULT ' ' NOT NULL,
FBUYERBANKACC NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSALERADDR NVARCHAR(200) DEFAULT ' ' NOT NULL,
FSALERTEL NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSALERBANK NVARCHAR(200) DEFAULT ' ' NOT NULL,
FSALERBANKACC NVARCHAR(100) DEFAULT ' ' NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SIM_MATCH_BILL_ITEM') 
 CREATE TABLE T_SIM_MATCH_BILL_ITEM (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FGOODSNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSPBM NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSPECIFICATION NVARCHAR(50) DEFAULT ' ' NOT NULL,
FUNIT NVARCHAR(50) DEFAULT ' ' NOT NULL,
FNUM DECIMAL(26,13) DEFAULT 0 NOT NULL,
FTAXRATE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FUNITPRICE DECIMAL(26,13) DEFAULT 0 NOT NULL,
FAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAXUNITPRICE DECIMAL(26,13) DEFAULT 0 NOT NULL,
FGOODSCODE VARCHAR(50) DEFAULT ' ' NOT NULL,
FITEMMATCHSTATUS VARCHAR(20) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SIM_MATCH_BILL_ORIITEM') 
 CREATE TABLE T_SIM_MATCH_BILL_ORIITEM (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FDETAILID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FORIINVOICECODE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FORIINVOICENO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FORIINVOICEID BIGINT DEFAULT 0 NOT NULL,
FORIITEMID BIGINT DEFAULT 0 NOT NULL,
FORIITEMSEQ BIGINT DEFAULT 0 NOT NULL,
FORIITEMAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FORIITEMTAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FORITAXRATE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FORIITEMNUM DECIMAL(26,13) DEFAULT 0 NOT NULL,
FORIITEMUNITPRICE DECIMAL(26,13) DEFAULT 0 NOT NULL,
FORIITEMTAXUNITPRICE DECIMAL(26,13) DEFAULT 0 NOT NULL,
FINFOCODE VARCHAR(50) DEFAULT ' ' NOT NULL,
FORIITEMGOODSNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FORIITEMSPECIFICATION NVARCHAR(50) DEFAULT ' ' NOT NULL,
FORIITEMUNIT NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPUSHSTATUS VARCHAR(20) DEFAULT '-1' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SIM_MATCHBILL_RELATION') 
 CREATE TABLE T_SIM_MATCHBILL_RELATION (
FID BIGINT DEFAULT 0 NOT NULL,
FSBILLID BIGINT DEFAULT 0 NOT NULL,
FSBILLNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSDETAILID BIGINT DEFAULT 0 NOT NULL,
FTBILLID BIGINT DEFAULT 0 NOT NULL,
FTBILLNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTDETAILID BIGINT DEFAULT 0 NOT NULL,
FAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FNUM DECIMAL(26,13) DEFAULT 0 NOT NULL,
FPRICE DECIMAL(26,13) DEFAULT 0 NOT NULL
);



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