33 * Copyright 2014 Adobe
44 * All Rights Reserved.
55 */
6-
76namespace Magento \Tax \Model \Sales \Total \Quote ;
87
98use Magento \Customer \Api \AccountManagementInterface as CustomerAccountManagement ;
109use Magento \Customer \Api \Data \AddressInterfaceFactory as CustomerAddressFactory ;
1110use Magento \Customer \Api \Data \AddressInterface as CustomerAddress ;
12- use Magento \Customer \Api \Data \RegionInterfaceFactory ;
1311use Magento \Customer \Api \Data \RegionInterfaceFactory as CustomerAddressRegionFactory ;
1412use Magento \Quote \Model \Quote \Address as QuoteAddress ;
1513use Magento \Quote \Model \Quote \Address \Total \AbstractTotal ;
2725use Magento \Tax \Api \TaxCalculationInterface ;
2826use Magento \Tax \Helper \Data as TaxHelper ;
2927use Magento \Framework \App \ObjectManager ;
30- use Magento \Tax \Api \Data \QuoteDetailsItemExtensionInterface ;
3128use Magento \Tax \Api \Data \QuoteDetailsItemExtensionInterfaceFactory ;
3229use Magento \Tax \Model \Config ;
3330
@@ -130,11 +127,6 @@ class CommonTaxCollector extends AbstractTotal
130127 */
131128 protected $ customerAddressRegionFactory ;
132129
133- /**
134- * @var RegionInterfaceFactory
135- */
136- private RegionInterfaceFactory $ regionFactory ;
137-
138130 /**
139131 * @var \Magento\Tax\Api\Data\TaxClassKeyInterfaceFactory
140132 */
@@ -170,7 +162,6 @@ class CommonTaxCollector extends AbstractTotal
170162 * @param TaxClassKeyInterfaceFactory $taxClassKeyDataObjectFactory
171163 * @param CustomerAddressFactory $customerAddressFactory
172164 * @param CustomerAddressRegionFactory $customerAddressRegionFactory
173- * @param RegionInterfaceFactory $regionInterfaceFactory
174165 * @param TaxHelper|null $taxHelper
175166 * @param QuoteDetailsItemExtensionInterfaceFactory|null $quoteDetailsItemExtensionInterfaceFactory
176167 * @param CustomerAccountManagement|null $customerAccountManagement
@@ -184,7 +175,6 @@ public function __construct(
184175 \Magento \Tax \Api \Data \TaxClassKeyInterfaceFactory $ taxClassKeyDataObjectFactory ,
185176 CustomerAddressFactory $ customerAddressFactory ,
186177 CustomerAddressRegionFactory $ customerAddressRegionFactory ,
187- RegionInterfaceFactory $ regionInterfaceFactory ,
188178 TaxHelper $ taxHelper = null ,
189179 QuoteDetailsItemExtensionInterfaceFactory $ quoteDetailsItemExtensionInterfaceFactory = null ,
190180 ?CustomerAccountManagement $ customerAccountManagement = null
@@ -196,7 +186,6 @@ public function __construct(
196186 $ this ->quoteDetailsItemDataObjectFactory = $ quoteDetailsItemDataObjectFactory ;
197187 $ this ->customerAddressFactory = $ customerAddressFactory ;
198188 $ this ->customerAddressRegionFactory = $ customerAddressRegionFactory ;
199- $ this ->regionFactory = $ regionInterfaceFactory ;
200189 $ this ->taxHelper = $ taxHelper ?: ObjectManager::getInstance ()->get (TaxHelper::class);
201190 $ this ->quoteDetailsItemExtensionFactory = $ quoteDetailsItemExtensionInterfaceFactory ?:
202191 ObjectManager::getInstance ()->get (QuoteDetailsItemExtensionInterfaceFactory::class);
@@ -223,11 +212,16 @@ public function mapAddress(QuoteAddress $address)
223212 {
224213 $ customerAddress = $ this ->customerAddressFactory ->create ();
225214 $ customerAddress ->setCountryId ($ address ->getCountryId ());
226- $ customerAddress ->setRegion (
227- $ this ->customerAddressRegionFactory ->create ()->setRegionId ($ address ->getRegionId ())
215+ $ region = $ this ->customerAddressRegionFactory ->create (
216+ [
217+ 'data ' =>
218+ [
219+ 'region_id ' => $ address ->getRegionId (),
220+ 'region_code ' => $ address ->getRegionCode (),
221+ 'region ' => $ address ->getRegion ()
222+ ]
223+ ]
228224 );
229- $ region = $ this ->regionFactory ->create ()->setRegionCode ($ address ->getRegionCode ());
230- $ region ->setRegion ($ address ->getRegion ());
231225 $ customerAddress ->setRegion ($ region );
232226 $ customerAddress ->setPostcode ($ address ->getPostcode ());
233227 $ customerAddress ->setCity ($ address ->getCity ());
0 commit comments