/** 更新付款单，付款金额含手续费 **/
update T_CAS_PaymentBill_e set ftotalpayamt=fdpamt where fsinglestream='1';
/** 初始化付款单已匹配信息 **/
update T_CAS_PaymentBill_e set frelateotherflow='0',fmatchflag='0',fmatchamountpay=0,funmatchamountpay=ftotalpayamt,fmatchamountrec=0,funmatchamountrec=fdpamt where fmatchflag=null or fmatchflag='0';
/** 初始化收款单已匹配信息 **/
update t_cas_receivingbill_e set frelateotherflow='0',fmatchflag='0',fmatchamountrec=0,funmatchamountrec=ISNULL((select sum(tcr.factrecamt) from t_cas_receivingbill tcr where tcr.fid = t_cas_receivingbill_e.fid),0),fmatchamountpay=0,funmatchamountpay=ISNULL((select sum(tcr.factrecamt) from t_cas_receivingbill tcr where tcr.fid = t_cas_receivingbill_e.fid),0) where fmatchflag=null or fmatchflag='0';
/** 初始化代发单头已匹配信息 **/
update t_cas_agentpaybill_e set fmatchflag='0',fmatchamount=0,funmatchamount=ISNULL((select sum(tca.factpayamount) from t_cas_agentpaybill tca where tca.fid = t_cas_agentpaybill_e.fid and tca.fbillstatus='D' and t_cas_agentpaybill_e.fisdiffcur='0'),ISNULL(fdpamt+ffee,0)) where fmatchflag=null or fmatchflag='0';
/** 初始化代发单分录已匹配信息 **/
update t_cas_agentpaybillentry_e set fentrymatchflag='0',fentrymatchamount=0,fentryunmatchamount=ISNULL((select sum(tca.fplainamount) from t_cas_agentpaybillentry tca where tca.fid = t_cas_agentpaybillentry_e.fid and tca.fentryid=t_cas_agentpaybillentry_e.fentryid),0) where fentrymatchflag=null or fentrymatchflag='0';
/** 初始化外币兑换单 **/
update t_cas_exchangebill set fbuymatchflag='0',fbuymatchamount=0,fbuyunmatchamount=fbuyamount where fbuymatchflag=null or fbuymatchflag='0';
update t_cas_exchangebill set fsellmatchflag='0',fsellmatchamount=0,fsellunmatchamount=fsellamount where fsellmatchflag=null or fsellmatchflag='0';
update t_cas_exchangebill set ffeematchflag='0',ffeematchamount=0,ffeeunmatchamount=fcommissionamount where ffeematchflag=null or ffeematchflag='0';
update t_cas_exchangebill set fmatchflag='0' where fmatchflag=null;