Example #1
0
 function it_returns_tax_of_all_units_and_both_neutral_and_non_neutral_tax_adjustments(OrderItemUnitInterface $orderItemUnit1, OrderItemUnitInterface $orderItemUnit2, AdjustmentInterface $nonNeutralTaxAdjustment, AdjustmentInterface $neutralTaxAdjustment)
 {
     $orderItemUnit1->getTotal()->willReturn(1200);
     $orderItemUnit1->getTaxTotal()->willReturn(200);
     $orderItemUnit1->getOrderItem()->willReturn($this);
     $orderItemUnit2->getTotal()->willReturn(1120);
     $orderItemUnit2->getTaxTotal()->willReturn(120);
     $orderItemUnit2->getOrderItem()->willReturn($this);
     $this->addUnit($orderItemUnit1);
     $this->addUnit($orderItemUnit2);
     $neutralTaxAdjustment->isNeutral()->willReturn(true);
     $neutralTaxAdjustment->getType()->willReturn(AdjustmentInterface::TAX_ADJUSTMENT);
     $neutralTaxAdjustment->getAmount()->willReturn(200);
     $nonNeutralTaxAdjustment->isNeutral()->willReturn(false);
     $nonNeutralTaxAdjustment->getType()->willReturn(AdjustmentInterface::TAX_ADJUSTMENT);
     $nonNeutralTaxAdjustment->getAmount()->willReturn(300);
     $neutralTaxAdjustment->setAdjustable($this)->shouldBeCalled();
     $nonNeutralTaxAdjustment->setAdjustable($this)->shouldBeCalled();
     $this->addAdjustment($neutralTaxAdjustment);
     $this->addAdjustment($nonNeutralTaxAdjustment);
     $this->getTaxTotal()->shouldReturn(820);
 }
Example #2
0
 function it_does_not_include_shipping_promotion_adjustment_in_order_promotion_total(AdjustmentInterface $shippingPromotionAdjustment, OrderItemInterface $orderItem1)
 {
     $orderItem1->getTotal()->willReturn(500);
     $orderItem1->getAdjustmentsTotalRecursively(AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT)->willReturn(-400);
     $shippingPromotionAdjustment->getType()->willReturn(AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT);
     $shippingPromotionAdjustment->isNeutral()->willReturn(false);
     $shippingPromotionAdjustment->getAmount()->willReturn(-100);
     $orderItem1->setOrder($this)->shouldBeCalled();
     $this->addItem($orderItem1);
     $shippingPromotionAdjustment->setAdjustable($this)->shouldBeCalled();
     $this->addAdjustment($shippingPromotionAdjustment);
     $this->getOrderPromotionTotal()->shouldReturn(-400);
 }
 function it_returns_only_sum_of_neutral_and_non_neutral_tax_adjustments_as_tax_total(OrderItemInterface $orderItem, AdjustmentInterface $nonNeutralTaxAdjustment, AdjustmentInterface $neutralTaxAdjustment, AdjustmentInterface $notTaxAdjustment)
 {
     $neutralTaxAdjustment->isNeutral()->willReturn(true);
     $neutralTaxAdjustment->getType()->willReturn(AdjustmentInterface::TAX_ADJUSTMENT);
     $neutralTaxAdjustment->getAmount()->willReturn(200);
     $nonNeutralTaxAdjustment->isNeutral()->willReturn(false);
     $nonNeutralTaxAdjustment->getType()->willReturn(AdjustmentInterface::TAX_ADJUSTMENT);
     $nonNeutralTaxAdjustment->getAmount()->willReturn(300);
     $notTaxAdjustment->isNeutral()->willReturn(false);
     $notTaxAdjustment->getType()->willReturn(AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT);
     $notTaxAdjustment->getAmount()->willReturn(100);
     $orderItem->recalculateUnitsTotal()->shouldBeCalled();
     $neutralTaxAdjustment->setAdjustable($this)->shouldBeCalled();
     $nonNeutralTaxAdjustment->setAdjustable($this)->shouldBeCalled();
     $notTaxAdjustment->setAdjustable($this)->shouldBeCalled();
     $this->addAdjustment($neutralTaxAdjustment);
     $this->addAdjustment($nonNeutralTaxAdjustment);
     $this->addAdjustment($notTaxAdjustment);
     $this->getTaxTotal()->shouldReturn(500);
 }
