1
1
<?php
2
2
/**
3
- * Copyright © Magento, Inc. All rights reserved.
4
- * See COPYING.txt for license details .
3
+ * Copyright 2014 Adobe
4
+ * All Rights Reserved .
5
5
*/
6
6
7
7
namespace Magento \Tax \Model \Sales \Total \Quote ;
8
8
9
9
use Magento \Customer \Api \AccountManagementInterface as CustomerAccountManagement ;
10
10
use Magento \Customer \Api \Data \AddressInterfaceFactory as CustomerAddressFactory ;
11
11
use Magento \Customer \Api \Data \AddressInterface as CustomerAddress ;
12
+ use Magento \Customer \Api \Data \RegionInterfaceFactory ;
12
13
use Magento \Customer \Api \Data \RegionInterfaceFactory as CustomerAddressRegionFactory ;
13
- use Magento \Framework \DataObject ;
14
14
use Magento \Quote \Model \Quote \Address as QuoteAddress ;
15
15
use Magento \Quote \Model \Quote \Address \Total \AbstractTotal ;
16
16
use Magento \Quote \Model \Quote \Item \AbstractItem ;
17
17
use Magento \Store \Model \Store ;
18
18
use Magento \Tax \Api \Data \QuoteDetailsInterfaceFactory ;
19
19
use Magento \Tax \Api \Data \QuoteDetailsItemInterface ;
20
+ use Magento \Tax \Api \Data \QuoteDetailsItemInterfaceFactory ;
20
21
use Magento \Tax \Api \Data \TaxClassKeyInterfaceFactory ;
21
22
use Magento \Tax \Api \Data \TaxClassKeyInterface ;
22
23
use Magento \Tax \Api \Data \TaxDetailsInterface ;
23
24
use Magento \Tax \Api \Data \TaxDetailsItemInterface ;
24
25
use Magento \Tax \Api \Data \QuoteDetailsInterface ;
25
26
use Magento \Quote \Api \Data \ShippingAssignmentInterface ;
27
+ use Magento \Tax \Api \TaxCalculationInterface ;
26
28
use Magento \Tax \Helper \Data as TaxHelper ;
27
29
use Magento \Framework \App \ObjectManager ;
28
30
use Magento \Tax \Api \Data \QuoteDetailsItemExtensionInterface ;
29
31
use Magento \Tax \Api \Data \QuoteDetailsItemExtensionInterfaceFactory ;
32
+ use Magento \Tax \Model \Config ;
30
33
31
34
/**
32
35
* Tax totals calculation model
@@ -127,6 +130,11 @@ class CommonTaxCollector extends AbstractTotal
127
130
*/
128
131
protected $ customerAddressRegionFactory ;
129
132
133
+ /**
134
+ * @var RegionInterfaceFactory
135
+ */
136
+ private RegionInterfaceFactory $ regionFactory ;
137
+
130
138
/**
131
139
* @var \Magento\Tax\Api\Data\TaxClassKeyInterfaceFactory
132
140
*/
@@ -155,13 +163,14 @@ class CommonTaxCollector extends AbstractTotal
155
163
/**
156
164
* Class constructor
157
165
*
158
- * @param \Magento\Tax\Model\ Config $taxConfig
159
- * @param \Magento\Tax\Api\ TaxCalculationInterface $taxCalculationService
166
+ * @param Config $taxConfig
167
+ * @param TaxCalculationInterface $taxCalculationService
160
168
* @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
163
171
* @param CustomerAddressFactory $customerAddressFactory
164
172
* @param CustomerAddressRegionFactory $customerAddressRegionFactory
173
+ * @param RegionInterfaceFactory $regionInterfaceFactory
165
174
* @param TaxHelper|null $taxHelper
166
175
* @param QuoteDetailsItemExtensionInterfaceFactory|null $quoteDetailsItemExtensionInterfaceFactory
167
176
* @param CustomerAccountManagement|null $customerAccountManagement
@@ -175,6 +184,7 @@ public function __construct(
175
184
\Magento \Tax \Api \Data \TaxClassKeyInterfaceFactory $ taxClassKeyDataObjectFactory ,
176
185
CustomerAddressFactory $ customerAddressFactory ,
177
186
CustomerAddressRegionFactory $ customerAddressRegionFactory ,
187
+ RegionInterfaceFactory $ regionInterfaceFactory ,
178
188
TaxHelper $ taxHelper = null ,
179
189
QuoteDetailsItemExtensionInterfaceFactory $ quoteDetailsItemExtensionInterfaceFactory = null ,
180
190
?CustomerAccountManagement $ customerAccountManagement = null
@@ -186,6 +196,7 @@ public function __construct(
186
196
$ this ->quoteDetailsItemDataObjectFactory = $ quoteDetailsItemDataObjectFactory ;
187
197
$ this ->customerAddressFactory = $ customerAddressFactory ;
188
198
$ this ->customerAddressRegionFactory = $ customerAddressRegionFactory ;
199
+ $ this ->regionFactory = $ regionInterfaceFactory ;
189
200
$ this ->taxHelper = $ taxHelper ?: ObjectManager::getInstance ()->get (TaxHelper::class);
190
201
$ this ->quoteDetailsItemExtensionFactory = $ quoteDetailsItemExtensionInterfaceFactory ?:
191
202
ObjectManager::getInstance ()->get (QuoteDetailsItemExtensionInterfaceFactory::class);
@@ -215,6 +226,9 @@ public function mapAddress(QuoteAddress $address)
215
226
$ customerAddress ->setRegion (
216
227
$ this ->customerAddressRegionFactory ->create ()->setRegionId ($ address ->getRegionId ())
217
228
);
229
+ $ region = $ this ->regionFactory ->create ()->setRegionCode ($ address ->getRegionCode ());
230
+ $ region ->setRegion ($ address ->getRegion ());
231
+ $ customerAddress ->setRegion ($ region );
218
232
$ customerAddress ->setPostcode ($ address ->getPostcode ());
219
233
$ customerAddress ->setCity ($ address ->getCity ());
220
234
$ customerAddress ->setStreet ($ address ->getStreet ());
0 commit comments