Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ define([
'Magento_Checkout/js/model/quote',
'Magento_Checkout/js/model/totals',
'jquery',
'mage/translate'
], function (ko, Component, quote, totals, $, $t) {
'mage/translate',
'underscore'
], function (ko, Component, quote, totals, $t, _) {
'use strict';

var isTaxDisplayedInGrandTotal = window.checkoutConfig.includeTaxInGrandTotal,
isFullTaxSummaryDisplayed = window.checkoutConfig.isFullTaxSummaryDisplayed,
isZeroTaxDisplayed = window.checkoutConfig.isZeroTaxDisplayed;
isZeroTaxDisplayed = window.checkoutConfig.isZeroTaxDisplayed,
taxAmount = 0,
rates = 0;

return Component.extend({
defaults: {
Expand Down Expand Up @@ -99,6 +102,33 @@ define([
return this.getFormattedPrice(amount);
},

/**
* @param {*} parent
* @param {*} percentage
* @return {*|String}
*/
getTaxAmount: function (parent, percentage) {
var totalPercentage = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

totalPercentage variable is declared twice in this file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @sivaschenko I've updated code. Thanks 👍


taxAmount = parent.amount;
rates = parent.rates;
_.each(rates, function (rate) {
totalPercentage += parseFloat(rate.percent);
});

return this.getFormattedPrice(this.getPercentAmount(taxAmount, totalPercentage, percentage));
},

/**
* @param {*} amount
* @param {*} totalPercentage
* @param {*} percentage
* @return {*|String}
*/
getPercentAmount: function (amount, totalPercentage, percentage) {
return parseFloat(amount * percentage / totalPercentage);
},

/**
* @return {Array}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,16 @@
<!-- ko if: !percent -->
<th class="mark" scope="row" colspan="1" data-bind="text: title"></th>
<!-- /ko -->
<!-- ko if: $index() == 0 -->
<td class="amount" rowspan="1">
<!-- ko if: $parents[1].isCalculated() -->
<span class="price"
data-bind="text: $parents[1].formatPrice($parents[0].amount), attr: {'data-th': title, 'rowspan': $parents[0].rates.length }"></span>
<!-- /ko -->
<!-- ko ifnot: $parents[1].isCalculated() -->
<span class="not-calculated"
data-bind="text: $parents[1].formatPrice($parents[0].amount), attr: {'data-th': title, 'rowspan': $parents[0].rates.length }"></span>
<!-- /ko -->
</td>
<!-- /ko -->
<td class="amount" rowspan="1">
<!-- ko if: $parents[1].isCalculated() -->
<span class="price"
data-bind="text: $parents[1].getTaxAmount($parents[0], percent), attr: {'data-th': title, 'rowspan': $parents[0].rates.length }"></span>
<!-- /ko -->
<!-- ko ifnot: $parents[1].isCalculated() -->
<span class="not-calculated"
data-bind="text: $parents[1].getTaxAmount($parents[0], percent), attr: {'data-th': title, 'rowspan': $parents[0].rates.length }"></span>
<!-- /ko -->
</td>
</tr>
<!-- /ko -->
<!-- /ko -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,16 @@
<!-- ko if: !percent -->
<th class="mark" scope="row" data-bind="text: title"></th>
<!-- /ko -->
<!-- ko if: $index() == 0 -->
<td class="amount">
<!-- ko if: $parents[1].isCalculated() -->
<span class="price"
data-bind="text: $parents[1].formatPrice($parents[0].amount), attr: {'data-th': title, 'rowspan': $parents[0].rates.length }"></span>
<!-- /ko -->
<!-- ko ifnot: $parents[1].isCalculated() -->
<span class="not-calculated"
data-bind="text: $parents[1].formatPrice($parents[0].amount), attr: {'data-th': title, 'rowspan': $parents[0].rates.length }"></span>
<!-- /ko -->
</td>
<!-- /ko -->
<td class="amount">
<!-- ko if: $parents[1].isCalculated() -->
<span class="price"
data-bind="text: $parents[1].getTaxAmount($parents[0], percent), attr: {'data-th': title, 'rowspan': $parents[0].rates.length }"></span>
<!-- /ko -->
<!-- ko ifnot: $parents[1].isCalculated() -->
<span class="not-calculated"
data-bind="text: $parents[1].getTaxAmount($parents[0], percent), attr: {'data-th': title, 'rowspan': $parents[0].rates.length }"></span>
<!-- /ko -->
</td>
</tr>
<!-- /ko -->
<!-- /ko -->
Expand Down