Example #4
0
 function it_should_remove_tax_adjustments(AdjustmentInterface $shippingAdjustment, AdjustmentInterface $taxAdjustment)
 {
     $shippingAdjustment->getLabel()->willReturn(AdjustmentInterface::SHIPPING_ADJUSTMENT);
     $shippingAdjustment->setAdjustable($this)->shouldBeCalled();
     $taxAdjustment->getLabel()->willReturn(AdjustmentInterface::TAX_ADJUSTMENT);
     $taxAdjustment->setAdjustable($this)->shouldBeCalled();
     $this->addAdjustment($shippingAdjustment);
     $this->addAdjustment($taxAdjustment);
     $this->getAdjustments()->count()->shouldReturn(2);
     //both adjustments have been added
     $taxAdjustment->isLocked()->willReturn(false);
     $taxAdjustment->setAdjustable(null)->shouldBeCalled();
     $this->removeAdjustments(AdjustmentInterface::TAX_ADJUSTMENT);
     $this->getAdjustments()->count()->shouldReturn(1);
     //one has been removed
     $this->getAdjustments(AdjustmentInterface::TAX_ADJUSTMENT)->count()->shouldReturn(0);
     //tax adjustment has been removed
 }
Example #5
0
 /**
  * Helper method
  *
  * @param OrderInterface      $order
  * @param AdjustmentInterface $shippingAdjustment
  * @param AdjustmentInterface $taxAdjustment
  */
 protected function addShippingAndTaxAdjustments(OrderInterface $order, AdjustmentInterface $shippingAdjustment, AdjustmentInterface $taxAdjustment)
 {
     $shippingAdjustment->getLabel()->willReturn(AdjustmentInterface::SHIPPING_ADJUSTMENT);
     $shippingAdjustment->setAdjustable($order)->shouldBeCalled();
     $taxAdjustment->getLabel()->willReturn(AdjustmentInterface::TAX_ADJUSTMENT);
     $taxAdjustment->setAdjustable($order)->shouldBeCalled();
     $order->addAdjustment($shippingAdjustment);
     $order->addAdjustment($taxAdjustment);
 }
Example #6
0
 function it_returns_promotions_total_recursively(AdjustmentInterface $orderPromotionAdjustment, AdjustmentInterface $orderItemPromotionAdjustment, OrderItemInterface $orderItem)
 {
     $orderPromotionAdjustment->getAmount()->willReturn(10000);
     $orderItemPromotionAdjustment->getAmount()->willReturn(5000);
     $orderPromotionAdjustment->isNeutral()->willReturn(false);
     $orderItemPromotionAdjustment->isNeutral()->willReturn(false);
     $orderPromotionAdjustment->getType()->willReturn(AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT);
     $orderItemPromotionAdjustment->getType()->willReturn(AdjustmentInterface::ORDER_ITEM_PROMOTION_ADJUSTMENT);
     $orderPromotionAdjustment->setAdjustable($this)->shouldBeCalled();
     $orderItem->getAdjustmentsRecursively(AdjustmentInterface::ORDER_ITEM_PROMOTION_ADJUSTMENT)->willReturn([$orderItemPromotionAdjustment]);
     $orderItem->setOrder($this)->shouldBeCalled();
     $orderItem->getTotal()->willReturn(15000);
     $orderItem->getAdjustmentsRecursively(AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT)->willReturn([]);
     $this->addItem($orderItem);
     $this->addAdjustment($orderPromotionAdjustment);
     $this->getPromotionsTotalRecursively()->shouldReturn(15000);
 }