0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

Updated price amount helper to return decimal values

no refs

- price amount helper was previously always returning whole numbers after rounding-off amount values
- this change updates the behavior to show decimal values upto 2 places when the amount is not a whole number, and a whole number otherwise
This commit is contained in:
Rishabh 2021-10-20 16:43:27 +05:30
parent 82470a723c
commit 27b7bcebac

View file

@ -2,7 +2,12 @@ import {helper} from '@ember/component/helper';
export function ghPriceAmount(amount) {
if (amount) {
return Math.round(amount / 100);
let price = amount / 100;
if (price % 1 === 0) {
return price;
} else {
return Math.round(price * 100) / 100;
}
}
return 0;
}