// Stock: removed id_currency. Warehouse: added id_currency. StockManager: fixed
This commit is contained in:
@@ -38,7 +38,6 @@ class StockCore extends ObjectModel
|
||||
public $physical_quantity;
|
||||
public $usable_quantity;
|
||||
public $price_te;
|
||||
public $id_currency;
|
||||
|
||||
protected $fieldsRequired = array(
|
||||
'id_warehouse',
|
||||
@@ -47,7 +46,6 @@ class StockCore extends ObjectModel
|
||||
'physical_quantity',
|
||||
'usable_quantity',
|
||||
'price_te',
|
||||
'id_currency'
|
||||
);
|
||||
|
||||
protected $fieldsSize = array();
|
||||
@@ -59,7 +57,6 @@ class StockCore extends ObjectModel
|
||||
'physical_quantity' => 'isUnsignedInt',
|
||||
'usable_quantity' => 'isInt',
|
||||
'price_te' => 'isPrice',
|
||||
'id_currency' => 'isUnsignedInt'
|
||||
);
|
||||
|
||||
protected $table = 'stock';
|
||||
@@ -74,7 +71,6 @@ class StockCore extends ObjectModel
|
||||
$fields['physical_quantity'] = (int)$this->physical_quantity;
|
||||
$fields['usable_quantity'] = (int)$this->usable_quantity;
|
||||
$fields['price_te'] = (float)round($this->price_te, 6);
|
||||
$fields['id_currency'] = (int)$this->id_currency;
|
||||
return $fields;
|
||||
}
|
||||
}
|
||||
@@ -66,7 +66,7 @@ class StockManagerCore implements StockManagerInterface
|
||||
'physical_quantity' => $quantity,
|
||||
'id_stock_mvt_reason' => $id_stock_mvt_reason,
|
||||
'id_supplier_order' => $id_supplier_order,
|
||||
'price_te' => round($price_te, 6),
|
||||
'price_te' => $price_te,
|
||||
'last_wa' => null,
|
||||
'current_wa' => null,
|
||||
'id_employee' => $context->employee->id,
|
||||
@@ -92,8 +92,8 @@ class StockManagerCore implements StockManagerInterface
|
||||
$stock = $stock_collection[0];
|
||||
|
||||
// calculates WA price
|
||||
$last_wa = round($stock->price_te, 6);
|
||||
$current_wa = round($this->calculateWA($stock, $quantity, $price_te), 6);
|
||||
$last_wa = $stock->price_te;
|
||||
$current_wa = $this->calculateWA($stock, $quantity, $price_te);
|
||||
|
||||
$mvt_params['id_stock'] = $stock->id;
|
||||
$mvt_params['last_wa'] = $last_wa;
|
||||
@@ -113,7 +113,7 @@ class StockManagerCore implements StockManagerInterface
|
||||
else // else, the product is not in sock
|
||||
{
|
||||
$mvt_params['last_wa'] = 0;
|
||||
$mvt_params['current_wa'] = round($price_te, 6);
|
||||
$mvt_params['current_wa'] = $price_te;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -160,10 +160,9 @@ class StockManagerCore implements StockManagerInterface
|
||||
'id_product_attribute' => $id_product_attribute,
|
||||
'id_product' => $id_product,
|
||||
'physical_quantity' => $quantity,
|
||||
'price_te' => round($price_te, 6),
|
||||
'price_te' => $price_te,
|
||||
'usable_quantity' => ($is_usable ? $quantity : 0),
|
||||
'id_warehouse' => $warehouse->id,
|
||||
'id_currency' => (int)Configuration::get('PS_CURRENCY_DEFAULT')
|
||||
'id_warehouse' => $warehouse->id
|
||||
);
|
||||
|
||||
// saves stock in warehouse
|
||||
@@ -242,8 +241,7 @@ class StockManagerCore implements StockManagerInterface
|
||||
);
|
||||
$stock_params = array(
|
||||
'physical_quantity' => ($stock->physical_quantity - $quantity),
|
||||
'usable_quantity' => ($is_usable ? ($stock->usable_quantity - $quantity) : $stock->usable_quantity),
|
||||
'id_currency' => (int)Configuration::get('PS_CURRENCY_DEFAULT')
|
||||
'usable_quantity' => ($is_usable ? ($stock->usable_quantity - $quantity) : $stock->usable_quantity)
|
||||
);
|
||||
|
||||
// saves stock in warehouse
|
||||
@@ -365,8 +363,7 @@ class StockManagerCore implements StockManagerInterface
|
||||
|
||||
$stock_params = array(
|
||||
'physical_quantity' => ($stock->physical_quantity - $total_quantity_for_current_stock),
|
||||
'usable_quantity' => ($is_usable ? ($stock->usable_quantity - $total_quantity_for_current_stock) : $stock->usable_quantity),
|
||||
'id_currency' => (int)Configuration::get('PS_CURRENCY_DEFAULT')
|
||||
'usable_quantity' => ($is_usable ? ($stock->usable_quantity - $total_quantity_for_current_stock) : $stock->usable_quantity)
|
||||
);
|
||||
|
||||
$return[$stock->id]['quantity'] = $total_quantity_for_current_stock;
|
||||
|
||||
+18
-16
@@ -37,6 +37,7 @@ class WarehouseCore extends ObjectModel
|
||||
public $reference;
|
||||
public $name;
|
||||
public $id_employee;
|
||||
public $id_currency;
|
||||
|
||||
/**
|
||||
* Describes the way a Warehouse is managed
|
||||
@@ -49,7 +50,8 @@ class WarehouseCore extends ObjectModel
|
||||
'reference',
|
||||
'name',
|
||||
'id_employee',
|
||||
'management_type'
|
||||
'management_type',
|
||||
'id_currency'
|
||||
);
|
||||
|
||||
protected $fieldsSize = array(
|
||||
@@ -63,7 +65,8 @@ class WarehouseCore extends ObjectModel
|
||||
'reference' => 'isString',
|
||||
'name' => 'isString',
|
||||
'id_employee' => 'isUnsignedId',
|
||||
'management_type' => 'isStockManagement'
|
||||
'management_type' => 'isStockManagement',
|
||||
'id_currency' => 'isUnsignedId'
|
||||
);
|
||||
|
||||
protected $table = 'warehouse';
|
||||
@@ -77,17 +80,18 @@ class WarehouseCore extends ObjectModel
|
||||
$fields['name'] = pSQL($this->name);
|
||||
$fields['id_employee'] = (int)$this->id_employee;
|
||||
$fields['management_type'] = pSQL($this->management_type);
|
||||
$fields['id_currency'] = (int)$this->id_currency;
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the shops associated to the current warehouse
|
||||
*
|
||||
* @return array
|
||||
* @return array ids
|
||||
*/
|
||||
public function getShops()
|
||||
{
|
||||
$shop_ids = array();
|
||||
$ids_shop = array();
|
||||
|
||||
$query = new DbQuery();
|
||||
$query->select('ws.id_shop');
|
||||
@@ -96,12 +100,11 @@ class WarehouseCore extends ObjectModel
|
||||
|
||||
$res = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
|
||||
|
||||
// Parse the result to return a simple array of ids
|
||||
foreach($res as $shops)
|
||||
foreach($shops as $shop)
|
||||
$shop_ids[] = $shop;
|
||||
foreach ($res as $shops)
|
||||
foreach ($shops as $shop)
|
||||
$ids_shop[] = $shop;
|
||||
|
||||
return $shop_ids;
|
||||
return $ids_shop;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -125,11 +128,11 @@ class WarehouseCore extends ObjectModel
|
||||
/**
|
||||
* Gets the carriers associated to the current warehouse
|
||||
*
|
||||
* @return array
|
||||
* @return array ids
|
||||
*/
|
||||
public function getCarriers()
|
||||
{
|
||||
$carriers_ids = array();
|
||||
$ids_carrier = array();
|
||||
|
||||
$query = new DbQuery();
|
||||
$query->select('wc.id_carrier');
|
||||
@@ -138,12 +141,11 @@ class WarehouseCore extends ObjectModel
|
||||
|
||||
$res = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
|
||||
|
||||
// Parse the result to return a simple array of ids
|
||||
foreach($res as $carriers)
|
||||
foreach($carriers as $carrier)
|
||||
$carriers_ids[] = $carrier;
|
||||
foreach ($res as $carriers)
|
||||
foreach ($carriers as $carrier)
|
||||
$ids_carrier[] = $carrier;
|
||||
|
||||
return $carriers_ids;
|
||||
return $ids_carrier;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user