【内参】T6-发票结算日期显示问题和库存对账问题-张彩用
发票结算日期显示问题和库存对账问题
【问题现象】
① 同一张发票:结算日期有的显示,有的不显示
② 库存模块,库存与存货对账,只显示3个仓库
【原因分析】
第一个现象原因:结算针对个别存货结算,没有结不完全
查看结算单列表:
同一张发票已经结算的只有以下存货:
第二个问题原因:
通过跟踪查找:
SELECT qdfUnion_A1_0.*,(Case When Convert(float,qdfTotal_A1_0.iIQuantity)=0 Then '' Else qdfTotal_A1_0.iIQuantity End) As a1, (Case When Convert(float,qdfTotal_A1_0.iOQuantity)=0 Then '' Else qdfTotal_A1_0.iOQuantity End) As b1, (Case When Convert(float,qdfTotal_A1_0.iBQuantity)=0 Then '' Else qdfTotal_A1_0.iBQuantity End) As c1, (Case When Convert(float,qdfRds_A1_0.iIncomeQuantity)=0 Then '' Else qdfRds_A1_0.iIncomeQuantity End) As d1, (Case When Convert(float,qdfRds_A1_0.iSentOutQuantity)=0 Then '' Else qdfRds_A1_0.iSentOutQuantity End) As e1, (Case When Convert(float,qdfRds_A1_0.iBeginQuantity)=0 Then '' Else qdfRds_A1_0.iBeginQuantity End) As f1
--INTO qdfresult_A1_0
-- select distinct qdfUnion_A1_0.cwhcode
FROM (qdfUnion_A1_0 LEFT JOIN qdfTotal_A1_0
ON (qdfUnion_A1_0.cInvCode = qdfTotal_A1_0.cInvCode)
AND (qdfUnion_A1_0.cWhCode = qdfTotal_A1_0.cWhCode))
LEFT JOIN qdfRds_A1_0 ON (qdfUnion_A1_0.cWhCode = qdfRds_A1_0.cWhCode) AND (qdfUnion_A1_0.cInvCode = qdfRds_A1_0.cInvCode)
WHERE (Abs(convert(numeric(20,6),IsNull([qdfRds_A1_0].[iInComeQuantity],0))
-convert(numeric(20,6),IsNull([qdfTotal_A1_0].[iIQuantity],0)))
+Abs(convert(numeric(20,6),IsNull([qdfRds_A1_0].[iSentOutQuantity],0))
-convert(numeric(20,6),IsNull([qdfTotal_A1_0].[iOQuantity],0)))
+Abs(convert(numeric(20,6),IsNull([qdfRds_A1_0].[ibeginQuantity],0))-
convert(numeric(20,6),IsNull([qdfTotal_A1_0].[iBQuantity],0))))>0
而且不加where条件,也是能查出全部仓库的,因此问题出在where 条件中 三个绝对值相加〉0
Where 中主要是qdfTotal_A1_0 表和qdfRds_A1_0
这两张表又来自下面这个表:
SELECT IA_Summary.cWhCode, IA_Summary.cInvCode, Inventory.cInvName, Inventory.cInvStd,
Str(isnull(sum(IA_Summary.iINum),0),20,2) AS iIncomeQuantity,
Str(isnull(sum(IA_Summary.iONum),0),20,2) AS iSentOutQuantity,
Str(isnull(sum(iNum),0),20,2) AS iBeginQuantity
--INTO qdfRds_A1_0
FROM IA_Summary INNER JOIN Inventory
ON IA_Summary.cInvCode = Inventory.cInvCode
Where iMonth = 2 AND ISNULL(IA_Summary.cWhCode,'')<>'' and IA_Summary.cWhCode='005' and IA_Summary.cInvCode='8SMPB200Z1004'
GROUP BY IA_Summary.cWhCode, IA_Summary.cInvCode, Inventory.cInvName,Inventory.cInvStd
SELECT RdRecord.cWhCode ,RdRecords.cInvCode ,Inventory.cInvName ,Inventory.cInvStd,
Str(Sum(Case When dDate >='2016-02-01' And dDate <='2016-02-29' And bRdFlag <> 0
Then RdRecords.iQuantity Else 0 End) ,20,2) AS iIQuantity ,
Str(Sum(Case When dDate >='2016-02-01' And dDate <='2016-02-29' And bRdFlag <> 1
Then RdRecords.iQuantity Else 0 End) ,20 ,2 ) As iOQuantity ,
Str((SUM((Case When dDate <'2016-02-01'
Then ((CASE WHEN bRdFlag <> 0 then 1 else -1 end) * RdRecords.iQuantity ) ELSE 0 END )))
+ (SUM(Case When dDate >='2016-02-01' And dDate <='2016-02-29' And bRdFlag <> 0
Then RdRecords.iQuantity Else 0 End))
- (SUM(Case When dDate >='2016-02-01' And dDate <='2016-02-29' And bRdFlag <> 1
Then RdRecords.iQuantity Else 0 End)),20 ,2 ) AS iBQuantity
--INTO qdfTotal_A1_0
FROM RdRecord INNER JOIN RdRecords ON RdRecord.Id = RdRecords.Id INNER JOIN Inventory
ON RdRecords.cInvCode = Inventory.cInvCode
WHERE RdRecord.cWhCode='005' and RdRecords.cInvCode ='8SMPB200Z1004' and ((RdRecord.dDate < '2016-01-01' And IsNull(RdRecord.bIsSTQc,0) = 1)
Or (RdRecord.dDate >= '2016-01-01'
And IsNull(RdRecord.bPUFirst,0) = 0
And IsNull(RdRecord.bIAFirst,0) = 0
And (not (RdRecord.cBusType = '假退料'and RdRecord.cVouchType = 11))
)
) GROUP BY RdRecord.cWhCode, RdRecords.cInvCode, Inventory.cInvName,Inventory.cInvStd
【解决方案】
第一个问题:确切的说,没有显示其他存货的结算日期是正常的,因为其他存货的确没有结算,可以手工进行结算,把其他存货也都结算后,结算日期可显示。
第二个问题:随机找几个不显示的存货:
得出结论是:对账平衡的存货都不显示,感觉这个结论有点辜负找原因的过程。但是可能最重要的也就是过程。通过这个过程,我了解了一步步寻找源头的方法。
作者:畅捷服务社区 |  时间:2021年08月04日 16:43