multi-currency support in roi calculator
This commit is contained in:
parent
adc3a6b905
commit
5cc6b779c5
7 changed files with 231 additions and 45 deletions
|
|
@ -3,9 +3,17 @@
|
|||
* Handles input formatting, validation, and parsing
|
||||
*/
|
||||
class InputUtils {
|
||||
static formatNumberWithCommas(num) {
|
||||
static formatNumberWithCommas(num, currency = null) {
|
||||
try {
|
||||
return parseInt(num).toLocaleString('en-US');
|
||||
// Get current currency if not provided
|
||||
if (!currency) {
|
||||
const currencyElement = document.getElementById('currency');
|
||||
currency = currencyElement ? currencyElement.value : 'CHF';
|
||||
}
|
||||
|
||||
// Use appropriate locale for number formatting
|
||||
const locale = currency === 'EUR' ? 'de-DE' : 'de-CH';
|
||||
return parseInt(num).toLocaleString(locale);
|
||||
} catch (error) {
|
||||
console.error('Error formatting number with commas:', error);
|
||||
return String(num);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue