// Stock : fixed bugs on cover/instant state/warehouse/management

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@10150 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
bMancone
2011-11-15 18:19:27 +00:00
parent 03823bc17d
commit 8931216544
11 changed files with 167 additions and 160 deletions
+8 -4
View File
@@ -141,11 +141,15 @@ class StockCore extends ObjectModel
$this->upc = $row['upc'];
}
}
else {
else
{
$product = new Product((int)$this->id_product);
$this->reference = $product->reference;
$this->ean13 = $product->ean13;
$this->upc = $product->upc;
if (Validate::isLoadedObject($product))
{
$this->reference = $product->reference;
$this->ean13 = $product->ean13;
$this->upc = $product->upc;
}
}
}
}
+9 -9
View File
@@ -51,7 +51,7 @@ class StockManagerCore implements StockManagerInterface
$id_stock_mvt_reason,
$price_te,
$is_usable = true,
$id_supplier_order = null)
$id_supply_order = null)
{
if (!Validate::isLoadedObject($warehouse) || !$price_te || !$quantity || !$id_product)
return false;
@@ -67,7 +67,7 @@ class StockManagerCore implements StockManagerInterface
'id_stock' => null,
'physical_quantity' => $quantity,
'id_stock_mvt_reason' => $id_stock_mvt_reason,
'id_supplier_order' => $id_supplier_order,
'id_supply_order' => $id_supply_order,
'price_te' => $price_te,
'last_wa' => null,
'current_wa' => null,
@@ -452,21 +452,21 @@ class StockManagerCore implements StockManagerInterface
$query->where('o.valid = 1');
$client_orders_qty = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query);
// Gets supplier_orders_qty
// Gets supply_orders_qty
$query = new DbQuery();
$query->select('SUM(sod.quantity_expected)');
$query->from('supplier_order so');
$query->leftjoin('supplier_order_detail sod ON (sod.id_supplier_order = so.id_supplier_order)');
$query->leftjoin('supplier_order_state sos ON (sos.id_supplier_order_state = so.id_supplier_order_state)');
$query->from('supply_order so');
$query->leftjoin('supply_order_detail sod ON (sod.id_supply_order = so.id_supply_order)');
$query->leftjoin('supply_order_state sos ON (sos.id_supply_order_state = so.id_supply_order_state)');
$query->where('sos.pending_receipt = 1');
$query->where('sod.id_product = '.(int)$id_product.' AND sod.id_product_attribute = '.(int)$id_product_attribute);
$supplier_orders_qty = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query);
$supply_orders_qty = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query);
// Gets {physical OR usable}_qty
$qty = $this->getProductPhysicalQuantities($id_product, $id_product_attribute, $ids_warehouse, $usable);
// real qty = actual qty in stock - current client orders + current supplier orders
return ($qty - $client_orders_qty + $supplier_orders_qty);
// real qty = actual qty in stock - current client orders + current supply orders
return ($qty - $client_orders_qty + $supply_orders_qty);
}
/**
+4 -4
View File
@@ -49,10 +49,10 @@ interface StockManagerInterface
* @param int $id_stock_movement_reason
* @param float $price_te
* @param bool $is_usable
* @param int $id_supplier_order optionnal
* @param int $id_supply_order optionnal
* @return bool
*/
public function addProduct($id_product, $id_product_attribute, Warehouse $warehouse, $quantity, $id_stock_movement_reason, $price_te, $is_usable = true, $id_supplier_order = null);
public function addProduct($id_product, $id_product_attribute, Warehouse $warehouse, $quantity, $id_stock_movement_reason, $price_te, $is_usable = true, $id_supply_order = null);
/**
* For a given product, removes a given quantity
@@ -83,8 +83,8 @@ interface StockManagerInterface
/**
* For a given product, returns its real quantity
* If the given product has combinations and $id_product_attribute is null, returns the sum for all combinations
* Real quantity : (physical_qty + supplier_orders_qty - client_orders_qty)
* If $usable is defined, real quantity: usable_qty + supplier_orders_qty - client_orders_qty
* Real quantity : (physical_qty + supply_orders_qty - client_orders_qty)
* If $usable is defined, real quantity: usable_qty + supply_orders_qty - client_orders_qty
*
* @param int $id_product
* @param int $id_product_attribute