Skip to content

Commit 32188b0

Browse files
committed
ACP2E-3472: [CLOUD] Shipping calculation is not considering the shopping cart rule
1 parent 26e966a commit 32188b0

File tree

2 files changed

+39
-15
lines changed

2 files changed

+39
-15
lines changed

app/code/Magento/Tax/Model/Sales/Total/Quote/CommonTaxCollector.php

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,35 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2014 Adobe
4+
* All Rights Reserved.
55
*/
66

77
namespace Magento\Tax\Model\Sales\Total\Quote;
88

99
use Magento\Customer\Api\AccountManagementInterface as CustomerAccountManagement;
1010
use Magento\Customer\Api\Data\AddressInterfaceFactory as CustomerAddressFactory;
1111
use Magento\Customer\Api\Data\AddressInterface as CustomerAddress;
12+
use Magento\Customer\Api\Data\RegionInterfaceFactory;
1213
use Magento\Customer\Api\Data\RegionInterfaceFactory as CustomerAddressRegionFactory;
13-
use Magento\Framework\DataObject;
1414
use Magento\Quote\Model\Quote\Address as QuoteAddress;
1515
use Magento\Quote\Model\Quote\Address\Total\AbstractTotal;
1616
use Magento\Quote\Model\Quote\Item\AbstractItem;
1717
use Magento\Store\Model\Store;
1818
use Magento\Tax\Api\Data\QuoteDetailsInterfaceFactory;
1919
use Magento\Tax\Api\Data\QuoteDetailsItemInterface;
20+
use Magento\Tax\Api\Data\QuoteDetailsItemInterfaceFactory;
2021
use Magento\Tax\Api\Data\TaxClassKeyInterfaceFactory;
2122
use Magento\Tax\Api\Data\TaxClassKeyInterface;
2223
use Magento\Tax\Api\Data\TaxDetailsInterface;
2324
use Magento\Tax\Api\Data\TaxDetailsItemInterface;
2425
use Magento\Tax\Api\Data\QuoteDetailsInterface;
2526
use Magento\Quote\Api\Data\ShippingAssignmentInterface;
27+
use Magento\Tax\Api\TaxCalculationInterface;
2628
use Magento\Tax\Helper\Data as TaxHelper;
2729
use Magento\Framework\App\ObjectManager;
2830
use Magento\Tax\Api\Data\QuoteDetailsItemExtensionInterface;
2931
use Magento\Tax\Api\Data\QuoteDetailsItemExtensionInterfaceFactory;
32+
use Magento\Tax\Model\Config;
3033

3134
/**
3235
* Tax totals calculation model
@@ -127,6 +130,11 @@ class CommonTaxCollector extends AbstractTotal
127130
*/
128131
protected $customerAddressRegionFactory;
129132

