Skip to content

Latest commit

 

History

History
246 lines (142 loc) · 6.72 KB

class.StockManagerCore.md

File metadata and controls

246 lines (142 loc) · 6.72 KB

Class StockManagerCore

StockManager : implementation of StockManagerInterface

Contents

Methods

Methods

addProduct

mixed StockManagerCore::addProduct($id_product, $id_product_attribute, \Warehouse $warehouse, $quantity, $id_stock_mvt_reason, $price_te, $is_usable, $id_supply_order)

For a given product, adds a given quantity

Arguments

  • $id_product mixed
  • $id_product_attribute mixed
  • $warehouse Warehouse
  • $quantity mixed
  • $id_stock_mvt_reason mixed
  • $price_te mixed
  • $is_usable mixed
  • $id_supply_order mixed

calculateWA

integer StockManagerCore::calculateWA(\Stock $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
  • $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

getStockCollection

\Collection 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

mixed StockManagerCore::removeProduct($id_product, $id_product_attribute, \Warehouse $warehouse, $quantity, $id_stock_mvt_reason, $is_usable, $id_order)

For a given product, removes a given quantity

Arguments

  • $id_product mixed
  • $id_product_attribute mixed
  • $warehouse Warehouse
  • $quantity mixed
  • $id_stock_mvt_reason mixed
  • $is_usable mixed
  • $id_order mixed

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