问题描述:
做12月月结的时候,本年度的期末数很多结转不到下一年度的期初数,科目对照功能有问题,比如管理费用下有水电费,租赁费,在别的科目下也有水电费,租赁费的时候,科目对照就会出现混乱,已经打过最新补丁了。
问题回复:
针对于该问题,可以执行以下脚本解决。使用以下脚本整理2011年和2012年对照有问题的科目 if exists(select * from sys.procedures where name='AccountDZ')drop Proc AccountDZ GOcreate Proc AccountDZ @Pre varchar(20),@Cur varchar(20)asdeclare @TempAccount table(Code varchar(100),Num int)declare @AllCount intdeclare @NowCount int--查出所有科目CODEinsert into @TempAccount(Code,Num) select code,ROW_NUMBER() over(order by code) as Num from aa_account where accountingyear=@Pre or accountingyear=@Cur group by codeset @AllCount=(select count(*) from @TempAccount)set @NowCount=1--删除科目对照表数据delete AA_AccountAssociation where preaccountingyear=@Pre and currentaccountingyear=@Cur--循环科目CODEwhile(@NowCount<=@AllCount)begin declare @TempCode varchar(20)select @TempCode=Code from @TempAccount where num=@NowCountdeclare @PreAccountID varchar(50)declare @CurAccountID varchar(50)select @PreAccountID=id from AA_Account where code=@TempCode and accountingyear=@Pre select @CurAccountID=id from AA_Account where code=@TempCode and accountingyear=@Cur if(@PreAccountID!='' and @CurAccountID!='') insert into AA_AccountAssociation(id,code,name,currentaccountingyear,createdtime,sequencenumber,updated,updatedBy,idcurrentaccountDTO,idpreaccountDTO,preaccountingyear)values(newid(),NULL,NULL,@Cur,GETDATE(),0,getdate(),'System',@CurAccountID,@PreAccountID,@Pre) set @NowCount=@NowCount+1set @PreAccountID=''set @CurAccountID=''endGO--2011 上年科目 2012 当年科目exec AccountDZ '2011','2012'