Skip to content

Latest commit

 

History

History
272 lines (158 loc) · 7.78 KB

class.StockManagerCore.md

File metadata and controls

272 lines (158 loc) · 7.78 KB

Class StockManagerCore

StockManager : implementation of StockManagerInterface

Contents

Methods

Methods

addProduct

boolean StockManagerCore::addProduct(integer $id_product, integer $id_product_attribute, \Warehouse $warehouse, integer $quantity, integer $id_stock_mvt_reason, float $price_te, boolean $is_usable, integer|null $id_supply_order, \Employee|null $employee)

For a given product, adds a given quantity

Arguments

  • $id_product integer
  • $id_product_attribute integer
  • $warehouse Warehouse
  • $quantity integer
  • $id_stock_mvt_reason integer
  • $price_te float
  • $is_usable boolean
  • $id_supply_order integer|null
  • $employee Employee|null

calculateWA

integer StockManagerCore::calculateWA(\Stock|\PrestaShopCollection $stock, integer $quantity, float $price_te)

For a given stock, calculates its new WA(Weighted Average) price based on the new quantities and price Formula : (physicalStock * lastCump + quantityToAdd * unitPrice) / (physicalStock + quantityToAdd)

Arguments

  • $stock Stock|Stock
  • $quantity integer
  • $price_te float

getProductCoverage

integer StockManagerCore::getProductCoverage($id_product, $id_product_attribute, $coverage, $id_warehouse)

For a given product, returns the time left before being out of stock.

By default, for the given product, it will use sum(quantities removed in all warehouses)

Arguments

  • $id_product mixed
  • $id_product_attribute mixed
  • $coverage mixed
  • $id_warehouse mixed

getProductPhysicalQuantities

mixed StockManagerCore::getProductPhysicalQuantities($id_product, $id_product_attribute, $ids_warehouse, $usable)

For a given product, returns its physical quantity If the given product has combinations and $id_product_attribute is null, returns the sum for all combinations

Arguments

  • $id_product mixed
  • $id_product_attribute mixed
  • $ids_warehouse mixed
  • $usable mixed

getProductRealQuantities

mixed StockManagerCore::getProductRealQuantities($id_product, $id_product_attribute, $ids_warehouse, $usable)

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 + supply_orders_qty - client_orders_qty) If $usable is defined, real quantity: usable_qty + supply_orders_qty - client_orders_qty

Arguments

  • $id_product mixed
  • $id_product_attribute mixed
  • $ids_warehouse mixed
  • $usable mixed

getStockByCarrier

integer StockManagerCore::getStockByCarrier(integer $id_product, integer $id_product_attribute, array $delivery_option)

For a given product, retrieves the stock in function of the delivery option

Arguments

  • $id_product integer
  • $id_product_attribute integer - optional
  • $delivery_option array

getStockCollection

\PrestaShopCollection StockManagerCore::getStockCollection(integer $id_product, integer $id_product_attribute, integer $id_warehouse, integer $price_te)

For a given product, retrieves the stock collection

Arguments

  • $id_product integer
  • $id_product_attribute integer
  • $id_warehouse integer - Optional
  • $price_te integer - Optional

isAvailable

mixed StockManagerCore::isAvailable()

Checks if the StockManager is available

removeProduct

array StockManagerCore::removeProduct(integer $id_product, integer|null $id_product_attribute, \Warehouse $warehouse, integer $quantity, integer $id_stock_mvt_reason, boolean $is_usable, integer|null $id_order, integer $ignore_pack, \Employee|null $employee)

For a given product, removes a given quantity

Arguments

  • $id_product integer
  • $id_product_attribute integer|null
  • $warehouse Warehouse
  • $quantity integer
  • $id_stock_mvt_reason integer
  • $is_usable boolean
  • $id_order integer|null
  • $ignore_pack integer
  • $employee Employee|null

transferBetweenWarehouses

mixed StockManagerCore::transferBetweenWarehouses($id_product, $id_product_attribute, $quantity, $id_warehouse_from, $id_warehouse_to, $usable_from, $usable_to)

For a given product, transfers quantities between two warehouses By default, it manages usable quantities It is also possible to transfer a usable quantity from warehouse 1 in an unusable quantity to warehouse 2 It is also possible to transfer a usable quantity from warehouse 1 in an unusable quantity to warehouse 1

Arguments

  • $id_product mixed
  • $id_product_attribute mixed
  • $quantity mixed
  • $id_warehouse_from mixed
  • $id_warehouse_to mixed
  • $usable_from mixed
  • $usable_to mixed