应收单表头数据校验

use AISXXXXXXXXXXX
go
if exists(select 1 where Convert(varchar(10),getdate(),120)=DATEADD(mm, DATEDIFF(mm,0,getdate()), 2) )
begin
update b set b.fallamount=V.fallamountE,b.ftaxamountfor=V.ftaxamountforE,b.ftaxamount=v.ftaxamountE, b.fnotaxamountfor=fnotaxamountforE,b.fnotaxamount=V.fnotaxamountE
from t_AR_receivable a inner join t_AR_receivableFIN b on a.fid=b.fid
inner join (select fid ,sum(fnotaxamountfor) as fnotaxamountforE,sum(fnotaxamount) as fnotaxamountE,sum(ftaxamountfor) as ftaxamountforE,sum(ftaxamount) as ftaxamountE ,sum(FALLAMOUNTFOR) AS FALLAMOUNTFORE,sum(fallamount) AS fallamountE from t_AR_receivableentry group by fid ) v on a.fid=v.fid
where (b.ftaxamount<>v.ftaxamountE or b.fnotaxamount<>v.fnotaxamountE or b.fnotaxamountfor<>v.fnotaxamountforE)

update a set a.fallamountFor=v.fallamountforE
from t_AR_receivable a inner join t_AR_receivableFIN b on a.fid=b.fid
inner join (select fid ,sum(fnotaxamountfor) as fnotaxamountforE,sum(fnotaxamount) as fnotaxamountE,sum(ftaxamountfor) as ftaxamountforE,sum(ftaxamount) as ftaxamountE ,sum(FALLAMOUNTFOR) AS FALLAMOUNTFORE,sum(fallamount) AS fallamountE from t_AR_receivableentry group by fid ) v on a.fid=v.fid
where (a.fallamountFor<>v.fallamountforE)
end
go

 

posted @ 2020-12-03 13:26  allen1991  阅读(111)  评论(0编辑  收藏  举报