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


PHP OrderDetail::getTaxCalculatorStatic方法代码示例

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


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

示例1: getTaxCalculator

 /**
  * Returns the tax calculator associated to this order detail.
  * @since 1.5.0.1
  * @return TaxCalculator
  */
 public function getTaxCalculator()
 {
     return OrderDetail::getTaxCalculatorStatic($this->id);
 }
开发者ID:nmardones,项目名称:PrestaShop,代码行数:9,代码来源:OrderDetail.php

示例2: setProductPrices

 /**
  * Marked as deprecated but should not throw any "deprecated" message
  * This function is used in order to keep front office backward compatibility 14 -> 1.5
  * (Order History)
  *
  * @deprecated
  */
 public function setProductPrices(&$row)
 {
     $tax_calculator = OrderDetail::getTaxCalculatorStatic((int) $row['id_order_detail']);
     $row['tax_calculator'] = $tax_calculator;
     $row['tax_rate'] = $tax_calculator->getTotalRate();
     $row['product_price'] = Tools::ps_round($row['unit_price_tax_excl'], 2);
     $row['product_price_wt'] = Tools::ps_round($row['unit_price_tax_incl'], 2);
     $group_reduction = 1;
     if ($row['group_reduction'] > 0) {
         $group_reduction = 1 - $row['group_reduction'] / 100;
     }
     $row['product_price_wt_but_ecotax'] = $row['product_price_wt'] - $row['ecotax'];
     $row['total_wt'] = $row['total_price_tax_incl'];
     $row['total_price'] = $row['total_price_tax_excl'];
 }
开发者ID:TheTypoMaster,项目名称:neotienda,代码行数:22,代码来源:NeoExchanges.php

示例3: getProductTaxesBreakdown

 public function getProductTaxesBreakdown()
 {
     $tmp_tax_infos = array();
     foreach ($this->order_slip->getOrdersSlipDetail((int) $this->order_slip->id) as $order_slip_details) {
         $tax_calculator = OrderDetail::getTaxCalculatorStatic((int) $order_slip_details['id_order_detail']);
         $tax_amount = $tax_calculator->getTaxesAmount($order_slip_details['amount_tax_excl']);
         if ($this->order->useOneAfterAnotherTaxComputationMethod()) {
             foreach ($tax_amount as $tax_id => $amount) {
                 $tax = new Tax((int) $tax_id);
                 if (!isset($total_tax_amount[$tax->rate])) {
                     $tmp_tax_infos[$tax->rate]['name'] = $tax->name;
                     $tmp_tax_infos[$tax->rate]['total_price_tax_excl'] = $order_slip_details['amount_tax_excl'];
                     $tmp_tax_infos[$tax->rate]['total_amount'] = $amount;
                 } else {
                     $tmp_tax_infos[$tax->rate]['total_price_tax_excl'] += $order_slip_details['amount_tax_excl'];
                     $tmp_tax_infos[$tax->rate]['total_amount'] += $amount;
                 }
             }
         } else {
             $infos = array('total_price_tax_excl' => 0, 'total_amount' => 0);
             $tax_rate = 0;
             foreach ($tax_amount as $tax_id => $amount) {
                 $tax = new Tax((int) $tax_id);
                 $tax_rate += $tax->rate;
                 $infos['total_price_tax_excl'] += $order_slip_details['amount_tax_excl'];
                 $infos['total_amount'] += $amount;
             }
             $tmp_tax_infos[(string) number_format($tax_rate, 3)] = $infos;
         }
     }
     return $tmp_tax_infos;
 }
开发者ID:jicheng17,项目名称:vipinsg,代码行数:32,代码来源:HTMLTemplateOrderSlip.php

