Skip to content

Commit 830807e

Browse files
committed
MAGETWO-53366: Tax Report does not display any records
- updating unit tests for modified classes on previous commit
1 parent 62964be commit 830807e

File tree

3 files changed

+106
-58
lines changed

3 files changed

+106
-58
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ protected function saveOrderTax(\Magento\Sales\Api\Data\OrderInterface $order)
7777

7878
$ratesIdQuoteItemId = [];
7979
foreach ($taxesForItems as $taxesArray) {
80-
foreach ($taxesArray->getAppliedTaxes() as $rates) {
80+
foreach ($taxesArray['applied_taxes'] as $rates) {
8181
if (count($rates['rates']) == 1) {
8282
$ratesIdQuoteItemId[$rates['id']][] = [
8383
'id' => $taxesArray['item_id'],

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

Lines changed: 49 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -256,49 +256,52 @@ public function afterSaveDataProvider()
256256
//item tax, three tax rates
257257
[
258258
//first two taxes are combined
259-
[
260-
'amount' => 0.11,
261-
'base_amount' => 0.11,
262-
'percent' => 11,
263-
'id' => 'ILUS',
264-
'rates' => [
259+
'item_id' => self::ITEMID,
260+
'type' => 'product',
261+
'associated_item_id' => null,
262+
'applied_taxes' => [
265263
[
266-
'percent' => 6,
267-
'code' => 'IL',
268-
'title' => 'IL',
264+
'amount' => 0.11,
265+
'base_amount' => 0.11,
266+
'percent' => 11,
267+
'id' => 'ILUS',
268+
'rates' => [
269+
[
270+
'percent' => 6,
271+
'code' => 'IL',
272+
'title' => 'IL',
273+
],
274+
[
275+
'percent' => 5,
276+
'code' => 'US',
277+
'title' => 'US',
278+
],
269279
],
270-
[
271-
'percent' => 5,
272-
'code' => 'US',
273-
'title' => 'US',
274280
],
275-
],
276-
'item_id' => self::ITEMID,
277-
'item_type' => 'product',
278-
'associated_item_id' => null,
279-
],
280-
//city tax
281-
[
282-
'amount' => 0.03,
283-
'base_amount' => 0.03,
284-
'percent' => 3.33,
285-
'id' => 'CityTax',
286-
'rates' => [
281+
//city tax
287282
[
288-
'percent' => 3,
289-
'code' => 'CityTax',
290-
'title' => 'CityTax',
283+
'amount' => 0.03,
284+
'base_amount' => 0.03,
285+
'percent' => 3.33,
286+
'id' => 'CityTax',
287+
'rates' => [
288+
[
289+
'percent' => 3,
290+
'code' => 'CityTax',
291+
'title' => 'CityTax',
292+
],
293+
]
291294
],
292295
],
293-
'item_id' => self::ITEMID,
294-
'item_type' => 'product',
295-
'associated_item_id' => null,
296-
],
297296
],
298297
//shipping tax
299298
[
300299
//first two taxes are combined
301-
[
300+
'item_id' => null,
301+
'type' => 'shipping',
302+
'associated_item_id' => null,
303+
'applied_taxes' => [
304+
[
302305
'amount' => 0.55,
303306
'base_amount' => 0.55,
304307
'percent' => 11,
@@ -315,26 +318,21 @@ public function afterSaveDataProvider()
315318
'title' => 'US',
316319
],
317320
],
318-
'item_id' => null,
319-
'item_type' => 'shipping',
320-
'associated_item_id' => null,
321-
],
322-
//city tax
323-
[
324-
'amount' => 0.17,
325-
'base_amount' => 0.17,
326-
'percent' => 3.33,
327-
'id' => 'CityTax',
328-
'rates' => [
329-
[
330-
'percent' => 3,
331-
'code' => 'CityTax',
332-
'title' => 'CityTax',
321+
],
322+
//city tax
323+
[
324+
'amount' => 0.17,
325+
'base_amount' => 0.17,
326+
'percent' => 3.33,
327+
'id' => 'CityTax',
328+
'rates' => [
329+
[
330+
'percent' => 3,
331+
'code' => 'CityTax',
332+
'title' => 'CityTax',
333+
],
333334
],
334335
],
335-
'item_id' => null,
336-
'item_type' => 'shipping',
337-
'associated_item_id' => null,
338336
],
339337
],
340338
],

app/code/Magento/Tax/Test/Unit/Model/Quote/ToOrderConverterTest.php

Lines changed: 56 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,16 @@ protected function setupOrderExtensionAttributeMock()
7575
}
7676

7777
/**
78+
* @param array $appliedTaxes
79+
* @param array $itemsAppliedTaxes
80+
* @param array $item_applied_taxes_expected
7881
* @dataProvider afterConvertDataProvider
7982
*/
80-
public function testAfterConvert($appliedTaxes, $itemsAppliedTaxes)
81-
{
83+
public function testAfterConvert(
84+
$appliedTaxes,
85+
$itemsAppliedTaxes,
86+
$item_applied_taxes_expected
87+
) {
8288
$this->model->beforeConvert($this->subjectMock, $this->quoteAddressMock);
8389

8490
$this->quoteAddressMock->expects($this->once())
@@ -106,7 +112,7 @@ public function testAfterConvert($appliedTaxes, $itemsAppliedTaxes)
106112
->with(true);
107113
$orderExtensionAttributeMock->expects($this->once())
108114
->method('setItemAppliedTaxes')
109-
->with($itemsAppliedTaxes);
115+
->with($item_applied_taxes_expected);
110116
$orderMock->expects($this->once())
111117
->method('setExtensionAttributes')
112118
->with($orderExtensionAttributeMock);
@@ -115,10 +121,16 @@ public function testAfterConvert($appliedTaxes, $itemsAppliedTaxes)
115121
}
116122

117123
/**
124+
* @param array $appliedTaxes
125+
* @param array $itemsAppliedTaxes
126+
* @param array $item_applied_taxes_expected
118127
* @dataProvider afterConvertDataProvider
119128
*/
120-
public function testAfterConvertNullExtensionAttribute($appliedTaxes, $itemsAppliedTaxes)
121-
{
129+
public function testAfterConvertNullExtensionAttribute(
130+
$appliedTaxes,
131+
$itemsAppliedTaxes,
132+
$item_applied_taxes_expected
133+
) {
122134
$this->model->beforeConvert($this->subjectMock, $this->quoteAddressMock);
123135

124136
$this->quoteAddressMock->expects($this->once())
@@ -150,14 +162,19 @@ public function testAfterConvertNullExtensionAttribute($appliedTaxes, $itemsAppl
150162
->with(true);
151163
$orderExtensionAttributeMock->expects($this->once())
152164
->method('setItemAppliedTaxes')
153-
->with($itemsAppliedTaxes);
165+
->with($item_applied_taxes_expected);
154166
$orderMock->expects($this->once())
155167
->method('setExtensionAttributes')
156168
->with($orderExtensionAttributeMock);
157169

158170
$this->assertEquals($orderMock, $this->model->afterConvert($this->subjectMock, $orderMock));
159171
}
160172

173+
/**
174+
* Data provider for testAfterConvert and testAfterConvertNullExtensionAttribute
175+
*
176+
* @return array
177+
*/
161178
public function afterConvertDataProvider()
162179
{
163180
return [
@@ -180,15 +197,48 @@ public function afterConvertDataProvider()
180197
[
181198
'amount' => 0.06,
182199
'item_id' => 146,
200+
'item_type' => 'product',
201+
'associated_item_id' => null
183202
],
184203
],
185204
'shipping' => [
186205
[
187206
'amount' => 0.30,
207+
'item_id' => 146,
188208
'item_type' => 'shipping',
209+
'associated_item_id' => null
189210
]
190211
],
191212
],
213+
'item_applied_taxes_expected' => [
214+
'sequence-1' => [
215+
'item_id' => 146,
216+
'type' => 'product',
217+
'associated_item_id' => null,
218+
'applied_taxes' => [
219+
[
220+
'amount' => 0.06,
221+
'item_id' => 146,
222+
'item_type' => 'product',
223+
'associated_item_id' => null,
224+
]
225+
],
226+
227+
],
228+
'shipping' => [
229+
'item_id' => 146,
230+
'type' => 'shipping',
231+
'associated_item_id' => null,
232+
'applied_taxes' => [
233+
[
234+
'amount' => 0.30,
235+
'item_id' => 146,
236+
'item_type' => 'shipping',
237+
'associated_item_id' => null,
238+
]
239+
],
240+
],
241+
],
192242
],
193243
];
194244
}

0 commit comments

Comments
 (0)