Ghost/ghost/admin/app/helpers/gh-price-amount.js
Simon Backx 2b4e80b3dd Rounded MRR in dashboard
refs https://github.com/TryGhost/Team/issues/1602

- Added `cents` option to ghPriceAmount helper.
- Removed cents from MRR in dashboard.
2022-05-10 17:35:51 +02:00

20 lines
606 B
JavaScript

import {formatNumber} from './format-number';
import {helper} from '@ember/component/helper';
export function ghPriceAmount(amount, {cents = true} = {}) {
if (amount) {
let price = cents ? amount / 100 : Math.round(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], options = {}) {
return ghPriceAmount(amount, options);
});