找回密码
 注册账号

QQ登录

只需一步,快速开始

手机号码,快捷登录

手机号码,快捷登录

初学者课程:T3自学|T6自学|U8自学软件下载课件下载工具下载资料:通资料|U8资料|NC|培训|年结积分规则 | 使用常见问题Q&A
知识库:U8 | | NC | U9 | OA | 政务U8|U9|NCC|NC65|NC65客开|NCC客开新手必读 | 任务 | 快速增金币用友QQ群[微信群]
查看: 180|回复: 0

科目对照存在问题,请联系代理商或者总部处理后再年结

[复制链接]
发表于 2023-4-21 12:00:00 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册账号

×
T+-总账

               
                    【问题现象】:财务结账提示科目对照存在问题,请联系代理商或者总部处理后再年结

                               
登录/注册后可看大图


【解决方案】:请备份好账套数据,选择账套库,执行脚本
if (select value from EAP_AccInformation where name='MultiAccountingOrgan')=1 and (select COUNT( distinct accountingyear) from AA_Account )>1
begin
delete from AA_AccountAssociation
declare @IdMarketingOrgan int
declare cur2 cursor for
select distinct IdMarketingOrgan from AA_Account order by IdMarketingOrgan
open cur2
fetch next from cur2 into @IdMarketingOrgan
while @@FETCH_STATUS=0
begin
print @IdMarketingOrgan
set nocount on
DECLARE @CurrentYear INT --当年  
DECLARE @NewAccountId int--本年科目ID  
DECLARE @PreAccountId int--上年科目ID  
DECLARE @NewAccountCode NVARCHAR(50)--本年科目编码  
DECLARE @PreAccountCode NVARCHAR(50)--上年科目编码
DECLARE @NewisEndNode tinyint--本年科目是否末级  
DECLARE @PreisEndNode tinyint--上年科目是否末级
DECLARE @PreYear INT --上年
declare cur cursor for
select a.accountingyear currentaccountingyear,b.accountingyear preaccountingyear from (
select distinct top 100  accountingyear from AA_Account where IdMarketingOrgan=@IdMarketingOrgan order by
accountingyear desc) a left join (
select  distinct top 100 accountingyear from AA_Account where IdMarketingOrgan=@IdMarketingOrgan order by
accountingyear desc) b on a.accountingyear >=b.accountingyear
open cur
fetch next from cur into @CurrentYear,@PreYear
while @@FETCH_STATUS=0
begin
        --年度一致直接插入
        if @CurrentYear@PreYear
                begin
                --科目完全一致且都是末级
                        INSERT INTO AA_AccountAssociation(currentaccountingyear,idcurrentaccountDTO,idpreaccountDTO,preaccountingyear)  
                                select @CurrentYear,a.id,b.id,@PreYear from aa_account a left join AA_Account b on a.code=b.code  where a.accountingyear=@CurrentYear and b.accountingyear =@PreYear and
                                a.isEndNode=1 and b.isEndNode=1 and a.IdMarketingOrgan=@IdMarketingOrgan and b.IdMarketingOrgan=@IdMarketingOrgan
                                --科目一致其中一个年度不是末级,对应下级科目第一个
                                declare curNoEnd cursor for
                                select a.id,b.id,a.isEndNode,b.isEndNode,a.code,b.code from aa_account a left join AA_Account b on a.code=b.code  where a.accountingyear=@CurrentYear and b.accountingyear =@PreYear and
                                ((a.isEndNode=1 and b.isEndNode=0) or (a.isEndNode=0 and b.isEndNode=1)) and a.IdMarketingOrgan=@IdMarketingOrgan and b.IdMarketingOrgan=@IdMarketingOrgan
                                open curNoEnd
                                fetch next from curNoEnd into @NewAccountId,@PreAccountId,@NewisEndNode,@PreisEndNode,@NewAccountCode,@PreAccountCode
                                while @@FETCH_STATUS=0
                                begin
                                        if @NewisEndNode =0
                                                select top 1 @NewAccountId=id from AA_Account where accountingyear=@CurrentYear and code like ''+@NewAccountCode+'%' and isEndNode=1 and IdMarketingOrgan=@IdMarketingOrgan order by code
                                        if @PreisEndNode =0
                                                select top 1 @PreAccountId=id from AA_Account where accountingyear=@PreYear and code like ''+@PreAccountCode+'%' and isEndNode=1 and IdMarketingOrgan=@IdMarketingOrgan order by code
                                               
                                                INSERT INTO AA_AccountAssociation(currentaccountingyear,idcurrentaccountDTO,idpreaccountDTO,preaccountingyear)  
                                                values(@CurrentYear,@NewAccountId,@PreAccountId,@PreYear)
                                                 fetch next from curNoEnd into @NewAccountId,@PreAccountId,@NewisEndNode,@PreisEndNode,@NewAccountCode,@PreAccountCode
                                end
                                close curNoEnd
                                deallocate curNoEnd
                end
                else
                begin
                INSERT INTO AA_AccountAssociation(currentaccountingyear,idcurrentaccountDTO,idpreaccountDTO,preaccountingyear)  
                                select @CurrentYear,id,id,@CurrentYear from aa_account where accountingyear=@CurrentYear  and IdMarketingOrgan=@IdMarketingOrgan
                end
        fetch next from cur into @CurrentYear,@PreYear
end
close cur
deallocate cur
fetch next from cur2 into @IdMarketingOrgan
end
close cur2
deallocate cur2
end
您需要登录后才可以回帖 登录 | 注册账号

本版积分规则

QQ|站长微信|Archiver|手机版|小黑屋|用友之家 ( 蜀ICP备07505338号|51072502110008 )

GMT+8, 2024-11-24 06:22 , Processed in 0.055469 second(s), 9 queries , Gzip On, Redis On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表