update vs4tteasuryTransMB set tttmmode=0 where tttmmode is null
update vs4tteasuryTransMB set tttmmode=1 where tttmmode =2 and tttmcutmode=0
update VS4VTeasuryTrans set tttmmode=1,tttmcutmode=0 where tttmmode =2 and ttetsavefrom='DE'
update VS4VTeasuryTrans set tttmmode=2,tttmcutmode=1 where  tttmmode =2 and (ttetsavefrom='PV' or ttetsavefrom ='PIV')

update vs4treceivevoucher set trvhttetno=(select top 1 ttetno from vs4tteasurytrans where ttetsavefrom='RV' AND ttetcancelstatus<>1 and ttetrefno=trvhno)

update vs4tteasuryTransMB set tttmchequeno=(select top 1 TCHRNo from VS4VChequeRec where TTTMTTeTNo=TRVHTTeTNo and TTTMLn=TRVRLn and trvhcancelstatus<>1)
where TTTMMode=1

update vs4tteasuryTransMB set tttmmode=1,tttmchequeno=(select top 1 TCHRNo from VS4VCashDeposit where TTTMTTeTNo=TDPSTTeTNo and TTTMLn=TDPMLn and tdpscancelstatus<>1)
where TTTMChequeStatus=1

update vs4tteasuryTransMB set tttmchequeStatus=(select top 1 tchrchqstatus from vs4tchequerec where tchrno=tttmchequeno) where tttmchequeno is not null and tttmmode=1

update vs4tteasuryTransMB set  tttmcutmode=0 where  tttmmode=1
update vs4tteasuryTransMB set  tttmmoneyincheque=tttmmoneyoutcheque where  tttmmode=1
update vs4tteasuryTransMB set  tttmmoneyoutcheque=0 where  tttmmode=1 and tttmmoneyincheque>0 and tttmmoneyincheque is not null

update VS4TTeasuryTransB set TTTMMoneyAmount=TTTMMoneyRate where TTTMMoneyAmount=0 or TTTMMoneyAmount is null
update vs4tteasuryTransMB set  TTTMMoneyAmount=abs(TTTMMoneyAmount)*-1,TTTMMoneyRate=abs(TTTMMoneyRate)*-1 where  tttmcutmode=1
update vs4tteasuryTransMB set  TTTMMoneyAmount=abs(TTTMMoneyAmount)*1,TTTMMoneyRate=abs(TTTMMoneyRate)*1 where  tttmcutmode=0

update VS4VTeasuryTrans set tttmmode=1,tttmcutmode=0 where tttmmode =2 and ttetsavefrom='DE'