Skip to content
Open
Show file tree
Hide file tree
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
30 changes: 14 additions & 16 deletions Model/Import/Importorder.php
Original file line number Diff line number Diff line change
Expand Up @@ -1444,37 +1444,35 @@ private function createQuote(MagentoCustomer $customer, array $products): Quote
->setSaveInAddressBook(0)
->setSameAsBilling(0);
$quote->assignCustomerWithAddressChange($customerRepo, $billingAddress, $shippingAddress);
// check if store include tax (Product and shipping cost)
$priceIncludeTax = ($this->taxConfig->priceIncludesTax($quote->getStore())
&& $this->taxConfig->displayCartPricesInclTax($quote->getStore())
&& $this->taxConfig->displaySalesPricesInclTax($quote->getStore()));

$shippingIncludeTax = ($this->taxConfig->shippingPriceIncludesTax($quote->getStore())
&& $this->taxConfig->displayCartShippingInclTax($quote->getStore())
&& $this->taxConfig->displaySalesShippingInclTax($quote->getStore()));
// check if store include tax (Product prices)
$priceIncludeTax = $this->taxConfig->priceIncludesTax($quote->getStore());

// if this order is b2b
if ((int) $this->backendSession->getIsLengowB2b() === 1) {
$priceIncludeTax = true;
$shippingIncludeTax = true;
}
// add product in quote
$quote->addLengowProducts($products, $priceIncludeTax);
// get shipping cost with tax
$shippingCost = $this->processingFee + $this->shippingCost;
$taxShippingCost = 0.0;
// if shipping cost not include tax -> get shipping cost without tax
if (!$shippingIncludeTax) {
// marketplace shipping is always TTC (tax-inclusive)
// Magento shipping rates are always treated as excl-tax internally,
// so we must always extract tax to get the correct base amount
if ($shippingCost > 0) {
$shippingTaxClass = $this->scopeConfig->getValue(
TaxConfig::CONFIG_XML_PATH_SHIPPING_TAX_CLASS,
\Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE,
$quote->getStore()->getWebsiteId()
);

$taxRate = $this->taxCalculation->getCalculatedRate(
$shippingTaxClass,
$customer->getId(),
$currentStore->getId()
$taxRequest = $this->calculation->getRateRequest(
$quote->getShippingAddress(),
$quote->getBillingAddress(),
$quote->getCustomerTaxClassId(),
$quote->getStore()
);
$taxRequest->setProductClassId($shippingTaxClass);
$taxRate = $this->calculation->getRate($taxRequest);
$taxShippingCost = $this->calculation->calcTaxAmount($shippingCost, $taxRate, true);
}
$shippingCost -= $taxShippingCost;
Expand Down
10 changes: 7 additions & 3 deletions Model/Import/Quote.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,15 @@ public function addLengowProducts($products, bool $priceIncludeTax = true): Quot
$priceProduct = $product['price_unit'] ?? 0.0;
$tax = $product['tax_unit'] ?? 0.0;
if (!$priceIncludeTax) {
$taxRate = $this->taxCalculation->getCalculatedRate(
$magentoProduct->getTaxClassId(),
$this->getCustomer()->getId(),
$taxRequest = $this->calculation->getRateRequest(
$this->getShippingAddress(),
$this->getBillingAddress(),
$this->getCustomerTaxClassId(),
$this->getStore()
);
$taxRequest->setProductClassId($magentoProduct->getTaxClassId());
$taxRate = $this->calculation->getRate($taxRequest);

Comment on lines +247 to +255
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.
$tax = $this->calculation->calcTaxAmount($priceProduct, $taxRate, true);
}

Expand Down
Loading