Is there an existing issue for this?
Current behavior
Description: I have found an issue with the toFormat method of the dinerojs library. When I try to format a monetary amount with the currency symbol at the end, the method removes the decimals from the amount.
Current behavior: The toFormat method removes the decimals when the currency symbol is placed at the end, displaying "10" instead of "10.51€".
Expected behavior
The toFormat method should allow placing the currency symbol at the end without removing the decimals. In the provided example, it should display "10.51€".
Steps to reproduce
- Create an instance of
Dinero with an amount that includes decimals.
- Use the
toFormat method to format the amount with the currency symbol at the end.
Example code:
const Dinero = require('dinero.js');
const amount = Dinero({ amount: 1051, currency: 'EUR' });
const formattedAmount = amount.toFormat('0,0.00$');
console.log(formattedAmount); // Should display "10.51€", but displays "10"
Version
1.9.1
Environment
NodeJs v18.19.0
Code of Conduct