133+
/**
134+
* @var RegionInterfaceFactory
135+
*/
136+
private RegionInterfaceFactory $regionFactory;
137+
130138
/**
131139
* @var \Magento\Tax\Api\Data\TaxClassKeyInterfaceFactory
132140
*/
@@ -155,13 +163,14 @@ class CommonTaxCollector extends AbstractTotal
155163
/**
156164
* Class constructor
157165
*
158-
* @param \Magento\Tax\Model\Config $taxConfig
159-
* @param \Magento\Tax\Api\TaxCalculationInterface $taxCalculationService
166+
* @param Config $taxConfig
167+
* @param TaxCalculationInterface $taxCalculationService
160168
* @param QuoteDetailsInterfaceFactory $quoteDetailsDataObjectFactory
161-
* @param \Magento\Tax\Api\Data\QuoteDetailsItemInterfaceFactory $quoteDetailsItemDataObjectFactory
162-
* @param \Magento\Tax\Api\Data\TaxClassKeyInterfaceFactory $taxClassKeyDataObjectFactory
169+
* @param QuoteDetailsItemInterfaceFactory $quoteDetailsItemDataObjectFactory
170+
* @param TaxClassKeyInterfaceFactory $taxClassKeyDataObjectFactory
163171
* @param CustomerAddressFactory $customerAddressFactory
164172
* @param CustomerAddressRegionFactory $customerAddressRegionFactory
173+
* @param RegionInterfaceFactory $regionInterfaceFactory
165174
* @param TaxHelper|null $taxHelper
166175
* @param QuoteDetailsItemExtensionInterfaceFactory|null $quoteDetailsItemExtensionInterfaceFactory
167176
* @param CustomerAccountManagement|null $customerAccountManagement
@@ -175,6 +184,7 @@ public function __construct(
175184
\Magento\Tax\Api\Data\TaxClassKeyInterfaceFactory $taxClassKeyDataObjectFactory,
176185
CustomerAddressFactory $customerAddressFactory,
177186
CustomerAddressRegionFactory $customerAddressRegionFactory,
187+
RegionInterfaceFactory $regionInterfaceFactory,
178188
TaxHelper $taxHelper = null,
179189
QuoteDetailsItemExtensionInterfaceFactory $quoteDetailsItemExtensionInterfaceFactory = null,
180190
?CustomerAccountManagement $customerAccountManagement = null
@@ -186,6 +196,7 @@ public function __construct(
186196
$this->quoteDetailsItemDataObjectFactory = $quoteDetailsItemDataObjectFactory;
187197
$this->customerAddressFactory = $customerAddressFactory;
188198
$this->customerAddressRegionFactory = $customerAddressRegionFactory;
199+
$this->regionFactory = $regionInterfaceFactory;
189200
$this->taxHelper = $taxHelper ?: ObjectManager::getInstance()->get(TaxHelper::class);
190201
$this->quoteDetailsItemExtensionFactory = $quoteDetailsItemExtensionInterfaceFactory ?:
191202
ObjectManager::getInstance()->get(QuoteDetailsItemExtensionInterfaceFactory::class);
@@ -215,6 +226,9 @@ public function mapAddress(QuoteAddress $address)
215226
$customerAddress->setRegion(
216227
$this->customerAddressRegionFactory->create()->setRegionId($address->getRegionId())
217228
);
229+
$region = $this->regionFactory->create()->setRegionCode($address->getRegionCode());
230+
$region->setRegion($address->getRegion());
231+
$customerAddress->setRegion($region);
218232
$customerAddress->setPostcode($address->getPostcode());
219233
$customerAddress->setCity($address->getCity());
220234
$customerAddress->setStreet($address->getStreet());

app/code/Magento/Tax/Model/Sales/Total/Quote/Tax.php

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,20 @@
66
namespace Magento\Tax\Model\Sales\Total\Quote;
77

88
use Magento\Customer\Api\Data\AddressInterfaceFactory as CustomerAddressFactory;
9+
use Magento\Customer\Api\Data\RegionInterfaceFactory;
910
use Magento\Customer\Api\Data\RegionInterfaceFactory as CustomerAddressRegionFactory;
1011
use Magento\Framework\App\ObjectManager;
1112
use Magento\Framework\Serialize\Serializer\Json;
1213
use Magento\Quote\Api\Data\ShippingAssignmentInterface;
1314
use Magento\Quote\Model\Quote\Address;
15+
use Magento\Tax\Api\Data\QuoteDetailsInterfaceFactory;
16+
use Magento\Tax\Api\Data\QuoteDetailsItemInterfaceFactory;
1417
use Magento\Tax\Api\Data\TaxClassKeyInterface;
18+
use Magento\Tax\Api\Data\TaxClassKeyInterfaceFactory;
19+
use Magento\Tax\Api\TaxCalculationInterface;
20+
use Magento\Tax\Helper\Data;
1521
use Magento\Tax\Model\Calculation;
22+
use Magento\Tax\Model\Config;
1623

1724
/**
1825
* Tax totals calculation model
@@ -52,15 +59,16 @@ class Tax extends CommonTaxCollector
5259
/**
5360
* Class constructor
5461
*
55-
* @param \Magento\Tax\Model\Config $taxConfig
56-
* @param \Magento\Tax\Api\TaxCalculationInterface $taxCalculationService
57-
* @param \Magento\Tax\Api\Data\QuoteDetailsInterfaceFactory $quoteDetailsDataObjectFactory
58-
* @param \Magento\Tax\Api\Data\QuoteDetailsItemInterfaceFactory $quoteDetailsItemDataObjectFactory
59-
* @param \Magento\Tax\Api\Data\TaxClassKeyInterfaceFactory $taxClassKeyDataObjectFactory
62+
* @param Config $taxConfig
63+
* @param TaxCalculationInterface $taxCalculationService
64+
* @param QuoteDetailsInterfaceFactory $quoteDetailsDataObjectFactory
65+
* @param QuoteDetailsItemInterfaceFactory $quoteDetailsItemDataObjectFactory
66+
* @param TaxClassKeyInterfaceFactory $taxClassKeyDataObjectFactory
6067
* @param CustomerAddressFactory $customerAddressFactory
6168
* @param CustomerAddressRegionFactory $customerAddressRegionFactory
62-
* @param \Magento\Tax\Helper\Data $taxData
63-
* @param Json $serializer
69+
* @param CustomerAddressRegionFactory $regionInterfaceFactory
70+
* @param Data $taxData
71+
* @param Json|null $serializer
6472
*/
6573
public function __construct(
6674
\Magento\Tax\Model\Config $taxConfig,
@@ -70,6 +78,7 @@ public function __construct(
7078
\Magento\Tax\Api\Data\TaxClassKeyInterfaceFactory $taxClassKeyDataObjectFactory,
7179
CustomerAddressFactory $customerAddressFactory,
7280
CustomerAddressRegionFactory $customerAddressRegionFactory,
81+
RegionInterfaceFactory $regionInterfaceFactory,
7382
\Magento\Tax\Helper\Data $taxData,
7483
Json $serializer = null
7584
) {
@@ -83,7 +92,8 @@ public function __construct(
8392
$quoteDetailsItemDataObjectFactory,
8493
$taxClassKeyDataObjectFactory,
8594
$customerAddressFactory,
86-
$customerAddressRegionFactory
95+
$customerAddressRegionFactory,
96+
$regionInterfaceFactory
8797
);
8898
}
8999

0 commit comments

Comments
 (0)