/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\ER_table.sql **/

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_EXPENSEPOOLBILL') 
 CREATE TABLE T_ER_EXPENSEPOOLBILL (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO VARCHAR(80) DEFAULT ' ' NOT NULL,
FBILLSTATUS VARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FAPPLIERID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FCOMPANYID BIGINT DEFAULT 0 NOT NULL,
FCREATEDATE DATETIME,
FCOSTDEPTID BIGINT DEFAULT 0 NOT NULL,
FCOSTCOMPANYID BIGINT DEFAULT 0 NOT NULL,
FPROJECTID BIGINT DEFAULT 0 NOT NULL,
FEXPENSEITEMEDIT BIGINT DEFAULT 0 NOT NULL,
FDESCRIPTION NVARCHAR(1000) DEFAULT ' ' NOT NULL,
FEXPENSEAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAXRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FORIENTRYAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCURRENCY BIGINT DEFAULT 0 NOT NULL,
FHAPPENDATE DATETIME,
FTRIPSTARTDATE DATETIME,
FTRIPCHECKINDATE DATETIME,
FTRIPDEPARTUREDATE DATETIME,
FTRIPCITYFIELD BIGINT DEFAULT 0 NOT NULL,
FTRIPFROM BIGINT DEFAULT 0 NOT NULL,
FTRIPTO BIGINT DEFAULT 0 NOT NULL,
FTRIPPASSENGER VARCHAR(100) DEFAULT ' ' NOT NULL,
AIRPORTCONSTRUCTIONFEE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBILLTYPEFIELD BIGINT DEFAULT 0 NOT NULL,
FTRIPAREA BIGINT DEFAULT 0 NOT NULL,
FBILLTYPESTR CHAR(1) DEFAULT '0' NOT NULL,
FTRIPEXPENSEITEM BIGINT DEFAULT 0 NOT NULL,
FAIRPORTCONSTRUCTIONFEE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSTARTDATE DATETIME,
FEXPENSEITEMID BIGINT DEFAULT 0 NOT NULL,
FFORMID VARCHAR(30) DEFAULT ' ' NOT NULL,
FINVOICENO  VARCHAR(129)  DEFAULT ' ' NOT NULL,
FINVOICELINK VARCHAR(129) DEFAULT ' ' NOT NULL,
FGOODSNAME   VARCHAR(50) DEFAULT ' ' NOT NULL,
FTAXCLASSCODEID BIGINT DEFAULT 0 NOT NULL,
FSERIALNO  VARCHAR(50) DEFAULT ' ' NOT NULL,
FVEHICLE CHAR(1) DEFAULT '0' NOT NULL,
FTEL VARCHAR(100) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_EXPENSEPOOLBILL_L') 
 CREATE TABLE T_ER_EXPENSEPOOLBILL_L (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FAPPLIERPOSITION VARCHAR(100) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_POOLMULSEATGRADE') 
 CREATE TABLE T_ER_POOLMULSEATGRADE (
FPKID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_INVOICEPOOLINFO') 
 CREATE TABLE T_ER_INVOICEPOOLINFO (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FINVOICETYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FINVOICENO NVARCHAR(129) DEFAULT ' ' NOT NULL,
FINVOICECODE NVARCHAR(129) DEFAULT ' ' NOT NULL,
FTOTALAMOUNT DECIMAL(23,10) DEFAULT 0.0000000000 NOT NULL,
FTAXRATE DECIMAL(23,10) DEFAULT 0.0000000000 NOT NULL,
FTAXAMOUNT DECIMAL(23,10) DEFAULT 0.0000000000 NOT NULL,
FSERIALNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FREMARK NVARCHAR(255),
FBUYERNAME NVARCHAR(80) DEFAULT ' ' NOT NULL,
FMAKEOUTCOMPNAME NVARCHAR(80) DEFAULT ' ' NOT NULL,
FCOUNT INT DEFAULT 0 NOT NULL,
FFROMINVOICECLOUD CHAR(1) DEFAULT '0' NOT NULL,
FBUYERORGID BIGINT DEFAULT 0 NOT NULL,
FOFFSET CHAR(1) DEFAULT '0' NOT NULL,
FOFFSETAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FINOUTAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FVALIDATEMESSAGE NVARCHAR(255) DEFAULT ' ' NOT NULL,
FINVOICEDATE DATETIME,
FPASSENGERNAME NVARCHAR(255),
FAIRPORTCONSTRUCTIONFEE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FALLTAXRATE VARCHAR(100) DEFAULT ' ' NOT NULL,
FINVOICEFROM VARCHAR(30) DEFAULT '1' NOT NULL,
FISMAPEXPENSE CHAR(1) DEFAULT '1' NOT NULL,
FFROMCITY NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTOCITY NVARCHAR(50) DEFAULT ' ' NOT NULL,
FIEVALIDATEST CHAR(1) DEFAULT '3' NOT NULL,
FMAPEXPENSEINFO NVARCHAR(255) DEFAULT ' ',
FSEATGRADE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FISTARTCITY NVARCHAR(50) DEFAULT ' ' NOT NULL,
FIDESTCITY NVARCHAR(50) DEFAULT ' ' NOT NULL,
FISTARTPROVINCE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FIDESTPROVINCE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FINVOICENOTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTRANSPORTNOTE VARCHAR(30) DEFAULT ' ' NOT NULL,
FREASONFORTRANSFEROUT VARCHAR(30) DEFAULT ' ' NOT NULL,
FINVOICEISCHANGE VARCHAR(30) DEFAULT ' ' NOT NULL,
FBUYERTAXNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTICKETCHANGES VARCHAR(30) DEFAULT ' ' NOT NULL,
FSEQUENCENUM VARCHAR(30) DEFAULT ' ' NOT NULL,
FFLIGHTTRAINNUMS VARCHAR(30) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_INVOICEPOOLITEM') 
 CREATE TABLE T_ER_INVOICEPOOLITEM (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FITEMENTRYID BIGINT DEFAULT 0 NOT NULL,
FINVOICEHEADENTRYID BIGINT DEFAULT 0 NOT NULL,
FUNITPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAXRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FEXCLUDEAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSPECMODEL NVARCHAR(50) DEFAULT ' ' NOT NULL,
FUNIT NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FGOODSCODE VARCHAR(255) DEFAULT ' ' NOT NULL,
FNUM DECIMAL(23,10) DEFAULT 0 NOT NULL,
FGOODSNAME VARCHAR(255) DEFAULT ' ' NOT NULL,
FINVOICEITEMOFFSET CHAR(1) DEFAULT '0' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_POOLTRIP2MULWAYTO') 
 CREATE TABLE T_ER_POOLTRIP2MULWAYTO (
FPKID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);



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