b374k
m1n1 1.01
Apache/2.4.41 (Ubuntu)
Linux vmi616275.contaboserver.net 5.4.0-84-generic #94-Ubuntu SMP Thu Aug 26 20:27:37 UTC 2021 x86_64
uid=33(www-data) gid=33(www-data) groups=33(www-data)
server ip : 62.171.164.128 | your ip : 127.0.0.1
safemode OFF
 >  / home / dev2.destoffenstraat.com / app / code / Geissweb / Euvat / Model / Rewrite /
Filename/home/dev2.destoffenstraat.com/app/code/Geissweb/Euvat/Model/Rewrite/TaxCalculation.php
Size3.92 kb
Permissionrwxrwxrwx
Ownerroot : root
Create time17-Aug-2025 10:26
Last modified09-Jul-2024 08:41
Last accessed21-Aug-2025 12:29
Actionsedit | rename | delete | download (gzip)
Viewtext | code | image
<?php
/**
* ||GEISSWEB| EU VAT Enhanced
*
* NOTICE OF LICENSE
*
* This source file is subject to the GEISSWEB End User License Agreement
* that is available through the world-wide-web at this URL: https://www.geissweb.de/legal-information/eula
*
* DISCLAIMER
*
* Do not edit this file if you wish to update the extension in the future. If you wish to customize the extension
* for your needs please refer to our support for more information.
*
* @copyright Copyright (c) 2015 GEISS Weblösungen (https://www.geissweb.de)
* @license https://www.geissweb.de/legal-information/eula GEISSWEB End User License Agreement
*/
declare(strict_types=1);

namespace Geissweb\Euvat\Model\Rewrite;

use Geissweb\Euvat\Helper\Configuration;
use Geissweb\Euvat\Logger\Logger;
use Geissweb\Euvat\Registry\CurrentTaxCountry;
use Magento\Tax\Model\Calculation;
use Magento\Store\Model\Store;

/**
* Class TaxCalculation must be rewritten because getRateOriginRequest is protected, but
* needs to be modified for destination country rate net price calculation
*/
class TaxCalculation extends Calculation
{
/**
* Get request object for getting tax rate based on store shipping original address
*
* MOD: Allows subtraction of the specific country rate when using CBT with a threshold country
*
* @param null|string|bool|int|Store $store
* @return \Magento\Framework\DataObject
*/
protected function getRateOriginRequest($store = null)
{
// UNTOUCHED
$request = new \Magento\Framework\DataObject();
$request->setCountryId(
$this->_scopeConfig->getValue(
\Magento\Shipping\Model\Config::XML_PATH_ORIGIN_COUNTRY_ID,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
$store
)
)->setRegionId(
$this->_scopeConfig->getValue(
\Magento\Shipping\Model\Config::XML_PATH_ORIGIN_REGION_ID,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
$store
)
)->setPostcode(
$this->_scopeConfig->getValue(
\Magento\Shipping\Model\Config::XML_PATH_ORIGIN_POSTCODE,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
$store
)
)->setCustomerClassId(
$this->getDefaultCustomerTaxClass($store)
)->setStore(
$store
);
// UNTOUCHED

$logger = $this->getData('euvat_logger');
$currentTaxCountryRegistry = $this->getData('euvat_current_tax_country_registry');
$config = $this->getData('euvat_config');
if (($logger instanceof Logger)
&& $currentTaxCountryRegistry instanceof CurrentTaxCountry
&& $config instanceof Configuration
) {
$currentTaxCountry = $currentTaxCountryRegistry->get();
$logger->customLog("[Rewrite\TaxCalculation] getRateOriginRequest data", [
'request_country' => $request->getCountryId(),
'current_tax_country' => $currentTaxCountry
]);
} else {
return $request;
}

// Calculate tax amount based on threshold country if needed
if ($currentTaxCountry !== null
&& $config->getUseVatCalculation()
&& $config->isCbtEnabled()
&& $config->getEnableThresholdCountries()
&& $config->isThresholdCountry($currentTaxCountry)
) {
$logger->customLog("[Rewrite\TaxCalculation] getRateOriginRequest calculate net amount
based on country: " . $currentTaxCountry);
$request->setCountryId($currentTaxCountry);
$request->setCustomerClassId($config->getConsumerTaxClass());

} else {
$logger->customLog(
"[Rewrite\TaxCalculation] getRateOriginRequest calculate net amount based on origin country."
);
}

return $request;
}
}