示例4: getProductTaxesBreakdown

 public function getProductTaxesBreakdown()
 {
     $tmp_tax_infos = array();
     $infos = array('total_price_tax_excl' => 0, 'total_amount' => 0);
     foreach ($this->order_slip->getOrdersSlipDetail((int) $this->order_slip->id) as $order_slip_details) {
         $tax_calculator = OrderDetail::getTaxCalculatorStatic((int) $order_slip_details['id_order_detail']);
         $tax_amount = $tax_calculator->getTaxesAmount($order_slip_details['amount_tax_excl']);
         if ($this->order->useOneAfterAnotherTaxComputationMethod()) {
             foreach ($tax_amount as $tax_id => $amount) {
                 $tax = new Tax((int) $tax_id);
                 if (!isset($total_tax_amount[$tax->rate])) {
                     $tmp_tax_infos[$tax->rate]['name'] = $tax->name;
                     $tmp_tax_infos[$tax->rate]['total_price_tax_excl'] = $order_slip_details['amount_tax_excl'];
                     $tmp_tax_infos[$tax->rate]['total_amount'] = $amount;
                 } else {
                     $tmp_tax_infos[$tax->rate]['total_price_tax_excl'] += $order_slip_details['amount_tax_excl'];
                     $tmp_tax_infos[$tax->rate]['total_amount'] += $amount;
                 }
             }
         } else {
             $tax_rate = 0;
             foreach ($tax_amount as $tax_id => $amount) {
                 $tax = new Tax((int) $tax_id);
                 $tax_rate = $tax->rate;
                 $infos['total_price_tax_excl'] += (double) Tools::ps_round($order_slip_details['amount_tax_excl'], 2);
                 $infos['total_amount'] += (double) Tools::ps_round($amount, 2);
             }
             $tmp_tax_infos[(string) number_format($tax_rate, 3)] = $infos;
         }
     }
     // Delete ecotax from the total
     $ecotax = $this->order_slip->getEcoTaxTaxesBreakdown();
     if ($this->order_slip->order_slip_type == 1) {
         foreach ($tmp_tax_infos as $rate => &$row) {
             $row['total_price_tax_excl'] -= Db::getInstance()->getValue('SELECT `value_tax_excl` FROM ' . _DB_PREFIX_ . 'order_cart_rule WHERE id_order = ' . $this->order_slip->id_order);
             $row['total_amount'] -= Db::getInstance()->getValue('SELECT `value` FROM ' . _DB_PREFIX_ . 'order_cart_rule WHERE id_order = ' . $this->order_slip->id_order) - $row['total_price_tax_excl'];
         }
     }
     if ($ecotax) {
         foreach ($tmp_tax_infos as $rate => &$row) {
             if (!isset($ecotax[$rate])) {
                 continue;
             }
             $row['total_price_tax_excl'] -= $ecotax[$rate]['ecotax_tax_excl'];
             $row['total_amount'] -= $ecotax[$rate]['ecotax_tax_incl'] - $ecotax[$rate]['ecotax_tax_excl'];
         }
     }
     return $tmp_tax_infos;
 }
开发者ID:ecssjapan,项目名称:guiding-you-afteropen,代码行数:49,代码来源:HTMLTemplateOrderSlip.php

