mirror of
				https://github.com/mokuappio/serverless-invoices.git
				synced 2025-10-27 16:01:07 -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 ''; |       return ''; | ||||||
|     } |     } | ||||||
|     const decimalLimiter = 10 ** digits; |     const decimalLimiter = 10 ** digits; | ||||||
|     x = Math.round(x * decimalLimiter) / decimalLimiter; |     x = Math.round((x + Number.EPSILON) * decimalLimiter) / decimalLimiter; | ||||||
|     const parts = x.toFixed(digits).split('.'); |     const parts = x.toFixed(digits).split('.'); | ||||||
|     parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ' '); |     parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ' '); | ||||||
|     return parts.join('.'); |     return parts.join('.'); | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user