【U8】固定资产新年度第一月份期初和期末对不上

这篇博客主要讨论了在10.0版本之后出现的新年度第一个月月末值匹配错误的问题,原因是老版本在判断折旧结转时的逻辑错误。提出了解决方案,包括恢复12月进行年结和直接在1月份补充数据的方法。文章详细介绍了如何在1月份补充数据的SQL操作步骤,强调执行前需备份数据,并警告在业务进行中执行可能会导致数据不一致。此外,还涉及了处理2014年12月和2015年1月新增资产的期末金额更新操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

– 10.0以后有很多新年度第一个月月末值对不上的问题
– 原因是老产品(尤其是10.0的 ImportAccountData12End 方法)判断fa_total是否结转判断:and convert(decimal(38,10),dblDeprTotal)<>0 ;
– 如果是12月新增资产不提折旧就会漏结转;
– 最根本的解决方案是恢复12月再进行年结
– 下面是不恢复,直接在1月份补数据的解决方案,执行前务必备份数据

– 0.使用前先看一下
–select *from fa_total where iyear = 2014 and iperiod = 12
–select *from fa_total where iyear = 2015 and iperiod = 1
–是否数据不一样
–如果是的话,可以使用下列语句补充数据
–使用时务必先备份数据,并且只能在月份未作业务的时候使用,否则会造成数据不一致

– 1.备份:

– begin tran
select *
into fa_total_201501
from fa_total where iyear = 2015 – and iperiod = 1

– 2.补漏结转
select sDeptNum, sTypeNum, 1 as iperiod, lMonthCount, lCount, dblYearValue,
dblYearDeprTotal, dblLastAccrualValue, dblLastDepr, dblLastAddValue, dblLastDecValue, dblLastWork,
dblLastWorkTotal, dblWork, dblWorkT, dblMonthValue, dblValue, dblMonthDeprTotal, dblDeprTotal, dblAddValue,
dblDecValue, dblTransInDeprTotal, dblTransOutDeprTotal, dblAccrualValue, dblDepr,2015 as iyear
into #1
FROM fa_Total where iyear = 2014 and iPeriod = 12 and sTypeNum+sDeptNum not in
(select sTypeNum+sDeptNum from fa_Total where iyear = 2015 and iPeriod=1)

UPDATE #1 SET lMonthCount = lCount,dblLastAccrualValue = dblAccrualValue,
dblLastDepr = dblDepr,dblLastAddValue=dblAddValue,dblLastDecValue=dblDecValue,dblLastWork=dblWork,
dblLastWorkTotal=dblWorkT,dblMonthValue=dblValue,dblMonthDeprTotal=dblDeprTotal

UPDATE #1 SET dblAccrualValue = 0,dblDepr = 0,dblTransInDeprTotal = 0,dblTransOutDeprTotal = 0,dblAddValue = 0,dblDecValue = 0

UPDATE #1 SET iPeriod = 1,dblYearValue = dblMonthValue,dblYearDeprTotal = dblMonthDeprTotal

insert into fa_Total(sDeptNum, sTypeNum, iperiod, lMonthCount, lCount, dblYearValue,
dblYearDeprTotal, dblLastAccrualValue, dblLastDepr, dblLastAddValue, dblLastDecValue, dblLastWork,
dblLastWorkTotal, dblWork, dblWorkT, dblMonthValue, dblValue, dblMonthDeprTotal, dblDeprTotal, dblAddValue,
dblDecValue, dblTransInDeprTotal, dblTransOutDeprTotal, dblAccrualValue, dblDepr, iyear)
select sDeptNum, sTypeNum, iperiod, lMonthCount, lCount, dblYearValue,
dblYearDeprTotal, dblLastAccrualValue, dblLastDepr, dblLastAddValue, dblLastDecValue, dblLastWork,
dblLastWorkTotal, dblWork, dblWorkT, dblMonthValue, dblValue, dblMonthDeprTotal, dblDeprTotal, dblAddValue,
dblDecValue, dblTransInDeprTotal, dblTransOutDeprTotal, dblAccrualValue, dblDepr, iyear
from #1

– 3.2014.12和2015.1存在同部门/类别的新增资产,期末金额更新处理
– DROP TABLE fa_total_subTypeDept

select sTypeNum,sDeptNum
into fa_total_subTypeDept
from fa_total where iyear = 2015 and iperiod = 1
and sTypeNum+sDeptNum
in
(
select a.sTypeNum+a.sDeptNum
from
(select dblValue,dblDeprTotal, sTypeNum,sDeptNum from fa_total where iyear = 2014 and iperiod = 12
–order by sTypeNum,sDeptNum
) a
inner join
(
select dblMonthValue,dblMonthDeprTotal, sTypeNum,sDeptNum from fa_total where iyear = 2015 and iperiod = 1
–order by sTypeNum,sDeptNum
) b
on a.sTypeNum = b.sTypeNum and a.sDeptNum = b.sDeptNum
where convert(decimal(18,2),abs(dblValue-dblMonthValue)) >= 0.01
or convert(decimal(18,2),abs(dblDeprTotal-dblMonthDeprTotal)) >= 0.01
)

– 开始更新
update a
set dblMonthValue = dblMonthValue+ b.dblValue, dblYearValue = dblYearValue+ b.dblValue,dblValue = a.dblValue+ b.dblValue
–select a.sDeptNum,a.sTypeNum,a.dblMonthValue,a.dblYearValue,a.dblValue,a.dblDeprTotal,
–b.dblValue as dblValue_b,b.dblDeprTotal as dblDeprTotal_b
from fa_total a
inner join
(
select dblValue,dblDeprTotal,sTypeNum+sDeptNum as sNum from fa_total where iyear = 2014 and iperiod = 12
and sTypeNum+sDeptNum in (select sTypeNum+sDeptNum from fa_total_subTypeDept)
) b
on a.sTypeNum+a.sDeptNum = b.sNum
where iyear = 2015 and iperiod = 1

– commit tran
– rollback tran
GO

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值