mirror of
https://github.com/mokuappio/serverless-invoices.git
synced 2025-10-27 07:51:08 -04:00
currency.filter.js - fix edge case rounding
This commit is contained in:
@ -5,7 +5,7 @@ export function formatCurrency(val, digits = 2) {
|
||||
return '';
|
||||
}
|
||||
const decimalLimiter = 10 ** digits;
|
||||
x = Math.round(x * decimalLimiter) / decimalLimiter;
|
||||
x = Math.round((x + Number.EPSILON) * decimalLimiter) / decimalLimiter;
|
||||
const parts = x.toFixed(digits).split('.');
|
||||
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ' ');
|
||||
return parts.join('.');
|
||||
|
||||
Reference in New Issue
Block a user