当前位置: 首页>>代码示例>>PHP>>正文


PHP Data::getCalculatedTaxes方法代码示例

本文整理汇总了PHP中Magento\Tax\Helper\Data::getCalculatedTaxes方法的典型用法代码示例。如果您正苦于以下问题:PHP Data::getCalculatedTaxes方法的具体用法?PHP Data::getCalculatedTaxes怎么用?PHP Data::getCalculatedTaxes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Tax\Helper\Data的用法示例。


在下文中一共展示了Data::getCalculatedTaxes方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getFullTaxInfo

 /**
  * Get full information about taxes applied to order
  *
  * @return array
  */
 public function getFullTaxInfo()
 {
     /** @var $source \Magento\Sales\Model\Order */
     $source = $this->getOrder();
     $taxClassAmount = array();
     if ($source instanceof \Magento\Sales\Model\Order) {
         $taxClassAmount = $this->_taxHelper->getCalculatedTaxes($source);
         if (empty($taxClassAmount)) {
             $rates = $this->_taxOrderFactory->create()->getCollection()->loadByOrder($source)->toArray();
             $taxClassAmount = $this->_taxCalculation->reproduceProcess($rates['items']);
         }
     }
     return $taxClassAmount;
 }
开发者ID:zhangjiachao,项目名称:magento2,代码行数:19,代码来源:Tax.php

示例2: getFullTaxInfo

 /**
  * Get array of arrays with tax information for display in PDF
  * array(
  *  $index => array(
  *      'amount'   => $amount,
  *      'label'    => $label,
  *      'font_size'=> $font_size
  *  )
  * )
  *
  * @return array
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function getFullTaxInfo()
 {
     $fontSize = $this->getFontSize() ? $this->getFontSize() : 7;
     $taxClassAmount = $this->_taxHelper->getCalculatedTaxes($this->getOrder());
     if (!empty($taxClassAmount)) {
         foreach ($taxClassAmount as &$tax) {
             $percent = $tax['percent'] ? ' (' . $tax['percent'] . '%)' : '';
             $tax['amount'] = $this->getAmountPrefix() . $this->getOrder()->formatPriceTxt($tax['tax_amount']);
             $tax['label'] = __($tax['title']) . $percent . ':';
             $tax['font_size'] = $fontSize;
         }
     } else {
         /** @var $orders \Magento\Tax\Model\Resource\Sales\Order\Tax\Collection */
         $orders = $this->_taxOrdersFactory->create();
         $rates = $orders->loadByOrder($this->getOrder())->toArray();
         $fullInfo = $this->_taxCalculation->reproduceProcess($rates['items']);
         $tax_info = [];
         if ($fullInfo) {
             foreach ($fullInfo as $info) {
                 if (isset($info['hidden']) && $info['hidden']) {
                     continue;
                 }
                 $_amount = $info['amount'];
                 foreach ($info['rates'] as $rate) {
                     $percent = $rate['percent'] ? ' (' . $rate['percent'] . '%)' : '';
                     $tax_info[] = ['amount' => $this->getAmountPrefix() . $this->getOrder()->formatPriceTxt($_amount), 'label' => __($rate['title']) . $percent . ':', 'font_size' => $fontSize];
                 }
             }
         }
         $taxClassAmount = $tax_info;
     }
     return $taxClassAmount;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:46,代码来源:DefaultTotal.php

示例3: testGetCalculatedTaxesForOrderItems

 /**
  * @dataProvider getCalculatedTaxesForOrderItemsDataProvider
  */
 public function testGetCalculatedTaxesForOrderItems($orderData, $invoiceData, $expectedResults)
 {
     $orderId = $orderData['order_id'];
     $orderShippingTaxAmount = isset($orderData['shipping_tax_amount']) ? $orderData['shipping_tax_amount'] : 0;
     $orderTaxDetails = $orderData['order_tax_details'];
     /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Sales\Model\Order $orderMock */
     $orderMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order')->disableOriginalConstructor()->getMock();
     $orderMock->expects($this->once())->method('getId')->willReturn($orderId);
     $orderMock->expects($this->once())->method('getShippingTaxAmount')->willReturn($orderShippingTaxAmount);
     $orderTaxDetailsMock = $this->mapOrderTaxItemDetail($orderTaxDetails);
     $this->orderTaxManagementMock->expects($this->any())->method('getOrderTaxDetails')->with($orderId)->will($this->returnValue($orderTaxDetailsMock));
     $invoiceShippingTaxAmount = isset($invoiceData['shipping_tax_amount']) ? $invoiceData['shipping_tax_amount'] : 0;
     $invoiceItems = $invoiceData['invoice_items'];
     /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Sales\Model\Order\Invoice $source */
     $source = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Invoice')->disableOriginalConstructor()->getMock();
     $source->expects($this->once())->method('getOrder')->willReturn($orderMock);
     $source->expects($this->once())->method('getShippingTaxAmount')->willReturn($invoiceShippingTaxAmount);
     $source->expects($this->once())->method('getItems')->willReturn($invoiceItems);
     $this->priceCurrencyMock->expects($this->any())->method('round')->will($this->returnCallback(function ($arg) {
         return round($arg, 2);
     }));
     $result = $this->helper->getCalculatedTaxes($source);
     foreach ($result as $index => $appliedTax) {
         $expectedTax = $expectedResults[$index];
         foreach ($appliedTax as $attr => $value) {
             $this->assertEquals($expectedTax[$attr], $value, "The " . $attr . " of tax does not match");
         }
     }
 }
开发者ID:tingyeeh,项目名称:magento2,代码行数:32,代码来源:DataTest.php

示例4: getFullTaxInfo

 /**
  * Get full information about taxes applied to order
  *
  * @return array
  */
 public function getFullTaxInfo()
 {
     $source = $this->getSource();
     if (!$source instanceof \Magento\Sales\Model\Order\Invoice && !$source instanceof \Magento\Sales\Model\Order\Creditmemo) {
         $source = $this->getOrder();
     }
     $taxClassAmount = [];
     if (empty($source)) {
         return $taxClassAmount;
     }
     $taxClassAmount = $this->_taxHelper->getCalculatedTaxes($source);
     if (empty($taxClassAmount)) {
         $rates = $this->_taxOrderFactory->create()->getCollection()->loadByOrder($source)->toArray();
         $taxClassAmount = $this->_taxCalculation->reproduceProcess($rates['items']);
     }
     return $taxClassAmount;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:22,代码来源:Tax.php

示例5: commonTestGetCalculatedTaxesInvoiceCreditmemo

 protected function commonTestGetCalculatedTaxesInvoiceCreditmemo($source, $orderTaxDetails, $expectedResults)
 {
     $this->orderTaxService->expects($this->once())->method('getOrderTaxDetails')->with($source->getId())->will($this->returnValue($orderTaxDetails));
     $orderTaxDetails = $this->taxHelper->getCalculatedTaxes($source);
     $this->assertEquals($expectedResults, $orderTaxDetails);
 }
开发者ID:zhangjiachao,项目名称:magento2,代码行数:6,代码来源:DataTest.php


注:本文中的Magento\Tax\Helper\Data::getCalculatedTaxes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。