Ejemplo n.º 1
0
 /**
  * Process lot data (create or update quantities).
  *
  * @param int $stockItemId Magento ID for stock item related to the lot.
  * @param \Praxigento\Odoo\Data\Odoo\Inventory\Product\Warehouse\Lot $lot
  * @return double quantity of the product in the lot
  */
 public function processLot($stockItemId, $lot)
 {
     $lotIdOdoo = $lot->getIdOdoo();
     $qty = $lot->getQuantity();
     $lotIdMage = $this->_repoAggLot->getMageIdByOdooId($lotIdOdoo);
     $pk = [EntityWarehouseQuantity::ATTR_STOCK_ITEM_REF => $stockItemId, EntityWarehouseQuantity::ATTR_LOT_REF => $lotIdMage];
     $qtyItem = $this->_repoWarehouseEntityQuantity->getById($pk);
     if ($qtyItem) {
         /* update lot qty data */
         $bind = [EntityWarehouseQuantity::ATTR_TOTAL => $qty];
         $this->_repoWarehouseEntityQuantity->updateById($pk, $bind);
     } else {
         /* create lot qty data */
         $pk[EntityWarehouseQuantity::ATTR_TOTAL] = $qty;
         $this->_repoWarehouseEntityQuantity->create($pk);
     }
     return $qty;
 }