コード例 #1
0
 /**
  * Convert applied tax from array to data object
  *
  * @param TaxDetailsDataObjectFactory $appliedTaxDataObjectFactory
  * @param array $itemAppliedTax
  * @param AppliedTax $existingAppliedTax
  * @return AppliedTax
  */
 protected function convertToAppliedTaxDataObject(TaxDetailsDataObjectFactory $appliedTaxDataObjectFactory, $itemAppliedTax, AppliedTax $existingAppliedTax = null)
 {
     // if there is an existingAppliedTax, include its amount and baseAmount
     $amount = $baseAmount = 0;
     if ($existingAppliedTax !== null) {
         $amount = $existingAppliedTax->getAmount();
         $baseAmount = $existingAppliedTax->getBaseAmount();
     }
     return $appliedTaxDataObjectFactory->create()->setCode($itemAppliedTax['code'])->setTitle($itemAppliedTax['title'])->setPercent($itemAppliedTax['tax_percent'])->setAmount($itemAppliedTax['real_amount'] + $amount)->setBaseAmount($itemAppliedTax['real_base_amount'] + $baseAmount);
 }
コード例 #2
0
 /**
  * @param array $orderItemAppliedTaxes
  * @return void
  * @dataProvider getOrderTaxDetailsDataProvider
  */
 public function testGetOrderTaxDetails($orderItemAppliedTaxes)
 {
     $orderId = 1;
     $data = $orderItemAppliedTaxes[0];
     $this->orderFactoryMock->expects($this->atLeastOnce())->method('create')->will($this->returnValue($this->orderMock));
     $this->orderMock->expects($this->once())->method('load')->with($orderId)->will($this->returnSelf());
     $this->taxItemFactoryMock->expects($this->once())->method('create')->willReturn($this->taxItemResourceMock);
     $this->taxItemResourceMock->expects($this->once())->method('getTaxItemsByOrderId')->with($orderId)->will($this->returnValue($orderItemAppliedTaxes));
     $this->assertEquals($this->orderTaxDetailsDataObject, $this->taxManagement->getOrderTaxDetails($orderId));
     $this->assertEquals($data['code'], $this->appliedTaxDataObject->getCode());
     $this->assertEquals($data['title'], $this->appliedTaxDataObject->getTitle());
     $this->assertEquals($data['tax_percent'], $this->appliedTaxDataObject->getPercent());
     $this->assertEquals($data['real_amount'], $this->appliedTaxDataObject->getAmount());
     $this->assertEquals($data['real_base_amount'], $this->appliedTaxDataObject->getBaseAmount());
 }