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
1 change: 1 addition & 0 deletions app/code/Magento/Catalog/view/base/web/js/price-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ define([
s = amount < 0 ? '-' : isShowSign ? '+' : '';
} else if (isShowSign === false) {
s = '';
pattern = '%s';
}
pattern = pattern.indexOf('{sign}') < 0 ? s + pattern : pattern.replace('{sign}', s);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ define([
return priceUtils.formatPrice(price, quote.getPriceFormat());
},

getFormattedPriceWithoutSign: function (price) {
return priceUtils.formatPrice(price, quote.getPriceFormat(), false);
},

/**
* @return {*}
*/
Expand All @@ -39,4 +43,4 @@ define([
return stepNavigator.isProcessed('shipping');
}
});
});
});
6 changes: 2 additions & 4 deletions app/code/Magento/Tax/view/frontend/templates/order/tax.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile

?>
<?php
$_order = $block->getOrder();
Expand All @@ -26,7 +24,7 @@
<td <?= /* @escapeNotVerified */ $block->getLabelProperties() ?>>
<?= $block->escapeHtml($title) ?>
<?php if (!is_null($percent)): ?>
(<?= (float)$percent ?>%)
(<?= /* @noEscape */ $_order->getOrderCurrency()->formatTxt((float)$percent, ['display' => \Magento\Framework\Currency::NO_SYMBOL]) ?>%)
<?php endif; ?>
<br />
</td>
Expand Down Expand Up @@ -54,4 +52,4 @@
<td <?= /* @escapeNotVerified */ $block->getValueProperties() ?> data-th="<?= $block->escapeHtml(__('Tax')) ?>">
<?= /* @escapeNotVerified */ $_order->formatPrice($_source->getTaxAmount()) ?>
</td>
</tr>
</tr>
Original file line number Diff line number Diff line change
Expand Up @@ -102,30 +102,11 @@ define([
},

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

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);
formatTxt: function (percent) {
return this.getFormattedPriceWithoutSign(percent);
},

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,24 @@
<!-- ko foreach: rates -->
<tr class="totals-tax-details">
<!-- ko if: percent -->
<th class="mark" scope="row" data-bind="text: title + ' (' + percent + '%)'"></th>
<th class="mark" scope="row" data-bind="text: title + ' (' + $parents[1].formatTxt(percent) + '%)'"></th>
<!-- /ko -->
<!-- ko if: !percent -->
<th class="mark" scope="row" data-bind="text: title"></th>
<!-- /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>
<!-- 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 -->
</tr>
<!-- /ko -->
<!-- /ko -->
<!-- /ko -->
<!-- /ko -->