Skip to content

fix(import): fix configuration causing tax calculation issue#81

Open
arnaud-hours wants to merge 2 commits intomainfrom
fix/order-tax-calculation
Open

fix(import): fix configuration causing tax calculation issue#81
arnaud-hours wants to merge 2 commits intomainfrom
fix/order-tax-calculation

Conversation

@arnaud-hours
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adjusts how taxes are interpreted and calculated during order import/quote creation to avoid configuration-dependent tax calculation errors.

Changes:

  • Update product tax-rate lookup in the quote import flow to use Magento’s tax RateRequest (based on quote addresses/customer tax class) instead of getCalculatedRate(...).
  • Simplify “price includes tax” / “shipping includes tax” configuration checks to rely on the core “includes tax” flags rather than display configuration.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
Model/Import/Quote.php Switch tax-rate computation to getRateRequest(...) + getRate(...) for address-aware product tax calculation.
Model/Import/Importorder.php Change how priceIncludeTax and shippingIncludeTax are derived from store tax configuration during quote creation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Model/Import/Quote.php
Comment on lines +247 to +255
$taxRequest = $this->calculation->getRateRequest(
$this->getShippingAddress(),
$this->getBillingAddress(),
$this->getCustomerTaxClassId(),
$this->getStore()
);
$taxRequest->setProductClassId($magentoProduct->getTaxClassId());
$taxRate = $this->calculation->getRate($taxRequest);

Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this change, the class no longer uses $this->taxCalculation (it was previously used for getCalculatedRate(...)). Consider removing the unused property and its constructor dependency to avoid dead code and reduce DI wiring.

Copilot uses AI. Check for mistakes.
… shipping

Marketplace shipping costs are always TTC (tax-inclusive). Magento's
setShippingPrice/updateRates treats shipping rates as excl-tax internally
and adds tax on top. Previously, the shippingIncludeTax config check was
always false (due to display config AND conditions), so tax was always
extracted before setting the shipping price. After simplifying the check,
shippingIncludeTax became true, skipping extraction and causing Magento
to add tax on top of an already-TTC amount (double-taxation).

Fix: always extract shipping tax using address-based getRateRequest
(consistent with the product tax fix in Quote.php), since marketplace
shipping is always TTC regardless of Magento's config.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@A-Oudjat A-Oudjat requested review from a team and michaelmaslengow and removed request for a team March 23, 2026 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants