Пример #1
0
 /**
  * @covers ::equals
  */
 public function testEquals()
 {
     $taxAmountA = new Amount('US-CA 8.25%', 8.25);
     $taxAmountB = new Amount('US-CA 8.25%', 8.25);
     $this->assertTrue($taxAmountA->equals($taxAmountB));
     $taxAmountC = new Amount('TVA 20%', 8.25);
     $this->assertFalse($taxAmountA->equals($taxAmountC));
     $taxAmountD = new Amount('US-CA 8.25%', 8);
     $this->assertFalse($taxAmountA->equals($taxAmountD));
 }
Пример #2
0
 /**
  * @inheritdoc
  */
 public function buildOrderItemAmounts(OrderItemInterface $item, AmountsInterface $amounts = null)
 {
     if (null === $amounts) {
         $amounts = new Amounts();
     }
     if ($item->hasChildren()) {
         $itemAmounts = new Amounts();
         $children = $item->getChildren()->toArray();
         foreach ($children as $child) {
             $this->buildOrderItemAmounts($child, $itemAmounts);
         }
         $itemAmounts->multiply($item->getQuantity());
         $amounts->merge($itemAmounts);
     } else {
         $amount = new Amount($this->mode == self::MODE_NET ? $this->round($item->getNetPrice()) : $item->getNetPrice(), $item->getTaxRate(), $item->getTaxName());
         $amount->multiply($item->getQuantity());
         $amounts->add($amount);
     }
     // TODO Percent adjustment applied to children if any
     return $amounts;
 }