Fix #478 - Add replace separators to internal format function

This commit is contained in:
Jack Anderson 2024-07-11 14:16:25 +01:00 committed by y.yerli
parent 3d9fcc190e
commit 7c96218746
2 changed files with 16 additions and 0 deletions

View file

@ -64,6 +64,7 @@ export class CurrencyFormatter implements Formatter {
const digitsInfo = this.getDigitsInfo(digits); const digitsInfo = this.getDigitsInfo(digits);
let formatted: string; let formatted: string;
value = this.replaceSeparatorsToInternalFormat(value);
if (options && options.mode === 'edit') { if (options && options.mode === 'edit') {
formatted = formatNumber(Number(value), this.locale, digitsInfo); formatted = formatNumber(Number(value), this.locale, digitsInfo);
@ -142,4 +143,8 @@ export class CurrencyFormatter implements Formatter {
replaceSeparators(transformed: string): string { replaceSeparators(transformed: string): string {
return this.numberFormatter.replaceSeparators(transformed); return this.numberFormatter.replaceSeparators(transformed);
} }
replaceSeparatorsToInternalFormat(value: string): string {
return this.numberFormatter.replaceSeparatorsToInternalFormat(value);
}
} }

View file

@ -151,6 +151,17 @@ export class NumberFormatter implements Formatter {
return transformed; return transformed;
} }
replaceSeparatorsToInternalFormat(value: string): string {
const decimalSymbol = this.getDecimalsSymbol() || '.';
const formattedValue = this.toInternalFormat(value);
if (decimalSymbol !== '.' && value.includes(decimalSymbol)) {
value = formattedValue;
}
return value;
}
validateIntUserFormat(inputValue: any): boolean { validateIntUserFormat(inputValue: any): boolean {
const trimmedInputValue = this.formUtils.getTrimmedInputValue(inputValue); const trimmedInputValue = this.formUtils.getTrimmedInputValue(inputValue);