Пример #1
0
 /**
  * @param ArrayCollection $initialLots
  * @param LotModel $model
  * @return int|null
  */
 protected function compareEqualQuantity(ArrayCollection $initialLots, LotModel $model)
 {
     foreach ($initialLots as $initialLot) {
         if (Util::floatcmp($initialLot->getQuantity(), $model->getQuantity())) {
             $model->setStatus(WealthbotLot::LOT_CLOSED);
             $model->setWasClosed(true);
             $model->setInitialLotId($initialLot->getId());
             $model->setRealizedGain($model->getAmount() - $initialLot->getAmount());
             // Close initial lot
             $this->closedLot($initialLot->getId());
             // Save lot
             return $this->lotRepo->save($model);
         }
     }
     return null;
 }