Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

select o.id,o.billnumberid,o.OperateType,e.usercode 操作员编号,e.fullname 操作员名称,o.operatetime 操作时间,o.IP,o.billcode,o.billdate,case when ifcheck ='f' then '草稿' when ifcheck='t' then '过账' end 单据状态 ,b.usercode 往来单位编号,b.fullname 往来单位名称,o.ntotalmoney 单据金额,bn.billname from BillOperateLog o left join employee e on e.typeid=o.etypeid left join btype b on b.typeid=o.btypeid left join billname bn on bn.billtype=o.billtype 
where o.billnumberid in(
select billnumberid from billindex b where ( b.ifcheck='f' or b.draft = 1)
and ( exists (select 1 from inoutstocktable i where i.billnumberid=b.billnumberid and i.billtype=b.billtype)
or exists(select 1 from listtable l where l.billnumberid=b.billnumberid and l.billtype=b.billtype)))
order by o.billnumberid,o.id


处理方法:备份数据后,执行下面脚本:DECLARE @BillCode TABLE 
( BillCode VARCHAR (300) )
UPDATE bi SET bi.draft = 0 , bi.ifcheck = 't' 
OUTPUT INSERTED.BillCode INTO @BillCode
FROM BillIndex bi 
WHERE 
(
( 
EXISTS (SELECT 1 FROM Listtable l WHERE l.BillNumberId = bi.BillNumberId ) 
AND EXISTS (SELECT 1 FROM InOutstocktable io1 WHERE bi.BillNumberId = io1.BillNumberId ) 
)
OR 
( ( 
EXISTS (SELECT 1 FROM Listtable l WHERE l.BillNumberId = bi.BillNumberId ) 
OR EXISTS (SELECT 1 FROM InOutstocktable io1 WHERE bi.BillNumberId = io1.BillNumberId )
) 
) 
)
AND ( bi.ifcheck = 'f' OR bi.draft = 1 ) 
AND bi.IsIni = 0 AND bi.ifYearBill = 0 
SELECT * FROM @BillCode

https://share.weiyun.com/KcZBknmh ---14、过账异常单据处理.sql

注意:执行完以上脚本后,该单据在经营历程了,请客户核对一下库存和往来即可。

...