--发票分录增加字段，主要涉及费用报销单、对公报报销单、差旅报销单、商旅付款申请单

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_PUBREIMINVOICEINFO' AND KSQL_COL_NAME ='FSTARTDATE')
ALTER TABLE T_ER_PUBREIMINVOICEINFO ADD (FSTARTDATE DATETIME);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_PUBREIMINVOICEINFO' AND KSQL_COL_NAME ='fenddate')
ALTER TABLE T_ER_PUBREIMINVOICEINFO ADD (fenddate DATETIME);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_PUBREIMINVOICEINFO' AND KSQL_COL_NAME ='fbuyeraddressphone')
ALTER TABLE T_ER_PUBREIMINVOICEINFO ADD (fbuyeraddressphone NVARCHAR(255)     DEFAULT ' ' NOT NULL);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_PUBREIMINVOICEINFO' AND KSQL_COL_NAME ='fcity')
ALTER TABLE T_ER_PUBREIMINVOICEINFO ADD (fcity NVARCHAR(50)     DEFAULT ' ' NOT NULL);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_PUBREIMINVOICEINFO' AND KSQL_COL_NAME ='ffuelsurcharge')
ALTER TABLE T_ER_PUBREIMINVOICEINFO ADD (ffuelsurcharge DECIMAL(23,10) DEFAULT 0 NOT NULL);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 't_er_pubreiminvoiceinfo' AND KSQL_COL_NAME ='ffairtime')
ALTER TABLE t_er_pubreiminvoiceinfo ADD (ffairtime VARCHAR(20)     DEFAULT ' ' NOT NULL);

---


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 't_er_invoiceinfo' AND KSQL_COL_NAME ='FSTARTDATE')
ALTER TABLE t_er_invoiceinfo ADD (FSTARTDATE DATETIME);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 't_er_invoiceinfo' AND KSQL_COL_NAME ='fenddate')
ALTER TABLE t_er_invoiceinfo ADD (fenddate DATETIME);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 't_er_invoiceinfo' AND KSQL_COL_NAME ='fbuyeraddressphone')
ALTER TABLE t_er_invoiceinfo ADD (fbuyeraddressphone NVARCHAR(255)     DEFAULT ' ' NOT NULL);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 't_er_invoiceinfo' AND KSQL_COL_NAME ='fcity')
ALTER TABLE t_er_invoiceinfo ADD (fcity NVARCHAR(50)     DEFAULT ' ' NOT NULL);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 't_er_invoiceinfo' AND KSQL_COL_NAME ='ffuelsurcharge')
ALTER TABLE t_er_invoiceinfo ADD (ffuelsurcharge DECIMAL(23,10) DEFAULT 0 NOT NULL);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 't_er_invoiceinfo' AND KSQL_COL_NAME ='ffairtime')
ALTER TABLE t_er_invoiceinfo ADD (ffairtime VARCHAR(20)     DEFAULT ' ' NOT NULL);


---


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 't_er_invoiceinfocp' AND KSQL_COL_NAME ='FSTARTDATE')
ALTER TABLE t_er_invoiceinfocp ADD (FSTARTDATE DATETIME);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 't_er_invoiceinfocp' AND KSQL_COL_NAME ='fenddate')
ALTER TABLE t_er_invoiceinfocp ADD (fenddate DATETIME);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 't_er_invoiceinfocp' AND KSQL_COL_NAME ='fbuyeraddressphone')
ALTER TABLE t_er_invoiceinfocp ADD (fbuyeraddressphone NVARCHAR(255)     DEFAULT ' ' NOT NULL);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 't_er_invoiceinfocp' AND KSQL_COL_NAME ='fcity')
ALTER TABLE t_er_invoiceinfocp ADD (fcity NVARCHAR(50)     DEFAULT ' ' NOT NULL);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 't_er_invoiceinfocp' AND KSQL_COL_NAME ='ffuelsurcharge')
ALTER TABLE t_er_invoiceinfocp ADD (ffuelsurcharge DECIMAL(23,10) DEFAULT 0 NOT NULL);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 't_er_invoiceinfocp' AND KSQL_COL_NAME ='ffairtime')
ALTER TABLE t_er_invoiceinfocp ADD (ffairtime VARCHAR(20)     DEFAULT ' ' NOT NULL);



