예제 #1
0
 /**
  * @param \Generated\Shared\Transfer\RefundItemTransfer $refundItem
  *
  * @throws \Propel\Runtime\Exception\PropelException
  * @return \Generated\Shared\Transfer\RefundItemTransfer
  */
 public function writeRefundItem(RefundItemTransfer $refundItem)
 {
     $refundItem = $this->totalsAggregator->aggregateItem($refundItem);
     $refundItemEntity = $this->queryContainer->createPavRefundItem();
     $refundItemEntity->fromArray($refundItem->toArray());
     $refundItemEntity->save();
     $refundItem->setIdRefundItem($refundItemEntity->getIdRefundItem());
     return $refundItem;
 }
예제 #2
0
 /**
  * @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;
 }