// 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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1963,7 +1963,6 @@ CREATE TABLE `PREFIX_stock` (
|
||||
`id_warehouse` INT(11) UNSIGNED NOT NULL,
|
||||
`id_product` INT(11) UNSIGNED NOT NULL,
|
||||
`id_product_attribute` INT(11) UNSIGNED NOT NULL,
|
||||
`id_currency` INT(11) UNSIGNED NOT NULL,
|
||||
`physical_quantity` INT(11) UNSIGNED NOT NULL,
|
||||
`usable_quantity` INT(11) UNSIGNED NOT NULL,
|
||||
`price_te` DECIMAL(20,6) DEFAULT '0.000000',
|
||||
@@ -1975,6 +1974,7 @@ CREATE TABLE `PREFIX_stock` (
|
||||
|
||||
CREATE TABLE `PREFIX_warehouse` (
|
||||
`id_warehouse` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`id_currency` INT(11) UNSIGNED NOT NULL,
|
||||
`id_address` INT(11) UNSIGNED NOT NULL,
|
||||
`id_employee` INT(11) UNSIGNED NOT NULL,
|
||||
`reference` VARCHAR(32) DEFAULT NULL,
|
||||
|
||||
@@ -860,7 +860,8 @@ INSERT INTO `PREFIX_tab` (`id_tab`, `class_name`, `id_parent`, `position`) VALUE
|
||||
(94, 'AdminCategories', 1, 2),
|
||||
(95, 'AdminStock', 0, 15),
|
||||
(96, 'AdminWarehouses', 95, 1),
|
||||
(97, 'AdminStockManagement', 95, 2);
|
||||
(97, 'AdminStockManagement', 95, 2),
|
||||
(98, 'AdminStockCover', 95, 4);
|
||||
|
||||
INSERT INTO `PREFIX_access` (`id_profile`, `id_tab`, `view`, `add`, `edit`, `delete`) (SELECT 1, id_tab, 1, 1, 1, 1 FROM `PREFIX_tab`);
|
||||
|
||||
@@ -882,7 +883,8 @@ INSERT INTO `PREFIX_tab_lang` (`id_lang`, `id_tab`, `name`) VALUES
|
||||
(1, 94, 'Categories'),
|
||||
(1, 95, 'Stock'),
|
||||
(1, 96, 'Warehouses'),
|
||||
(1, 97, 'Stock Management');
|
||||
(1, 97, 'Stock Management'),
|
||||
(1, 98, 'Stock cover');
|
||||
|
||||
INSERT INTO `PREFIX_tab_lang` (`id_lang`, `id_tab`, `name`) VALUES
|
||||
(2, 1, 'Catalogue'),(2, 2, 'Clients'),(2, 3, 'Commandes'),(2, 4, 'Paiement'),(2, 5, 'Transport'),
|
||||
@@ -902,7 +904,8 @@ INSERT INTO `PREFIX_tab_lang` (`id_lang`, `id_tab`, `name`) VALUES
|
||||
(2, 94, 'Catégories'),
|
||||
(2, 95, 'Stock'),
|
||||
(2, 96, 'Entrepôts'),
|
||||
(2, 97, 'Gestion du stock');
|
||||
(2, 97, 'Gestion du stock'),
|
||||
(2, 98, 'Couverture du stock');
|
||||
|
||||
INSERT INTO `PREFIX_tab_lang` (`id_lang`, `id_tab`, `name`) VALUES
|
||||
(3, 1, 'Catálogo'),(3, 2, 'Clientes'),(3, 3, 'Pedidos'),(3, 4, 'Pago'),(3, 5, 'Transporte'),
|
||||
@@ -921,7 +924,8 @@ INSERT INTO `PREFIX_tab_lang` (`id_lang`, `id_tab`, `name`) VALUES
|
||||
(3, 94, 'Categories'),
|
||||
(3, 95, 'Stock'),
|
||||
(3, 96, 'Warehouses'),
|
||||
(3, 97, 'Stock Management');
|
||||
(3, 97, 'Stock Management'),
|
||||
(3, 98, 'Stock cover');
|
||||
|
||||
INSERT INTO `PREFIX_tab_lang` (`id_lang`, `id_tab`, `name`) VALUES
|
||||
(4, 1, 'Katalog'),(4, 2, 'Kunden'),(4, 3, 'Bestellungen'),(4, 4, 'Zahlung'),
|
||||
@@ -941,7 +945,8 @@ INSERT INTO `PREFIX_tab_lang` (`id_lang`, `id_tab`, `name`) VALUES
|
||||
(4, 94, 'Categories'),
|
||||
(4, 95, 'Stock'),
|
||||
(4, 96, 'Warehouses'),
|
||||
(4, 97, 'Stock Management');
|
||||
(4, 97, 'Stock Management'),
|
||||
(4, 98, 'Stock cover');
|
||||
|
||||
INSERT INTO `PREFIX_tab_lang` (`id_lang`, `id_tab`, `name`) VALUES
|
||||
(5, 1, 'Catalogo'),(5, 2, 'Clienti'),(5, 3, 'Ordini'),(5, 4, 'Pagamento'),
|
||||
@@ -961,7 +966,8 @@ INSERT INTO `PREFIX_tab_lang` (`id_lang`, `id_tab`, `name`) VALUES
|
||||
(5, 94, 'Categories'),
|
||||
(5, 95, 'Stock'),
|
||||
(5, 96, 'Warehouses'),
|
||||
(5, 97, 'Stock Management');
|
||||
(5, 97, 'Stock Management'),
|
||||
(5, 98, 'Stock cover');
|
||||
|
||||
|
||||
INSERT IGNORE INTO `PREFIX_tab_lang` (`id_tab`, `id_lang`, `name`)
|
||||
@@ -1363,8 +1369,8 @@ INSERT INTO `PREFIX_stock_available` (`id_stock_available`, `id_product`, `id_pr
|
||||
(37, 8, 0, 1, 1, 0, 2),
|
||||
(38, 9, 0, 1, 1, 0, 2);
|
||||
|
||||
INSERT INTO `PREFIX_warehouse` (`id_warehouse`, `id_address`, `id_employee`, `reference`, `name`, `management_type`) VALUES
|
||||
(1, 0, 1, 'default_warehouse', 'default warehous', 'FIFO');
|
||||
INSERT INTO `PREFIX_warehouse` (`id_warehouse`, `id_currency`, `id_address`, `id_employee`, `reference`, `name`, `management_type`) VALUES
|
||||
(1, 1, 0, 1, 'default_warehouse', 'default warehous', 'FIFO');
|
||||
|
||||
|
||||
INSERT INTO `PREFIX_address_format` (`id_country`, `format`)
|
||||
|
||||
Reference in New Issue
Block a user