/** 立项单  **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_APPLYPROJECTBILL')
 CREATE TABLE T_ER_APPLYPROJECTBILL (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FBILLSTATUS CHAR(1) 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,
FCOMPANYID BIGINT DEFAULT 0 NOT NULL,
FBIZDATE DATETIME,
FISCURRENCY CHAR(1) DEFAULT '0' NOT NULL,
FDESCRIPTION NVARCHAR(1000) DEFAULT ' ' NOT NULL,
FCOSTCOMPANYID BIGINT DEFAULT 0 NOT NULL,
FCOSTDEPTID BIGINT DEFAULT 0 NOT NULL,
FAPPLIERID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FTEL VARCHAR(30) DEFAULT ' ' NOT NULL,
FFORMID VARCHAR(30) DEFAULT ' ' NOT NULL,
FAPPLYAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAPPROVEAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBALANCEAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBILLCANLOANAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLOANEDAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FIMAGENUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FHASVOUCHER CHAR(1) DEFAULT '0' NOT NULL,
FAPPLIERPOSITIONSTR NVARCHAR(100) DEFAULT ' ' NOT NULL,
FISOVERBUDGET CHAR(1) DEFAULT '0' NOT NULL,
FPROJECTNAMEDESC NVARCHAR(255) DEFAULT ' ' NOT NULL,
FPROJECTTYPE BIGINT DEFAULT 0 NOT NULL,
FBILLTYPE BIGINT DEFAULT 0 NOT NULL,
FUSEDAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCHANGEAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCHANGETIMES INT DEFAULT 0 NOT NULL,
FISCHANGE CHAR(1) DEFAULT '0' NOT NULL,
FCOSTCENTERID BIGINT DEFAULT 0 NOT NULL,
FWLTYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FWLUNIT BIGINT DEFAULT 0 NOT NULL,
FWITHHOLDINGAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCHANGETYPE CHAR(1) DEFAULT '0' NOT NULL
);

/** 立项单 分录 **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_APPLYPROJECTENTRY')
 CREATE TABLE T_ER_APPLYPROJECTENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FEXPENSEITEMID BIGINT DEFAULT 0 NOT NULL,
FHAPPENDATE DATETIME,
FENTRYCURRENCY BIGINT DEFAULT 0 NOT NULL,
FEXCHANGERATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCURRAPPLYAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAPPLYAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FEXPEAPPROVEAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FEXPEAPPROVECURRAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FORGIEXPEBALANCEAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FEXPEBALANCEAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREIMBURSEDAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREIMBURSEDCURRAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCANLOANAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCANLOANCURRAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPUSHEDAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPUSHEDCURRAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FENTRYCOSTCOMPANYID BIGINT DEFAULT 0 NOT NULL,
FENTRYCOSTDEPTID BIGINT DEFAULT 0 NOT NULL,
FPROJECTID BIGINT DEFAULT 0 NOT NULL,
FENTRYCOSTCENTERID BIGINT DEFAULT 0 NOT NULL,
FENTRYWLTYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FENTRYWLUNIT BIGINT DEFAULT 0 NOT NULL,
FENTRYPRODUCTTYPE BIGINT DEFAULT 0 NOT NULL,
FTAXRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FORIAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSOURCEBILLTYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FSOURCEBILLID BIGINT DEFAULT 0 NOT NULL,
FSOURCEENTRYID BIGINT DEFAULT 0 NOT NULL,
FENTRYREMARK VARCHAR(500) DEFAULT ' ' NOT NULL,
FEXPORIWITHHOLDINGAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FEXPWITHHOLDINGAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSOURCEBILLNO VARCHAR(50) DEFAULT ' ' NOT NULL,
FENTRYCHANGEAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FENTRYORICHANGEAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL
);

/**立项单 关联子实体 **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_APPLYPROJECTBILL_LK')
 CREATE TABLE T_ER_APPLYPROJECTBILL_LK (
FID BIGINT DEFAULT 0 NOT NULL,
FPKID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FSTABLEID BIGINT DEFAULT 0 NOT NULL,
FSBILLID BIGINT DEFAULT 0 NOT NULL,
FSID BIGINT DEFAULT 0 NOT NULL
);

/**立项单 反写记录 **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_APPLYPROJECTBILL_WB')
 CREATE TABLE T_ER_APPLYPROJECTBILL_WB (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FRULEVERID BIGINT DEFAULT 0 NOT NULL,
FRULEITEMID BIGINT DEFAULT 0 NOT NULL,
FOPERATE VARCHAR(30) DEFAULT ' ' NOT NULL,
FSTABLEID BIGINT DEFAULT 0 NOT NULL,
FSID BIGINT DEFAULT 0 NOT NULL,
FSBILLID BIGINT DEFAULT 0 NOT NULL,
FWRITEVALUE DECIMAL(23,10) DEFAULT 0 NOT NULL
);

/**立项单 追踪**/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_APPLYPROJECTBILL_TC')
 CREATE TABLE T_ER_APPLYPROJECTBILL_TC (
FID BIGINT DEFAULT 0 NOT NULL,
FTBILLID BIGINT DEFAULT 0 NOT NULL,
FTTABLEID BIGINT DEFAULT 0 NOT NULL,
FTID BIGINT DEFAULT 0 NOT NULL,
FSBILLID BIGINT DEFAULT 0 NOT NULL,
FSTABLEID BIGINT DEFAULT 0 NOT NULL,
FSID BIGINT DEFAULT 0 NOT NULL
);

/**立项单分录关联 **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_APPLYPROJECTENTRY_LK')
 CREATE TABLE T_ER_APPLYPROJECTENTRY_LK (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FPKID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FSTABLEID BIGINT DEFAULT 0 NOT NULL,
FSBILLID BIGINT DEFAULT 0 NOT NULL,
FSID BIGINT DEFAULT 0 NOT NULL
);

/**立项单 项目干系人 **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_APPLYPROJECTOWER')
 CREATE TABLE T_ER_APPLYPROJECTOWER (
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_APPLYPROJECTBILL_L')
 CREATE TABLE T_ER_APPLYPROJECTBILL_L (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FAPPLIERPOSITIONSTR NVARCHAR(100) DEFAULT ' ' NOT NULL
);








/**End D:\PDM_UPGRADE\PDM1\ER_table.sql **/

