I am trying to write a query to show part adjustment percentages based on the system on hand quantity at the time the inventory adjustment was made. This is in an effort to show inventory accuracy trends over time. I know cycle counting does this, and we are using cycle counting, but there is a backstory here that involves working around the cycle count system to more favorably report accuracy so the data from our cycle count tolerance reports is not accurate.
Within our system are backdated transactions and this is causing me to be unable to get an accurate quantity at a given transaction occurence.
I have made a custom field in a BAQ to invert the sign orf the PartTran.TranQty when the PartTran.TranType includes STK-MTL or STK-CUS, all others post as PartTran.TranQty.
case
when PartTran.TranType IN (‘STK-MTL’, ‘STK-CUS’) then -PartTran.TranQty
when PartTran.TranType = ‘ADJ-CST’ or PartTran.TranType = ‘RMA-INS’ then 0
else PartTran.TranQty
end as ActTransAmount
Then to total all of these inventory transactions I am using the SUM() OVER (PARTITION BY ORDERBY).
SUM(ActTransAmount) OVER (PARTITION BY PartTran.PartNum ORDER BY PartTran.TranNum)
The problem with this method is that it does not take into account backdated transactions where the PartTran.TransNum occurs after other inventory transactions on this part number. Ordering by PartTran.SysDate or PartTran.TranDate or a combination thereof also does not give me an accurate number.
I am making the assumption that Epicor handles this by a posting process that is triggered by transactions that fixes records in the Part Transaction History Tracker to accurately give the correct number in the Running Total column of that form.
- Does Epicor store this information anywhere?
- If not then is there a reliable way to get this appropriately calculated?