Jump to content

Advanced Stock Managment incorrectly managing stocks!


Recommended Posts

Hello,

 

I have been having troubles with Advanced Stock Management incorrectly calculating stock levels for a long time and think that now found an issue.

 

The problem is when 1 product is ordered actually more then one is subtracted from stock levels.

Run following script to check if you might have similar problem.

select ordered_products.id_order, ordered_products.name, ordered_products.id_product, ordered_products.quantity as ordered_quantity, subtracted_products.quantity as subtracted_quantity
  from
(	select ps_orders.id_order, ps_product_lang.name, ps_product_lang.id_product, ps_cart_product.quantity as quantity  from ps_orders
	inner join ps_cart on ps_orders.id_cart = ps_cart.id_cart
	inner join ps_cart_product on ps_cart.id_cart = ps_cart_product.id_cart
	inner join ps_product_lang on (ps_cart_product.id_product = ps_product_lang.id_product  and ps_product_lang.id_lang = 7)
) ordered_products
inner join
(
	select ps_stock_mvt.id_order, ps_product_lang.name, ps_product_lang.id_product, sum(ps_stock_mvt.physical_quantity) as quantity
	from ps_stock_mvt 
	inner join ps_stock on ps_stock_mvt.id_stock = ps_stock.id_stock
	inner join ps_product_lang on (ps_stock.id_product = ps_product_lang.id_product and ps_product_lang.id_lang = 7)
	where 
		ps_stock_mvt.id_order != 0 -- only subtractions related to purchases
		and sign = -1 -- only subtractions
	group by ps_stock_mvt.id_order, ps_stock.id_product
) subtracted_products
on (
	ordered_products.id_order = subtracted_products.id_order
and ordered_products.id_product = subtracted_products.id_product)
where subtracted_products.quantity > ordered_products.quantity
order by subtracted_products.id_order desc;

Is anyone else facing same issue? Would like to confirm before I'll register a bug on forge.

 

My version is 1.5.4.

 

Link to comment
Share on other sites

×
×
  • Create New...