// Fixed StockCover
// Removed id_stock_mvt_reason from StockManager::transferBetweenWarehouses() // It is now allowed to transfer stock within one warehouse if and only if it only changes, for a given quantity, its usable state
This commit is contained in:
@@ -444,7 +444,6 @@ class StockManagerCore implements StockManagerInterface
|
||||
public function transferBetweenWarehouses($id_product,
|
||||
$id_product_attribute,
|
||||
$quantity,
|
||||
$id_stock_mvt_reason,
|
||||
$id_warehouse_from,
|
||||
$id_warehouse_to,
|
||||
$usable_from = true,
|
||||
@@ -454,7 +453,7 @@ class StockManagerCore implements StockManagerInterface
|
||||
if ($this->getProductPhysicalQuantities($id_product, $id_product_attribute, array($id_warehouse_from), $usable_from) < $quantity)
|
||||
return false;
|
||||
|
||||
if ($id_warehouse_from == $id_warehouse_to)
|
||||
if ($id_warehouse_from == $id_warehouse_to && $usable_from == $usable_to)
|
||||
return false;
|
||||
|
||||
// Checks if the given warehouses are available
|
||||
@@ -469,7 +468,7 @@ class StockManagerCore implements StockManagerInterface
|
||||
$id_product_attribute,
|
||||
$warehouse_from,
|
||||
$quantity,
|
||||
$id_stock_mvt_reason,
|
||||
Configuration::get('PS_STOCK_MVT_TRANSFER_FROM'),
|
||||
$usable_from);
|
||||
if (!count($stocks))
|
||||
return false;
|
||||
@@ -493,7 +492,7 @@ class StockManagerCore implements StockManagerInterface
|
||||
$id_product_attribute,
|
||||
$warehouse_to,
|
||||
$stock['quantity'],
|
||||
$id_stock_mvt_reason,
|
||||
Configuration::get('PS_STOCK_MVT_TRANSFER_TO'),
|
||||
$price,
|
||||
$usable_to))
|
||||
return false;
|
||||
@@ -522,6 +521,7 @@ class StockManagerCore implements StockManagerInterface
|
||||
LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product` = s.`id_product`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON (p.`id_product` = pa.`id_product`)
|
||||
WHERE sm.`sign` = -1
|
||||
AND sm.`id_stock_mvt_reason` != '.Configuration::get('PS_STOCK_MVT_TRANSFER_FROM').'
|
||||
AND TO_DAYS(NOW()) - TO_DAYS(sm.`date_add`) <= '.(int)$coverage.'
|
||||
AND s.`id_product` = '.(int)$id_product.'
|
||||
AND s.`id_product_attribute` = '.(int)$id_product_attribute.
|
||||
|
||||
@@ -101,14 +101,13 @@ interface StockManagerInterface
|
||||
* @param int $id_product
|
||||
* @param int $id_product_attribute
|
||||
* @param int $quantity
|
||||
* @param int $id_stock_movement_reason
|
||||
* @param int $warehouse_from
|
||||
* @param int $warehouse_to
|
||||
* @param bool $usable_from true by default
|
||||
* @param bool $usable_to true by default
|
||||
* @return bool
|
||||
*/
|
||||
public function transferBetweenWarehouses($id_product, $id_product_attribute, $quantity, $id_stock_movement_reason, $warehouse_from, $warehouse_to, $usable_from = true, $usable_to = true);
|
||||
public function transferBetweenWarehouses($id_product, $id_product_attribute, $quantity, $warehouse_from, $warehouse_to, $usable_from = true, $usable_to = true);
|
||||
|
||||
/**
|
||||
* For a given product, returns the time left before being out of stock.
|
||||
|
||||
@@ -146,9 +146,10 @@ class AdminStockCoverControllerCore extends AdminController
|
||||
|
||||
$this->_select = 'a.id_product as id, COUNT(pa.id_product_attribute) as variations, s.physical_quantity as stock';
|
||||
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON (pa.id_product = a.id_product)
|
||||
LEFT JOIN `'._DB_PREFIX_.'stock` s ON (s.id_product = a.id_product AND s.id_product_attribute = 0)';
|
||||
INNER JOIN `'._DB_PREFIX_.'stock` s ON (s.id_product = a.id_product)';
|
||||
$this->where = 'AND s.id_product_attribute = 0';
|
||||
if ($this->getCurrentCoverageWarehouse() != -1)
|
||||
$this->_where = 'AND s.id_warehouse = '.$this->getCurrentCoverageWarehouse();
|
||||
$this->_where .= 'AND s.id_warehouse = '.$this->getCurrentCoverageWarehouse();
|
||||
|
||||
$this->context->smarty->assign('stock_cover_periods', $this->stock_cover_periods);
|
||||
$this->context->smarty->assign('stock_cover_cur_period', $this->getCurrentCoveragePeriod());
|
||||
|
||||
@@ -650,7 +650,6 @@ class AdminStockManagementControllerCore extends AdminController
|
||||
$id_product,
|
||||
$id_product_attribute,
|
||||
$quantity,
|
||||
1, //@TOTO specify new default movement for transfer
|
||||
$id_warehouse_from,
|
||||
$id_warehouse_to,
|
||||
$usable_from,
|
||||
|
||||
Reference in New Issue
Block a user