问题是:
1、在结转损益时产生的凭证中,有部分科目本来挂核算项目,但是凭证是没有核算项目,所以过帐时提示科目缺少核算项目。
select * from t_itemdetail where fdetailid in (select fdetailid from t_itemdetailv where fitemid=-1)
and fdetailcount=1
select * from t_itemdetail where fdetailid in (select fdetailid from t_itemdetailv where fitemid=-1)
and fdetailcount=2
select fdetailid,* from t_account where fdetailid in (select fdetailid from t_itemdetail where
fdetailid in (select fdetailid from t_itemdetailv where fitemid=-1))
exec sp_cleanitemdetailv
update a set a.fdetailcount=b.Fcount
from t_itemdetail a join
(select Fdetailid,count(Fitemid) Fcount
from t_itemdetailv
where fitemid<>0 group by Fdetailid) b
on a.fdetailid=b.fdetailid
exec sp_cleanitemdetailv
--F2=-1 and f3=-1
select fdetailid from t_itemdetail where fdetailcount=2 and f2=-1 and f3=-1
update t_account
set Fdetailid =(select min(fdetailid) from t_itemdetail
where fdetailid in (select Fdetailid from t_itemdetailv
where fitemid=-1)
and Fdetailcount=2 and F2=-1 and f3=-1)
where Fdetailid in (select (fdetailid) from t_itemdetail
where fdetailid in (select Fdetailid from t_itemdetailv
where fitemid=-1)
and Fdetailcount=2 and F2=-1 and f3=-1)
delete from t_itemdetail
where Fdetailid in(select (fdetailid) from t_itemdetail
where fdetailid in (select Fdetailid from t_itemdetailv
where fitemid=-1)
and Fdetailcount=2 and F2=-1 and f3=-1)
and Fdetailid <>(select min(fdetailid) from t_itemdetail
where fdetailid in (select Fdetailid from t_itemdetailv
where fitemid=-1)
and Fdetailcount=2 and F2=-1 and f3=-1)
---f1=-1
update t_account
set Fdetailid =(select min(fdetailid) from t_itemdetail
where fdetailid in (select Fdetailid from t_itemdetailv
where fitemid=-1)
and Fdetailcount=1 and F1=-1 )
where Fdetailid in (select (fdetailid) from t_itemdetail
where fdetailid in (select Fdetailid from t_itemdetailv
where fitemid=-1)
and Fdetailcount=1 and F1=-1 )
delete from t_itemdetail
where Fdetailid in(select (fdetailid) from t_itemdetail
where fdetailid in (select Fdetailid from t_itemdetailv
where fitemid=-1)
and Fdetailcount=1 and F1=-1 )
and Fdetailid <>(select min(fdetailid) from t_itemdetail
where fdetailid in (select Fdetailid from t_itemdetailv
where fitemid=-1)
and Fdetailcount=1 and F1=-1 )
--f2=-1
update t_account
set Fdetailid =(select min(fdetailid) from t_itemdetail
where fdetailid in (select Fdetailid from t_itemdetailv
where fitemid=-1)
and Fdetailcount=1 and F2=-1 )
where Fdetailid in (select (fdetailid) from t_itemdetail
where fdetailid in (select Fdetailid from t_itemdetailv
where fitemid=-1)
and Fdetailcount=1 and F2=-1 )
delete from t_itemdetail
where Fdetailid in(select (fdetailid) from t_itemdetail
where fdetailid in (select Fdetailid from t_itemdetailv
where fitemid=-1)
and Fdetailcount=1 and F2=-1 )
and Fdetailid <>(select min(fdetailid) from t_itemdetail
where fdetailid in (select Fdetailid from t_itemdetailv
where fitemid=-1)
and Fdetailcount=1 and F2=-1 )
--f3=-1
update t_account
set Fdetailid =(select min(fdetailid) from t_itemdetail
where fdetailid in (select Fdetailid from t_itemdetailv
where fitemid=-1)
and Fdetailcount=1 and F3=-1 )
where Fdetailid in (select (fdetailid) from t_itemdetail
where fdetailid in (select Fdetailid from t_itemdetailv
where fitemid=-1)
and Fdetailcount=1 and F3=-1 )
delete from t_itemdetail
where Fdetailid in(select (fdetailid) from t_itemdetail
where fdetailid in (select Fdetailid from t_itemdetailv
where fitemid=-1)
and Fdetailcount=1 and F3=-1 )
and Fdetailid <>(select min(fdetailid) from t_itemdetail
where fdetailid in (select Fdetailid from t_itemdetailv
where fitemid=-1)
and Fdetailcount=1 and F3=-1 )
--f4=-1
update t_account
set Fdetailid =(select min(fdetailid) from t_itemdetail
where fdetailid in (select Fdetailid from t_itemdetailv
where fitemid=-1)
and Fdetailcount=1 and F4=-1 )
where Fdetailid in (select (fdetailid) from t_itemdetail
where fdetailid in (select Fdetailid from t_itemdetailv
where fitemid=-1)
and Fdetailcount=1 and F4=-1 )
delete from t_itemdetail
where Fdetailid in(select (fdetailid) from t_itemdetail
where fdetailid in (select Fdetailid from t_itemdetailv
where fitemid=-1)
and Fdetailcount=1 and F4=-1 )
and Fdetailid <>(select min(fdetailid) from t_itemdetail
where fdetailid in (select Fdetailid from t_itemdetailv
where fitemid=-1)
and Fdetailcount=1 and F4=-1 )
--f8=-1
update t_account
set Fdetailid =(select min(fdetailid) from t_itemdetail
where fdetailid in (select Fdetailid from t_itemdetailv
where fitemid=-1)
and Fdetailcount=1 and F8=-1 )
where Fdetailid in (select (fdetailid) from t_itemdetail
where fdetailid in (select Fdetailid from t_itemdetailv
where fitemid=-1)
and Fdetailcount=1 and F8=-1 )
delete from t_itemdetail
where Fdetailid in(select (fdetailid) from t_itemdetail
where fdetailid in (select Fdetailid from t_itemdetailv
where fitemid=-1)
and Fdetailcount=1 and F8=-1 )
and Fdetailid <>(select min(fdetailid) from t_itemdetail
where fdetailid in (select Fdetailid from t_itemdetailv
where fitemid=-1)
and Fdetailcount=1 and F8=-1 )
exec sp_cleanitemdetailv
2、结转损益并过账后,部分损益类二级科目有余额,没有结转平衡。
--查找余额表中有没有非法的fdetailid
select * from t_balance
where fdetailid not in (select fdetailid from t_itemdetail)
--删除非法的fdetailid
delete from t_balance
where fdetailid not in (select fdetailid from t_itemdetail)
查找数量余额表中有没有非法的fdetailid
select * from t_quantitybalance
where fdetailid not in (select fdetailid from t_itemdetail)
查找损益类图目实际发生额表中有没有非法的fdetailid
select * from t_profitandloss
where fdetailid not in (select fdetailid from t_itemdetail)
删除损益类图目实际发生额表中有没有非法的fdetailid
delete from t_profitandloss
where fdetailid not in (select fdetailid from t_itemdetail)