1
0
mirror of https://github.com/TryGhost/Ghost.git synced 2024-12-21 09:52:06 +03:00
Ghost/ghost/admin/app/helpers/gh-price-amount.js
Rishabh 209d3662d4 Fixed incorrect price amount formatting
no refs

- price amount formatting was incorrectly calling `toFixed` method on a string, which is not needed as we already round off the amount before formatting
2022-01-18 15:16:09 +05:30

20 lines
527 B
JavaScript

import {formatNumber} from './format-number';
import {helper} from '@ember/component/helper';
export function ghPriceAmount(amount) {
if (amount) {
let price = amount / 100;
if (price % 1 === 0) {
return formatNumber(price);
} else {
return formatNumber(Math.round(price * 100) / 100);
}
}
return 0;
}
// like {{pluralize}} but formats the number according to current locale
export default helper(function ([amount]) {
return ghPriceAmount(amount);
});