Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding the Total Available and Available physical for an Item/Warehouse

I have a method for a display field which does the following;

return InventSum::find(_salesLine.ItemId, InventDim::_salesLine.InventDimId).AvailPhysical();

This gives me the on-hand Available Physical for the line site/warehouse/location.

I need to see the total available for just the site/warehouse. I think I need to search inventDim by Item/Warehouse to get my inventdimid, but I cannot find the method so I am suspicious that this is incorrect.

Can anyone help?

like image 588
AnthonyBlake Avatar asked Jan 27 '12 13:01

AnthonyBlake


2 Answers

My working solution...

InventDimParm       invDimParm;
InventDim           warehouseInvDim;
InventDim           salesLineInventDim;
;

salesLineInventDim = _salesLine.inventDim();

warehouseInvDim.InventSiteId = salesLineInventDim.InventSiteId;
warehouseInvDim.InventLocationId = salesLineInventDim.InventLocationId;

warehouseInvDim = InventDim::findOrCreate(warehouseInvDim);
invDimParm.initFromInventDim(InventDim::find(warehouseInvDim.inventDimId));

return InventSum::findSum(_salesLine.ItemId,warehouseInvDim,invDimParm).availOrdered();

I know this is for availOrdered() but it works exactly the same for availPhysical()

like image 137
AnthonyBlake Avatar answered Oct 14 '22 16:10

AnthonyBlake


You should use the InventOnhand class.

It sums the invent on-hand values based on criteria like item id and inventory dimensions.

There are lots of uses in AX, search the Class node.

like image 29
Jan B. Kjeldsen Avatar answered Oct 14 '22 16:10

Jan B. Kjeldsen