/*费用报销、对公报销、差旅报销添加事前分摊字段*/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_PUBREIMBILL' AND KSQL_COL_NAME ='FISBEFORESHARE') 
 ALTER TABLE T_ER_PUBREIMBILL ADD (FISBEFORESHARE CHAR(1) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_PUBREIMBILL' AND KSQL_COL_NAME ='FSHARERULE') 
 ALTER TABLE T_ER_PUBREIMBILL ADD (FSHARERULE VARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_PUBREIMBILL' AND KSQL_COL_NAME ='FSHAREMETHOD') 
 ALTER TABLE T_ER_PUBREIMBILL ADD (FSHAREMETHOD VARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_PUBREIMBILL' AND KSQL_COL_NAME ='FMONTHRULESTARTDATE') 
 ALTER TABLE T_ER_PUBREIMBILL ADD (FMONTHRULESTARTDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_PUBREIMBILL' AND KSQL_COL_NAME ='FMONTHRULEENDDATE') 
 ALTER TABLE T_ER_PUBREIMBILL ADD (FMONTHRULEENDDATE DATETIME );
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_REIMBURSEBILL' AND KSQL_COL_NAME ='FISBEFORESHARE') 
 ALTER TABLE T_ER_REIMBURSEBILL ADD (FISBEFORESHARE CHAR(1) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_REIMBURSEBILL' AND KSQL_COL_NAME ='FSHARERULE') 
 ALTER TABLE T_ER_REIMBURSEBILL ADD (FSHARERULE VARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_REIMBURSEBILL' AND KSQL_COL_NAME ='FSHAREMETHOD') 
 ALTER TABLE T_ER_REIMBURSEBILL ADD (FSHAREMETHOD VARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_REIMBURSEBILL' AND KSQL_COL_NAME ='FMONTHRULESTARTDATE') 
 ALTER TABLE T_ER_REIMBURSEBILL ADD (FMONTHRULESTARTDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_REIMBURSEBILL' AND KSQL_COL_NAME ='FMONTHRULEENDDATE') 
 ALTER TABLE T_ER_REIMBURSEBILL ADD (FMONTHRULEENDDATE DATETIME );
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_DAILYREIMBURSEBILL_A' AND KSQL_COL_NAME ='FISBEFORESHARE') 
 ALTER TABLE T_ER_DAILYREIMBURSEBILL_A ADD (FISBEFORESHARE CHAR(1) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_DAILYREIMBURSEBILL_A' AND KSQL_COL_NAME ='FSHARERULE') 
 ALTER TABLE T_ER_DAILYREIMBURSEBILL_A ADD (FSHARERULE VARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_DAILYREIMBURSEBILL_A' AND KSQL_COL_NAME ='FSHAREMETHOD') 
 ALTER TABLE T_ER_DAILYREIMBURSEBILL_A ADD (FSHAREMETHOD VARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_DAILYREIMBURSEBILL_A' AND KSQL_COL_NAME ='FMONTHRULESTARTDATE') 
 ALTER TABLE T_ER_DAILYREIMBURSEBILL_A ADD (FMONTHRULESTARTDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_DAILYREIMBURSEBILL_A' AND KSQL_COL_NAME ='FMONTHRULEENDDATE') 
 ALTER TABLE T_ER_DAILYREIMBURSEBILL_A ADD (FMONTHRULEENDDATE DATETIME );
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_DAILYRESHARERULE') 
 CREATE TABLE T_ER_DAILYRESHARERULE (
FID BIGINT DEFAULT 0 NOT NULL,
FDETAILID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FENTRYCOSTCOMPANYID BIGINT DEFAULT 0 NOT NULL,
FENTRYCOSTDEPTID BIGINT DEFAULT 0 NOT NULL,
FPROJECTID BIGINT DEFAULT 0 NOT NULL,
FSHARERATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FENTRYMONTH DATETIME,
FSHAREREMARK NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_PUBLICRESHARERULE') 
 CREATE TABLE T_ER_PUBLICRESHARERULE (
FID BIGINT DEFAULT 0 NOT NULL,
FDETAILID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FENTRYCOSTCOMPANYID BIGINT DEFAULT 0 NOT NULL,
FENTRYCOSTDEPTID BIGINT DEFAULT 0 NOT NULL,
FPROJECTID BIGINT DEFAULT 0 NOT NULL,
FSHARERATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FENTRYMONTH DATETIME,
FSHAREREMARK NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_DAILYRESHAREDETAIL') 
 CREATE TABLE T_ER_DAILYRESHAREDETAIL (
FID BIGINT DEFAULT 0 NOT NULL,
FDETAILID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FEXPENSEITEMID BIGINT DEFAULT 0 NOT NULL,
FHAPPENDATE DATETIME,
FEXCHANGERATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FORIAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCURRREIMBURSEAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREIMBURSEAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAXRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREMARK NVARCHAR(255) DEFAULT ' ' NOT NULL,
FISSPECIALINVOICE CHAR(1) DEFAULT '1' NOT NULL,
FENTRYCURRENCY BIGINT DEFAULT 0 NOT NULL,
FEXPEAPPROVEAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FEXPEAPPROVECURRAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAXCLASSCODEID BIGINT DEFAULT 0 NOT NULL,
FINVOICENO NVARCHAR(129) DEFAULT ' ' NOT NULL,
FINVOICELINK NVARCHAR(129) DEFAULT ' ' NOT NULL,
FOFFSET CHAR(1) DEFAULT '1' NOT NULL,
FENTRYCOSTCOMPANYID BIGINT DEFAULT 0 NOT NULL,
FENTRYCOSTDEPTID BIGINT DEFAULT 0 NOT NULL,
FSERIALNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FAIRPORTCONSTRUCTIONFEE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FGOODSNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FDEDUCTIBLETAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FITEMFROM VARCHAR(2) DEFAULT '0' NOT NULL,
FINVOICETYPEITEM VARCHAR(2) DEFAULT '0' NOT NULL,
FPROJECTID BIGINT DEFAULT 0 NOT NULL,
FSHARERATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLKWAITENTRYID VARCHAR(200) DEFAULT ' ' NOT NULL,
FPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FENTRYMONTH DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_PUBLICRESHAREDETAIL') 
 CREATE TABLE T_ER_PUBLICRESHAREDETAIL (
FID BIGINT DEFAULT 0 NOT NULL,
FDETAILID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FEXPENSEITEMID BIGINT DEFAULT 0 NOT NULL,
FHAPPENDATE DATETIME,
FEXCHANGERATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FORIAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCURRREIMBURSEAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREIMBURSEAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAXRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREMARK NVARCHAR(255) DEFAULT ' ' NOT NULL,
FISSPECIALINVOICE CHAR(1) DEFAULT '1' NOT NULL,
FENTRYCURRENCY BIGINT DEFAULT 0 NOT NULL,
FEXPEAPPROVEAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FEXPEAPPROVECURRAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAXCLASSCODEID BIGINT DEFAULT 0 NOT NULL,
FINVOICENO NVARCHAR(129) DEFAULT ' ' NOT NULL,
FINVOICELINK NVARCHAR(129) DEFAULT ' ' NOT NULL,
FOFFSET CHAR(1) DEFAULT '1' NOT NULL,
FENTRYCOSTCOMPANYID BIGINT DEFAULT 0 NOT NULL,
FENTRYCOSTDEPTID BIGINT DEFAULT 0 NOT NULL,
FSERIALNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FAIRPORTCONSTRUCTIONFEE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FGOODSNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FDEDUCTIBLETAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FITEMFROM VARCHAR(2) DEFAULT '0' NOT NULL,
FINVOICETYPEITEM VARCHAR(2) DEFAULT '0' NOT NULL,
FPROJECTID BIGINT DEFAULT 0 NOT NULL,
FSHARERATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLKWAITENTRYID VARCHAR(200) DEFAULT ' ' NOT NULL,
FPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FENTRYMONTH DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_TRIPRESHARERULE') 
 CREATE TABLE T_ER_TRIPRESHARERULE (
FID BIGINT DEFAULT 0 NOT NULL,
FDETAILID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FENTRYCOSTCOMPANYID BIGINT DEFAULT 0 NOT NULL,
FENTRYCOSTDEPTID BIGINT DEFAULT 0 NOT NULL,
FPROJECTID BIGINT DEFAULT 0 NOT NULL,
FSHARERATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FENTRYMONTH DATETIME,
FSHAREREMARK NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_TRIPRESHAREDETAIL') 
 CREATE TABLE T_ER_TRIPRESHAREDETAIL (
FID BIGINT DEFAULT 0 NOT NULL,
FDETAILID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FEXPENSEITEMID BIGINT DEFAULT 0 NOT NULL,
FHAPPENDATE DATETIME,
FEXCHANGERATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FORIAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCURRREIMBURSEAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREIMBURSEAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAXRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREMARK NVARCHAR(255) DEFAULT ' ' NOT NULL,
FISSPECIALINVOICE CHAR(1) DEFAULT '1' NOT NULL,
FENTRYCURRENCY BIGINT DEFAULT 0 NOT NULL,
FEXPEAPPROVEAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FEXPEAPPROVECURRAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAXCLASSCODEID BIGINT DEFAULT 0 NOT NULL,
FINVOICENO NVARCHAR(129) DEFAULT ' ' NOT NULL,
FINVOICELINK NVARCHAR(129) DEFAULT ' ' NOT NULL,
FOFFSET CHAR(1) DEFAULT '1' NOT NULL,
FENTRYCOSTCOMPANYID BIGINT DEFAULT 0 NOT NULL,
FENTRYCOSTDEPTID BIGINT DEFAULT 0 NOT NULL,
FSERIALNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FAIRPORTCONSTRUCTIONFEE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FGOODSNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FDEDUCTIBLETAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FITEMFROM VARCHAR(2) DEFAULT '0' NOT NULL,
FINVOICETYPEITEM VARCHAR(2) DEFAULT '0' NOT NULL,
FPROJECTID BIGINT DEFAULT 0 NOT NULL,
FSHARERATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLKWAITENTRYID VARCHAR(200) DEFAULT ' ' NOT NULL,
FPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FENTRYMONTH DATETIME
);

 EXEC P_ALTERPK 'PK_T_ER_DAILYRESHAREDETAIL', 'T_ER_DAILYRESHAREDETAIL', 'FDETAILID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_DAILYRESHAREDETAIL_FSEQ') CREATE INDEX IDX_ER_DAILYRESHAREDETAIL_FSEQ ON T_ER_DAILYRESHAREDETAIL ( FID ,FSEQ );


 EXEC P_ALTERPK 'PK_T_ER_DAILYRESHARERULE', 'T_ER_DAILYRESHARERULE', 'FDETAILID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_DAILYRESHARERULE_FSEQ') CREATE INDEX IDX_ER_DAILYRESHARERULE_FSEQ ON T_ER_DAILYRESHARERULE ( FID ,FSEQ );


 EXEC P_ALTERPK 'PK_T_ER_PUBLICRESHAREDETAIL', 'T_ER_PUBLICRESHAREDETAIL', 'FDETAILID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_PUBLICSHAREDETAIL_FSEQ') CREATE INDEX IDX_ER_PUBLICSHAREDETAIL_FSEQ ON T_ER_PUBLICRESHAREDETAIL ( FID ,FSEQ );


 EXEC P_ALTERPK 'PK_T_ER_PUBLICRESHARERULE', 'T_ER_PUBLICRESHARERULE', 'FDETAILID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_PUBLICRESHARERULE_FSEQ') CREATE INDEX IDX_ER_PUBLICRESHARERULE_FSEQ ON T_ER_PUBLICRESHARERULE ( FID ,FSEQ );


 EXEC P_ALTERPK 'PK_T_ER_TRIPRESHAREDETAIL', 'T_ER_TRIPRESHAREDETAIL', 'FDETAILID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_TRIPRESHAREDETAIL_FSEQ') CREATE INDEX IDX_ER_TRIPRESHAREDETAIL_FSEQ ON T_ER_TRIPRESHAREDETAIL ( FID ,FSEQ );


 EXEC P_ALTERPK 'PK_T_ER_TRIPRESHARERULE', 'T_ER_TRIPRESHARERULE', 'FDETAILID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_TRIPRESHARERULE_FSEQ') CREATE INDEX IDX_ER_TRIPRESHARERULE_FSEQ ON T_ER_TRIPRESHARERULE ( FID ,FSEQ );

