/**对公报销单换发票增加发票序列号、是否解绑等字段**/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_PUBREIMINVOICEITEM' AND KSQL_COL_NAME IN ('FINVOICEITEMSERIALNO'))
ALTER TABLE T_ER_PUBREIMINVOICEITEM ADD (FINVOICEITEMSERIALNO NVARCHAR(255) DEFAULT ' ' NOT NULL);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_PUBREIMINVOICEITEM' AND KSQL_COL_NAME IN ('FINVOICEITEMISUNBIND'))
ALTER TABLE T_ER_PUBREIMINVOICEITEM ADD (FINVOICEITEMISUNBIND CHAR(1) DEFAULT '0' NOT NULL);

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

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_PUBINVOICEANDEXPENSE' AND KSQL_COL_NAME IN ('FINVOICEEXPISUNBIND'))
ALTER TABLE T_ER_PUBINVOICEANDEXPENSE ADD (FINVOICEEXPISUNBIND CHAR(1) DEFAULT '0' NOT NULL);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_PUBREIMEXPDET' AND KSQL_COL_NAME ='FEXPISCHANGEINVOICE')
ALTER TABLE T_ER_PUBREIMEXPDET ADD (FEXPISCHANGEINVOICE CHAR(1) DEFAULT '0' NOT NULL);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_PUBREIMBILL_A' AND KSQL_COL_NAME ='FISCHANGEINVOICE')
ALTER TABLE T_ER_PUBREIMBILL_A ADD (FISCHANGEINVOICE CHAR(1) DEFAULT '0' NOT NULL);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_PUBREIMBILL_A' AND KSQL_COL_NAME ='FCHANGEINVOICEDES')
ALTER TABLE T_ER_PUBREIMBILL_A ADD (FCHANGEINVOICEDES NVARCHAR(1000) DEFAULT ' ' NOT NULL);


/**费用报销单及差旅报销单换发票增加发票序列号、是否解绑等字段**/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_INVOICEITEM' AND KSQL_COL_NAME IN ('FINVOICEITEMSERIALNO'))
ALTER TABLE T_ER_INVOICEITEM ADD (FINVOICEITEMSERIALNO NVARCHAR(255) DEFAULT ' ' NOT NULL);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_INVOICEITEM' AND KSQL_COL_NAME IN ('FINVOICEITEMISUNBIND'))
ALTER TABLE T_ER_INVOICEITEM ADD (FINVOICEITEMISUNBIND CHAR(1) DEFAULT '0' NOT NULL);

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

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_INVOICEANDEXPENSE' AND KSQL_COL_NAME IN ('FINVOICEEXPISUNBIND'))
ALTER TABLE T_ER_INVOICEANDEXPENSE ADD (FINVOICEEXPISUNBIND CHAR(1) DEFAULT '0' NOT NULL);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_EXPENSEDETAIL' AND KSQL_COL_NAME ='FEXPISCHANGEINVOICE')
ALTER TABLE T_ER_EXPENSEDETAIL ADD (FEXPISCHANGEINVOICE CHAR(1) DEFAULT '0' NOT NULL);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_DAILYREIMBURSEBILL_A' AND KSQL_COL_NAME ='FISCHANGEINVOICE')
ALTER TABLE T_ER_DAILYREIMBURSEBILL_A ADD (FISCHANGEINVOICE CHAR(1) DEFAULT '0' NOT NULL);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_DAILYREIMBURSEBILL_A' AND KSQL_COL_NAME ='FCHANGEINVOICEDES')
ALTER TABLE T_ER_DAILYREIMBURSEBILL_A ADD (FCHANGEINVOICEDES NVARCHAR(1000) DEFAULT ' ' NOT NULL);

/**商旅付款申请单换发票增加发票序列号 增加是否解绑字段**/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_INVOICEITEMCP' AND KSQL_COL_NAME IN ('FINVOICEITEMSERIALNO'))
ALTER TABLE T_ER_INVOICEITEMCP ADD (FINVOICEITEMSERIALNO NVARCHAR(255) DEFAULT ' ' NOT NULL);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_INVOICEITEMCP' AND KSQL_COL_NAME IN ('FINVOICEITEMISUNBIND'))
ALTER TABLE T_ER_INVOICEITEMCP ADD (FINVOICEITEMISUNBIND CHAR(1) DEFAULT '0' NOT NULL);

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

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_TRIPINVOICEANDITEM' AND KSQL_COL_NAME IN ('FINVOICEEXPISUNBIND'))
ALTER TABLE T_ER_TRIPINVOICEANDITEM ADD (FINVOICEEXPISUNBIND CHAR(1) DEFAULT '0' NOT NULL);

