2022-01-17 21:53:43 +03:00
|
|
|
import {formatNumber} from './format-number';
|
2021-06-04 10:37:47 +03:00
|
|
|
import {helper} from '@ember/component/helper';
|
|
|
|
|
|
|
|
export function ghPriceAmount(amount) {
|
|
|
|
if (amount) {
|
2021-10-20 14:13:27 +03:00
|
|
|
let price = amount / 100;
|
|
|
|
if (price % 1 === 0) {
|
2022-01-17 21:53:43 +03:00
|
|
|
return formatNumber(price);
|
2021-10-20 14:13:27 +03:00
|
|
|
} else {
|
2022-01-18 12:45:55 +03:00
|
|
|
return formatNumber(Math.round(price * 100) / 100);
|
2021-10-20 14:13:27 +03:00
|
|
|
}
|
2021-06-04 10:37:47 +03:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// like {{pluralize}} but formats the number according to current locale
|
|
|
|
export default helper(function ([amount]) {
|
|
|
|
return ghPriceAmount(amount);
|
|
|
|
});
|