This commit is contained in:
@@ -180,6 +180,38 @@ todo: restock required feature
|
|||||||
|
|
||||||
Create a view for this:
|
Create a view for this:
|
||||||
|
|
||||||
|
--VPARTSONORDER
|
||||||
|
create view vpartsonorder as select partid, partwarehouseid, sum((coalesce(apurchaseorderitem.quantityordered,0)-coalesce(apurchaseorderitem.quantityreceived,0))) as quantityonorder
|
||||||
|
from apurchaseorderitem
|
||||||
|
where
|
||||||
|
(coalesce(apurchaseorderitem.quantityordered,0)-coalesce(apurchaseorderitem.quantityreceived,0)) > 0
|
||||||
|
group by partid, partwarehouseid
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--VRESTOCKREQUIRED
|
||||||
|
create view vrestockrequired as select
|
||||||
|
apart.id as partid, apartwarehouse.id as partwarehouseid, apart.partnumber, apartwarehouse.name as displaywarehouse, apartstocklevel.minimumquantity, vpartinventorynow.balance,
|
||||||
|
coalesce(vpartsonorder.quantityonorder,0) as onorderquantity,
|
||||||
|
apartstocklevel.minimumquantity - (coalesce(vpartinventorynow.balance, 0) + coalesce(vpartsonorder.quantityonorder, 0)) as requiredquantity
|
||||||
|
from
|
||||||
|
vpartinventorynow
|
||||||
|
left join apart on vpartinventorynow.partid=apart.id
|
||||||
|
left join apartwarehouse on vpartinventorynow.partwarehouseid = apartwarehouse.id
|
||||||
|
left join apartstocklevel on vpartinventorynow.partid=apartstocklevel.partid and vpartinventorynow.partwarehouseid=apartstocklevel.partwarehouseid
|
||||||
|
left join vpartsonorder on vpartinventorynow.partid=vpartsonorder.partid and vpartinventorynow.partwarehouseid=vpartsonorder.partwarehouseid
|
||||||
|
where
|
||||||
|
apartstocklevel.minimumquantity is not null
|
||||||
|
and
|
||||||
|
(apartstocklevel.minimumquantity - (coalesce(vpartinventorynow.balance, 0) + coalesce(vpartsonorder.quantityonorder, 0))) >0
|
||||||
|
order by
|
||||||
|
requiredquantity desc
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Query:
|
Query:
|
||||||
create view vrestockrequired on
|
create view vrestockrequired on
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user