Skip to content

Commit a2ded12

Browse files
committed
MAGETWO-90971: Error is returned when customer checks out with multiple addresses
1 parent 426e322 commit a2ded12

File tree

2 files changed

+71
-97
lines changed

2 files changed

+71
-97
lines changed

app/code/Magento/Tax/Model/Plugin/OrderSave.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ protected function saveOrderTax(\Magento\Sales\Api\Data\OrderInterface $order)
7979
foreach ($taxesForItems as $taxesArray) {
8080
foreach ($taxesArray['applied_taxes'] as $rates) {
8181
if (isset($rates['extension_attributes'])) {
82-
/** @var \Magento\Tax\Api\Data\AppliedTaxRateInterface[] $taxRates */
83-
$taxRates = $rates['extension_attributes']->getRates();
82+
$taxRates = $rates['extension_attributes']['rates'];
8483
if (is_array($taxRates)) {
8584
if (count($taxRates) == 1) {
8685
$ratesIdQuoteItemId[$rates['id']][] = [
@@ -124,8 +123,7 @@ protected function saveOrderTax(\Magento\Sales\Api\Data\OrderInterface $order)
124123
foreach ($taxes as $row) {
125124
$id = $row['id'];
126125
if (isset($row['extension_attributes'])) {
127-
/** @var \Magento\Tax\Api\Data\AppliedTaxRateInterface[] $taxRates */
128-
$taxRates = $row['extension_attributes']->getRates();
126+
$taxRates = $row['extension_attributes']['rates'];
129127
if (is_array($taxRates)) {
130128
foreach ($taxRates as $tax) {
131129
if ($row['percent'] == null) {

app/code/Magento/Tax/Test/Unit/Model/Plugin/OrderSaveTest.php

Lines changed: 69 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -210,93 +210,6 @@ public function testAfterSave(
210210
*/
211211
public function afterSaveDataProvider()
212212
{
213-
$orderTaxDetailsApplied = $this->getMockBuilder(\Magento\Tax\Api\Data\OrderTaxDetailsAppliedTaxInterface::class)
214-
->disableOriginalConstructor()
215-
->setMethods(['getRates'])
216-
->getMockForAbstractClass();
217-
218-
$orderTaxDetailsApplied->expects($this->at(0))
219-
->method('getRates')
220-
->willReturn(
221-
[
222-
[
223-
'percent' => 6,
224-
'code' => 'IL',
225-
'title' => 'IL',
226-
],
227-
[
228-
'percent' => 5,
229-
'code' => 'US',
230-
'title' => 'US',
231-
]
232-
]
233-
);
234-
$orderTaxDetailsApplied->expects($this->at(1))
235-
->method('getRates')
236-
->willReturn(
237-
[
238-
[
239-
'percent' => 3,
240-
'code' => 'CityTax',
241-
'title' => 'CityTax',
242-
],
243-
]
244-
);
245-
$orderTaxDetailsApplied->expects($this->at(2))
246-
->method('getRates')
247-
->willReturn(
248-
[
249-
[
250-
'percent' => 6,
251-
'code' => 'IL',
252-
'title' => 'IL',
253-
],
254-
[
255-
'percent' => 5,
256-
'code' => 'US',
257-
'title' => 'US',
258-
],
259-
]
260-
);
261-
$orderTaxDetailsApplied->expects($this->at(3))
262-
->method('getRates')
263-
->willReturn(
264-
[
265-
[
266-
'percent' => 3,
267-
'code' => 'CityTax',
268-
'title' => 'CityTax',
269-
],
270-
]
271-
);
272-
$orderTaxDetailsApplied->expects($this->at(4))
273-
->method('getRates')
274-
->willReturn(
275-
[
276-
[
277-
'percent' => 6,
278-
'code' => 'IL',
279-
'title' => 'IL',
280-
],
281-
[
282-
'percent' => 5,
283-
'code' => 'US',
284-
'title' => 'US',
285-
],
286-
]
287-
);
288-
$orderTaxDetailsApplied->expects($this->at(5))
289-
->method('getRates')
290-
->willReturn(
291-
[
292-
[
293-
'percent' => 3,
294-
'code' => 'CityTax',
295-
'title' => 'CityTax',
296-
],
297-
]
298-
);
299-
300213
return [
301214
//one item with shipping
302215
//three tax rates: state and national tax rates of 6 and 5 percent with priority 0
@@ -308,14 +221,35 @@ public function afterSaveDataProvider()
308221
'base_amount' => 0.66,
309222
'percent' => 11,
310223
'id' => 'ILUS',
311-
'extension_attributes' => $orderTaxDetailsApplied,
224+
'extension_attributes' => [
225+
'rates' => [
226+
[
227+
'percent' => 6,
228+
'code' => 'IL',
229+
'title' => 'IL',
230+
],
231+
[
232+
'percent' => 5,
233+
'code' => 'US',
234+
'title' => 'US',
235+
],
236+
]
237+
],
312238
],
313239
[
314240
'amount' => 0.2,
315241
'base_amount' => 0.2,
316242
'percent' => 3.33,
317243
'id' => 'CityTax',
318-
'extension_attributes' => $orderTaxDetailsApplied,
244+
'extension_attributes' => [
245+
'rates' => [
246+
[
247+
'percent' => 3,
248+
'code' => 'CityTax',
249+
'title' => 'CityTax',
250+
],
251+
]
252+
],
319253
],
320254
],
321255
'item_applied_taxes' => [
@@ -331,15 +265,36 @@ public function afterSaveDataProvider()
331265
'base_amount' => 0.11,
332266
'percent' => 11,
333267
'id' => 'ILUS',
334-
'extension_attributes' => $orderTaxDetailsApplied,
268+
'extension_attributes' => [
269+
'rates' => [
270+
[
271+
'percent' => 6,
272+
'code' => 'IL',
273+
'title' => 'IL',
274+
],
275+
[
276+
'percent' => 5,
277+
'code' => 'US',
278+
'title' => 'US',
279+
],
280+
]
281+
],
335282
],
336283
//city tax
337284
[
338285
'amount' => 0.03,
339286
'base_amount' => 0.03,
340287
'percent' => 3.33,
341288
'id' => 'CityTax',
342-
'extension_attributes' => $orderTaxDetailsApplied,
289+
'extension_attributes' => [
290+
'rates' => [
291+
[
292+
'percent' => 3,
293+
'code' => 'CityTax',
294+
'title' => 'CityTax',
295+
],
296+
]
297+
],
343298
],
344299
],
345300
],
@@ -355,15 +310,36 @@ public function afterSaveDataProvider()
355310
'base_amount' => 0.55,
356311
'percent' => 11,
357312
'id' => 'ILUS',
358-
'extension_attributes' => $orderTaxDetailsApplied,
313+
'extension_attributes' => [
314+
'rates' => [
315+
[
316+
'percent' => 6,
317+
'code' => 'IL',
318+
'title' => 'IL',
319+
],
320+
[
321+
'percent' => 5,
322+
'code' => 'US',
323+
'title' => 'US',
324+
],
325+
]
326+
],
359327
],
360328
//city tax
361329
[
362330
'amount' => 0.17,
363331
'base_amount' => 0.17,
364332
'percent' => 3.33,
365333
'id' => 'CityTax',
366-
'extension_attributes' => $orderTaxDetailsApplied,
334+
'extension_attributes' => [
335+
'rates' => [
336+
[
337+
'percent' => 3,
338+
'code' => 'CityTax',
339+
'title' => 'CityTax',
340+
],
341+
]
342+
],
367343
],
368344
],
369345
],

0 commit comments

Comments
 (0)