解决用友U8固定资产对账不平

上传人:s9****2 文档编号:454548260 上传时间:2023-03-20 格式:DOC 页数:4 大小:27.50KB
返回 下载 相关 举报
解决用友U8固定资产对账不平_第1页
第1页 / 共4页
解决用友U8固定资产对账不平_第2页
第2页 / 共4页
解决用友U8固定资产对账不平_第3页
第3页 / 共4页
解决用友U8固定资产对账不平_第4页
第4页 / 共4页
亲,该文档总共4页,全部预览完了,如果喜欢就下载吧!
资源描述

《解决用友U8固定资产对账不平》由会员分享,可在线阅读,更多相关《解决用友U8固定资产对账不平(4页珍藏版)》请在金锄头文库上搜索。

1、beginTRANSACTIONkk-创建临时表CREATETABLE#fq(sCardIDint,PRIMARYkeynonCLUSTERED(sCardID)commitTRANSACTIONkk-初始化定义变量declareBegindatetime,enddatetime,iperiodint,acc_idvarchar(10),acc_yearvarchar(10)declareSQLnchar(2000)-得到当前本数据库的有关信息selectacc_id=999,acc_year=2013,iperiod=1,Begin=2013-01-0100:00:00.000,end=20

2、13-01-3100:00:00.000修改成需要重算总账的相关信息-SELECTBegin=dBegin,end=dEndFROMUFSystem.dbo.UA_Period-wherecAcc_Id=acc_idandiYear=acc_yearandiId=iperiodSelectacc_id,acc_year,iperiod,Begin,end-取月初有效卡片序号数据,计算月初累计折旧数据ifiperiod12returninsert#fqSELECTmax(C.sCardID)FROMfa_CardsCWHERE(c.dInputDateBegin)AND(c.dTransDate

3、BeginOrc.dTransDateIsNull)AND(c.dDisposeDateBeginOrc.dDisposeDateIsNull)groupbyC.sCardNum-SetSQL=updatefa_totalsetdblMonthDeprTotal=isnull(DT,0),dblMonthvalue=isnull(Dv,0)FROMfa_totalTleftjoin(SelectD.sDeptNum,C.sTypeNum,sum(D.dblValue)DV,sum(caseiperiod-1when0thendblDeprT1-dblDepr1when1thendblDeprT

4、1when2thendblDeprT2when3thendblDeprT3when4thendblDeprT4when5thendblDeprT5when6thendblDeprT6when7thendblDeprT7when8thendblDeprT8when9thendblDeprT9when10thendblDeprT10when11thendblDeprT11else0end)DTfromfa_CardsCJOINfa_Cards_DetailDOND.sCardID=C.sCardIDANDJOINfa_DeprTransactions_DetailPONC.sCardNum=P.s

5、CardNumD.sDeptNum=P.sDeptNumjoin#fqon#fq.sCardID=C.sCardIDWHEREC.dDisposeDateisnullandiyear=acc_yeargroupbyD.sDeptNum,C.sTypeNum)asAonT.sDeptNum=a.sDeptNumandT.sTypeNum=a.sTypeNumwhere(T.dblMonthDeprTotalisnull(DT,0)orT.dblMonthvalueisnull(Dv,0)andT.iperiod=iperiod-取月末有效卡片序号数据,计算月末累计折旧数据truncatetabl

6、e#fqinsert#fqSELECTmax(C.sCardID)FROMfa_CardsCWHERE(c.dInputDate=end)AND(c.dTransDate=endOrc.dTransDateIsNull)AND(c.dDisposeDate=endOrc.dDisposeDateIsNull)groupbyC.sCardNum-SetSQL=updatefa_totalsetdblDeprTotal=isnull(DT,0),dblDepr=isnull(DP,0),dblvalue=isnull(Dv,0)FROMfa_totalTleftjoin(SelectD.sDept

7、Num,C.sTypeNum,sum(D.dblValue)DV,sum(caseiperiodwhen1thendblDeprT1when2thendblDeprT2when3thendblDeprT3when4thendblDeprT4when5thendblDeprT5when6thendblDeprT6when7thendblDeprT7when8thendblDeprT8when9thendblDeprT9when10thendblDeprT10when11thendblDeprT11when12thendblDeprT12else0end)DT,sum(caseiperiodwhe

8、n1thendblDepr1when2thendblDepr2when3thendblDepr3when4thendblDepr4when5thendblDepr5when6thendblDepr6when7thendblDepr7when8thendblDepr8when9thendblDepr9when10thendblDepr10when11thendblDepr11when12thendblDepr12else0end)DPfromfa_CardsCJOINfa_Cards_DetailDOND.sCardID=C.sCardIDJOINfa_DeprTransactions_Deta

9、ilPONC.sCardNum=P.sCardNumANDD.sDeptNum=P.sDeptNumjoin#fqon#fq.sCardID=C.sCardIDWHEREC.dDisposeDateisnullandiyear=acc_yeargroupbyD.sDeptNum,C.sTypeNum)asAonT.sDeptNum=a.sDeptNumandT.sTypeNum=a.sTypeNumwhere(T.dblDeprTotalisnull(DT,0)ort.dblDeprisnull(DP,0)ort.dblvalueisnull(Dv,0)andT.iperiod=iperiod

10、truncatetable#fq-取本月新增或变动有效卡片序号数据,计算本月折旧变动情况insert#fqSELECTC.sCardIDFROMfa_CardsCWHERE(c.dInputDatebetweenbeginandend)or(c.dTransDatebetweenbeginandend)or(c.dDisposeDatebetweenbeginandend)updatefa_totalsetdblTransInDeprTotal=indt,dblTransOutDeprTotal=(outdt)FROMfa_totalTleftjoin(SelectD.sDeptNum,C.s

11、TypeNum,sum(d.dblTransInDeprTCard)inDt,sum(d.dblTransOutDeprTCard+casewhenc.iopttype3then0elsecaseiperiodwhen1thenp.dblDepr1when2thenp.dblDepr2when3thenp.dblDepr3when4thenp.dblDepr4when5thenp.dblDepr5when6thenp.dblDepr6when7thenp.dblDepr7when8thenp.dblDepr8when9thenp.dblDepr9when10thenp.dblDepr10whe

12、n11thenp.dblDepr11when12thenp.dblDepr12else0endend)outDTfromfa_CardsCJOINfa_Cards_DetailDOND.sCardID=C.sCardIDANDJOINfa_DeprTransactions_DetailPONC.sCardNum=P.sCardNumD.sDeptNum=P.sDeptNumjoin#fqon#fq.sCardID=C.sCardIDgroupbyD.sDeptNum,C.sTypeNum)asAonT.sDeptNum=a.sDeptNumandT.sTypeNum=a.sTypeNumwhereT.iperiod=iperiodand(dblTransOutDeprTotalisnull(outdt,0)ordblTransInDeprTotalisnull(indt,0)droptable#fq

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > 解决方案

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号