diff --git a/packages/loot-core/src/shared/util.test.ts b/packages/loot-core/src/shared/util.test.ts index 019b51c34546f16998bac84dc864233be9325c1d..ea42f2532d684470127f99a1973330ffadde3d0b 100644 --- a/packages/loot-core/src/shared/util.test.ts +++ b/packages/loot-core/src/shared/util.test.ts @@ -44,6 +44,16 @@ describe('utility functions', () => { expect(formatter.format(Number('1234.56'))).toBe('1,235'); }); + test('number formatting works with comma-dot-in format', () => { + setNumberFormat({ format: 'comma-dot-in', hideFraction: false }); + let formatter = getNumberFormat().formatter; + expect(formatter.format(Number('1234567.89'))).toBe('12,34,567.89'); + + setNumberFormat({ format: 'comma-dot-in', hideFraction: true }); + formatter = getNumberFormat().formatter; + expect(formatter.format(Number('1234567.89'))).toBe('12,34,568'); + }); + test('number formatting works with dot-comma format', () => { setNumberFormat({ format: 'dot-comma', hideFraction: false }); let formatter = getNumberFormat().formatter; diff --git a/packages/loot-core/src/shared/util.ts b/packages/loot-core/src/shared/util.ts index e28d1d4c8abb3751fc0dcfc6f422b35ed923f778..eedbceb877bef941edebee66c287696092ea57d6 100644 --- a/packages/loot-core/src/shared/util.ts +++ b/packages/loot-core/src/shared/util.ts @@ -188,6 +188,7 @@ export let numberFormats = [ { value: 'dot-comma', label: '1.000,33', labelNoFraction: '1.000' }, { value: 'space-comma', label: '1 000,33', labelNoFraction: '1 000' }, { value: 'space-dot', label: '1 000.33', labelNoFraction: '1 000' }, + { value: 'comma-dot-in', label: '1,00,000.33', labelNoFraction: '1,00,000' }, ] as const; let numberFormat: { @@ -220,6 +221,11 @@ export function setNumberFormat({ format, hideFraction }) { regex = /[^-0-9.]/g; separator = '.'; break; + case 'comma-dot-in': + locale = 'en-IN'; + regex = /[^-0-9.]/g; + separator = '.'; + break; case 'comma-dot': default: locale = 'en-US'; diff --git a/upcoming-release-notes/1412.md b/upcoming-release-notes/1412.md new file mode 100644 index 0000000000000000000000000000000000000000..a194298bcaea6f9aa12893f784ca4a7f89b291d0 --- /dev/null +++ b/upcoming-release-notes/1412.md @@ -0,0 +1,6 @@ +--- +category: Enhancements +authors: [sidvishnoi] +--- + +Add Indian numbering format (lakh, crore)