Skip to content

Commit 8825752

Browse files
committed
[Backport] Full Tax Summary display wrong numbers
1 parent 994348f commit 8825752

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
@@ -13,13 +13,16 @@ define([
1313
'Magento_Checkout/js/model/quote',
1414
'Magento_Checkout/js/model/totals',
1515
'jquery',
16-
'mage/translate'
17-
], function (ko, Component, quote, totals, $, $t) {
16+
'mage/translate',
17+
'underscore'
18+
], function (ko, Component, quote, totals, $t, _) {
1819
'use strict';
1920

2021
var isTaxDisplayedInGrandTotal = window.checkoutConfig.includeTaxInGrandTotal,
2122
isFullTaxSummaryDisplayed = window.checkoutConfig.isFullTaxSummaryDisplayed,
22-
isZeroTaxDisplayed = window.checkoutConfig.isZeroTaxDisplayed;
23+
isZeroTaxDisplayed = window.checkoutConfig.isZeroTaxDisplayed,
24+
taxAmount = 0,
25+
rates = 0;
2326

2427
return Component.extend({
2528
defaults: {
@@ -99,6 +102,33 @@ define([
99102
return this.getFormattedPrice(amount);
100103
},
101104

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

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)