Fix somewhat ridiculous formatMoney to work with negative amounts

This commit is contained in:
Marshall Polaris 2022-10-02 21:58:49 -07:00
parent 6bdb490992
commit 4ab843d34f

View File

@ -13,7 +13,9 @@ export function formatMoney(amount: number) {
Math.round(amount) === 0
? 0
: // Handle 499.9999999999999 case
Math.floor(amount + 0.00000000001 * Math.sign(amount))
(amount > 0 ? Math.floor : Math.ceil)(
amount + 0.00000000001 * Math.sign(amount)
)
return ENV_CONFIG.moneyMoniker + formatter.format(newAmount).replace('$', '')
}