/**
  * @param int[] $itemIds
  * @param bool $aggregateTotals
  *
  * @throws \Exception
  * @return \Generated\Shared\Transfer\RefundTransfer|null
  */
 public function getRefundForOrderItems(array $itemIds, $aggregateTotals = false)
 {
     $refunds = $this->queryContainer->queryRefundForOrderItems($itemIds)->find();
     $refundCount = count($refunds);
     if ($refundCount === 0) {
         return null;
     }
     if ($refundCount > 1) {
         throw new MultipleRefundsFoundException('Multiple refunds found for items.');
     }
     $refundEntity = $refunds[0];
     $refundTransfer = $this->convertToTransfer($refundEntity);
     if ($aggregateTotals) {
         $this->totalsAggregator->aggregate($refundTransfer);
     }
     return $refundTransfer;
 }
 /**
  * @param int $idRefund
  *
  * @throws \Pav\Zed\Refund\Business\Exception\RefundNotFoundException
  * @return \Orm\Zed\Refund\Persistence\PavRefund
  */
 protected function getRefundEntity($idRefund)
 {
     $refundEntity = $this->queryContainer->queryRefundById($idRefund)->findOne();
     if ($refundEntity === null) {
         throw new RefundNotFoundException(sprintf('Refund %s not found', $idRefund));
     }
     return $refundEntity;
 }