Skip to content

Commit 1bcea07

Browse files
author
Mike Weis
committed
Merge branch 'FearlessKiwis-MAGETWO-48452-GITHUB-2451-base_tax_amount-is-inaccurate-for-Credit-Memo-items_NEW' into develop
2 parents 7d07c0b + 98fa339 commit 1bcea07

File tree

2 files changed

+90
-1
lines changed
  • app/code/Magento/Sales

2 files changed

+90
-1
lines changed

app/code/Magento/Sales/Model/Order/Creditmemo/Total/Tax.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function collect(\Magento\Sales\Model\Order\Creditmemo $creditmemo)
4242
*/
4343

4444
$tax = $orderItemTax - $orderItem->getTaxRefunded();
45-
$baseTax = $baseOrderItemTax - $orderItem->getTaxRefunded();
45+
$baseTax = $baseOrderItemTax - $orderItem->getBaseTaxRefunded();
4646
$discountTaxCompensation = $orderItem->getDiscountTaxCompensationInvoiced() -
4747
$orderItem->getDiscountTaxCompensationRefunded();
4848
$baseDiscountTaxCompensation = $orderItem->getBaseDiscountTaxCompensationInvoiced() -

app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Total/TaxTest.php

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,95 @@ public function collectDataProvider()
232232
],
233233
];
234234

235+
$currencyRatio = 2;
236+
// scenario 1: 3 item_1, 3 item_2, $99 each, 8.19 tax rate
237+
// 1 item_1 and 2 item_2 are invoiced and base currency <> display currency
238+
$result['partial_invoice_partial_creditmemo_different_currencies'] = [
239+
'order_data' => [
240+
'data_fields' => [
241+
'shipping_tax_amount' => 2.45 * $currencyRatio,
242+
'base_shipping_tax_amount' => 2.45,
243+
'shipping_discount_tax_compensation_amount' => 0.00,
244+
'base_shipping_discount_tax_compensation_amount' => 0.00,
245+
'tax_amount' => 53.56 * $currencyRatio,
246+
'base_tax_amount' => 53.56,
247+
'tax_invoiced' => 24.33 * $currencyRatio,
248+
'base_tax_invoiced' => 24.33,
249+
'tax_refunded' => 0.00,
250+
'base_tax_refunded' => 0.00,
251+
'base_shipping_amount' => 30.00,
252+
],
253+
],
254+
'creditmemo_data' => [
255+
'items' => [
256+
'item_1' => [
257+
'order_item' => [
258+
'qty_invoiced' => 1,
259+
'tax_invoiced' => 8.11 * $currencyRatio,
260+
'tax_refunded' => 0,
261+
'base_tax_invoiced' => 8.11,
262+
'base_tax_refunded' => 0,
263+
'discount_tax_compensation_amount' => 0,
264+
'base_discount_tax_compensation_amount' => 0,
265+
'qty_refunded' => 0,
266+
],
267+
'is_last' => false,
268+
'qty' => 1,
269+
],
270+
'item_2' => [
271+
'order_item' => [
272+
'qty_invoiced' => 2,
273+
'tax_refunded' => 0,
274+
'tax_invoiced' => 16.22 * $currencyRatio,
275+
'base_tax_refunded' => 0,
276+
'base_tax_invoiced' => 16.22,
277+
'discount_tax_compensation_amount' => 0,
278+
'base_discount_tax_compensation_amount' => 0,
279+
'qty_refunded' => 0,
280+
],
281+
'is_last' => false,
282+
'qty' => 1,
283+
],
284+
],
285+
'is_last' => false,
286+
'data_fields' => [
287+
'grand_total' => 198 * $currencyRatio,
288+
'base_grand_total' => 198,
289+
'base_shipping_amount' => 30,
290+
'tax_amount' => 0.82 * $currencyRatio,
291+
'base_tax_amount' => 0.82,
292+
'invoice' => new MagentoObject(
293+
[
294+
'shipping_tax_amount' => 2.45 * $currencyRatio,
295+
'base_shipping_tax_amount' => 2.45,
296+
'shipping_discount_tax_compensation_amount' => 0,
297+
'base_shipping_discount_tax_compensation_amount' => 0,
298+
]
299+
),
300+
],
301+
],
302+
'expected_results' => [
303+
'creditmemo_items' => [
304+
'item_1' => [
305+
'tax_amount' => 8.11 * $currencyRatio,
306+
'base_tax_amount' => 8.11,
307+
],
308+
'item_2' => [
309+
'tax_amount' => 8.11 * $currencyRatio,
310+
'base_tax_amount' => 8.11,
311+
],
312+
],
313+
'creditmemo_data' => [
314+
'grand_total' => 216.67 * $currencyRatio,
315+
'base_grand_total' => 216.67,
316+
'tax_amount' => 19.49 * $currencyRatio,
317+
'base_tax_amount' => 19.49,
318+
'shipping_tax_amount' => 2.45 * $currencyRatio,
319+
'base_shipping_tax_amount' => 2.45,
320+
],
321+
],
322+
];
323+
235324
// scenario 2: 3 items, 2 invoiced, rowtotal of 150 with 8.25 tax rate
236325
// extra tax amount exist (weee tax), make sure that tax amount
237326
// is not over the amount invoiced

0 commit comments

Comments
 (0)