taler-ios

iOS apps for GNU Taler (wallet)
Log | Files | Refs | README | LICENSE

commit d6a3539c91e480b6528b12ba18ab3ffdecfac5ce
parent cce5bdd535fd33dd8d65682c47994f2f8d06d19a
Author: Marc Stibane <marc@taler.net>
Date:   Mon, 26 Feb 2024 21:45:30 +0100

fake Swiss Francs

Diffstat:
MTalerWallet1/Controllers/Controller.swift | 3++-
MTalerWallet1/Helper/CurrencySpecification.swift | 12++++++++++++
2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/TalerWallet1/Controllers/Controller.swift b/TalerWallet1/Controllers/Controller.swift @@ -69,7 +69,8 @@ class Controller: ObservableObject { } func info(for currency: String) -> CurrencyInfo? { -// return CurrencyInfo.euro() // FAKE EURO instead of the real Currency +// return CurrencyInfo.euro() // Fake EUR instead of the real Currency +// return CurrencyInfo.francs() // Fake CHF instead of the real Currency for info in currencyInfos { if info.scope.currency == currency { return info diff --git a/TalerWallet1/Helper/CurrencySpecification.swift b/TalerWallet1/Helper/CurrencySpecification.swift @@ -90,6 +90,18 @@ public struct CurrencyInfo { return CurrencyInfo(scope: scope, specs: specs, formatter: formatter) } + public static func francs() -> CurrencyInfo { + let currency = "CHF" + let scope = ScopeInfo(type: .global, currency: currency) + let specs = CurrencySpecification(name: currency, + fractionalInputDigits: 2, + fractionalNormalDigits: 2, + fractionalTrailingZeroDigits: 2, + altUnitNames: [0 : "CHF"]) + let formatter = CurrencyFormatter.formatter(scope: scope, specs: specs) + return CurrencyInfo(scope: scope, specs: specs, formatter: formatter) + } + /// returns all characters left from the decimalSeparator func integerPartStr(_ integerStr: String, decimalSeparator: String) -> String { if let integerIndex = integerStr.endIndex(of: decimalSeparator) {