234 $this->_scopeConfig = $scopeConfig;
235 $this->_config = $taxConfig;
237 $this->_customerSession = $customerSession;
239 $this->_classesFactory = $classesFactory;
267 if ($this->_defaultCustomerTaxClass ===
null) {
269 $defaultCustomerGroup = $this->customerGroupManagement->getDefaultGroup(
$store);
270 $this->_defaultCustomerTaxClass = $defaultCustomerGroup->getTaxClassId();
295 if (!isset($this->_rates[
$ruleId])) {
296 $this->_rates[
$ruleId] = $this->
_getResource()->getCalculationsById(
'tax_calculation_rate_id', $ruleId);
309 if (!isset($this->_ctc[
$ruleId])) {
310 $this->_ctc[
$ruleId] = $this->
_getResource()->getCalculationsById(
'customer_tax_class_id', $ruleId);
323 if (!isset($this->_ptc[
$ruleId])) {
324 $this->_ptc[
$ruleId] = $this->
getResource()->getCalculationsById(
'product_tax_class_id', $ruleId);
336 $title = $this->getRateTitle();
337 $value = $this->getRateValue();
338 $id = $this->getRateId();
343 $process[
'percent'] =
$value;
344 $process[
'id'] =
"{$id}-{$value}";
345 $process[
'rates'][] =
$rate;
363 if (!isset($this->_rateCache[$cacheKey])) {
364 $this->unsRateValue();
365 $this->unsCalculationProcess();
366 $this->unsEventModuleId();
367 $this->_eventManager->dispatch(
'tax_rate_data_fetch', [
'request' =>
$request,
'sender' => $this]);
368 if (!$this->hasRateValue()) {
370 $this->setCalculationProcess($rateInfo[
'process']);
371 $this->setRateValue($rateInfo[
'value']);
375 $this->_rateCache[$cacheKey] = $this->getRateValue();
376 $this->_rateCalculationProcess[$cacheKey] = $this->getCalculationProcess();
378 return $this->_rateCache[$cacheKey];
392 $key =
$store->getId() .
'|';
396 $key .=
$request->getProductClassId() .
'|' 397 .
$request->getCustomerClassId() .
'|' 416 return $this->
getRate($storeRequest);
427 $request = new \Magento\Framework\DataObject();
429 $this->_scopeConfig->getValue(
430 \
Magento\Shipping\Model\Config::XML_PATH_ORIGIN_COUNTRY_ID,
435 $this->_scopeConfig->getValue(
436 \
Magento\Shipping\Model\Config::XML_PATH_ORIGIN_REGION_ID,
441 $this->_scopeConfig->getValue(
442 \
Magento\Shipping\Model\Config::XML_PATH_ORIGIN_POSTCODE,
446 )->setCustomerClassId(
479 return (
bool)$this->_config->crossBorderTradeEnabled(
$store);
512 $address = new \Magento\Framework\DataObject();
513 $basedOn = $this->_scopeConfig->getValue(
521 $basedOn =
'default';
524 && $basedOn ==
'billing' 526 && $basedOn ==
'shipping' 531 $defaultBilling = $this->customerAccountManagement->getDefaultBillingAddress(
$customerId);
536 $defaultShipping = $this->customerAccountManagement->getDefaultShippingAddress(
$customerId);
540 if ($basedOn ==
'billing' && isset($defaultBilling) && $defaultBilling->getCountryId()) {
542 }
elseif ($basedOn ==
'shipping' && isset($defaultShipping) && $defaultShipping->getCountryId()) {
545 $basedOn =
'default';
554 $basedOn =
'default';
572 $this->_scopeConfig->getValue(
578 $this->_scopeConfig->getValue(
584 $this->_scopeConfig->getValue(
602 $customerTaxClass = $this->customerGroupManagement->getNotLoggedInGroup()->getTaxClassId();
606 $request = new \Magento\Framework\DataObject();
608 if (
$address->getRegion() instanceof AddressRegion) {
609 $regionId =
$address->getRegion()->getRegionId();
611 $regionId =
$address->getRegionId();
614 ->setRegionId($regionId)
615 ->setPostcode(
$address->getPostcode())
634 if (!isset($this->_rateCalculationProcess[$cacheKey])) {
635 $this->_rateCalculationProcess[$cacheKey] = $this->
_getResource()->getCalculationProcess(
$request);
637 return $this->_rateCalculationProcess[$cacheKey];
665 if ($priceIncludeTax) {
686 return $this->priceCurrency->round(
$price);
697 $billingAddressObj =
null;
698 $shippingAddressObj =
null;
700 $billingAddressObj = new \Magento\Framework\DataObject(
$billingAddress);
705 $rateRequest = $this->
getRateRequest($shippingAddressObj, $billingAddressObj, $customerTaxClassId);
712 $ids = $this->taxClassRepository->getList(
$searchCriteria)->getItems();
715 $idKeys = array_keys($ids);
716 foreach ($idKeys as $idKey) {
717 $rateRequest->setProductClassId($idKey);
719 $productRates[$idKey] =
$rate;
721 return $productRates;
_getRequestCacheKey($request)
elseif(isset( $params[ 'redirect_parent']))
const CONFIG_XML_PATH_DEFAULT_POSTCODE
const CONFIG_XML_PATH_DEFAULT_REGION
const CALC_TAX_BEFORE_DISCOUNT_ON_INCL
const CONFIG_XML_PATH_DEFAULT_COUNTRY
getRateOriginRequest($store=null)
getAppliedRates($request)
getDefaultCustomerTaxClass($store=null)
$customerAccountManagement
getDefaultRateRequest($store=null, $customerId=null)
calcTaxAmount($price, $taxRate, $priceIncludeTax=false, $round=true)
getRateRequest( $shippingAddress=null, $billingAddress=null, $customerTaxClass=null, $store=null, $customerId=null)
const CALC_TAX_BEFORE_DISCOUNT_ON_EXCL
_formCalculationProcess()
getProductTaxClasses($ruleId)
getCustomerTaxClasses($ruleId)
const CONFIG_XML_PATH_BASED_ON
getTaxRates($billingAddress, $shippingAddress, $customerTaxClassId)
const CALC_TAX_AFTER_DISCOUNT_ON_INCL
__construct(\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, Config $taxConfig, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Customer\Model\Session $customerSession, \Magento\Customer\Model\CustomerFactory $customerFactory, \Magento\Tax\Model\ResourceModel\TaxClass\CollectionFactory $classesFactory, \Magento\Tax\Model\ResourceModel\Calculation $resource, CustomerAccountManagement $customerAccountManagement, CustomerGroupManagement $customerGroupManagement, CustomerGroupRepository $customerGroupRepository, CustomerRepository $customerRepository, PriceCurrencyInterface $priceCurrency, SearchCriteriaBuilder $searchCriteriaBuilder, FilterBuilder $filterBuilder, TaxClassRepositoryInterface $taxClassRepository, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection=null, array $data=[])
getStoreRate($request, $store=null)
const CALC_TAX_AFTER_DISCOUNT_ON_EXCL
_isCrossBorderTradeEnabled($store=null)
$_defaultCustomerTaxClass