function it_executes_request(InvoiceNumberGeneratorInterface $invoiceNumberGenerator, CurrencyConverterInterface $currencyConverter, Convert $request, PaymentInterface $payment, OrderInterface $order, OrderItemInterface $orderItem, ProductVariantInterface $productVariant, ProductInterface $product)
 {
     $request->getTo()->willReturn('array');
     $payment->getId()->willReturn(19);
     $order->getId()->willReturn(92);
     $order->getId()->willReturn(92);
     $order->getCurrencyCode()->willReturn('PLN');
     $order->getTotal()->willReturn(22000);
     $order->getItems()->willReturn([$orderItem]);
     $order->getAdjustmentsTotalRecursively(AdjustmentInterface::TAX_ADJUSTMENT)->willReturn(0);
     $order->getOrderPromotionTotal()->willReturn(0);
     $order->getShippingTotal()->willReturn(2000);
     $orderItem->getVariant()->willReturn($productVariant);
     $orderItem->getDiscountedUnitPrice()->willReturn(20000);
     $orderItem->getQuantity()->willReturn(1);
     $productVariant->getProduct()->willReturn($product);
     $product->getName()->willReturn('Lamborghini Aventador Model');
     $request->getSource()->willReturn($payment);
     $payment->getOrder()->willReturn($order);
     $invoiceNumberGenerator->generate($order, $payment)->willReturn('19-92');
     $currencyConverter->convertFromBase(22000, 'PLN')->willReturn(88000);
     $currencyConverter->convertFromBase(20000, 'PLN')->willReturn(80000);
     $currencyConverter->convertFromBase(2000, 'PLN')->willReturn(8000);
     $details = ['PAYMENTREQUEST_0_INVNUM' => '19-92', 'PAYMENTREQUEST_0_CURRENCYCODE' => 'PLN', 'PAYMENTREQUEST_0_AMT' => 880.0, 'PAYMENTREQUEST_0_ITEMAMT' => 880.0, 'L_PAYMENTREQUEST_0_NAME0' => 'Lamborghini Aventador Model', 'L_PAYMENTREQUEST_0_AMT0' => 800.0, 'L_PAYMENTREQUEST_0_QTY0' => 1, 'L_PAYMENTREQUEST_0_NAME1' => 'Shipping Total', 'L_PAYMENTREQUEST_0_AMT1' => 80.0, 'L_PAYMENTREQUEST_0_QTY1' => 1];
     $request->setResult($details)->shouldBeCalled();
     $this->execute($request);
 }
 function it_does_nothing_if_there_are_no_shipment_taxes_on_order($adjustmentsFactory, $calculator, $taxRateResolver, Collection $shippingAdjustments, OrderInterface $order, ShipmentInterface $shipment, ShippingMethodInterface $shippingMethod, TaxRateInterface $taxRate, ZoneInterface $zone)
 {
     $order->getLastShipment()->willReturn($shipment);
     $shipment->getMethod()->willReturn($shippingMethod);
     $taxRateResolver->resolve($shippingMethod, ['zone' => $zone])->willReturn($taxRate);
     $order->getAdjustments(AdjustmentInterface::SHIPPING_ADJUSTMENT)->willReturn($shippingAdjustments);
     $shippingAdjustments->isEmpty()->willReturn(false);
     $order->getShippingTotal()->willReturn(1000);
     $calculator->calculate(1000, $taxRate)->willReturn(0);
     $adjustmentsFactory->createWithData(Argument::cetera())->shouldNotBeCalled();
     $order->addAdjustment(Argument::any())->shouldNotBeCalled();
     $this->apply($order, $zone);
 }
 /**
  * {@inheritdoc}
  */
 public function apply(OrderInterface $order, ZoneInterface $zone)
 {
     $shippingTotal = $order->getShippingTotal();
     if (0 === $shippingTotal) {
         return;
     }
     $taxRate = $this->taxRateResolver->resolve($this->getShippingMethod($order), ['zone' => $zone]);
     if (null === $taxRate) {
         return;
     }
     $taxAmount = $this->calculator->calculate($shippingTotal, $taxRate);
     if (0 === $taxAmount) {
         return;
     }
     $this->addAdjustment($order, $taxAmount, $taxRate->getLabel(), $taxRate->isIncludedInPrice());
 }
 /**
  * {@inheritdoc}
  */
 public function apply(OrderInterface $order, ZoneInterface $zone)
 {
     $lastShipment = $order->getLastShipment();
     if (!$lastShipment) {
         return;
     }
     $shippingAdjustments = $order->getAdjustments(AdjustmentInterface::SHIPPING_ADJUSTMENT);
     if ($shippingAdjustments->isEmpty()) {
         return;
     }
     $taxRate = $this->taxRateResolver->resolve($lastShipment->getMethod(), ['zone' => $zone]);
     if (null === $taxRate) {
         return;
     }
     $shippingPrice = $order->getShippingTotal();
     $taxAmount = $this->calculator->calculate($shippingPrice, $taxRate);
     if (0 === $taxAmount) {
         return;
     }
     $this->addAdjustment($order, $taxAmount, $taxRate->getLabel(), $taxRate->isIncludedInPrice());
 }
 function it_does_nothing_if_order_has_0_shipping_total(TaxRateResolverInterface $taxRateResolver, OrderInterface $order, ZoneInterface $zone)
 {
     $order->getShippingTotal()->willReturn(0);
     $taxRateResolver->resolve(Argument::any())->shouldNotBeCalled();
     $order->addAdjustment(Argument::any())->shouldNotBeCalled();
     $this->apply($order, $zone);
 }