/** * Check if tax calculation type and price display settings are compatible * * Invalid settings if * Tax Calculation Method Based On 'Total' or 'Row' * and at least one Price Display Settings has 'Including and Excluding Tax' value * * @param null|int|bool|string|\Magento\Store\Model\Store $store $store * @return bool */ public function checkDisplaySettings($store = null) { if ($this->taxConfig->getAlgorithm($store) == \Magento\Tax\Model\Calculation::CALC_UNIT_BASE) { return true; } return $this->taxConfig->getPriceDisplayType($store) != \Magento\Tax\Model\Config::DISPLAY_TYPE_BOTH && $this->taxConfig->getShippingPriceDisplayType($store) != \Magento\Tax\Model\Config::DISPLAY_TYPE_BOTH && !$this->taxConfig->displayCartPricesBoth($store) && !$this->taxConfig->displayCartSubtotalBoth($store) && !$this->taxConfig->displayCartShippingBoth($store) && !$this->taxConfig->displaySalesPricesBoth($store) && !$this->taxConfig->displaySalesSubtotalBoth($store) && !$this->taxConfig->displaySalesShippingBoth($store); }
/** * Check if we need display both sobtotals * * @return bool */ public function displayBoth() { /** * Check without store parameter - we wil get admin configuration value */ return $this->_taxConfig->displayCartSubtotalBoth(); }
/** * Add tax totals information to address object * * @param \Magento\Quote\Model\Quote $quote * @param Address\Total $total * @return array|null * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) */ public function fetch(\Magento\Quote\Model\Quote $quote, \Magento\Quote\Model\Quote\Address\Total $total) { $totals = []; $store = $quote->getStore(); $applied = $total->getAppliedTaxes(); if (is_string($applied)) { $applied = unserialize($applied); } $amount = $total->getTaxAmount(); if ($amount == null) { $this->enhanceTotalData($quote, $total); $amount = $total->getTaxAmount(); } $taxAmount = $amount + $total->getTotalAmount('discount_tax_compensation'); $area = null; if ($this->_config->displayCartTaxWithGrandTotal($store) && $total->getGrandTotal()) { $area = 'taxes'; } $totals[] = ['code' => $this->getCode(), 'title' => __('Tax'), 'full_info' => $applied ? $applied : [], 'value' => $amount, 'area' => $area]; /** * Modify subtotal */ if ($this->_config->displayCartSubtotalBoth($store) || $this->_config->displayCartSubtotalInclTax($store)) { if ($total->getSubtotalInclTax() > 0) { $subtotalInclTax = $total->getSubtotalInclTax(); } else { $subtotalInclTax = $total->getSubtotal() + $taxAmount - $total->getShippingTaxAmount(); } $totals[] = ['code' => 'subtotal', 'title' => __('Subtotal'), 'value' => $subtotalInclTax, 'value_incl_tax' => $subtotalInclTax, 'value_excl_tax' => $total->getSubtotal()]; } if (empty($totals)) { return null; } return $totals; }
/** * Add tax totals information to address object * * @param Address $address * @return $this * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function fetch(Address $address) { $applied = $address->getAppliedTaxes(); $store = $address->getQuote()->getStore(); $amount = $address->getTaxAmount(); $items = $this->_getAddressItems($address); $discountTaxCompensation = 0; foreach ($items as $item) { $discountTaxCompensation += $item->getDiscountTaxCompensation(); } $taxAmount = $amount + $discountTaxCompensation; $area = null; if ($this->_config->displayCartTaxWithGrandTotal($store) && $address->getGrandTotal()) { $area = 'taxes'; } if ($amount != 0 || $this->_config->displayCartZeroTax($store)) { $address->addTotal(['code' => $this->getCode(), 'title' => __('Tax'), 'full_info' => $applied ? $applied : [], 'value' => $amount, 'area' => $area]); } $store = $address->getQuote()->getStore(); /** * Modify subtotal */ if ($this->_config->displayCartSubtotalBoth($store) || $this->_config->displayCartSubtotalInclTax($store)) { if ($address->getSubtotalInclTax() > 0) { $subtotalInclTax = $address->getSubtotalInclTax(); } else { $subtotalInclTax = $address->getSubtotal() + $taxAmount - $address->getShippingTaxAmount(); } $address->addTotal(['code' => 'subtotal', 'title' => __('Subtotal'), 'value' => $subtotalInclTax, 'value_incl_tax' => $subtotalInclTax, 'value_excl_tax' => $address->getSubtotal()]); } return $this; }
/** * Get review item price display mode * * @return string 'both', 'including', 'excluding' */ public function getReviewTotalsDisplayMode() { if ($this->taxConfig->displayCartSubtotalBoth()) { return 'both'; } if ($this->taxConfig->displayCartSubtotalExclTax()) { return 'excluding'; } return 'including'; }
/** * Check if we need display grid totals include tax * * @return bool */ public function displayTotalsIncludeTax() { $result = $this->_taxConfig->displayCartSubtotalInclTax($this->getStore()) || $this->_taxConfig->displayCartSubtotalBoth($this->getStore()); return $result; }
/** * @return bool */ public function displayBoth() { return $this->_taxConfig->displayCartSubtotalBoth($this->getStore()); }
/** * Return whether subtotal should be displayed excluding and including tax * * @return bool */ public function getDisplaySubtotalBoth() { return $this->_taxConfig->displayCartSubtotalBoth(); }