mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-28 05:14:12 +03:00
209d3662d4
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
20 lines
527 B
JavaScript
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);
|
|
});
|