taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit 26795a873da076487486edc0dd36384511af5a3f
parent 277525602b8831f036ab34fe96ea64f22c292b4c
Author: Sebastian <sebasjm@taler-systems.com>
Date:   Mon,  1 Jun 2026 11:19:16 -0300

handle when there is no currency spec

Diffstat:
Mpackages/taler-util/src/amounts.ts | 14++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/packages/taler-util/src/amounts.ts b/packages/taler-util/src/amounts.ts @@ -722,18 +722,24 @@ export class Amounts { static stringifyValueWithSpec( value: AmountJson, - spec: CurrencySpecification, + spec: CurrencySpecification | undefined, ): { currency: string; normal: string; small?: string } { const strValue = Amounts.stringifyValue(value); + let currency = value.currency; + if (!spec) { + return { + currency, + normal: strValue, + }; + } 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); + const names = !spec ? [] : Object.keys(spec.alt_unit_names); let FRAC_POS_NEW_POSITION = originalPosition; //find symbol //FIXME: this should be based on a cache to speed up - if (names.length > 0) { + if (spec && names.length > 0) { let unitIndex: string = "0"; //default entry by DD51 names.forEach((index) => { const i = Number.parseInt(index, 10);