Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php namespace Magento\Tax\Model\Calculation; use Magento\Tax\Api\Data\QuoteDetailsItemI..
Decoded Output download
<?php
namespace Magento\Tax\Model\Calculation; use Magento\Tax\Api\Data\QuoteDetailsItemInterface; abstract class AbstractAggregateCalculator extends AbstractCalculator { protected function calculateWithTaxInPrice(QuoteDetailsItemInterface $item, $quantity, $round = true) { $taxRateRequest = $this->getAddressRateRequest()->setProductClassId($this->taxClassManagement->getTaxClassId($item->getTaxClassKey())); $rate = $this->calculationTool->getRate($taxRateRequest); $storeRate = $this->calculationTool->getStoreRate($taxRateRequest, $this->storeId); $discountTaxCompensationAmount = 0; $applyTaxAfterDiscount = $this->config->applyTaxAfterDiscount($this->storeId); $discountAmount = $item->getDiscountAmount(); $priceInclTax = $this->calculationTool->round($item->getUnitPrice()); $rowTotalInclTax = $priceInclTax * $quantity; if (!$this->isSameRateAsStore($rate, $storeRate)) { $priceInclTax = $this->calculatePriceInclTax($priceInclTax, $storeRate, $rate, $round); $rowTotalInclTax = $priceInclTax * $quantity; } $rowTaxExact = $this->calculationTool->calcTaxAmount($rowTotalInclTax, $rate, true, false); $deltaRoundingType = self::KEY_REGULAR_DELTA_ROUNDING; if ($applyTaxAfterDiscount) { $deltaRoundingType = self::KEY_TAX_BEFORE_DISCOUNT_DELTA_ROUNDING; } $rowTax = $this->roundAmount($rowTaxExact, $rate, true, $deltaRoundingType, $round, $item); $rowTotal = $rowTotalInclTax - $rowTax; $price = $rowTotal / $quantity; if ($round) { $price = $this->calculationTool->round($price); } if ($applyTaxAfterDiscount) { $taxableAmount = max($rowTotalInclTax - $discountAmount, 0); $rowTaxAfterDiscount = $this->calculationTool->calcTaxAmount($taxableAmount, $rate, true, false); $rowTaxAfterDiscount = $this->roundAmount($rowTaxAfterDiscount, $rate, true, self::KEY_REGULAR_DELTA_ROUNDING, $round, $item); $discountTaxCompensationAmount = $rowTax - $rowTaxAfterDiscount; $rowTax = $rowTaxAfterDiscount; } $appliedRates = $this->calculationTool->getAppliedRates($taxRateRequest); $appliedTaxes = $this->getAppliedTaxes($rowTax, $rate, $appliedRates); return $this->taxDetailsItemDataObjectFactory->create()->setCode($item->getCode())->setType($item->getType())->setRowTax($rowTax)->setPrice($price)->setPriceInclTax($priceInclTax)->setRowTotal($rowTotal)->setRowTotalInclTax($rowTotalInclTax)->setDiscountTaxCompensationAmount($discountTaxCompensationAmount)->setAssociatedItemCode($item->getAssociatedItemCode())->setTaxPercent($rate)->setAppliedTaxes($appliedTaxes); } protected function calculateWithTaxNotInPrice(QuoteDetailsItemInterface $item, $quantity, $round = true) { $taxRateRequest = $this->getAddressRateRequest()->setProductClassId($this->taxClassManagement->getTaxClassId($item->getTaxClassKey())); $rate = $this->calculationTool->getRate($taxRateRequest); $appliedRates = $this->calculationTool->getAppliedRates($taxRateRequest); $applyTaxAfterDiscount = $this->config->applyTaxAfterDiscount($this->storeId); $discountAmount = $item->getDiscountAmount(); $discountTaxCompensationAmount = 0; $price = $this->calculationTool->round($item->getUnitPrice()); $rowTotal = $price * $quantity; $rowTaxes = array(); $rowTaxesBeforeDiscount = array(); $appliedTaxes = array(); $rowTotalForTaxCalculation = $this->getPriceForTaxCalculation($item, $price) * $quantity; foreach ($appliedRates as $appliedRate) { $taxId = $appliedRate["id"]; $taxRate = $appliedRate["percent"]; $rowTaxPerRate = $this->calculationTool->calcTaxAmount($rowTotalForTaxCalculation, $taxRate, false, false); $deltaRoundingType = self::KEY_REGULAR_DELTA_ROUNDING; if ($applyTaxAfterDiscount) { $deltaRoundingType = self::KEY_TAX_BEFORE_DISCOUNT_DELTA_ROUNDING; } $rowTaxPerRate = $this->roundAmount($rowTaxPerRate, $taxId, false, $deltaRoundingType, $round, $item); $rowTaxAfterDiscount = $rowTaxPerRate; if ($applyTaxAfterDiscount) { $taxableAmount = max($rowTotalForTaxCalculation - $discountAmount, 0); if ($taxableAmount && !$applyTaxAfterDiscount) { $taxableAmount = $rowTotalForTaxCalculation; } $rowTaxAfterDiscount = $this->calculationTool->calcTaxAmount($taxableAmount, $taxRate, false, false); $rowTaxAfterDiscount = $this->roundAmount($rowTaxAfterDiscount, $taxId, false, self::KEY_REGULAR_DELTA_ROUNDING, $round, $item); } $appliedTaxes[$taxId] = $this->getAppliedTax($rowTaxAfterDiscount, $appliedRate); $rowTaxes[] = $rowTaxAfterDiscount; $rowTaxesBeforeDiscount[] = $rowTaxPerRate; } $rowTax = array_sum($rowTaxes); $rowTaxBeforeDiscount = array_sum($rowTaxesBeforeDiscount); $rowTotalInclTax = $rowTotal + $rowTaxBeforeDiscount; $priceInclTax = $rowTotalInclTax / $quantity; if ($round) { $priceInclTax = $this->calculationTool->round($priceInclTax); } return $this->taxDetailsItemDataObjectFactory->create()->setCode($item->getCode())->setType($item->getType())->setRowTax($rowTax)->setPrice($price)->setPriceInclTax($priceInclTax)->setRowTotal($rowTotal)->setRowTotalInclTax($rowTotalInclTax)->setDiscountTaxCompensationAmount($discountTaxCompensationAmount)->setAssociatedItemCode($item->getAssociatedItemCode())->setTaxPercent($rate)->setAppliedTaxes($appliedTaxes); } private function getPriceForTaxCalculation(QuoteDetailsItemInterface $item, float $price) { if ($item->getExtensionAttributes() && $item->getExtensionAttributes()->getPriceForTaxCalculation()) { $priceForTaxCalculation = $this->calculationTool->round($item->getExtensionAttributes()->getPriceForTaxCalculation()); } else { $priceForTaxCalculation = $price; } return $priceForTaxCalculation; } protected abstract function roundAmount($amount, $rate = null, $direction = null, $type = self::KEY_REGULAR_DELTA_ROUNDING, $round = true, $item = null); } ?>
Did this file decode correctly?
Original Code
<?php
namespace Magento\Tax\Model\Calculation; use Magento\Tax\Api\Data\QuoteDetailsItemInterface; abstract class AbstractAggregateCalculator extends AbstractCalculator { protected function calculateWithTaxInPrice(QuoteDetailsItemInterface $item, $quantity, $round = true) { $taxRateRequest = $this->getAddressRateRequest()->setProductClassId($this->taxClassManagement->getTaxClassId($item->getTaxClassKey())); $rate = $this->calculationTool->getRate($taxRateRequest); $storeRate = $this->calculationTool->getStoreRate($taxRateRequest, $this->storeId); $discountTaxCompensationAmount = 0; $applyTaxAfterDiscount = $this->config->applyTaxAfterDiscount($this->storeId); $discountAmount = $item->getDiscountAmount(); $priceInclTax = $this->calculationTool->round($item->getUnitPrice()); $rowTotalInclTax = $priceInclTax * $quantity; if (!$this->isSameRateAsStore($rate, $storeRate)) { $priceInclTax = $this->calculatePriceInclTax($priceInclTax, $storeRate, $rate, $round); $rowTotalInclTax = $priceInclTax * $quantity; } $rowTaxExact = $this->calculationTool->calcTaxAmount($rowTotalInclTax, $rate, true, false); $deltaRoundingType = self::KEY_REGULAR_DELTA_ROUNDING; if ($applyTaxAfterDiscount) { $deltaRoundingType = self::KEY_TAX_BEFORE_DISCOUNT_DELTA_ROUNDING; } $rowTax = $this->roundAmount($rowTaxExact, $rate, true, $deltaRoundingType, $round, $item); $rowTotal = $rowTotalInclTax - $rowTax; $price = $rowTotal / $quantity; if ($round) { $price = $this->calculationTool->round($price); } if ($applyTaxAfterDiscount) { $taxableAmount = max($rowTotalInclTax - $discountAmount, 0); $rowTaxAfterDiscount = $this->calculationTool->calcTaxAmount($taxableAmount, $rate, true, false); $rowTaxAfterDiscount = $this->roundAmount($rowTaxAfterDiscount, $rate, true, self::KEY_REGULAR_DELTA_ROUNDING, $round, $item); $discountTaxCompensationAmount = $rowTax - $rowTaxAfterDiscount; $rowTax = $rowTaxAfterDiscount; } $appliedRates = $this->calculationTool->getAppliedRates($taxRateRequest); $appliedTaxes = $this->getAppliedTaxes($rowTax, $rate, $appliedRates); return $this->taxDetailsItemDataObjectFactory->create()->setCode($item->getCode())->setType($item->getType())->setRowTax($rowTax)->setPrice($price)->setPriceInclTax($priceInclTax)->setRowTotal($rowTotal)->setRowTotalInclTax($rowTotalInclTax)->setDiscountTaxCompensationAmount($discountTaxCompensationAmount)->setAssociatedItemCode($item->getAssociatedItemCode())->setTaxPercent($rate)->setAppliedTaxes($appliedTaxes); } protected function calculateWithTaxNotInPrice(QuoteDetailsItemInterface $item, $quantity, $round = true) { $taxRateRequest = $this->getAddressRateRequest()->setProductClassId($this->taxClassManagement->getTaxClassId($item->getTaxClassKey())); $rate = $this->calculationTool->getRate($taxRateRequest); $appliedRates = $this->calculationTool->getAppliedRates($taxRateRequest); $applyTaxAfterDiscount = $this->config->applyTaxAfterDiscount($this->storeId); $discountAmount = $item->getDiscountAmount(); $discountTaxCompensationAmount = 0; $price = $this->calculationTool->round($item->getUnitPrice()); $rowTotal = $price * $quantity; $rowTaxes = array(); $rowTaxesBeforeDiscount = array(); $appliedTaxes = array(); $rowTotalForTaxCalculation = $this->getPriceForTaxCalculation($item, $price) * $quantity; foreach ($appliedRates as $appliedRate) { $taxId = $appliedRate["\151\144"]; $taxRate = $appliedRate["\x70\x65\162\143\x65\156\x74"]; $rowTaxPerRate = $this->calculationTool->calcTaxAmount($rowTotalForTaxCalculation, $taxRate, false, false); $deltaRoundingType = self::KEY_REGULAR_DELTA_ROUNDING; if ($applyTaxAfterDiscount) { $deltaRoundingType = self::KEY_TAX_BEFORE_DISCOUNT_DELTA_ROUNDING; } $rowTaxPerRate = $this->roundAmount($rowTaxPerRate, $taxId, false, $deltaRoundingType, $round, $item); $rowTaxAfterDiscount = $rowTaxPerRate; if ($applyTaxAfterDiscount) { $taxableAmount = max($rowTotalForTaxCalculation - $discountAmount, 0); if ($taxableAmount && !$applyTaxAfterDiscount) { $taxableAmount = $rowTotalForTaxCalculation; } $rowTaxAfterDiscount = $this->calculationTool->calcTaxAmount($taxableAmount, $taxRate, false, false); $rowTaxAfterDiscount = $this->roundAmount($rowTaxAfterDiscount, $taxId, false, self::KEY_REGULAR_DELTA_ROUNDING, $round, $item); } $appliedTaxes[$taxId] = $this->getAppliedTax($rowTaxAfterDiscount, $appliedRate); $rowTaxes[] = $rowTaxAfterDiscount; $rowTaxesBeforeDiscount[] = $rowTaxPerRate; } $rowTax = array_sum($rowTaxes); $rowTaxBeforeDiscount = array_sum($rowTaxesBeforeDiscount); $rowTotalInclTax = $rowTotal + $rowTaxBeforeDiscount; $priceInclTax = $rowTotalInclTax / $quantity; if ($round) { $priceInclTax = $this->calculationTool->round($priceInclTax); } return $this->taxDetailsItemDataObjectFactory->create()->setCode($item->getCode())->setType($item->getType())->setRowTax($rowTax)->setPrice($price)->setPriceInclTax($priceInclTax)->setRowTotal($rowTotal)->setRowTotalInclTax($rowTotalInclTax)->setDiscountTaxCompensationAmount($discountTaxCompensationAmount)->setAssociatedItemCode($item->getAssociatedItemCode())->setTaxPercent($rate)->setAppliedTaxes($appliedTaxes); } private function getPriceForTaxCalculation(QuoteDetailsItemInterface $item, float $price) { if ($item->getExtensionAttributes() && $item->getExtensionAttributes()->getPriceForTaxCalculation()) { $priceForTaxCalculation = $this->calculationTool->round($item->getExtensionAttributes()->getPriceForTaxCalculation()); } else { $priceForTaxCalculation = $price; } return $priceForTaxCalculation; } protected abstract function roundAmount($amount, $rate = null, $direction = null, $type = self::KEY_REGULAR_DELTA_ROUNDING, $round = true, $item = null); }
Function Calls
None |
Stats
MD5 | 7b8cd142d7ace0177cf7b4c6d2cb7d3c |
Eval Count | 0 |
Decode Time | 122 ms |