I want to know how epicor calculates inventory at any point in time?

@Banderson Thank you so much this is the answer I needed

with [OnHandCurrent] as 
(select 
	[PartBin].[Company] as [PartBin_Company],
	[PartBin].[PartNum] as [PartBin_PartNum],
	[PartBin].[DimCode] as [PartBin_DimCode],
	(--số lượng tồn kho hiện tại
   sum(PartBin.OnhandQty)) as [Calculated_TotalOnHandCurrent]
from Erp.PartBin as PartBin
where (PartBin.PartNum = @PartNum)
group by [PartBin].[Company],
	[PartBin].[PartNum],
	[PartBin].[DimCode])

select 
	[PartTran].[Company] as [PartTran_Company],
	[PartTran].[PartNum] as [PartTran_PartNum],
	[PartTran].[TranDate] as [PartTran_TranDate],
	(--xác định dữ liệu nhập xuất
 (case
     when PartTran.TranType IN ('STK-ASM', 'STK-CUS', 'STK-INS', 'STK-KIT', 'STK-FAM', 'STK-MTL', 'STK-PLT', 'STK-STK', 'STK-UKN', 'STK-DMR') then -1 
     when PartTran.TranType IN ('ADJ-CST', 'ADJ-QTY', 'AST-STK', 'DMR-STK', 'INS-STK', 'MFG-STK', 'PLT-STK', 'PUR-STK', 'STK-STK', 'SVG-STK')  then 1 
     else 0
 end) * PartTran.TranQty) as [Calculated_SignedTranQty],
	(SUM(SignedTranQty) OVER (PARTITION BY PartTran.PartNum ORDER BY PartTran.TranNum)) as [Calculated_RunningQOH],
	[PartTran].[UM] as [PartTran_UM],
	[OnHandCurrent].[Calculated_TotalOnHandCurrent] as [Calculated_TotalOnHandCurrent],
	[OnHandCurrent].[PartBin_DimCode] as [PartBin_DimCode]
from Erp.PartTran as PartTran
inner join  OnHandCurrent  as OnHandCurrent on 
	PartTran.Company = OnHandCurrent.PartBin_Company
	and PartTran.PartNum = OnHandCurrent.PartBin_PartNum
where (PartTran.PartNum = @PartNum  and PartTran.TranDate <= @TranDateTo)

DMS_OnHandRunningTotalCutOff.baq (8.2 KB)


Thank you very much! Have a good day! :smiling_face_with_three_hearts: :smiling_face_with_three_hearts:

1 Like