122 \
Magento\Framework\Locale\FormatInterface $localeFormat,
124 \
Magento\Framework\Locale\ResolverInterface $localeResolver,
128 Json $serializer =
null 130 parent::__construct($context);
132 $this->_config = $taxConfig;
135 $this->_localeFormat = $localeFormat;
136 $this->_orderTaxCollectionFactory = $orderTaxCollectionFactory;
137 $this->_localeResolver = $localeResolver;
150 $len = (int) $this->_postCodeSubStringLength;
176 return $this->_config->priceIncludesTax(
$store) || $this->_config->getNeedUseShippingExcludeTax();
187 return $this->_config->applyTaxAfterDiscount(
$store);
201 return $this->_config->getPriceDisplayType(
$store);
213 return $this->_config->needPriceConversion(
$store);
224 return $this->_config->displayCartFullSummary(
$store);
235 return $this->_config->displayCartZeroTax(
$store);
246 return $this->_config->displayCartPricesInclTax(
$store);
257 return $this->_config->displayCartPricesExclTax(
$store);
268 return $this->_config->displayCartPricesBoth(
$store);
279 return $this->_config->displaySalesPricesInclTax(
$store);
290 return $this->_config->displaySalesPricesExclTax(
$store);
301 return $this->_config->displaySalesPricesBoth(
$store);
312 return $this->_config->displaySalesSubtotalBoth(
$store);
323 return $this->_config->displaySalesSubtotalInclTax(
$store);
334 return $this->_config->displaySalesSubtotalExclTax(
$store);
345 $this->_localeResolver->emulate(
$store);
346 $priceFormat = $this->_localeFormat->getPriceFormat();
347 $this->_localeResolver->revert();
349 $priceFormat[
'pattern'] = $this->_storeManager->getStore(
$store)->getCurrentCurrency()->getOutputFormat();
352 return $this->jsonHelper->jsonEncode($priceFormat);
394 return $this->_config->shippingPriceIncludesTax(
$store);
405 return $this->_config->getShippingPriceDisplayType(
$store);
446 return $this->_config->getShippingTaxClass(
$store);
461 $pseudoProduct = new \Magento\Framework\DataObject();
469 $price = $this->catalogHelper->getTaxPrice(
491 return $this->_config->discountTax(
$store);
502 return $this->scopeConfig->getValue(
517 return (
int) $this->scopeConfig->getValue(
532 return (
int) $this->scopeConfig->getValue(
550 return $this->_config->getCalculationSequence(
$store);
561 return $this->_config->getAlgorithm(
$store);
583 $taxClassAmount = [];
585 return $taxClassAmount;
589 $source = $current->getOrder();
594 $taxClassAmount = $this->calculateTaxForItems(
$source, $current);
597 foreach ($taxClassAmount as $key =>
$tax) {
598 $taxClassAmount[$key][
'tax_amount'] = $this->priceCurrency->round(
$tax[
'tax_amount']);
599 $taxClassAmount[$key][
'base_tax_amount'] = $this->priceCurrency->round(
$tax[
'base_tax_amount']);
602 return array_values($taxClassAmount);
626 foreach ($itemAppliedTaxes as $itemAppliedTax) {
627 $taxAmount = $itemAppliedTax->getAmount() * $ratio;
628 $baseTaxAmount = $itemAppliedTax->getBaseAmount() * $ratio;
633 $taxCode = $itemAppliedTax->getCode();
634 if (!isset($taxClassAmount[$taxCode])) {
635 $taxClassAmount[$taxCode][
'title'] = $itemAppliedTax->getTitle();
636 $taxClassAmount[$taxCode][
'percent'] = $itemAppliedTax->getPercent();
637 $taxClassAmount[$taxCode][
'tax_amount'] =
$taxAmount;
638 $taxClassAmount[$taxCode][
'base_tax_amount'] = $baseTaxAmount;
640 $taxClassAmount[$taxCode][
'tax_amount'] +=
$taxAmount;
641 $taxClassAmount[$taxCode][
'base_tax_amount'] += $baseTaxAmount;
645 return $taxClassAmount;
656 return $this->_orderTaxCollectionFactory->create()->loadByOrder(
$order)->toArray();
666 return $this->scopeConfig->getValue(
667 self::CONFIG_DEFAULT_CUSTOMER_TAX_CLASS,
679 return $this->scopeConfig->getValue(
680 self::CONFIG_DEFAULT_PRODUCT_TAX_CLASS,
693 return (
bool) $this->_config->crossBorderTradeEnabled(
$store);
702 $taxClassAmount = [];
704 $orderTaxDetails = $this->orderTaxManagement->getOrderTaxDetails($current->getId());
705 $appliedTaxes = $orderTaxDetails->getAppliedTaxes();
706 foreach ($appliedTaxes as $appliedTax) {
707 $taxCode = $appliedTax->getCode();
708 $taxClassAmount[$taxCode][
'tax_amount'] = $appliedTax->getAmount();
709 $taxClassAmount[$taxCode][
'base_tax_amount'] = $appliedTax->getBaseAmount();
710 $taxClassAmount[$taxCode][
'title'] = $appliedTax->getTitle();
711 $taxClassAmount[$taxCode][
'percent'] = $appliedTax->getPercent();
714 return $taxClassAmount;
725 $taxClassAmount = [];
727 $orderTaxDetails = $this->orderTaxManagement->getOrderTaxDetails(
$order->getId());
731 foreach ($salesItem->getItems() as
$item) {
735 $itemTax =
$item->getTaxAmount();
736 if (!$itemTax || !(
float)$orderItemTax) {
740 $itemRatio = $itemTax / $orderItemTax;
741 $itemTaxDetails = $orderTaxDetails->getItems();
742 foreach ($itemTaxDetails as $itemTaxDetail) {
744 if ($itemTaxDetail->getItemId() == $orderItemId) {
745 $taxClassAmount = $this->_aggregateTaxes($taxClassAmount, $itemTaxDetail, $itemRatio);
746 }
elseif ($itemTaxDetail->getAssociatedItemId() == $orderItemId) {
747 $taxableItemType = $itemTaxDetail->getType();
749 if (
$item->getTaxRatio()) {
750 $taxRatio = $this->serializer->unserialize(
$item->getTaxRatio());
751 if (isset($taxRatio[$taxableItemType])) {
752 $ratio = $taxRatio[$taxableItemType];
755 $taxClassAmount = $this->_aggregateTaxes($taxClassAmount, $itemTaxDetail, $ratio);
761 $shippingTaxAmount = $salesItem->getShippingTaxAmount();
762 $originalShippingTaxAmount =
$order->getShippingTaxAmount();
763 if ($shippingTaxAmount && $originalShippingTaxAmount &&
764 $shippingTaxAmount != 0 && (
float)$originalShippingTaxAmount
767 $shippingRatio = $shippingTaxAmount / $originalShippingTaxAmount;
768 $itemTaxDetails = $orderTaxDetails->getItems();
769 foreach ($itemTaxDetails as $itemTaxDetail) {
771 if ($itemTaxDetail->getType() == \Magento\Quote\Model\Quote\Address::TYPE_SHIPPING) {
772 $taxClassAmount = $this->_aggregateTaxes($taxClassAmount, $itemTaxDetail, $shippingRatio);
777 return $taxClassAmount;
const CONFIG_DEFAULT_CUSTOMER_TAX_CLASS
displayCartPriceExclTax($store=null)
isCatalogPriceDisplayAffectedByTax($store=null)
elseif(isset( $params[ 'redirect_parent']))
const CONFIG_XML_PATH_APPLY_ON
displaySalesPriceExclTax($store=null)
displaySalesSubtotalExclTax($store=null)
getPriceFormat($store=null)
displayBothPrices($store=null)
_getTaxRateSubtotals($order)
$_postCodeSubStringLength
const CONFIG_DEFAULT_PRODUCT_TAX_CLASS
getPostCodeSubStringLength()
getCalculationAlgorithm($store=null)
priceIncludesTax($store=null)
displayShippingBothPrices()
getCalculationSequence($store=null)
const DISPLAY_TYPE_EXCLUDING_TAX
const DISPLAY_TYPE_INCLUDING_TAX
displayShippingPriceIncludingTax()
applyTaxOnCustomPrice($store=null)
getShippingTaxClass($store)
getShippingPriceDisplayType($store=null)
getShippingPrice($price, $includingTax=null, $shippingAddress=null, $ctc=null, $store=null)
getPriceDisplayType($store=null)
getCalculatedTaxes($source)
displaySalesSubtotalInclTax($store=null)
displayCartBothPrices($store=null)
displaySalesSubtotalBoth($store=null)
getTaxBasedOn($store=null)
__construct(\Magento\Framework\App\Helper\Context $context, \Magento\Framework\Json\Helper\Data $jsonHelper, Config $taxConfig, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\Locale\FormatInterface $localeFormat, \Magento\Tax\Model\ResourceModel\Sales\Order\Tax\CollectionFactory $orderTaxCollectionFactory, \Magento\Framework\Locale\ResolverInterface $localeResolver, \Magento\Catalog\Helper\Data $catalogHelper, OrderTaxManagementInterface $orderTaxManagement, PriceCurrencyInterface $priceCurrency, Json $serializer=null)
displayPriceExcludingTax()
$_orderTaxCollectionFactory
displayCartPriceInclTax($store=null)
getDefaultCustomerTaxClass()
const CONFIG_XML_PATH_BASED_ON
displayFullSummary($store=null)
displayShippingPriceExcludingTax()
displayZeroTax($store=null)
shippingPriceIncludesTax($store=null)
isCrossBorderTradeEnabled($store=null)
needPriceConversion($store=null)
applyTaxOnOriginalPrice($store=null)
calculateTaxForOrder(EntityInterface $current)
displaySalesBothPrices($store=null)
displaySalesPriceInclTax($store=null)
applyTaxAfterDiscount($store=null)
getDefaultProductTaxClass()
displayPriceIncludingTax()