I am utilizing an Additional Charge module(Magento model 2.3.4), it doesn’t matter what state I choose on the cart web page, the tax will solely be calculated by Michigan tax fee.
Listed below are the Tax charges,
Right here is the video for higher understanding:- https://nimb.ws/248uAG
Tax is being calculated on,
Tax quantity = (Subtotal+Whole Extrafee)*Tax fee
I am overriding MagentoTaxModelSalesTotalQuoteTax
class.
Vendor/ExtraFee/and so on/di.xml
<choice for="MagentoTaxModelSalesTotalQuoteTax" sort="VendorExtraFeeModelSalesTotalQuoteTax" />
Vendor/ExtraFee/Mannequin/Gross sales/Whole/Quote/Tax.php
<?php
$enabled = $this->helperData->isModuleEnabled();
if ($enabled) {
$charge = $this->helperData->getExtrafee();
$extraFeeTax = 0;
$subtotal = $quote->getSubtotal();
if (isset($fee[0])) {
$charge = $subtotal + $charge;
$extraFeeTax = ($fee[0] * $charge) / 100;
} else {
$classid =$quote->getCustomerTaxClassId();
$taxRates = $this->_taxModelConfig->getCollection()->getData();
$logger->data('classid');
$logger->data($classid);
$array_rates =array_column($taxRates, 'tax_calculation_rate_id');
$tax_id = array_search($classid, $array_rates);
if (isset($taxRates[$tax_id])) {
$taxData = $taxRates[$tax_id];
$fee = $taxData['rate'];
// $logger->data($taxData);
$logger->data($fee);
}
$charge = $subtotal + $charge;
$extraFeeTax = ($fee * $charge) / 100;
}
$quantity = $quantity + $extraFeeTax;
$total->setTotalAmount('tax', $quantity);
$total->setExtraTax($extraFeeTax);
$quote->setExtraTax($extraFeeTax);
}
If anybody has any concepts, please let me know.