服务热线:022-26677809 , 13821206318
坚守“用户之友”的初心,做“专业的奋斗者”,始终坚持“持续创新”
首页 > 知识库 > 正文

财务通现存量不对

- 浏览:1076 - 发布时间:2007-08-29 12:24:00.0
问题版本: 4-财务通标准版821 问题模块: 16-存货核算
所属行业: 0-通用 问题状态: 1-UU通注册用户
关 键 字: 现存量 适用产品: 4
补 丁 号: 开放状态: 0-UU通注册用户
原问题号: 提交时间: 2007-8-29 12:24:00
问题名称: 财务通现存量不对
问题现象: 财务通现存量不正确怎么办?
原因分析: 执行以下脚本能解决问题 select * from sysobjects where name='tempcurrentstock' drop table TempCurrentStock SELECT cWhCode,cInvCode,(CASE WHEN cFree1=''THEN NULL ELSE cFree1 END) AS cFree1 ,(CASE WHEN cFree2=''THEN NULL ELSE cFree2 END) AS cFree2 ,iainquantity AS iQuantity, CAST(0 AS FLOAT) AS fOutQuantity,CAST(0 AS FLOAT) AS fInQuantity INTO TempCurrentStock From ia_subsidiary Where cvoutype='34' group by ia_subsidiary.cWhCode,ia_subsidiary.cInvCode,ia_subsidiary.cFree1, ia_subsidiary.cFree2,ia_subsidiary.iainquantity INSERT INTO TempCurrentStock(cWhCode,cInvCode,cFree1,cFree2,iQuantity) SELECT cWhCode, cInvCode,(CASE WHEN cFree1=''THEN NULL ELSE cFree1 END) AS cFree1 ,( CASE WHEN cFree2=''THEN NULL ELSE cFree2 END) AS cFree2 , (CASE WHEN bRdFlag<>0 THEN iQuantity ELSE -iQuantity END) AS iQuantity FROM RdRecord INNER JOIN RdRecords ON RdRecord.ID = RdRecords.ID WHERE cVouchType<>'33'AND cVouchType<>'34' AND RdRecord.dDate>='2007-1-01' INSERT INTO TempCurrentSt
解决方案: 执行以下脚本能解决问题 select * from sysobjects where name='tempcurrentstock' drop table TempCurrentStock SELECT cWhCode,cInvCode,(CASE WHEN cFree1=''THEN NULL ELSE cFree1 END) AS cFree1 ,(CASE WHEN cFree2=''THEN NULL ELSE cFree2 END) AS cFree2 ,iainquantity AS iQuantity, CAST(0 AS FLOAT) AS fOutQuantity,CAST(0 AS FLOAT) AS fInQuantity INTO TempCurrentStock From ia_subsidiary Where cvoutype='34' group by ia_subsidiary.cWhCode,ia_subsidiary.cInvCode,ia_subsidiary.cFree1, ia_subsidiary.cFree2,ia_subsidiary.iainquantity INSERT INTO TempCurrentStock(cWhCode,cInvCode,cFree1,cFree2,iQuantity) SELECT cWhCode, cInvCode,(CASE WHEN cFree1=''THEN NULL ELSE cFree1 END) AS cFree1 ,( CASE WHEN cFree2=''THEN NULL ELSE cFree2 END) AS cFree2 , (CASE WHEN bRdFlag<>0 THEN iQuantity ELSE -iQuantity END) AS iQuantity FROM RdRecord INNER JOIN RdRecords ON RdRecord.ID = RdRecords.ID WHERE cVouchType<>'33'AND cVouchType<>'34' AND RdRecord.dDate>='2007-1-01' INSERT INTO TempCurrentStock(cWhCode,cInvCode,cFree1,cFree2,fOutQuantity) SELECT EnDispatchs.cWhCode, EnDispatchs.cInvCode,(CASE WHEN EnDispatchs.cFree1= '' THEN NULL ELSE EnDispatchs.cFree1 END) AS cFree1 ,(CASE WHEN EnDispatchs. cFree2='' THEN NULL ELSE EnDispatchs.cFree2 END) AS cFree2 , (ISNULL(iQuantity, 0)-ISNULL(fOutQuantity,0)) AS fOutQuantity FROM EnDispatch INNER JOIN EnDispatchs ON EnDispatch.EDID = EnDispatchs.EDID WHERE ISNULL(EnDispatchs.cWhCode,'')<>'' AND ISNULL(EnDispatch.cSTCode,'')<>'' AND EnDispatchs.iQuantity>0 AND bReturnFlag=0 INSERT INTO TempCurrentStock(cWhCode,cInvCode,cFree1,cFree2,fOutQuantity) SELECT DispatchLists.cWhCode as cWhCode, DispatchLists.cInvCode as cInvCode,( CASE WHEN DispatchLists.cFree1='' THEN NULL ELSE DispatchLists.cFree1 END) AS cFree1 , (CASE WHEN DispatchLists.cFree2='' THEN NULL ELSE DispatchLists.cFree2 END) AS cFree2 , (ISNULL(iQuantity,0)-ISNULL(fOutQuantity,0)) AS fOutQuantity FROM DispatchLists INNER JOIN DispatchList ON DispatchLists.DLID = DispatchList.DLID WHERE DispatchList.cVouchType='05' AND ISNULL(DispatchLists.cWhCode,'')<>'' AND ISNULL(DispatchList.cSTCode,'')<>'' AND (DispatchList.iSale=0 or DispatchList.iSale IS NULL) AND DispatchLists.iQuantity>0 INSERT INTO TempCurrentStock(cWhCode,cInvCode,cFree1,cFree2,fOutQuantity) SELECT cWhCode, cInvCode,(CASE WHEN cFree1=''THEN NULL ELSE cFree1 END) AS cFree1 , (CASE WHEN cFree2=''THEN NULL ELSE cFree2 END) AS cFree2 , (ISNULL( iQuantity,0)-ISNULL(fOutQuantity,0)) AS fOutQuantity FROM SaleBillVouchs INNER JOIN SaleBillVouch ON SaleBillVouch.SBVID= SaleBillVouchs.SBVID WHERE ISNULL(SaleBillVouchs.cWhCode,'')<>'' AND (SaleBillVouch.iDisp=0 OR SaleBillVouch.iDisp IS NULL) AND ISNULL(cBusType,'')<>'委托' AND ISNULL( cSTCode,'')<>'' AND ISNULL(cInvalider,'')='' AND SaleBillVouchs.iQuantity> 0INSERT INTO CurrentStock(cWhCode,cInvCode,cFree1,cFree2,iQuantity,fOutQuantity, fInQuantity) SELECT cWhCode, cInvCode,cFree1,cFree2 , sum(iQuantity) AS iQuantity,sum( ISNULL(fOutQuantity,0)) AS fOutQuantity, sum(ISNULL(fInQuantity,0)) AS fInQuantity FROM TempCurrentStock GROUP BY cWhCode,cInvCode,cFree1,cFree2 Delete From CurrentStock where iquantity is null and foutquantity=0 and finquantity=0