Exemplo n.º 1
0
 /**
  * @param ApiLot[] $lots
  * @throws \Exception
  */
 public function processLots($lots)
 {
     /** @var  $data AggLot */
     $data = $this->_manObj->create(AggLot::class);
     foreach ($lots as $item) {
         $data->setOdooId($item->getIdOdoo());
         $data->setCode($item->getNumber());
         $data->setExpDate($item->getExpirationDate());
         $lotExists = $this->_repoAggLot->getByOdooId($data->getOdooId());
         if (!$lotExists) {
             $this->_repoAggLot->create($data);
         }
     }
 }
Exemplo n.º 2
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;
 }