示例5: getProductTaxesDetails

 /**
  * By default this function was made for invoice, to compute tax amounts and balance delta (because of computation made on round values).
  * If you provide $limitToOrderDetails, only these item will be taken into account. This option is usefull for order slip for example,
  * where only sublist of the order is refunded.
  *
  * @param $limitToOrderDetails Optional array of OrderDetails to take into account. False by default to take all OrderDetails from the current Order.
  * @return array A list of tax rows applied to the given OrderDetails (or all OrderDetails linked to the current Order).
  */
 public function getProductTaxesDetails($limitToOrderDetails = false)
 {
     $round_type = $this->round_type;
     if ($round_type == 0) {
         // if this is 0, it means the field did not exist
         // at the time the order was made.
         // Set it to old type, which was closest to line.
         $round_type = Order::ROUND_LINE;
     }
     // compute products discount
     $order_discount_tax_excl = $this->total_discounts_tax_excl;
     $free_shipping_tax = 0;
     $product_specific_discounts = array();
     $expected_total_base = $this->total_products - $this->total_discounts_tax_excl;
     foreach ($this->getCartRules() as $order_cart_rule) {
         if ($order_cart_rule['free_shipping'] && $free_shipping_tax === 0) {
             $free_shipping_tax = $this->total_shipping_tax_incl - $this->total_shipping_tax_excl;
             $order_discount_tax_excl -= $this->total_shipping_tax_excl;
             $expected_total_base += $this->total_shipping_tax_excl;
         }
         $cart_rule = new CartRule($order_cart_rule['id_cart_rule']);
         if ($cart_rule->reduction_product > 0) {
             if (empty($product_specific_discounts[$cart_rule->reduction_product])) {
                 $product_specific_discounts[$cart_rule->reduction_product] = 0;
             }
             $product_specific_discounts[$cart_rule->reduction_product] += $order_cart_rule['value_tax_excl'];
             $order_discount_tax_excl -= $order_cart_rule['value_tax_excl'];
         }
     }
     $products_tax = $this->total_products_wt - $this->total_products;
     $discounts_tax = $this->total_discounts_tax_incl - $this->total_discounts_tax_excl;
     // We add $free_shipping_tax because when there is free shipping, the tax that would
     // be paid if there wasn't is included in $discounts_tax.
     $expected_total_tax = $products_tax - $discounts_tax + $free_shipping_tax;
     $actual_total_tax = 0;
     $actual_total_base = 0;
     $order_detail_tax_rows = array();
     $breakdown = array();
     // Get order_details
     $order_details = $limitToOrderDetails ? $limitToOrderDetails : $this->getOrderDetailList();
     $order_ecotax_tax = 0;
     $tax_rates = array();
     foreach ($order_details as $order_detail) {
         $id_order_detail = $order_detail['id_order_detail'];
         $tax_calculator = OrderDetail::getTaxCalculatorStatic($id_order_detail);
         // TODO: probably need to make an ecotax tax breakdown here instead,
         // but it seems unlikely there will be different tax rates applied to the
         // ecotax in the same order in the real world
         $unit_ecotax_tax = $order_detail['ecotax'] * $order_detail['ecotax_tax_rate'] / 100.0;
         $order_ecotax_tax += $order_detail['product_quantity'] * $unit_ecotax_tax;
         $discount_ratio = 0;
         if ($this->total_products > 0) {
             $discount_ratio = ($order_detail['unit_price_tax_excl'] + $order_detail['ecotax']) / $this->total_products;
         }
         // share of global discount
         $discounted_price_tax_excl = $order_detail['unit_price_tax_excl'] - $discount_ratio * $order_discount_tax_excl;
         // specific discount
         if (!empty($product_specific_discounts[$order_detail['product_id']])) {
             $discounted_price_tax_excl -= $product_specific_discounts[$order_detail['product_id']];
         }
         $quantity = $order_detail['product_quantity'];
         foreach ($tax_calculator->taxes as $tax) {
             $tax_rates[$tax->id] = $tax->rate;
         }
         foreach ($tax_calculator->getTaxesAmount($discounted_price_tax_excl) as $id_tax => $unit_amount) {
             $total_tax_base = 0;
             switch ($round_type) {
                 case Order::ROUND_ITEM:
                     $total_tax_base = $quantity * Tools::ps_round($discounted_price_tax_excl, _PS_PRICE_COMPUTE_PRECISION_, $this->round_mode);
                     $total_amount = $quantity * Tools::ps_round($unit_amount, _PS_PRICE_COMPUTE_PRECISION_, $this->round_mode);
                     break;
                 case Order::ROUND_LINE:
                     $total_tax_base = Tools::ps_round($quantity * $discounted_price_tax_excl, _PS_PRICE_COMPUTE_PRECISION_, $this->round_mode);
                     $total_amount = Tools::ps_round($quantity * $unit_amount, _PS_PRICE_COMPUTE_PRECISION_, $this->round_mode);
                     break;
                 case Order::ROUND_TOTAL:
                     $total_tax_base = $quantity * $discounted_price_tax_excl;
                     $total_amount = $quantity * $unit_amount;
                     break;
             }
             if (!isset($breakdown[$id_tax])) {
                 $breakdown[$id_tax] = array('tax_base' => 0, 'tax_amount' => 0);
             }
             $breakdown[$id_tax]['tax_base'] += $total_tax_base;
             $breakdown[$id_tax]['tax_amount'] += $total_amount;
             $order_detail_tax_rows[] = array('id_order_detail' => $id_order_detail, 'id_tax' => $id_tax, 'tax_rate' => $tax_rates[$id_tax], 'unit_tax_base' => $discounted_price_tax_excl, 'total_tax_base' => $total_tax_base, 'unit_amount' => $unit_amount, 'total_amount' => $total_amount);
         }
     }
     if (!empty($order_detail_tax_rows)) {
         foreach ($breakdown as $data) {
             $actual_total_tax += Tools::ps_round($data['tax_amount'], _PS_PRICE_COMPUTE_PRECISION_, $this->round_mode);
             $actual_total_base += Tools::ps_round($data['tax_base'], _PS_PRICE_COMPUTE_PRECISION_, $this->round_mode);
//.........这里部分代码省略.........
开发者ID:ekachandrasetiawan,项目名称:BeltcareCom,代码行数:101,代码来源:Order.php


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