Skip to content

Commit 8622773

Browse files
ENGCOM-4022: Full Tax Summary display wrong numbers #20682
- Merge Pull Request #20682 from niravkrish/magento2:patch-19701 - Merged commits: 1. 2258f50 2. 938eaf3 3. d6b1000 4. 8e4c9ad 5. 11b9b44
2 parents 2957731 + 11b9b44 commit 8622773

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,17 @@ 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+
totalPercentage = 0,
24+
amount = '',
25+
rates = '';
2226

2327
return Component.extend({
2428
defaults: {
@@ -98,6 +102,32 @@ define([
98102
return this.getFormattedPrice(amount);
99103
},
100104

105+
/**
106+
* @param {*} parent
107+
* @param {*} percentage
108+
* @return {*|String}
109+
*/
110+
getTaxAmount: function (parent, percentage) {
111+
amount = parent.amount;
112+
rates = parent.rates;
113+
totalPercentage = 0;
114+
_.each(rates, function (rate) {
115+
totalPercentage += parseFloat(rate.percent);
116+
});
117+
118+
return this.getFormattedPrice(this.getPercentAmount(amount, 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)