Skip to content

Commit a83adce

Browse files
authored
ENGCOM-4022: Full Tax Summary display wrong numbers #20682
2 parents 6bbbfe2 + 77968b3 commit a83adce

File tree

3 files changed

+53
-27
lines changed
  • app/code/Magento/Tax/view/frontend/web

3 files changed

+53
-27
lines changed

app/code/Magento/Tax/view/frontend/web/js/view/checkout/summary/tax.js

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@ define([
1212
'Magento_Checkout/js/view/summary/abstract-total',
1313
'Magento_Checkout/js/model/quote',
1414
'Magento_Checkout/js/model/totals',
15-
'mage/translate'
16-
], function (ko, Component, quote, totals, $t) {
15+
'mage/translate',
16+
'underscore'
17+
], function (ko, Component, quote, totals, $t, _) {
1718
'use strict';
1819

1920
var isTaxDisplayedInGrandTotal = window.checkoutConfig.includeTaxInGrandTotal,
2021
isFullTaxSummaryDisplayed = window.checkoutConfig.isFullTaxSummaryDisplayed,
21-
isZeroTaxDisplayed = window.checkoutConfig.isZeroTaxDisplayed;
22+
isZeroTaxDisplayed = window.checkoutConfig.isZeroTaxDisplayed,
23+
taxAmount = 0,
24+
rates = 0;
2225

2326
return Component.extend({
2427
defaults: {
@@ -98,6 +101,33 @@ define([
98101
return this.getFormattedPrice(amount);
99102
},
100103

104+
/**
105+
* @param {*} parent
106+
* @param {*} percentage
107+
* @return {*|String}
108+
*/
109+
getTaxAmount: function (parent, percentage) {
110+
var totalPercentage = 0;
111+
112+
taxAmount = parent.amount;
113+
rates = parent.rates;
114+
_.each(rates, function (rate) {
115+
totalPercentage += parseFloat(rate.percent);
116+
});
117+
118+
return this.getFormattedPrice(this.getPercentAmount(taxAmount, totalPercentage, percentage));
119+
},
120+
121+
/**
122+
* @param {*} amount
123+
* @param {*} totalPercentage
124+
* @param {*} percentage
125+
* @return {*|String}
126+
*/
127+
getPercentAmount: function (amount, totalPercentage, percentage) {
128+
return parseFloat(amount * percentage / totalPercentage);
129+
},
130+
101131
/**
102132
* @return {Array}
103133
*/

app/code/Magento/Tax/view/frontend/web/template/checkout/cart/totals/tax.html

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,16 @@
3232
<!-- ko if: !percent -->
3333
<th class="mark" scope="row" colspan="1" data-bind="text: title"></th>
3434
<!-- /ko -->
35-
<!-- ko if: $index() == 0 -->
36-
<td class="amount" rowspan="1">
37-
<!-- ko if: $parents[1].isCalculated() -->
38-
<span class="price"
39-
data-bind="text: $parents[1].formatPrice($parents[0].amount), attr: {'data-th': title, 'rowspan': $parents[0].rates.length }"></span>
40-
<!-- /ko -->
41-
<!-- ko ifnot: $parents[1].isCalculated() -->
42-
<span class="not-calculated"
43-
data-bind="text: $parents[1].formatPrice($parents[0].amount), attr: {'data-th': title, 'rowspan': $parents[0].rates.length }"></span>
44-
<!-- /ko -->
45-
</td>
46-
<!-- /ko -->
35+
<td class="amount" rowspan="1">
36+
<!-- ko if: $parents[1].isCalculated() -->
37+
<span class="price"
38+
data-bind="text: $parents[1].getTaxAmount($parents[0], percent), attr: {'data-th': title, 'rowspan': $parents[0].rates.length }"></span>
39+
<!-- /ko -->
40+
<!-- ko ifnot: $parents[1].isCalculated() -->
41+
<span class="not-calculated"
42+
data-bind="text: $parents[1].getTaxAmount($parents[0], percent), attr: {'data-th': title, 'rowspan': $parents[0].rates.length }"></span>
43+
<!-- /ko -->
44+
</td>
4745
</tr>
4846
<!-- /ko -->
4947
<!-- /ko -->

app/code/Magento/Tax/view/frontend/web/template/checkout/summary/tax.html

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,16 @@
4343
<!-- ko if: !percent -->
4444
<th class="mark" scope="row" data-bind="text: title"></th>
4545
<!-- /ko -->
46-
<!-- ko if: $index() == 0 -->
47-
<td class="amount">
48-
<!-- ko if: $parents[1].isCalculated() -->
49-
<span class="price"
50-
data-bind="text: $parents[1].formatPrice($parents[0].amount), attr: {'data-th': title, 'rowspan': $parents[0].rates.length }"></span>
51-
<!-- /ko -->
52-
<!-- ko ifnot: $parents[1].isCalculated() -->
53-
<span class="not-calculated"
54-
data-bind="text: $parents[1].formatPrice($parents[0].amount), attr: {'data-th': title, 'rowspan': $parents[0].rates.length }"></span>
55-
<!-- /ko -->
56-
</td>
57-
<!-- /ko -->
46+
<td class="amount">
47+
<!-- ko if: $parents[1].isCalculated() -->
48+
<span class="price"
49+
data-bind="text: $parents[1].getTaxAmount($parents[0], percent), attr: {'data-th': title, 'rowspan': $parents[0].rates.length }"></span>
50+
<!-- /ko -->
51+
<!-- ko ifnot: $parents[1].isCalculated() -->
52+
<span class="not-calculated"
53+
data-bind="text: $parents[1].getTaxAmount($parents[0], percent), attr: {'data-th': title, 'rowspan': $parents[0].rates.length }"></span>
54+
<!-- /ko -->
55+
</td>
5856
</tr>
5957
<!-- /ko -->
6058
<!-- /ko -->

0 commit comments

Comments
 (0)