mirror of
https://github.com/SuiteCRM/SuiteCRM-Core.git
synced 2025-08-29 21:00:39 +08:00
Fix #478 - Add from format check on toUserFormat
This commit is contained in:
parent
464830fd9d
commit
c6778416d3
2 changed files with 12 additions and 3 deletions
|
@ -81,7 +81,8 @@ export class UpdateValueAction extends FieldLogicActionHandler {
|
|||
|
||||
if (this.isCurrencyField(field)) {
|
||||
const options = {
|
||||
mode: 'edit' as ViewMode
|
||||
mode: 'edit' as ViewMode,
|
||||
fromFormat: 'system'
|
||||
}
|
||||
value = this.currencyFormatter.toUserFormat(value, options);
|
||||
}
|
||||
|
|
|
@ -29,7 +29,8 @@ import {UserPreferenceStore} from '../../../store/user-preference/user-preferenc
|
|||
import {formatCurrency, formatNumber} from '@angular/common';
|
||||
import {NumberFormatter} from '../number/number-formatter.service';
|
||||
import {FormatOptions, Formatter} from '../formatter.model';
|
||||
import {isVoid} from '../../../common/utils/value-utils';
|
||||
import {isVoid} from 'common';
|
||||
import {SystemConfigStore} from "../../../store/system-config/system-config.store";
|
||||
|
||||
export interface CurrencyFormat {
|
||||
iso4217: string;
|
||||
|
@ -44,6 +45,7 @@ export class CurrencyFormatter implements Formatter {
|
|||
|
||||
constructor(
|
||||
protected preferences: UserPreferenceStore,
|
||||
protected configs: SystemConfigStore,
|
||||
protected numberFormatter: NumberFormatter,
|
||||
@Inject(LOCALE_ID) public locale: string
|
||||
) {
|
||||
|
@ -57,6 +59,7 @@ export class CurrencyFormatter implements Formatter {
|
|||
|
||||
const symbol = (options && options.symbol) || this.getSymbol();
|
||||
const code = (options && options.code) || this.getCode();
|
||||
const defaultGroup = this.configs.getConfigValue('default_number_grouping_seperator');
|
||||
let digits = null;
|
||||
if (options && options.digits !== null && isFinite(options.digits)) {
|
||||
digits = options.digits;
|
||||
|
@ -64,7 +67,12 @@ export class CurrencyFormatter implements Formatter {
|
|||
|
||||
const digitsInfo = this.getDigitsInfo(digits);
|
||||
let formatted: string;
|
||||
|
||||
if (options?.fromFormat === 'system' && value.includes(defaultGroup)){
|
||||
value = value.replace(defaultGroup, '');
|
||||
} else {
|
||||
value = this.replaceSeparatorsToInternalFormat(value);
|
||||
}
|
||||
|
||||
if (options && options.mode === 'edit') {
|
||||
formatted = formatNumber(Number(value), this.locale, digitsInfo);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue