Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Don't allow Cross Border Trade to kick in when the tax rate is 0 #35593

Draft
wants to merge 2 commits into
base: 2.4-develop
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 10 additions & 19 deletions app/code/Magento/Tax/Model/Calculation/AbstractCalculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,54 +22,44 @@ abstract class AbstractCalculator
/**#@+
* Constants for delta rounding key
*/
const KEY_REGULAR_DELTA_ROUNDING = 'regular';
public const KEY_REGULAR_DELTA_ROUNDING = 'regular';

const KEY_APPLIED_TAX_DELTA_ROUNDING = 'applied_tax_amount';
public const KEY_APPLIED_TAX_DELTA_ROUNDING = 'applied_tax_amount';

const KEY_TAX_BEFORE_DISCOUNT_DELTA_ROUNDING = 'tax_before_discount';
public const KEY_TAX_BEFORE_DISCOUNT_DELTA_ROUNDING = 'tax_before_discount';
/**#@-*/

/**#@-*/
/**
* @var TaxDetailsItemInterfaceFactory
*/
protected $taxDetailsItemDataObjectFactory;

/**
* Tax calculation tool
*
* @var Calculation
*/
protected $calculationTool;

/**
* Store id
*
* @var int
*/
protected $storeId;

/**
* Customer tax class id
*
* @var int
*/
protected $customerTaxClassId;

/**
* Customer id
*
* @var int
*/
protected $customerId;

/**
* Shipping Address
*
* @var CustomerAddress
*/
protected $shippingAddress;

/**
* Billing Address
*
* @var CustomerAddress
*/
protected $billingAddress;
Expand Down Expand Up @@ -276,7 +266,7 @@ protected function getAddressRateRequest()
*/
protected function isSameRateAsStore($rate, $storeRate)
{
if ((bool)$this->config->crossBorderTradeEnabled($this->storeId)) {
if ((bool)$this->config->crossBorderTradeEnabled($this->storeId) && $rate > 0.0) {
return true;
} else {
return (abs($rate - $storeRate) < 0.00001);
Expand Down Expand Up @@ -424,8 +414,9 @@ protected function deltaRound($price, $rate, $direction, $type = self::KEY_REGUL
}

/**
* Given a store price that includes tax at the store rate, this function will back out the store's tax, and add in
* the customer's tax. Returns this new price which is the customer's price including tax.
* Given a store price that includes tax at the store rate, this function will back out the store's tax, ...
*
* ... and add in the customer's tax. Returns this new price which is the customer's price including tax.
*
* @param float $storePriceInclTax
* @param float $storeRate
Expand Down