/**
  * @param \Generated\Shared\Transfer\CalculatedDiscountTransfer $calculatedDiscountTransfer
  *
  * @return void
  */
 protected function assertCalculatedDiscountRequirements(CalculatedDiscountTransfer $calculatedDiscountTransfer)
 {
     $calculatedDiscountTransfer->requireQuantity()->requireUnitGrossAmount();
 }
Ejemplo n.º 2
0
 /**
  * @return void
  */
 public function testSaveDiscountMustNotSaveSalesDiscountCodesIfUsedCodeCanNotBeFound()
 {
     $discountSaver = $this->getDiscountOrderSaverMock(['persistSalesDiscount', 'persistSalesDiscountCode', 'getDiscountVoucherEntityByCode']);
     $discountSaver->expects($this->once())->method('persistSalesDiscount');
     $discountSaver->expects($this->never())->method('persistSalesDiscountCode');
     $discountSaver->expects($this->once())->method('getDiscountVoucherEntityByCode')->will($this->returnValue(false));
     $calculatedDiscountTransfer = new CalculatedDiscountTransfer();
     $calculatedDiscountTransfer->setVoucherCode(self::USED_CODE_1);
     $quoteTransfer = new QuoteTransfer();
     $orderItemTransfer = new ItemTransfer();
     $orderItemTransfer->addCalculatedDiscount($calculatedDiscountTransfer);
     $quoteTransfer->addItem($orderItemTransfer);
     $checkoutResponseTransfer = new CheckoutResponseTransfer();
     $saverOrderTransfer = new SaveOrderTransfer();
     $saverOrderTransfer->setIdSalesOrder(self::ID_SALES_ORDER);
     $saverOrderTransfer->setOrderItems($quoteTransfer->getItems());
     $checkoutResponseTransfer->setSaveOrder($saverOrderTransfer);
     $discountSaver->saveDiscounts($quoteTransfer, $checkoutResponseTransfer);
 }
Ejemplo n.º 3
0
 /**
  * @param \Generated\Shared\Transfer\CalculatedDiscountTransfer $calculatedDiscountTransfer
  * @param \Orm\Zed\Sales\Persistence\SpySalesDiscount $salesDiscountEntity
  *
  * @return void
  */
 protected function saveUsedCodes(CalculatedDiscountTransfer $calculatedDiscountTransfer, SpySalesDiscount $salesDiscountEntity)
 {
     $voucherCode = $calculatedDiscountTransfer->getVoucherCode();
     $discountVoucherEntity = $this->getDiscountVoucherEntityByCode($voucherCode);
     if ($discountVoucherEntity) {
         $salesDiscountCodeEntity = $this->getSalesDiscountCodeEntity();
         $salesDiscountCodeEntity->fromArray($discountVoucherEntity->toArray());
         $salesDiscountCodeEntity->setCodepoolName($discountVoucherEntity->getVoucherPool()->getName());
         $salesDiscountCodeEntity->setDiscount($salesDiscountEntity);
         if (!isset($this->voucherCodesUsed[$voucherCode])) {
             $this->voucherCodesUsed[$voucherCode] = $voucherCode;
         }
         $this->persistSalesDiscountCode($salesDiscountCodeEntity);
     }
 }
Ejemplo n.º 4
0
 /**
  * @param \Generated\Shared\Transfer\DiscountTransfer $discountTransfer
  *
  * @return \Generated\Shared\Transfer\CalculatedDiscountTransfer
  */
 protected function createBaseCalculatedDiscountTransfer(DiscountTransfer $discountTransfer)
 {
     $calculatedDiscountTransfer = new CalculatedDiscountTransfer();
     $calculatedDiscountTransfer->fromArray($discountTransfer->toArray(), true);
     return $calculatedDiscountTransfer;
 }