-- 预扣税新增字段

-- 对公报销单 费用明细
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_PUBREIMEXPDET_A' AND KSQL_COL_NAME ='FCURWITHHOLDINGTAXAMOUNT')
ALTER TABLE T_ER_PUBREIMEXPDET_A ADD (FCURWITHHOLDINGTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_PUBREIMEXPDET_A' AND KSQL_COL_NAME ='FWITHHOLDINGTAXRATE')
ALTER TABLE T_ER_PUBREIMEXPDET_A ADD (FWITHHOLDINGTAXRATE DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_PUBREIMEXPDET_A' AND KSQL_COL_NAME ='FWITHHOLDINGTAXAMOUNT')
ALTER TABLE T_ER_PUBREIMEXPDET_A ADD (FWITHHOLDINGTAXAMOUNT 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 ='FCURWITHHOLDINGTAXAMOUNT')
ALTER TABLE T_ER_PUBREIMINVOICEINFO ADD (FCURWITHHOLDINGTAXAMOUNT 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 ='FWITHHOLDINGTAXRATE')
ALTER TABLE T_ER_PUBREIMINVOICEINFO ADD (FWITHHOLDINGTAXRATE 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 ='FWITHHOLDINGTAXAMOUNT')
ALTER TABLE T_ER_PUBREIMINVOICEINFO ADD (FWITHHOLDINGTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );

-- 立项单 立项明细
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_APPLYPROJECTENTRY' AND KSQL_COL_NAME ='FCURWITHHOLDINGTAXAMOUNT')
ALTER TABLE T_ER_APPLYPROJECTENTRY ADD (FCURWITHHOLDINGTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_APPLYPROJECTENTRY' AND KSQL_COL_NAME ='FWITHHOLDINGTAXRATE')
ALTER TABLE T_ER_APPLYPROJECTENTRY ADD (FWITHHOLDINGTAXRATE DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_APPLYPROJECTENTRY' AND KSQL_COL_NAME ='FWITHHOLDINGTAXAMOUNT')
ALTER TABLE T_ER_APPLYPROJECTENTRY ADD (FWITHHOLDINGTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );

-- 暂估单 暂估明细
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_COSTESTIMATEENTRY' AND KSQL_COL_NAME ='FCURWITHHOLDINGTAXAMOUNT')
ALTER TABLE T_ER_COSTESTIMATEENTRY ADD (FCURWITHHOLDINGTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_COSTESTIMATEENTRY' AND KSQL_COL_NAME ='FWITHHOLDINGTAXRATE')
ALTER TABLE T_ER_COSTESTIMATEENTRY ADD (FWITHHOLDINGTAXRATE DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_COSTESTIMATEENTRY' AND KSQL_COL_NAME ='FWITHHOLDINGTAXAMOUNT')
ALTER TABLE T_ER_COSTESTIMATEENTRY ADD (FWITHHOLDINGTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );

-- 合同台账单 付款计划
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_CONTRACTENTRY' AND KSQL_COL_NAME ='FCURWITHHOLDINGTAXAMOUNT')
ALTER TABLE T_ER_CONTRACTENTRY ADD (FCURWITHHOLDINGTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_CONTRACTENTRY' AND KSQL_COL_NAME ='FWITHHOLDINGTAXRATE')
ALTER TABLE T_ER_CONTRACTENTRY ADD (FWITHHOLDINGTAXRATE DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_CONTRACTENTRY' AND KSQL_COL_NAME ='FWITHHOLDINGTAXAMOUNT')
ALTER TABLE T_ER_CONTRACTENTRY ADD (FWITHHOLDINGTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );

-- 费用预提单 费用明细
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_WITHHOLDINGENTRY' AND KSQL_COL_NAME ='FCURWITHHOLDINGTAXAMOUNT')
ALTER TABLE T_ER_WITHHOLDINGENTRY ADD (FCURWITHHOLDINGTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_WITHHOLDINGENTRY' AND KSQL_COL_NAME ='FWITHHOLDINGTAXRATE')
ALTER TABLE T_ER_WITHHOLDINGENTRY ADD (FWITHHOLDINGTAXRATE DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_WITHHOLDINGENTRY' AND KSQL_COL_NAME ='FWITHHOLDINGTAXAMOUNT')
ALTER TABLE T_ER_WITHHOLDINGENTRY ADD (FWITHHOLDINGTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );

-- 挂账付款申请单 立项/合同信息
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_APPLYPAYBILLENTRY' AND KSQL_COL_NAME ='FCURWITHHOLDINGTAXAMOUNT')
ALTER TABLE T_ER_APPLYPAYBILLENTRY ADD (FCURWITHHOLDINGTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_APPLYPAYBILLENTRY' AND KSQL_COL_NAME ='FWITHHOLDINGTAXRATE')
ALTER TABLE T_ER_APPLYPAYBILLENTRY ADD (FWITHHOLDINGTAXRATE DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_APPLYPAYBILLENTRY' AND KSQL_COL_NAME ='FWITHHOLDINGTAXAMOUNT')
ALTER TABLE T_ER_APPLYPAYBILLENTRY ADD (FWITHHOLDINGTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );

-- 预付单 预付信息
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_PREPAYBILLENTRY' AND KSQL_COL_NAME ='FCURWITHHOLDINGTAXAMOUNT')
ALTER TABLE T_ER_PREPAYBILLENTRY ADD (FCURWITHHOLDINGTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_PREPAYBILLENTRY' AND KSQL_COL_NAME ='FWITHHOLDINGTAXRATE')
ALTER TABLE T_ER_PREPAYBILLENTRY ADD (FWITHHOLDINGTAXRATE DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_PREPAYBILLENTRY' AND KSQL_COL_NAME ='FWITHHOLDINGTAXAMOUNT')
ALTER TABLE T_ER_PREPAYBILLENTRY ADD (FWITHHOLDINGTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );


-- 账单池
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_BILLINGPOOL' AND KSQL_COL_NAME ='FCURWITHHOLDINGTAXAMOUNT')
ALTER TABLE T_ER_BILLINGPOOL ADD (FCURWITHHOLDINGTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_BILLINGPOOL' AND KSQL_COL_NAME ='FWITHHOLDINGTAXRATE')
ALTER TABLE T_ER_BILLINGPOOL ADD (FWITHHOLDINGTAXRATE DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_BILLINGPOOL' AND KSQL_COL_NAME ='FWITHHOLDINGTAXAMOUNT')
ALTER TABLE T_ER_BILLINGPOOL ADD (FWITHHOLDINGTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );

-- 对公报销单冲预付分录
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_PUBREIMWRIOFFDET' AND KSQL_COL_NAME ='FCURACCWHTAXAMOUNT')
ALTER TABLE T_ER_PUBREIMWRIOFFDET ADD (FCURACCWHTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_PUBREIMWRIOFFDET' AND KSQL_COL_NAME ='FBALANCEWHTAXAMOUNT')
ALTER TABLE T_ER_PUBREIMWRIOFFDET ADD (FBALANCEWHTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_PUBREIMWRIOFFDET' AND KSQL_COL_NAME ='FACCWHTAXAMOUNT')
ALTER TABLE T_ER_PUBREIMWRIOFFDET ADD (FACCWHTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_PUBREIMWRIOFFDET' AND KSQL_COL_NAME ='FCURBALANCEWHTAXAMOUNT')
ALTER TABLE T_ER_PUBREIMWRIOFFDET ADD (FCURBALANCEWHTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );