I had the same issue but in my case I set the tax amount programmatically.
So if you are into controlling and manipulating the tax in your module, follow these steps:
in your di.xml file add the following:
<preference for="Magento\Tax\Model\Sales\Total\Quote\Tax" type="Vendor\Module\Model\Sales\Total\Quote\Tax"/>
Add the following class override (in Vendor/Module/Model/Sales/Total/Quote/Tax.php):
<?php
namespace Vendor\Module\Model\Sales\Total\Quote;
use Magento\Customer\Api\Data\AddressInterfaceFactory as CustomerAddressFactory;
use Magento\Customer\Api\Data\RegionInterfaceFactory as CustomerAddressRegionFactory;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Serialize\Serializer\Json;
use Magento\Quote\Api\Data\ShippingAssignmentInterface;
use Magento\Quote\Model\Quote\Address;
use Magento\Tax\Api\Data\TaxClassKeyInterface;
use Magento\Tax\Model\Calculation;
class Tax extends \Magento\Tax\Model\Sales\Total\Quote\Tax
{
/**
* Class constructor
*
* @param \Magento\Tax\Model\Config $taxConfig
* @param \Magento\Tax\Api\TaxCalculationInterface $taxCalculationService
* @param \Magento\Tax\Api\Data\QuoteDetailsInterfaceFactory $quoteDetailsDataObjectFactory
* @param \Magento\Tax\Api\Data\QuoteDetailsItemInterfaceFactory $quoteDetailsItemDataObjectFactory
* @param \Magento\Tax\Api\Data\TaxClassKeyInterfaceFactory $taxClassKeyDataObjectFactory
* @param CustomerAddressFactory $customerAddressFactory
* @param CustomerAddressRegionFactory $customerAddressRegionFactory
* @param \Magento\Tax\Helper\Data $taxData
*/
public function __construct(
\Magento\Tax\Model\Config $taxConfig,
\Magento\Tax\Api\TaxCalculationInterface $taxCalculationService,
\Magento\Tax\Api\Data\QuoteDetailsInterfaceFactory $quoteDetailsDataObjectFactory,
\Magento\Tax\Api\Data\QuoteDetailsItemInterfaceFactory $quoteDetailsItemDataObjectFactory,
\Magento\Tax\Api\Data\TaxClassKeyInterfaceFactory $taxClassKeyDataObjectFactory,
CustomerAddressFactory $customerAddressFactory,
CustomerAddressRegionFactory $customerAddressRegionFactory,
\Magento\Tax\Helper\Data $taxData
) {
$this->setCode('tax');
parent::__construct(
$taxConfig,
$taxCalculationService,
$quoteDetailsDataObjectFactory,
$quoteDetailsItemDataObjectFactory,
$taxClassKeyDataObjectFactory,
$customerAddressFactory,
$customerAddressRegionFactory,
$taxData
);
}
/**
* Custom Collect tax totals for quote address
*
* @param Quote $quote
* @param ShippingAssignmentInterface $shippingAssignment
* @param Address\Total $total
* @return $this
* @throws RemoteServiceUnavailableException
*/
public function collect(
\Magento\Quote\Model\Quote $quote,
\Magento\Quote\Api\Data\ShippingAssignmentInterface $shippingAssignment,
\Magento\Quote\Model\Quote\Address\Total $total
) {
$total->setTotalAmount('tax', $set_your_tax_here);
$total->setBaseTotalAmount('tax', $set_your_tax_here);
return $this;
}
}