现金流量表常见数据异常检查脚本原创
4人赞赏了该文章
644次浏览
编辑于2021年08月05日 19:20:28
整理了一下现金流量表常见数据异常的查询脚本,遇到现金流量表的数据不正确,当做完前台的排查步骤和现金流量检查后还是异常,可以使用下列脚本排查一下是否已知异常。
--检查项1:检查指定的现金流量金额原币是否正确 select c.FNUMBER 账簿编码,d.FYEAR 年度,d.FPERIOD 期间,e.FNAME 凭证字,d.FVOUCHERGROUPNO 凭证号,a.* --update a set FAMOUNTFOR = a.FAMOUNT from T_GL_CASHFLOWBAL a inner join T_GL_VOUCHERENTRY b on b.FENTRYID=a.FVCHENTRYID inner join T_BD_ACCOUNTBOOK c on c.FBOOKID=a.FACCTBOOKID inner join T_GL_VOUCHER d on d.FVOUCHERID=b.FVOUCHERID inner join T_BD_VOUCHERGROUP_L e on e.FVCHGROUPID=d.FVOUCHERGROUPID and e.FLOCALEID=2052 where a.FAMOUNTFOR<>a.FAMOUNT and a.fcurrencyid=c.fcurrencyid --检查项2:检查指定的现金流量对方分录是否还存在 SELECT DISTINCT c.FNAME 账簿名称,b.FYEAR 年,b.FPERIOD 期,d.FNAME 凭证字,b.FVOUCHERGROUPNO 凭证号 FROM dbo.T_GL_CASHFLOWBAL a LEFT JOIN dbo.T_GL_VOUCHER b ON b.FVOUCHERID=a.FVOUCHERID LEFT JOIN dbo.T_BD_ACCOUNTBOOK_L c ON c.FBOOKID=b.FACCOUNTBOOKID AND c.FLOCALEID=2052 LEFT JOIN dbo.T_BD_VOUCHERGROUP_L d ON d.FVCHGROUPID=b.FVOUCHERGROUPID AND d.FLOCALEID=2052 WHERE a.FVCHENTRYID NOT IN (SELECT FENTRYID FROM T_GL_VOUCHERENTRY) OR a.FVCHOPPOENTRYID NOT IN (SELECT FENTRYID FROM T_GL_VOUCHERENTRY) --检查项3:检查指定的现金流量项目是否属于其他的现金流量表 select distinct d.FNUMBER 账簿编码,b.FYEAR 年度,b.FPERIOD 期间,h.FNAME 凭证字,b.FVOUCHERGROUPNO 凭证号 from T_GL_CASHFLOWBAL a left join T_GL_VOUCHER b on b.FVOUCHERID=a.FVOUCHERID --left join T_GL_VOUCHERENTRY c on c.FVOUCHERID=a.FVOUCHERID left join T_BD_ACCOUNTBOOK d on d.FBOOKID=b.FACCOUNTBOOKID left join T_GL_CASHFLOW e on e.fid=a.FSUBITEMID left join T_GL_CASHFLOWITEMTABLE f on f.fid=e.FCASHFLOWITEMTABLE left join T_BD_ACCOUNTTABLE g on g.FACCTTABLEID=d.FACCTTABLEID left join T_BD_VOUCHERGROUP_L h on h.FVCHGROUPID=b.FVOUCHERGROUPID and h.FLOCALEID=2052 where f.FACCTGROUPTBLID<>g.FACCTGROUPTBLID --检查项4:检查主附表是否指定错乱(附表项目里指定了主表或主表项目里指定了附表) select distinct d.fnumber 账簿编码,b.fyear 年度,b.fperiod 期间,e.fname 凭证字,b.fvouchergroupno 凭证号 from T_GL_CASHFLOWBAL a inner join T_GL_VOUCHER b on b.FVOUCHERID=a.FVOUCHERID inner join T_GL_VOUCHERENTRY c on c.FVOUCHERID=b.FVOUCHERID inner join T_BD_ACCOUNTBOOK d on d.FBOOKID=b.FACCOUNTBOOKID inner join t_bd_vouchergroup_l e on e.fvchgroupid=b.fvouchergroupid and e.flocaleid=2052 where a.fitemid in (select t1.fid from t_gl_cashflow t1 inner join T_GL_CASHFLOWtype t2 on t1.FITEMTYPEID=t2.FITEMTYPEID where t2.FITEMGROUPID=2 ) or a.fsubitemid in (select t1.fid from t_gl_cashflow t1 inner join T_GL_CASHFLOWtype t2 on t1.FITEMTYPEID=t2.FITEMTYPEID where t2.FITEMGROUPID=1 )
赞 4
4人点赞
还没有人点赞,快来当第一个点赞的人吧!
打赏
0人打赏
还没有人打赏,快来当第一个打赏的人吧!
推荐阅读