diff options
Diffstat (limited to 'packages/taler-util/src/amounts.ts')
-rw-r--r-- | packages/taler-util/src/amounts.ts | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/packages/taler-util/src/amounts.ts b/packages/taler-util/src/amounts.ts index 76ba3a0c5..3750cf61f 100644 --- a/packages/taler-util/src/amounts.ts +++ b/packages/taler-util/src/amounts.ts @@ -51,7 +51,7 @@ export const amountFractionalLength = 8; export const amountMaxValue = 2 ** 52; /** - * Separator character between interger and fractional + * Separator character between integer and fractional */ export const FRAC_SEPARATOR = "." @@ -550,12 +550,12 @@ export class Amounts { return amountFractionalLength - i + 1; } - + static stringifyValueWithSpec(value: AmountJson, spec: CurrencySpecification): { currency: string, normal: string, small?: string } { const strValue = Amounts.stringifyValue(value) const pos = strValue.indexOf(FRAC_SEPARATOR) const originalPosition = pos < 0 ? strValue.length : pos; - + let currency = value.currency const names = Object.keys(spec.alt_unit_names) let FRAC_POS_NEW_POSITION = originalPosition @@ -574,21 +574,21 @@ export class Amounts { }) currency = spec.alt_unit_names[unitIndex] } - + if (originalPosition === FRAC_POS_NEW_POSITION) { const { normal, small } = splitNormalAndSmall(strValue, originalPosition, spec) return { currency, normal, small } } - + const intPart = strValue.substring(0, originalPosition) const fracPArt = strValue.substring(originalPosition + 1) //indexSize is always smaller than originalPosition - const newValue = intPart.substring(0, FRAC_POS_NEW_POSITION) + FRAC_SEPARATOR + intPart.substring(FRAC_POS_NEW_POSITION) + fracPArt + const newValue = intPart.substring(0, FRAC_POS_NEW_POSITION) + FRAC_SEPARATOR + intPart.substring(FRAC_POS_NEW_POSITION) + fracPArt const { normal, small } = splitNormalAndSmall(newValue, FRAC_POS_NEW_POSITION, spec) return { currency, normal, small } } - - + + } function splitNormalAndSmall(decimal: string, fracSeparatorIndex: number, spec: CurrencySpecification): { normal: string, small?: string } { |