/**
  * @return void
  */
 public function testSetTaxRateWhenExemptTaxRateUsedAndCountryMatchingShouldUseCountryRate()
 {
     $shipmentMethodEntity = $this->createShipmentMethodWithTaxSet(20, 'DE');
     $quoteTransfer = new QuoteTransfer();
     $addressTransfer = new AddressTransfer();
     $addressTransfer->setIso2Code('DE');
     $quoteTransfer->setShippingAddress($addressTransfer);
     $shipmentTransfer = new ShipmentTransfer();
     $shipmentMethodTransfer = new ShipmentMethodTransfer();
     $shipmentMethodTransfer->fromArray($shipmentMethodEntity->toArray(), true);
     $shipmentTransfer->setMethod($shipmentMethodTransfer);
     $quoteTransfer->setShipment($shipmentTransfer);
     $shipmentFacadeTest = $this->createShipmentFacade();
     $shipmentFacadeTest->calculateShipmentTaxRate($quoteTransfer);
     $this->assertEquals('20.00', $shipmentMethodTransfer->getTaxRate());
 }
示例#2
0
 /**
  * @param \Symfony\Component\HttpFoundation\Request $request
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function editAction(Request $request)
 {
     $idMethod = $this->castId($request->query->get(self::ID_METHOD_PARAMETER));
     if ($this->getFacade()->hasMethod($idMethod)) {
         $dataProvider = $this->getFactory()->createMethodFormDataProvider();
         $form = $this->getFactory()->createMethodForm($dataProvider->getData($idMethod), $dataProvider->getOptions())->handleRequest($request);
         if ($form->isValid()) {
             $data = $form->getData();
             $methodTransfer = new ShipmentMethodTransfer();
             $methodTransfer->fromArray($data, true);
             $this->getFacade()->updateMethod($methodTransfer);
             $this->addSuccessMessage('Shipment method ' . $methodTransfer->getName() . ' updated');
             return $this->redirectResponse('/shipment');
         }
         return $this->viewResponse(['form' => $form->createView()]);
     }
     return $this->redirectResponse('/shipment');
 }
示例#3
0
 /**
  * @param \Orm\Zed\Sales\Persistence\SpySalesOrder $orderEntity
  * @param \Generated\Shared\Transfer\OrderTransfer $orderTransfer
  *
  * @return void
  */
 protected function hydrateShipmentMethodToOrderTransfer(SpySalesOrder $orderEntity, OrderTransfer $orderTransfer)
 {
     $shipmentMethodTransfer = new ShipmentMethodTransfer();
     $shipmentMethodEntity = $orderEntity->getShipmentMethod();
     if (!empty($shipmentMethodEntity)) {
         $shipmentMethodTransfer->fromArray($shipmentMethodEntity->toArray(), true);
         $shipmentMethodTransfer->setCarrierName($shipmentMethodEntity->getShipmentCarrier()->getName());
         $orderTransfer->setShipmentMethod($shipmentMethodTransfer);
     }
 }
示例#4
0
 /**
  * @param int $idMethod
  *
  * @return \Generated\Shared\Transfer\ShipmentMethodTransfer
  */
 public function getShipmentMethodTransferById($idMethod)
 {
     $shipmentMethodTransfer = new ShipmentMethodTransfer();
     $methodQuery = $this->queryContainer->queryMethodByIdMethod($idMethod);
     $shipmentMethodTransferEntity = $methodQuery->findOne();
     $shipmentMethodTransfer->fromArray($shipmentMethodTransferEntity->toArray());
     return $shipmentMethodTransfer;
 }