科目餘額表中部分客戶顯示兩行數據記錄

問題描述


科目餘額表過濾本期,科目選擇'應收賬款',顯示覈算項目,報表顯示
有部分客戶顯示兩行數據,正確數據爲這兩行數據之和
 

問題原因


這種情況一般是由於覈算項目橫表中被憑證表、餘額表引用的核算項目組
合有重複記錄導致
 

解決方法

備份賬套後請參考如下方法處理:
Use AIS2009###### --(指問題賬套的賬套號)
(1)創建臨時表t_itemdetail_error,把重複覈算項目記錄插入該表
select a.*, a.fdetailid Fdetailid_temp
into t_itemdetail_error
from t_itemdetail a join t_itemdetail b on a.f1=b.f1 and
a.fdetailcount=b.fdetailcount
where a.fdetailcount=1 and a.fdetailid<>b.fdetailid
and a.f1>0
order by a.f1
(2)在臨時表t_itemdetail_error中修改錯誤的fdetailid值(以最小的fdetailid值爲基準):
update b set b.fdetailid_temp=a.fdetailid
from t_itemdetail_error a join t_itemdetail_error b on a.f1=b.f1 and
a.fdetailcount=b.fdetailcount
where a.fdetailcount=1 and a.fdetailidand a.f1>0
(3)創建餘額表臨時表t_balance_temp :
select * into t_balance_temp from t_balance
order by fyear,fperiod,faccountid,fdetailid,fcurrencyid
(4)更新餘額表臨時表的錯誤detailid值:
update a set a.fdetailid=b.fdetailid_temp
from t_balance_temp a join t_itemdetail_error b on a.fdetailid=b.fdetailid
(5)創建臨時表temp002:
select top 0 * into temp002 from t_balance
(6)合併t_balance_temp 相同覈算項目項的金額,把結果插入temp002:
insert into temp002
(fyear,fperiod,faccountid,fdetailid,fcurrencyid,FFrameWorkID,
FBeginBalanceFor,FDebitFor,FCreditFor,FYtdDebitFor,FYtdCreditFor,FEndBalanceFor,
FBeginBalance,FDebit,FCredit,FYtdDebit,FYtdCredit,FEndBalance,FIsAdjustPeriod)
select fyear,fperiod,faccountid,fdetailid,fcurrencyid,FFrameWorkID,
sum(FBeginBalanceFor)FBeginBalanceFor,sum(FDebitFor)FDebitFor,sum(FCreditFor)FCreditFor,
sum(FYtdDebitFor)FYtdDebitFor,sum(FYtdCreditFor)FYtdCreditFor,sum(FEndBalanceFor)FEndBalanceFor,
sum(FBeginBalance)FBeginBalance,sum(FDebit)FDebit,sum(FCredit)FCredit,sum(FYtdDebit)FYtdDebit,
sum(FYtdCredit)FYtdCredit,sum(FEndBalance)FEndBalance,sum(FIsAdjustPeriod)FIsAdjustPeriod
from t_balance_temp
group by fyear,fperiod,faccountid,fdetailid,fcurrencyid,FFrameWorkID
(7)清空t_balance數據 :
delete from t_balance
(8)把temp002的值寫回t_balance:
insert into t_balance
(fyear,fperiod,faccountid,fdetailid,fcurrencyid,FBeginBalanceFor,FDebitFor,FCreditFor,FYtdDebitFor,
FYtdCreditFor,FEndBalanceFor,FBeginBalance,FDebit,FCredit,FYtdDebit,FYtdCredit,FEndBalance,FFrameWorkID,FIsAdjustPeriod)
select
fyear,fperiod,faccountid,fdetailid,fcurrencyid,FBeginBalanceFor,FDebitFor,FCreditFor,FYtdDebitFor,
FYtdCreditFor,FEndBalanceFor,FBeginBalance,FDebit,FCredit,FYtdDebit,FYtdCredit,FEndBalance,FFrameWorkID,FIsAdjustPeriod
from temp002
(9)刪除t_itemdetail中的重複值:
delete from t_itemdetail
where fdetailid in (select fdetailid from t_itemdetail_error)
and fdetailid not in (select fdetailid_temp from t_itemdetail_error)
(10)更新縱表:
exec sp_cleanitemdetailv
(11)更正憑證分錄數據:
update a set a.fdetailid=b.fdetailid_temp
from t_voucherentry a join t_itemdetail_error b on a.fdetailid=b.fdetailid
where a.fdetailid<>b.fdetailid_temp
 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章