diff --git a/vendor/magento/module-negotiable-quote/Model/Customer/StoreCustomerRate.php b/vendor/magento/module-negotiable-quote/Model/Customer/StoreCustomerRate.php index cbc1d08882..f36acf8184 100644 --- a/vendor/magento/module-negotiable-quote/Model/Customer/StoreCustomerRate.php +++ b/vendor/magento/module-negotiable-quote/Model/Customer/StoreCustomerRate.php @@ -62,6 +62,8 @@ class StoreCustomerRate } /** + * Inits the quote. + * * @param CartInterface $quote */ public function init(CartInterface $quote) @@ -71,6 +73,8 @@ class StoreCustomerRate } /** + * Returns tax rate factor. + * * @param CartItemInterface $cartItem * @return float * @throws LocalizedException @@ -80,7 +84,7 @@ class StoreCustomerRate { $taxRateFactor = 1.0; - if ($this->hasNegotiatedPrice() && $this->taxConfig->priceIncludesTax($cartItem->getStoreId())) { + if ($this->isTaxFactorApplicable((int)$cartItem->getStoreId())) { $customerRate = $this->getCustomerRate($cartItem); $storeRate = $this->getStoreRate($cartItem); @@ -91,6 +95,8 @@ class StoreCustomerRate } /** + * Returns customer tax rate factor. + * * @param CartItemInterface $cartItem * @return float * @throws LocalizedException @@ -100,7 +106,7 @@ class StoreCustomerRate { $taxRateFactor = 1.0; - if ($this->hasNegotiatedPrice() && $this->taxConfig->priceIncludesTax($cartItem->getStoreId())) { + if ($this->isTaxFactorApplicable((int)$cartItem->getStoreId())) { $customerRate = $this->getCustomerRate($cartItem); $taxRateFactor = (100 + $customerRate) / 100; @@ -110,6 +116,8 @@ class StoreCustomerRate } /** + * Returns store tax rate factor. + * * @param CartItemInterface $cartItem * @return float * @throws LocalizedException @@ -118,8 +126,7 @@ class StoreCustomerRate public function getStoreTaxRateFactor(CartItemInterface $cartItem): float { $taxRateFactor = 1.0; - - if ($this->hasNegotiatedPrice() && $this->taxConfig->priceIncludesTax($cartItem->getStoreId())) { + if ($this->isTaxFactorApplicable((int)$cartItem->getStoreId())) { $storeRate = $this->getStoreRate($cartItem); $taxRateFactor = (100 + $storeRate) / 100; @@ -129,6 +136,21 @@ class StoreCustomerRate } /** + * Checks whether tax factor calculation is applicable. + * + * @param int $storeId + * @return bool + */ + private function isTaxFactorApplicable(int $storeId): bool + { + return $this->hasNegotiatedPrice() + && $this->taxConfig->priceIncludesTax($storeId) + && !$this->taxConfig->crossBorderTradeEnabled($storeId); + } + + /** + * Checks negotiated price. + * * @return bool */ private function hasNegotiatedPrice(): bool @@ -146,6 +168,8 @@ class StoreCustomerRate } /** + * Returns customer rate. + * * @param CartItemInterface $cartItem * @return float * @throws LocalizedException @@ -160,6 +184,8 @@ class StoreCustomerRate } /** + * Returns store rate. + * * @param CartItemInterface $cartItem * @return float * @throws LocalizedException @@ -174,6 +200,8 @@ class StoreCustomerRate } /** + * Returns quote tax rate request. + * * @return DataObject * @throws LocalizedException * @throws NoSuchEntityException @@ -194,6 +222,8 @@ class StoreCustomerRate } /** + * Returns customer tax class. + * * @return int * @throws LocalizedException * @throws NoSuchEntityException