From 6f585df0045ce10e1d25acd0f751a6dc6f71c63d Mon Sep 17 00:00:00 2001 From: Nathan Harris Date: Wed, 8 Jan 2020 20:33:05 -0800 Subject: [PATCH 1/9] Add `CurrencyMetadata` protocol that defines ISO 4217 information properties --- Sources/Currency/CurrencyMetadata.swift | 35 +++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Sources/Currency/CurrencyMetadata.swift diff --git a/Sources/Currency/CurrencyMetadata.swift b/Sources/Currency/CurrencyMetadata.swift new file mode 100644 index 0000000..d68cb3d --- /dev/null +++ b/Sources/Currency/CurrencyMetadata.swift @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Currency open source project +// +// Copyright (c) 2020 Currency project authors +// Licensed under MIT License +// +// See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Currency project authors +// +// SPDX-License-Identifier: MIT +// +//===----------------------------------------------------------------------===// + +/// A type that provides static currency information as defined by ISO 4217. +public protocol CurrencyMetadata { + /// The name of the currency, such as "United States Dollar". + static var name: String { get } + /// The ISO 4217 3-digit letter currency code. + /// + /// For example: "USD" for "United States Dollar". + static var alphabeticCode: String { get } + /// The ISO 4217 3-digit numeric currency code. + /// + /// This code is nomally the same as the ISO 3166-1 country codes, where appropriate. + /// + /// For example, "United States of America" has the ISO 3166-1 code of 840, which is the same for the "USD" currency in ISO 4217. + static var numericCode: UInt16 { get } + /// The number of decimal digits used to express minor units of the currency. + /// + /// For example, the US Dollar has the minor unit (cents) that are 1/100 of a dollar. Therefore, the the minorUnits is `2`. + /// + /// However, the Japanese Yen has no minor unit, so it has `0` minorUnits. + static var minorUnits: UInt8 { get } +} From e541381dd9eade562b39ed32b8cc682eef37afa6 Mon Sep 17 00:00:00 2001 From: Nathan Harris Date: Thu, 9 Jan 2020 13:44:50 -0800 Subject: [PATCH 2/9] Add `Money` protocol for defining how currencies will work --- Sources/Currency/Money.swift | 240 +++++++++++++++++++++++++++++++++++ 1 file changed, 240 insertions(+) create mode 100644 Sources/Currency/Money.swift diff --git a/Sources/Currency/Money.swift b/Sources/Currency/Money.swift new file mode 100644 index 0000000..f64e584 --- /dev/null +++ b/Sources/Currency/Money.swift @@ -0,0 +1,240 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Currency open source project +// +// Copyright (c) 2020 Currency project authors +// Licensed under MIT License +// +// See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Currency project authors +// +// SPDX-License-Identifier: MIT +// +//===----------------------------------------------------------------------===// + +import Foundation + +/// A generic representation of money, with a single `Foundation.Decimal` value holding the exact value of money. +/// +/// Conforming types will also provide `CurrencyMetadata` to access specific ISO 4217 information, such as the alphabetic code and "minor units". +/// +/// **Initialization** +/// +/// As `Foundation.Decimal` has different precision to `BinaryFloatingPoint`, precision will be lost when initializing using float literals. +/// +/// **Equality Comparisons** +/// +/// Floating point values are notorious for having precision variance, even when they are equivalent within the precision range a developer desires. +/// +/// To overcome this, all equality checks between two given Money values by default will use the rounded `amount`. +public protocol Money { + /// The ISO 4217 information about this money's currency. + var currency: CurrencyMetadata.Type { get } + + /// The exact amount of money being represented. + /// - Note: This is likely to be more precise than necessary, so it is recommended to prefer use of `amount` which uses "bankers" rounding. + var rawAmount: Decimal { get } + + /// The "bankers" rounded amount of money being represented. + /// + /// The `rawAmount` will be rounded to the significant digits as defined by the `currency.minorUnits`. + /// + /// See `CurrencyMetadata.minorUnits` and `Foundation.Decimal.RoundingMode.bankers`. + /// - Note: This is usually the desired value to work with, as it is as precise as usually needed. + var amount: Decimal { get } + + /// Initializes a representation of the provided amount. + /// - Parameter amount: The exact amount this instance should represent. + init(_ amount: Decimal) +} + +// MARK: Computed Properties + +fileprivate func round(_ amount: Decimal, to scale: UInt8) -> Decimal { + var result = Decimal.zero + withUnsafePointer(to: amount) { NSDecimalRound(&result, $0, Int(scale), .bankers) } + return result +} + +extension Money { + public var amount: Decimal { return round(self.rawAmount, to: self.currency.minorUnits) } +} + +extension Money where Self: CurrencyMetadata { + public var currency: CurrencyMetadata.Type { return Self.self } +} + +extension Money { + /// Initializes a currency value from it's smallest unit. + /// + /// For example, the USD has cents, which are 1/100 of 1 USD. Calling `USD(minorUnits: 100)` will create a value of `1.0`. + /// + /// See `CurrencyMetadata.minorUnits`. + /// - Parameter minorUnits: The amount of the smallest units in the currency to initialize with. + public init(minorUnits: Int) { + self.init(.zero) + let minorUnitsScale = Int16(self.currency.minorUnits) * -1 + let scaledTotal = NSDecimalNumber(value: minorUnits).multiplying(byPowerOf10: minorUnitsScale) + self = .init(scaledTotal.decimalValue) + } +} + +// MARK: - +// MARK: Arithmetic + +extension Money { + public static func +(lhs: Self, rhs: Self) -> Self { + return .init(lhs.rawAmount + rhs.rawAmount) + } + + public static func -(lhs: Self, rhs: Self) -> Self { + return .init(lhs.rawAmount - rhs.rawAmount) + } + + public static func *(lhs: Self, rhs: Self) -> Self { + return .init(lhs.rawAmount * rhs.rawAmount) + } + + public static func /(lhs: Self, rhs: Self) -> Self { + return .init(lhs.rawAmount / rhs.rawAmount) + } + + public static func +=(lhs: inout Self, rhs: Self) { lhs = lhs + rhs } + public static func -=(lhs: inout Self, rhs: Self) { lhs = lhs - rhs } + public static func *=(lhs: inout Self, rhs: Self) { lhs = lhs * rhs } + public static func /=(lhs: inout Self, rhs: Self) { lhs = lhs / rhs } + + public static func +(lhs: Self, rhs: Decimal) -> Self { + return .init(lhs.rawAmount + rhs) + } + + public static func -(lhs: Self, rhs: Decimal) -> Self { + return .init(lhs.rawAmount - rhs) + } + + public static func *(lhs: Self, rhs: Decimal) -> Self { + return .init(lhs.rawAmount * rhs) + } + + public static func /(lhs: Self, rhs: Decimal) -> Self { + return .init(lhs.rawAmount / rhs) + } + + public static func +=(lhs: inout Self, rhs: Decimal) { lhs = lhs + rhs } + public static func -=(lhs: inout Self, rhs: Decimal) { lhs = lhs - rhs } + public static func *=(lhs: inout Self, rhs: Decimal) { lhs = lhs * rhs } + public static func /=(lhs: inout Self, rhs: Decimal) { lhs = lhs / rhs } +} + +// MARK: Equatable + +extension Money { + public static func ==(lhs: Self, rhs: M) -> Bool { + guard lhs.currency.alphabeticCode == rhs.currency.alphabeticCode else { return false } + return lhs.amount == rhs.amount + } + + /// Checks if the current `amount` is equivalent to the provided decimal, after rounding. + /// + /// As floating point type precisions can vary, doing exact comparisons to raw `amount` values has a high degree of false negatives. + /// To get around this, the provided `other` amount will be rounded to the same precision as the `minorUnits` of the Money's currency using the "banker" mode. + /// + /// See `Money.amount`. + /// - Parameter other: The other amount to "bankers' round, then compare against. + /// - Returns: `true` if the rounded values are equal, otherwise `false`. + public func isEqual(to other: Decimal) -> Bool { + return self.amount == round(other, to: self.currency.minorUnits) + } + + /// Checks if the current `amount` is equivalent to the provided decimal, after rounding. + /// + /// As floating point type precisions can vary, doing exact comparisons to raw `amount` values has a high degree of false negatives. + /// To get around this, the `amount` values will be compared, rather than `rawValues`. + /// + /// See `Money.amount`. + /// - Parameter other: The other money to check if the amounts are equal. + /// - Returns: `true` if the amounts are equal, otherwise `false`. + public func isEqual(to other: M) -> Bool { return self == other } +} + +// MARK: Comparable + +extension Money { + public static func <(lhs: Self, rhs: Self) -> Bool { + return lhs.amount < rhs.amount + } +} + +// MARK: Hashable + +extension Money { + public var hashValue: Int { return self.rawAmount.hashValue } + + public func hash(into hasher: inout Hasher) { + hasher.combine(self.rawAmount) + } +} + +// MARK: - +// MARK: ExpressibleByIntegerLiteral + +extension Money { + public init(integerLiteral value: Int) { + self.init(Decimal(integerLiteral: value)) + } +} + +// MARK: ExpressibleByFloatLiteral + +extension Money { + public init(floatLiteral value: Double) { + self.init(Decimal(floatLiteral: value)) + } +} + +// MARK: - +// MARK: CustomStringCovertible + +extension Money { + public var description: String { return "\(self.amount.description) \(self.currency.alphabeticCode)" } +} + +// MARK: String Interpolation + +// "\(price, withFormatter: ...)" $3,000.98 +// "\(price.description)" 3000.98 USD +// "\(price, forLocale: .current)" $3,000.98 +// "\(price)" $3,000.98 + +extension String.StringInterpolation { + public mutating func appendInterpolation( + _ money: Optional, + forLocale locale: Locale = .current, + nilDescription nilValue: String = "nil" + ) { + switch money { + case .none: self.appendInterpolation(nilValue) + case let .some(value): self.appendInterpolation(value, forLocale: locale, nilDescription: nilValue) + } + } + + public mutating func appendInterpolation( + _ money: Money, + forLocale locale: Locale = .current, + nilDescription nilValue: String = "nil" + ) { + let formatter = NumberFormatter() + formatter.numberStyle = .currency + formatter.locale = locale + formatter.currencyCode = money.currency.alphabeticCode + self.appendInterpolation(money, withFormatter: formatter, nilDescription: nilValue) + } + + public mutating func appendInterpolation( + _ money: Money, + withFormatter formatter: NumberFormatter, + nilDescription nilValue: String = "nil" + ) { + self.appendInterpolation(formatter.string(from: NSDecimalNumber(decimal: money.amount)) ?? nilValue) + } +} From 3a5b64fd9479558835382705421c9ca860e6fea6 Mon Sep 17 00:00:00 2001 From: Nathan Harris Date: Thu, 9 Jan 2020 20:47:31 -0800 Subject: [PATCH 3/9] Add ISO 4217 currencies with gyb template --- README.md | 16 + Resources/ISO4217.csv | 159 ++ Sources/Currency/ISOCurrencies.swift | 2242 ++++++++++++++++++++++ Sources/Currency/ISOCurrencies.swift.gyb | 58 + 4 files changed, 2475 insertions(+) create mode 100644 Resources/ISO4217.csv create mode 100644 Sources/Currency/ISOCurrencies.swift create mode 100644 Sources/Currency/ISOCurrencies.swift.gyb diff --git a/README.md b/README.md index 491c4d9..d9a65a2 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,19 @@ # Currency A description of this package. + +## ISO 4271 Currency List + +### Updating the list + +> You will need **gyb** installed on your machine. + +After updating the [`Resources/ISO4217.csv`](/Resources/ISO4217.csv) with the latest from the [ISO Currency Workgroup](https://www.currency-iso.org/en/home/tables/table-a1.html), +run the following command: + +```bash +find . -name '*.gyb' | \ +while read file; do \ + --line-directive '' -o "${file%.gyb}" "$file"; \ +done +``` diff --git a/Resources/ISO4217.csv b/Resources/ISO4217.csv new file mode 100644 index 0000000..133bce4 --- /dev/null +++ b/Resources/ISO4217.csv @@ -0,0 +1,159 @@ +CtryNm,CcyNm,Ccy,CcyNbr,CcyMnrUnts,CcyNm/_IsFund,CcyNm/__text +UNITED ARAB EMIRATES (THE),UAE Dirham,AED,784,2,, +AFGHANISTAN,Afghani,AFN,971,2,, +ALBANIA,Lek,ALL,8,2,, +ARMENIA,Armenian Dram,AMD,51,2,, +CURAÇAO,Netherlands Antillean Guilder,ANG,532,2,, +ANGOLA,Kwanza,AOA,973,2,, +ARGENTINA,Argentine Peso,ARS,32,2,, +AUSTRALIA,Australian Dollar,AUD,36,2,, +ARUBA,Aruban Florin,AWG,533,2,, +AZERBAIJAN,Azerbaijan Manat,AZN,944,2,, +BOSNIA AND HERZEGOVINA,Convertible Mark,BAM,977,2,, +BARBADOS,Barbados Dollar,BBD,52,2,, +BANGLADESH,Taka,BDT,50,2,, +BULGARIA,Bulgarian Lev,BGN,975,2,, +BAHRAIN,Bahraini Dinar,BHD,48,3,, +BURUNDI,Burundi Franc,BIF,108,0,, +BERMUDA,Bermudian Dollar,BMD,60,2,, +BRUNEI DARUSSALAM,Brunei Dollar,BND,96,2,, +BOLIVIA (PLURINATIONAL STATE OF),Boliviano,BOB,68,2,, +BRAZIL,Brazilian Real,BRL,986,2,, +BAHAMAS (THE),Bahamian Dollar,BSD,44,2,, +BHUTAN,Ngultrum,BTN,64,2,, +BOTSWANA,Pula,BWP,72,2,, +BELARUS,Belarusian Ruble,BYN,933,2,, +BELIZE,Belize Dollar,BZD,84,2,, +CANADA,Canadian Dollar,CAD,124,2,, +CONGO (THE DEMOCRATIC REPUBLIC OF THE),Congolese Franc,CDF,976,2,, +SWITZERLAND,Swiss Franc,CHF,756,2,, +CHILE,Chilean Peso,CLP,152,0,, +CHINA,Yuan Renminbi,CNY,156,2,, +COLOMBIA,Colombian Peso,COP,170,2,, +COSTA RICA,Costa Rican Colon,CRC,188,2,, +CUBA,Peso Convertible,CUC,931,2,, +CUBA,Cuban Peso,CUP,192,2,, +CABO VERDE,Cabo Verde Escudo,CVE,132,2,, +CZECHIA,Czech Koruna,CZK,203,2,, +DJIBOUTI,Djibouti Franc,DJF,262,0,, +DENMARK,Danish Krone,DKK,208,2,, +DOMINICAN REPUBLIC (THE),Dominican Peso,DOP,214,2,, +ALGERIA,Algerian Dinar,DZD,12,2,, +EGYPT,Egyptian Pound,EGP,818,2,, +ERITREA,Nakfa,ERN,232,2,, +ETHIOPIA,Ethiopian Birr,ETB,230,2,, +ÅLAND ISLANDS,Euro,EUR,978,2,, +FIJI,Fiji Dollar,FJD,242,2,, +FALKLAND ISLANDS (THE) [MALVINAS],Falkland Islands Pound,FKP,238,2,, +UNITED KINGDOM OF GREAT BRITAIN AND NORTHERN IRELAND (THE),Pound Sterling,GBP,826,2,, +GEORGIA,Lari,GEL,981,2,, +GHANA,Ghana Cedi,GHS,936,2,, +GIBRALTAR,Gibraltar Pound,GIP,292,2,, +GAMBIA (THE),Dalasi,GMD,270,2,, +GUINEA,Guinean Franc,GNF,324,0,, +GUATEMALA,Quetzal,GTQ,320,2,, +GUYANA,Guyana Dollar,GYD,328,2,, +HONG KONG,Hong Kong Dollar,HKD,344,2,, +HONDURAS,Lempira,HNL,340,2,, +CROATIA,Kuna,HRK,191,2,, +HAITI,Gourde,HTG,332,2,, +HUNGARY,Forint,HUF,348,2,, +INDONESIA,Rupiah,IDR,360,2,, +ISRAEL,New Israeli Sheqel,ILS,376,2,, +INDIA,Indian Rupee,INR,356,2,, +IRAQ,Iraqi Dinar,IQD,368,3,, +IRAN (ISLAMIC REPUBLIC OF),Iranian Rial,IRR,364,2,, +ICELAND,Iceland Krona,ISK,352,0,, +JAMAICA,Jamaican Dollar,JMD,388,2,, +JORDAN,Jordanian Dinar,JOD,400,3,, +JAPAN,Yen,JPY,392,0,, +KENYA,Kenyan Shilling,KES,404,2,, +KYRGYZSTAN,Som,KGS,417,2,, +CAMBODIA,Riel,KHR,116,2,, +COMOROS (THE),Comorian Franc,KMF,174,0,, +KOREA (THE DEMOCRATIC PEOPLE’S REPUBLIC OF),North Korean Won,KPW,408,2,, +KOREA (THE REPUBLIC OF),Won,KRW,410,0,, +KUWAIT,Kuwaiti Dinar,KWD,414,3,, +CAYMAN ISLANDS (THE),Cayman Islands Dollar,KYD,136,2,, +KAZAKHSTAN,Tenge,KZT,398,2,, +LAO PEOPLE’S DEMOCRATIC REPUBLIC (THE),Lao Kip,LAK,418,2,, +LEBANON,Lebanese Pound,LBP,422,2,, +SRI LANKA,Sri Lanka Rupee,LKR,144,2,, +LIBERIA,Liberian Dollar,LRD,430,2,, +LESOTHO,Loti,LSL,426,2,, +LIBYA,Libyan Dinar,LYD,434,3,, +MOROCCO,Moroccan Dirham,MAD,504,2,, +MOLDOVA (THE REPUBLIC OF),Moldovan Leu,MDL,498,2,, +MADAGASCAR,Malagasy Ariary,MGA,969,2,, +MACEDONIA (THE FORMER YUGOSLAV REPUBLIC OF),Denar,MKD,807,2,, +MYANMAR,Kyat,MMK,104,2,, +MONGOLIA,Tugrik,MNT,496,2,, +MACAO,Pataca,MOP,446,2,, +MAURITANIA,Ouguiya,MRU,929,2,, +MAURITIUS,Mauritius Rupee,MUR,480,2,, +MALDIVES,Rufiyaa,MVR,462,2,, +MALAWI,Malawi Kwacha,MWK,454,2,, +MEXICO,Mexican Peso,MXN,484,2,, +MALAYSIA,Malaysian Ringgit,MYR,458,2,, +MOZAMBIQUE,Mozambique Metical,MZN,943,2,, +NAMIBIA,Namibia Dollar,NAD,516,2,, +NIGERIA,Naira,NGN,566,2,, +NICARAGUA,Cordoba Oro,NIO,558,2,, +NORWAY,Norwegian Krone,NOK,578,2,, +NEPAL,Nepalese Rupee,NPR,524,2,, +NEW ZEALAND,New Zealand Dollar,NZD,554,2,, +OMAN,Rial Omani,OMR,512,3,, +PANAMA,Balboa,PAB,590,2,, +PERU,Sol,PEN,604,2,, +PAPUA NEW GUINEA,Kina,PGK,598,2,, +PHILIPPINES (THE),Philippine Peso,PHP,608,2,, +PAKISTAN,Pakistan Rupee,PKR,586,2,, +POLAND,Zloty,PLN,985,2,, +PARAGUAY,Guarani,PYG,600,0,, +QATAR,Qatari Rial,QAR,634,2,, +ROMANIA,Romanian Leu,RON,946,2,, +SERBIA,Serbian Dinar,RSD,941,2,, +RUSSIAN FEDERATION (THE),Russian Ruble,RUB,643,2,, +RWANDA,Rwanda Franc,RWF,646,0,, +SAUDI ARABIA,Saudi Riyal,SAR,682,2,, +SOLOMON ISLANDS,Solomon Islands Dollar,SBD,90,2,, +SEYCHELLES,Seychelles Rupee,SCR,690,2,, +SUDAN (THE),Sudanese Pound,SDG,938,2,, +SWEDEN,Swedish Krona,SEK,752,2,, +SINGAPORE,Singapore Dollar,SGD,702,2,, +"SAINT HELENA, ASCENSION AND TRISTAN DA CUNHA",Saint Helena Pound,SHP,654,2,, +SIERRA LEONE,Leone,SLL,694,2,, +SOMALIA,Somali Shilling,SOS,706,2,, +SURINAME,Surinam Dollar,SRD,968,2,, +SOUTH SUDAN,South Sudanese Pound,SSP,728,2,, +SAO TOME AND PRINCIPE,Dobra,STN,930,2,, +EL SALVADOR,El Salvador Colon,SVC,222,2,, +SYRIAN ARAB REPUBLIC,Syrian Pound,SYP,760,2,, +ESWATINI,Lilangeni,SZL,748,2,, +THAILAND,Baht,THB,764,2,, +TAJIKISTAN,Somoni,TJS,972,2,, +TURKMENISTAN,Turkmenistan New Manat,TMT,934,2,, +TUNISIA,Tunisian Dinar,TND,788,3,, +TONGA,Pa’anga,TOP,776,2,, +TURKEY,Turkish Lira,TRY,949,2,, +TRINIDAD AND TOBAGO,Trinidad and Tobago Dollar,TTD,780,2,, +TAIWAN (PROVINCE OF CHINA),New Taiwan Dollar,TWD,901,2,, +"TANZANIA, UNITED REPUBLIC OF",Tanzanian Shilling,TZS,834,2,, +UKRAINE,Hryvnia,UAH,980,2,, +UGANDA,Uganda Shilling,UGX,800,0,, +UNITED STATES OF AMERICA (THE),US Dollar,USD,840,2,, +URUGUAY,Peso Uruguayo,UYU,858,2,, +URUGUAY,Unidad Previsional,UYW,927,4,, +UZBEKISTAN,Uzbekistan Sum,UZS,860,2,, +VENEZUELA (BOLIVARIAN REPUBLIC OF),Bolívar Soberano,VES,928,2,, +VIET NAM,Dong,VND,704,0,, +VANUATU,Vatu,VUV,548,0,, +SAMOA,Tala,WST,882,2,, +CAMEROON,CFA Franc BEAC,XAF,950,0,, +ANGUILLA,East Caribbean Dollar,XCD,951,2,, +BENIN,CFA Franc BCEAO,XOF,952,0,, +FRENCH POLYNESIA,CFP Franc,XPF,953,0,, +YEMEN,Yemeni Rial,YER,886,2,, +LESOTHO,Rand,ZAR,710,2,, +ZAMBIA,Zambian Kwacha,ZMW,967,2,, +ZIMBABWE,Zimbabwe Dollar,ZWL,932,2,, \ No newline at end of file diff --git a/Sources/Currency/ISOCurrencies.swift b/Sources/Currency/ISOCurrencies.swift new file mode 100644 index 0000000..d9ba977 --- /dev/null +++ b/Sources/Currency/ISOCurrencies.swift @@ -0,0 +1,2242 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Currency open source project +// +// Copyright (c) 2020 Currency project authors +// Licensed under MIT License +// +// See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Currency project authors +// +// SPDX-License-Identifier: MIT +// +//===----------------------------------------------------------------------===// + +import struct Foundation.Decimal + +/// This is a "private" protocol for conforming all ISO 4217 money types to a list of different protocols. +/// - Warning: Do not conform any type to this protocol, nor use it as a type constraint. +/// +/// Breaking changes to this **will** be allowed outside of major semver changes. +public protocol _MoneyUmbrellaProtocol: Money, CurrencyMetadata, + Comparable, Hashable, + ExpressibleByIntegerLiteral, ExpressibleByFloatLiteral, + AdditiveArithmetic { } + +// Contents following this line are automatically generated, and should not be edited. + +// MARK: - +// MARK: ISO 4217 Currencies + +/// The UAE Dirham (AED). +public struct AED: _MoneyUmbrellaProtocol { + public static var name: String { return "UAE Dirham" } + public static var alphabeticCode: String { return "AED" } + public static var numericCode: UInt16 { return 784 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Afghani (AFN). +public struct AFN: _MoneyUmbrellaProtocol { + public static var name: String { return "Afghani" } + public static var alphabeticCode: String { return "AFN" } + public static var numericCode: UInt16 { return 971 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Lek (ALL). +public struct ALL: _MoneyUmbrellaProtocol { + public static var name: String { return "Lek" } + public static var alphabeticCode: String { return "ALL" } + public static var numericCode: UInt16 { return 8 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Armenian Dram (AMD). +public struct AMD: _MoneyUmbrellaProtocol { + public static var name: String { return "Armenian Dram" } + public static var alphabeticCode: String { return "AMD" } + public static var numericCode: UInt16 { return 51 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Netherlands Antillean Guilder (ANG). +public struct ANG: _MoneyUmbrellaProtocol { + public static var name: String { return "Netherlands Antillean Guilder" } + public static var alphabeticCode: String { return "ANG" } + public static var numericCode: UInt16 { return 532 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Kwanza (AOA). +public struct AOA: _MoneyUmbrellaProtocol { + public static var name: String { return "Kwanza" } + public static var alphabeticCode: String { return "AOA" } + public static var numericCode: UInt16 { return 973 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Argentine Peso (ARS). +public struct ARS: _MoneyUmbrellaProtocol { + public static var name: String { return "Argentine Peso" } + public static var alphabeticCode: String { return "ARS" } + public static var numericCode: UInt16 { return 32 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Australian Dollar (AUD). +public struct AUD: _MoneyUmbrellaProtocol { + public static var name: String { return "Australian Dollar" } + public static var alphabeticCode: String { return "AUD" } + public static var numericCode: UInt16 { return 36 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Aruban Florin (AWG). +public struct AWG: _MoneyUmbrellaProtocol { + public static var name: String { return "Aruban Florin" } + public static var alphabeticCode: String { return "AWG" } + public static var numericCode: UInt16 { return 533 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Azerbaijan Manat (AZN). +public struct AZN: _MoneyUmbrellaProtocol { + public static var name: String { return "Azerbaijan Manat" } + public static var alphabeticCode: String { return "AZN" } + public static var numericCode: UInt16 { return 944 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Convertible Mark (BAM). +public struct BAM: _MoneyUmbrellaProtocol { + public static var name: String { return "Convertible Mark" } + public static var alphabeticCode: String { return "BAM" } + public static var numericCode: UInt16 { return 977 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Barbados Dollar (BBD). +public struct BBD: _MoneyUmbrellaProtocol { + public static var name: String { return "Barbados Dollar" } + public static var alphabeticCode: String { return "BBD" } + public static var numericCode: UInt16 { return 52 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Taka (BDT). +public struct BDT: _MoneyUmbrellaProtocol { + public static var name: String { return "Taka" } + public static var alphabeticCode: String { return "BDT" } + public static var numericCode: UInt16 { return 50 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Bulgarian Lev (BGN). +public struct BGN: _MoneyUmbrellaProtocol { + public static var name: String { return "Bulgarian Lev" } + public static var alphabeticCode: String { return "BGN" } + public static var numericCode: UInt16 { return 975 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Bahraini Dinar (BHD). +public struct BHD: _MoneyUmbrellaProtocol { + public static var name: String { return "Bahraini Dinar" } + public static var alphabeticCode: String { return "BHD" } + public static var numericCode: UInt16 { return 48 } + public static var minorUnits: UInt8 { return 3 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Burundi Franc (BIF). +public struct BIF: _MoneyUmbrellaProtocol { + public static var name: String { return "Burundi Franc" } + public static var alphabeticCode: String { return "BIF" } + public static var numericCode: UInt16 { return 108 } + public static var minorUnits: UInt8 { return 0 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Bermudian Dollar (BMD). +public struct BMD: _MoneyUmbrellaProtocol { + public static var name: String { return "Bermudian Dollar" } + public static var alphabeticCode: String { return "BMD" } + public static var numericCode: UInt16 { return 60 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Brunei Dollar (BND). +public struct BND: _MoneyUmbrellaProtocol { + public static var name: String { return "Brunei Dollar" } + public static var alphabeticCode: String { return "BND" } + public static var numericCode: UInt16 { return 96 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Boliviano (BOB). +public struct BOB: _MoneyUmbrellaProtocol { + public static var name: String { return "Boliviano" } + public static var alphabeticCode: String { return "BOB" } + public static var numericCode: UInt16 { return 68 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Brazilian Real (BRL). +public struct BRL: _MoneyUmbrellaProtocol { + public static var name: String { return "Brazilian Real" } + public static var alphabeticCode: String { return "BRL" } + public static var numericCode: UInt16 { return 986 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Bahamian Dollar (BSD). +public struct BSD: _MoneyUmbrellaProtocol { + public static var name: String { return "Bahamian Dollar" } + public static var alphabeticCode: String { return "BSD" } + public static var numericCode: UInt16 { return 44 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Ngultrum (BTN). +public struct BTN: _MoneyUmbrellaProtocol { + public static var name: String { return "Ngultrum" } + public static var alphabeticCode: String { return "BTN" } + public static var numericCode: UInt16 { return 64 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Pula (BWP). +public struct BWP: _MoneyUmbrellaProtocol { + public static var name: String { return "Pula" } + public static var alphabeticCode: String { return "BWP" } + public static var numericCode: UInt16 { return 72 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Belarusian Ruble (BYN). +public struct BYN: _MoneyUmbrellaProtocol { + public static var name: String { return "Belarusian Ruble" } + public static var alphabeticCode: String { return "BYN" } + public static var numericCode: UInt16 { return 933 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Belize Dollar (BZD). +public struct BZD: _MoneyUmbrellaProtocol { + public static var name: String { return "Belize Dollar" } + public static var alphabeticCode: String { return "BZD" } + public static var numericCode: UInt16 { return 84 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Canadian Dollar (CAD). +public struct CAD: _MoneyUmbrellaProtocol { + public static var name: String { return "Canadian Dollar" } + public static var alphabeticCode: String { return "CAD" } + public static var numericCode: UInt16 { return 124 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Congolese Franc (CDF). +public struct CDF: _MoneyUmbrellaProtocol { + public static var name: String { return "Congolese Franc" } + public static var alphabeticCode: String { return "CDF" } + public static var numericCode: UInt16 { return 976 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Swiss Franc (CHF). +public struct CHF: _MoneyUmbrellaProtocol { + public static var name: String { return "Swiss Franc" } + public static var alphabeticCode: String { return "CHF" } + public static var numericCode: UInt16 { return 756 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Chilean Peso (CLP). +public struct CLP: _MoneyUmbrellaProtocol { + public static var name: String { return "Chilean Peso" } + public static var alphabeticCode: String { return "CLP" } + public static var numericCode: UInt16 { return 152 } + public static var minorUnits: UInt8 { return 0 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Yuan Renminbi (CNY). +public struct CNY: _MoneyUmbrellaProtocol { + public static var name: String { return "Yuan Renminbi" } + public static var alphabeticCode: String { return "CNY" } + public static var numericCode: UInt16 { return 156 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Colombian Peso (COP). +public struct COP: _MoneyUmbrellaProtocol { + public static var name: String { return "Colombian Peso" } + public static var alphabeticCode: String { return "COP" } + public static var numericCode: UInt16 { return 170 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Costa Rican Colon (CRC). +public struct CRC: _MoneyUmbrellaProtocol { + public static var name: String { return "Costa Rican Colon" } + public static var alphabeticCode: String { return "CRC" } + public static var numericCode: UInt16 { return 188 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Peso Convertible (CUC). +public struct CUC: _MoneyUmbrellaProtocol { + public static var name: String { return "Peso Convertible" } + public static var alphabeticCode: String { return "CUC" } + public static var numericCode: UInt16 { return 931 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Cuban Peso (CUP). +public struct CUP: _MoneyUmbrellaProtocol { + public static var name: String { return "Cuban Peso" } + public static var alphabeticCode: String { return "CUP" } + public static var numericCode: UInt16 { return 192 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Cabo Verde Escudo (CVE). +public struct CVE: _MoneyUmbrellaProtocol { + public static var name: String { return "Cabo Verde Escudo" } + public static var alphabeticCode: String { return "CVE" } + public static var numericCode: UInt16 { return 132 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Czech Koruna (CZK). +public struct CZK: _MoneyUmbrellaProtocol { + public static var name: String { return "Czech Koruna" } + public static var alphabeticCode: String { return "CZK" } + public static var numericCode: UInt16 { return 203 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Djibouti Franc (DJF). +public struct DJF: _MoneyUmbrellaProtocol { + public static var name: String { return "Djibouti Franc" } + public static var alphabeticCode: String { return "DJF" } + public static var numericCode: UInt16 { return 262 } + public static var minorUnits: UInt8 { return 0 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Danish Krone (DKK). +public struct DKK: _MoneyUmbrellaProtocol { + public static var name: String { return "Danish Krone" } + public static var alphabeticCode: String { return "DKK" } + public static var numericCode: UInt16 { return 208 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Dominican Peso (DOP). +public struct DOP: _MoneyUmbrellaProtocol { + public static var name: String { return "Dominican Peso" } + public static var alphabeticCode: String { return "DOP" } + public static var numericCode: UInt16 { return 214 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Algerian Dinar (DZD). +public struct DZD: _MoneyUmbrellaProtocol { + public static var name: String { return "Algerian Dinar" } + public static var alphabeticCode: String { return "DZD" } + public static var numericCode: UInt16 { return 12 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Egyptian Pound (EGP). +public struct EGP: _MoneyUmbrellaProtocol { + public static var name: String { return "Egyptian Pound" } + public static var alphabeticCode: String { return "EGP" } + public static var numericCode: UInt16 { return 818 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Nakfa (ERN). +public struct ERN: _MoneyUmbrellaProtocol { + public static var name: String { return "Nakfa" } + public static var alphabeticCode: String { return "ERN" } + public static var numericCode: UInt16 { return 232 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Ethiopian Birr (ETB). +public struct ETB: _MoneyUmbrellaProtocol { + public static var name: String { return "Ethiopian Birr" } + public static var alphabeticCode: String { return "ETB" } + public static var numericCode: UInt16 { return 230 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Euro (EUR). +public struct EUR: _MoneyUmbrellaProtocol { + public static var name: String { return "Euro" } + public static var alphabeticCode: String { return "EUR" } + public static var numericCode: UInt16 { return 978 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Fiji Dollar (FJD). +public struct FJD: _MoneyUmbrellaProtocol { + public static var name: String { return "Fiji Dollar" } + public static var alphabeticCode: String { return "FJD" } + public static var numericCode: UInt16 { return 242 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Falkland Islands Pound (FKP). +public struct FKP: _MoneyUmbrellaProtocol { + public static var name: String { return "Falkland Islands Pound" } + public static var alphabeticCode: String { return "FKP" } + public static var numericCode: UInt16 { return 238 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Pound Sterling (GBP). +public struct GBP: _MoneyUmbrellaProtocol { + public static var name: String { return "Pound Sterling" } + public static var alphabeticCode: String { return "GBP" } + public static var numericCode: UInt16 { return 826 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Lari (GEL). +public struct GEL: _MoneyUmbrellaProtocol { + public static var name: String { return "Lari" } + public static var alphabeticCode: String { return "GEL" } + public static var numericCode: UInt16 { return 981 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Ghana Cedi (GHS). +public struct GHS: _MoneyUmbrellaProtocol { + public static var name: String { return "Ghana Cedi" } + public static var alphabeticCode: String { return "GHS" } + public static var numericCode: UInt16 { return 936 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Gibraltar Pound (GIP). +public struct GIP: _MoneyUmbrellaProtocol { + public static var name: String { return "Gibraltar Pound" } + public static var alphabeticCode: String { return "GIP" } + public static var numericCode: UInt16 { return 292 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Dalasi (GMD). +public struct GMD: _MoneyUmbrellaProtocol { + public static var name: String { return "Dalasi" } + public static var alphabeticCode: String { return "GMD" } + public static var numericCode: UInt16 { return 270 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Guinean Franc (GNF). +public struct GNF: _MoneyUmbrellaProtocol { + public static var name: String { return "Guinean Franc" } + public static var alphabeticCode: String { return "GNF" } + public static var numericCode: UInt16 { return 324 } + public static var minorUnits: UInt8 { return 0 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Quetzal (GTQ). +public struct GTQ: _MoneyUmbrellaProtocol { + public static var name: String { return "Quetzal" } + public static var alphabeticCode: String { return "GTQ" } + public static var numericCode: UInt16 { return 320 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Guyana Dollar (GYD). +public struct GYD: _MoneyUmbrellaProtocol { + public static var name: String { return "Guyana Dollar" } + public static var alphabeticCode: String { return "GYD" } + public static var numericCode: UInt16 { return 328 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Hong Kong Dollar (HKD). +public struct HKD: _MoneyUmbrellaProtocol { + public static var name: String { return "Hong Kong Dollar" } + public static var alphabeticCode: String { return "HKD" } + public static var numericCode: UInt16 { return 344 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Lempira (HNL). +public struct HNL: _MoneyUmbrellaProtocol { + public static var name: String { return "Lempira" } + public static var alphabeticCode: String { return "HNL" } + public static var numericCode: UInt16 { return 340 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Kuna (HRK). +public struct HRK: _MoneyUmbrellaProtocol { + public static var name: String { return "Kuna" } + public static var alphabeticCode: String { return "HRK" } + public static var numericCode: UInt16 { return 191 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Gourde (HTG). +public struct HTG: _MoneyUmbrellaProtocol { + public static var name: String { return "Gourde" } + public static var alphabeticCode: String { return "HTG" } + public static var numericCode: UInt16 { return 332 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Forint (HUF). +public struct HUF: _MoneyUmbrellaProtocol { + public static var name: String { return "Forint" } + public static var alphabeticCode: String { return "HUF" } + public static var numericCode: UInt16 { return 348 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Rupiah (IDR). +public struct IDR: _MoneyUmbrellaProtocol { + public static var name: String { return "Rupiah" } + public static var alphabeticCode: String { return "IDR" } + public static var numericCode: UInt16 { return 360 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The New Israeli Sheqel (ILS). +public struct ILS: _MoneyUmbrellaProtocol { + public static var name: String { return "New Israeli Sheqel" } + public static var alphabeticCode: String { return "ILS" } + public static var numericCode: UInt16 { return 376 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Indian Rupee (INR). +public struct INR: _MoneyUmbrellaProtocol { + public static var name: String { return "Indian Rupee" } + public static var alphabeticCode: String { return "INR" } + public static var numericCode: UInt16 { return 356 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Iraqi Dinar (IQD). +public struct IQD: _MoneyUmbrellaProtocol { + public static var name: String { return "Iraqi Dinar" } + public static var alphabeticCode: String { return "IQD" } + public static var numericCode: UInt16 { return 368 } + public static var minorUnits: UInt8 { return 3 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Iranian Rial (IRR). +public struct IRR: _MoneyUmbrellaProtocol { + public static var name: String { return "Iranian Rial" } + public static var alphabeticCode: String { return "IRR" } + public static var numericCode: UInt16 { return 364 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Iceland Krona (ISK). +public struct ISK: _MoneyUmbrellaProtocol { + public static var name: String { return "Iceland Krona" } + public static var alphabeticCode: String { return "ISK" } + public static var numericCode: UInt16 { return 352 } + public static var minorUnits: UInt8 { return 0 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Jamaican Dollar (JMD). +public struct JMD: _MoneyUmbrellaProtocol { + public static var name: String { return "Jamaican Dollar" } + public static var alphabeticCode: String { return "JMD" } + public static var numericCode: UInt16 { return 388 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Jordanian Dinar (JOD). +public struct JOD: _MoneyUmbrellaProtocol { + public static var name: String { return "Jordanian Dinar" } + public static var alphabeticCode: String { return "JOD" } + public static var numericCode: UInt16 { return 400 } + public static var minorUnits: UInt8 { return 3 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Yen (JPY). +public struct JPY: _MoneyUmbrellaProtocol { + public static var name: String { return "Yen" } + public static var alphabeticCode: String { return "JPY" } + public static var numericCode: UInt16 { return 392 } + public static var minorUnits: UInt8 { return 0 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Kenyan Shilling (KES). +public struct KES: _MoneyUmbrellaProtocol { + public static var name: String { return "Kenyan Shilling" } + public static var alphabeticCode: String { return "KES" } + public static var numericCode: UInt16 { return 404 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Som (KGS). +public struct KGS: _MoneyUmbrellaProtocol { + public static var name: String { return "Som" } + public static var alphabeticCode: String { return "KGS" } + public static var numericCode: UInt16 { return 417 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Riel (KHR). +public struct KHR: _MoneyUmbrellaProtocol { + public static var name: String { return "Riel" } + public static var alphabeticCode: String { return "KHR" } + public static var numericCode: UInt16 { return 116 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Comorian Franc (KMF). +public struct KMF: _MoneyUmbrellaProtocol { + public static var name: String { return "Comorian Franc" } + public static var alphabeticCode: String { return "KMF" } + public static var numericCode: UInt16 { return 174 } + public static var minorUnits: UInt8 { return 0 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The North Korean Won (KPW). +public struct KPW: _MoneyUmbrellaProtocol { + public static var name: String { return "North Korean Won" } + public static var alphabeticCode: String { return "KPW" } + public static var numericCode: UInt16 { return 408 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Won (KRW). +public struct KRW: _MoneyUmbrellaProtocol { + public static var name: String { return "Won" } + public static var alphabeticCode: String { return "KRW" } + public static var numericCode: UInt16 { return 410 } + public static var minorUnits: UInt8 { return 0 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Kuwaiti Dinar (KWD). +public struct KWD: _MoneyUmbrellaProtocol { + public static var name: String { return "Kuwaiti Dinar" } + public static var alphabeticCode: String { return "KWD" } + public static var numericCode: UInt16 { return 414 } + public static var minorUnits: UInt8 { return 3 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Cayman Islands Dollar (KYD). +public struct KYD: _MoneyUmbrellaProtocol { + public static var name: String { return "Cayman Islands Dollar" } + public static var alphabeticCode: String { return "KYD" } + public static var numericCode: UInt16 { return 136 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Tenge (KZT). +public struct KZT: _MoneyUmbrellaProtocol { + public static var name: String { return "Tenge" } + public static var alphabeticCode: String { return "KZT" } + public static var numericCode: UInt16 { return 398 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Lao Kip (LAK). +public struct LAK: _MoneyUmbrellaProtocol { + public static var name: String { return "Lao Kip" } + public static var alphabeticCode: String { return "LAK" } + public static var numericCode: UInt16 { return 418 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Lebanese Pound (LBP). +public struct LBP: _MoneyUmbrellaProtocol { + public static var name: String { return "Lebanese Pound" } + public static var alphabeticCode: String { return "LBP" } + public static var numericCode: UInt16 { return 422 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Sri Lanka Rupee (LKR). +public struct LKR: _MoneyUmbrellaProtocol { + public static var name: String { return "Sri Lanka Rupee" } + public static var alphabeticCode: String { return "LKR" } + public static var numericCode: UInt16 { return 144 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Liberian Dollar (LRD). +public struct LRD: _MoneyUmbrellaProtocol { + public static var name: String { return "Liberian Dollar" } + public static var alphabeticCode: String { return "LRD" } + public static var numericCode: UInt16 { return 430 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Loti (LSL). +public struct LSL: _MoneyUmbrellaProtocol { + public static var name: String { return "Loti" } + public static var alphabeticCode: String { return "LSL" } + public static var numericCode: UInt16 { return 426 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Libyan Dinar (LYD). +public struct LYD: _MoneyUmbrellaProtocol { + public static var name: String { return "Libyan Dinar" } + public static var alphabeticCode: String { return "LYD" } + public static var numericCode: UInt16 { return 434 } + public static var minorUnits: UInt8 { return 3 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Moroccan Dirham (MAD). +public struct MAD: _MoneyUmbrellaProtocol { + public static var name: String { return "Moroccan Dirham" } + public static var alphabeticCode: String { return "MAD" } + public static var numericCode: UInt16 { return 504 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Moldovan Leu (MDL). +public struct MDL: _MoneyUmbrellaProtocol { + public static var name: String { return "Moldovan Leu" } + public static var alphabeticCode: String { return "MDL" } + public static var numericCode: UInt16 { return 498 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Malagasy Ariary (MGA). +public struct MGA: _MoneyUmbrellaProtocol { + public static var name: String { return "Malagasy Ariary" } + public static var alphabeticCode: String { return "MGA" } + public static var numericCode: UInt16 { return 969 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Denar (MKD). +public struct MKD: _MoneyUmbrellaProtocol { + public static var name: String { return "Denar" } + public static var alphabeticCode: String { return "MKD" } + public static var numericCode: UInt16 { return 807 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Kyat (MMK). +public struct MMK: _MoneyUmbrellaProtocol { + public static var name: String { return "Kyat" } + public static var alphabeticCode: String { return "MMK" } + public static var numericCode: UInt16 { return 104 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Tugrik (MNT). +public struct MNT: _MoneyUmbrellaProtocol { + public static var name: String { return "Tugrik" } + public static var alphabeticCode: String { return "MNT" } + public static var numericCode: UInt16 { return 496 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Pataca (MOP). +public struct MOP: _MoneyUmbrellaProtocol { + public static var name: String { return "Pataca" } + public static var alphabeticCode: String { return "MOP" } + public static var numericCode: UInt16 { return 446 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Ouguiya (MRU). +public struct MRU: _MoneyUmbrellaProtocol { + public static var name: String { return "Ouguiya" } + public static var alphabeticCode: String { return "MRU" } + public static var numericCode: UInt16 { return 929 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Mauritius Rupee (MUR). +public struct MUR: _MoneyUmbrellaProtocol { + public static var name: String { return "Mauritius Rupee" } + public static var alphabeticCode: String { return "MUR" } + public static var numericCode: UInt16 { return 480 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Rufiyaa (MVR). +public struct MVR: _MoneyUmbrellaProtocol { + public static var name: String { return "Rufiyaa" } + public static var alphabeticCode: String { return "MVR" } + public static var numericCode: UInt16 { return 462 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Malawi Kwacha (MWK). +public struct MWK: _MoneyUmbrellaProtocol { + public static var name: String { return "Malawi Kwacha" } + public static var alphabeticCode: String { return "MWK" } + public static var numericCode: UInt16 { return 454 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Mexican Peso (MXN). +public struct MXN: _MoneyUmbrellaProtocol { + public static var name: String { return "Mexican Peso" } + public static var alphabeticCode: String { return "MXN" } + public static var numericCode: UInt16 { return 484 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Malaysian Ringgit (MYR). +public struct MYR: _MoneyUmbrellaProtocol { + public static var name: String { return "Malaysian Ringgit" } + public static var alphabeticCode: String { return "MYR" } + public static var numericCode: UInt16 { return 458 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Mozambique Metical (MZN). +public struct MZN: _MoneyUmbrellaProtocol { + public static var name: String { return "Mozambique Metical" } + public static var alphabeticCode: String { return "MZN" } + public static var numericCode: UInt16 { return 943 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Namibia Dollar (NAD). +public struct NAD: _MoneyUmbrellaProtocol { + public static var name: String { return "Namibia Dollar" } + public static var alphabeticCode: String { return "NAD" } + public static var numericCode: UInt16 { return 516 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Naira (NGN). +public struct NGN: _MoneyUmbrellaProtocol { + public static var name: String { return "Naira" } + public static var alphabeticCode: String { return "NGN" } + public static var numericCode: UInt16 { return 566 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Cordoba Oro (NIO). +public struct NIO: _MoneyUmbrellaProtocol { + public static var name: String { return "Cordoba Oro" } + public static var alphabeticCode: String { return "NIO" } + public static var numericCode: UInt16 { return 558 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Norwegian Krone (NOK). +public struct NOK: _MoneyUmbrellaProtocol { + public static var name: String { return "Norwegian Krone" } + public static var alphabeticCode: String { return "NOK" } + public static var numericCode: UInt16 { return 578 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Nepalese Rupee (NPR). +public struct NPR: _MoneyUmbrellaProtocol { + public static var name: String { return "Nepalese Rupee" } + public static var alphabeticCode: String { return "NPR" } + public static var numericCode: UInt16 { return 524 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The New Zealand Dollar (NZD). +public struct NZD: _MoneyUmbrellaProtocol { + public static var name: String { return "New Zealand Dollar" } + public static var alphabeticCode: String { return "NZD" } + public static var numericCode: UInt16 { return 554 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Rial Omani (OMR). +public struct OMR: _MoneyUmbrellaProtocol { + public static var name: String { return "Rial Omani" } + public static var alphabeticCode: String { return "OMR" } + public static var numericCode: UInt16 { return 512 } + public static var minorUnits: UInt8 { return 3 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Balboa (PAB). +public struct PAB: _MoneyUmbrellaProtocol { + public static var name: String { return "Balboa" } + public static var alphabeticCode: String { return "PAB" } + public static var numericCode: UInt16 { return 590 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Sol (PEN). +public struct PEN: _MoneyUmbrellaProtocol { + public static var name: String { return "Sol" } + public static var alphabeticCode: String { return "PEN" } + public static var numericCode: UInt16 { return 604 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Kina (PGK). +public struct PGK: _MoneyUmbrellaProtocol { + public static var name: String { return "Kina" } + public static var alphabeticCode: String { return "PGK" } + public static var numericCode: UInt16 { return 598 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Philippine Peso (PHP). +public struct PHP: _MoneyUmbrellaProtocol { + public static var name: String { return "Philippine Peso" } + public static var alphabeticCode: String { return "PHP" } + public static var numericCode: UInt16 { return 608 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Pakistan Rupee (PKR). +public struct PKR: _MoneyUmbrellaProtocol { + public static var name: String { return "Pakistan Rupee" } + public static var alphabeticCode: String { return "PKR" } + public static var numericCode: UInt16 { return 586 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Zloty (PLN). +public struct PLN: _MoneyUmbrellaProtocol { + public static var name: String { return "Zloty" } + public static var alphabeticCode: String { return "PLN" } + public static var numericCode: UInt16 { return 985 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Guarani (PYG). +public struct PYG: _MoneyUmbrellaProtocol { + public static var name: String { return "Guarani" } + public static var alphabeticCode: String { return "PYG" } + public static var numericCode: UInt16 { return 600 } + public static var minorUnits: UInt8 { return 0 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Qatari Rial (QAR). +public struct QAR: _MoneyUmbrellaProtocol { + public static var name: String { return "Qatari Rial" } + public static var alphabeticCode: String { return "QAR" } + public static var numericCode: UInt16 { return 634 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Romanian Leu (RON). +public struct RON: _MoneyUmbrellaProtocol { + public static var name: String { return "Romanian Leu" } + public static var alphabeticCode: String { return "RON" } + public static var numericCode: UInt16 { return 946 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Serbian Dinar (RSD). +public struct RSD: _MoneyUmbrellaProtocol { + public static var name: String { return "Serbian Dinar" } + public static var alphabeticCode: String { return "RSD" } + public static var numericCode: UInt16 { return 941 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Russian Ruble (RUB). +public struct RUB: _MoneyUmbrellaProtocol { + public static var name: String { return "Russian Ruble" } + public static var alphabeticCode: String { return "RUB" } + public static var numericCode: UInt16 { return 643 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Rwanda Franc (RWF). +public struct RWF: _MoneyUmbrellaProtocol { + public static var name: String { return "Rwanda Franc" } + public static var alphabeticCode: String { return "RWF" } + public static var numericCode: UInt16 { return 646 } + public static var minorUnits: UInt8 { return 0 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Saudi Riyal (SAR). +public struct SAR: _MoneyUmbrellaProtocol { + public static var name: String { return "Saudi Riyal" } + public static var alphabeticCode: String { return "SAR" } + public static var numericCode: UInt16 { return 682 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Solomon Islands Dollar (SBD). +public struct SBD: _MoneyUmbrellaProtocol { + public static var name: String { return "Solomon Islands Dollar" } + public static var alphabeticCode: String { return "SBD" } + public static var numericCode: UInt16 { return 90 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Seychelles Rupee (SCR). +public struct SCR: _MoneyUmbrellaProtocol { + public static var name: String { return "Seychelles Rupee" } + public static var alphabeticCode: String { return "SCR" } + public static var numericCode: UInt16 { return 690 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Sudanese Pound (SDG). +public struct SDG: _MoneyUmbrellaProtocol { + public static var name: String { return "Sudanese Pound" } + public static var alphabeticCode: String { return "SDG" } + public static var numericCode: UInt16 { return 938 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Swedish Krona (SEK). +public struct SEK: _MoneyUmbrellaProtocol { + public static var name: String { return "Swedish Krona" } + public static var alphabeticCode: String { return "SEK" } + public static var numericCode: UInt16 { return 752 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Singapore Dollar (SGD). +public struct SGD: _MoneyUmbrellaProtocol { + public static var name: String { return "Singapore Dollar" } + public static var alphabeticCode: String { return "SGD" } + public static var numericCode: UInt16 { return 702 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Saint Helena Pound (SHP). +public struct SHP: _MoneyUmbrellaProtocol { + public static var name: String { return "Saint Helena Pound" } + public static var alphabeticCode: String { return "SHP" } + public static var numericCode: UInt16 { return 654 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Leone (SLL). +public struct SLL: _MoneyUmbrellaProtocol { + public static var name: String { return "Leone" } + public static var alphabeticCode: String { return "SLL" } + public static var numericCode: UInt16 { return 694 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Somali Shilling (SOS). +public struct SOS: _MoneyUmbrellaProtocol { + public static var name: String { return "Somali Shilling" } + public static var alphabeticCode: String { return "SOS" } + public static var numericCode: UInt16 { return 706 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Surinam Dollar (SRD). +public struct SRD: _MoneyUmbrellaProtocol { + public static var name: String { return "Surinam Dollar" } + public static var alphabeticCode: String { return "SRD" } + public static var numericCode: UInt16 { return 968 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The South Sudanese Pound (SSP). +public struct SSP: _MoneyUmbrellaProtocol { + public static var name: String { return "South Sudanese Pound" } + public static var alphabeticCode: String { return "SSP" } + public static var numericCode: UInt16 { return 728 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Dobra (STN). +public struct STN: _MoneyUmbrellaProtocol { + public static var name: String { return "Dobra" } + public static var alphabeticCode: String { return "STN" } + public static var numericCode: UInt16 { return 930 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The El Salvador Colon (SVC). +public struct SVC: _MoneyUmbrellaProtocol { + public static var name: String { return "El Salvador Colon" } + public static var alphabeticCode: String { return "SVC" } + public static var numericCode: UInt16 { return 222 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Syrian Pound (SYP). +public struct SYP: _MoneyUmbrellaProtocol { + public static var name: String { return "Syrian Pound" } + public static var alphabeticCode: String { return "SYP" } + public static var numericCode: UInt16 { return 760 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Lilangeni (SZL). +public struct SZL: _MoneyUmbrellaProtocol { + public static var name: String { return "Lilangeni" } + public static var alphabeticCode: String { return "SZL" } + public static var numericCode: UInt16 { return 748 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Baht (THB). +public struct THB: _MoneyUmbrellaProtocol { + public static var name: String { return "Baht" } + public static var alphabeticCode: String { return "THB" } + public static var numericCode: UInt16 { return 764 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Somoni (TJS). +public struct TJS: _MoneyUmbrellaProtocol { + public static var name: String { return "Somoni" } + public static var alphabeticCode: String { return "TJS" } + public static var numericCode: UInt16 { return 972 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Turkmenistan New Manat (TMT). +public struct TMT: _MoneyUmbrellaProtocol { + public static var name: String { return "Turkmenistan New Manat" } + public static var alphabeticCode: String { return "TMT" } + public static var numericCode: UInt16 { return 934 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Tunisian Dinar (TND). +public struct TND: _MoneyUmbrellaProtocol { + public static var name: String { return "Tunisian Dinar" } + public static var alphabeticCode: String { return "TND" } + public static var numericCode: UInt16 { return 788 } + public static var minorUnits: UInt8 { return 3 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Pa’anga (TOP). +public struct TOP: _MoneyUmbrellaProtocol { + public static var name: String { return "Pa’anga" } + public static var alphabeticCode: String { return "TOP" } + public static var numericCode: UInt16 { return 776 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Turkish Lira (TRY). +public struct TRY: _MoneyUmbrellaProtocol { + public static var name: String { return "Turkish Lira" } + public static var alphabeticCode: String { return "TRY" } + public static var numericCode: UInt16 { return 949 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Trinidad and Tobago Dollar (TTD). +public struct TTD: _MoneyUmbrellaProtocol { + public static var name: String { return "Trinidad and Tobago Dollar" } + public static var alphabeticCode: String { return "TTD" } + public static var numericCode: UInt16 { return 780 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The New Taiwan Dollar (TWD). +public struct TWD: _MoneyUmbrellaProtocol { + public static var name: String { return "New Taiwan Dollar" } + public static var alphabeticCode: String { return "TWD" } + public static var numericCode: UInt16 { return 901 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Tanzanian Shilling (TZS). +public struct TZS: _MoneyUmbrellaProtocol { + public static var name: String { return "Tanzanian Shilling" } + public static var alphabeticCode: String { return "TZS" } + public static var numericCode: UInt16 { return 834 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Hryvnia (UAH). +public struct UAH: _MoneyUmbrellaProtocol { + public static var name: String { return "Hryvnia" } + public static var alphabeticCode: String { return "UAH" } + public static var numericCode: UInt16 { return 980 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Uganda Shilling (UGX). +public struct UGX: _MoneyUmbrellaProtocol { + public static var name: String { return "Uganda Shilling" } + public static var alphabeticCode: String { return "UGX" } + public static var numericCode: UInt16 { return 800 } + public static var minorUnits: UInt8 { return 0 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The US Dollar (USD). +public struct USD: _MoneyUmbrellaProtocol { + public static var name: String { return "US Dollar" } + public static var alphabeticCode: String { return "USD" } + public static var numericCode: UInt16 { return 840 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Peso Uruguayo (UYU). +public struct UYU: _MoneyUmbrellaProtocol { + public static var name: String { return "Peso Uruguayo" } + public static var alphabeticCode: String { return "UYU" } + public static var numericCode: UInt16 { return 858 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Unidad Previsional (UYW). +public struct UYW: _MoneyUmbrellaProtocol { + public static var name: String { return "Unidad Previsional" } + public static var alphabeticCode: String { return "UYW" } + public static var numericCode: UInt16 { return 927 } + public static var minorUnits: UInt8 { return 4 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Uzbekistan Sum (UZS). +public struct UZS: _MoneyUmbrellaProtocol { + public static var name: String { return "Uzbekistan Sum" } + public static var alphabeticCode: String { return "UZS" } + public static var numericCode: UInt16 { return 860 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Bolívar Soberano (VES). +public struct VES: _MoneyUmbrellaProtocol { + public static var name: String { return "Bolívar Soberano" } + public static var alphabeticCode: String { return "VES" } + public static var numericCode: UInt16 { return 928 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Dong (VND). +public struct VND: _MoneyUmbrellaProtocol { + public static var name: String { return "Dong" } + public static var alphabeticCode: String { return "VND" } + public static var numericCode: UInt16 { return 704 } + public static var minorUnits: UInt8 { return 0 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Vatu (VUV). +public struct VUV: _MoneyUmbrellaProtocol { + public static var name: String { return "Vatu" } + public static var alphabeticCode: String { return "VUV" } + public static var numericCode: UInt16 { return 548 } + public static var minorUnits: UInt8 { return 0 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Tala (WST). +public struct WST: _MoneyUmbrellaProtocol { + public static var name: String { return "Tala" } + public static var alphabeticCode: String { return "WST" } + public static var numericCode: UInt16 { return 882 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The CFA Franc BEAC (XAF). +public struct XAF: _MoneyUmbrellaProtocol { + public static var name: String { return "CFA Franc BEAC" } + public static var alphabeticCode: String { return "XAF" } + public static var numericCode: UInt16 { return 950 } + public static var minorUnits: UInt8 { return 0 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The East Caribbean Dollar (XCD). +public struct XCD: _MoneyUmbrellaProtocol { + public static var name: String { return "East Caribbean Dollar" } + public static var alphabeticCode: String { return "XCD" } + public static var numericCode: UInt16 { return 951 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The CFA Franc BCEAO (XOF). +public struct XOF: _MoneyUmbrellaProtocol { + public static var name: String { return "CFA Franc BCEAO" } + public static var alphabeticCode: String { return "XOF" } + public static var numericCode: UInt16 { return 952 } + public static var minorUnits: UInt8 { return 0 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The CFP Franc (XPF). +public struct XPF: _MoneyUmbrellaProtocol { + public static var name: String { return "CFP Franc" } + public static var alphabeticCode: String { return "XPF" } + public static var numericCode: UInt16 { return 953 } + public static var minorUnits: UInt8 { return 0 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Yemeni Rial (YER). +public struct YER: _MoneyUmbrellaProtocol { + public static var name: String { return "Yemeni Rial" } + public static var alphabeticCode: String { return "YER" } + public static var numericCode: UInt16 { return 886 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Rand (ZAR). +public struct ZAR: _MoneyUmbrellaProtocol { + public static var name: String { return "Rand" } + public static var alphabeticCode: String { return "ZAR" } + public static var numericCode: UInt16 { return 710 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Zambian Kwacha (ZMW). +public struct ZMW: _MoneyUmbrellaProtocol { + public static var name: String { return "Zambian Kwacha" } + public static var alphabeticCode: String { return "ZMW" } + public static var numericCode: UInt16 { return 967 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + +/// The Zimbabwe Dollar (ZWL). +public struct ZWL: _MoneyUmbrellaProtocol { + public static var name: String { return "Zimbabwe Dollar" } + public static var alphabeticCode: String { return "ZWL" } + public static var numericCode: UInt16 { return 932 } + public static var minorUnits: UInt8 { return 2 } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + diff --git a/Sources/Currency/ISOCurrencies.swift.gyb b/Sources/Currency/ISOCurrencies.swift.gyb new file mode 100644 index 0000000..272f49f --- /dev/null +++ b/Sources/Currency/ISOCurrencies.swift.gyb @@ -0,0 +1,58 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Currency open source project +// +// Copyright (c) 2020 Currency project authors +// Licensed under MIT License +// +// See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Currency project authors +// +// SPDX-License-Identifier: MIT +// +//===----------------------------------------------------------------------===// + +import struct Foundation.Decimal + +/// This is a "private" protocol for conforming all ISO 4217 money types to a list of different protocols. +/// - Warning: Do not conform any type to this protocol, nor use it as a type constraint. +/// +/// Breaking changes to this **will** be allowed outside of major semver changes. +public protocol _MoneyUmbrellaProtocol: Money, CurrencyMetadata, + Comparable, Hashable, + ExpressibleByIntegerLiteral, ExpressibleByFloatLiteral, + AdditiveArithmetic { } + +% warning = "Contents following this line are automatically generated, and should not be edited." +// ${warning} + +// MARK: - +// MARK: ISO 4217 Currencies + +%{ import csv }% +% with open('../../Resources/ISO4217.csv') as file: + % for row in csv.DictReader(file): + %{ + alphaCode = row["Ccy"] + numCode = row["CcyNbr"] + name = row["CcyNm"] + minorUnit = row["CcyMnrUnts"] + }% + % if alphaCode and numCode and numCode.isdigit() and name and minorUnit and minorUnit.isdigit(): +/// The ${name} (${alphaCode}). +public struct ${alphaCode}: _MoneyUmbrellaProtocol { + public static var name: String { return "${name}" } + public static var alphabeticCode: String { return "${alphaCode}" } + public static var numericCode: UInt16 { return ${numCode} } + public static var minorUnits: UInt8 { return ${minorUnit} } + + public var rawAmount: Decimal { return self._rawAmount } + + public init(_ amount: Decimal) { self._rawAmount = amount } + + private let _rawAmount: Decimal +} + + %end + %end +%end From 54afdd880c7725149b4d3bd0653d63ed570a9aaa Mon Sep 17 00:00:00 2001 From: Nathan Harris Date: Thu, 9 Jan 2020 20:47:55 -0800 Subject: [PATCH 4/9] Add CurrencyMint class that provides a way of looking up currencies from metadata --- Sources/Currency/CurrencyMint.swift | 412 ++++++++++++++++++++++++ Sources/Currency/CurrencyMint.swift.gyb | 116 +++++++ 2 files changed, 528 insertions(+) create mode 100644 Sources/Currency/CurrencyMint.swift create mode 100644 Sources/Currency/CurrencyMint.swift.gyb diff --git a/Sources/Currency/CurrencyMint.swift b/Sources/Currency/CurrencyMint.swift new file mode 100644 index 0000000..b1b74bf --- /dev/null +++ b/Sources/Currency/CurrencyMint.swift @@ -0,0 +1,412 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Currency open source project +// +// Copyright (c) 2020 Currency project authors +// Licensed under MIT License +// +// See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Currency project authors +// +// SPDX-License-Identifier: MIT +// +//===----------------------------------------------------------------------===// + +import struct Foundation.Decimal + +/// A generator class that supports lookup of ISO 4217 currencies by their alphabetic and numeric codes. +public final class CurrencyMint { + public init() { } + + /// Attempts to find the appropriate currency type that matches the provided code and intialize it. + /// - Paramter code: The alphabetic ISO 4217 code to search for. + /// - Returns: An instance of a `Money` type that matches the provided `code`, with a `.zero` amount. Otherwise `nil`. + public func make(alphabeticCode code: String) -> Money? { + return self.make(alphabeticCode: code, amount: .zero) + } + + /// Attempts to find the appropriate currency type that matches the provided code and initialize it. + /// - Parameters: + /// - code: The alphabetic ISO 4217 code to search for. + /// - amount: The amount the instance should be set to. + /// - Returns: An instance of a `Money` type that matches the provided `code`, with the appropriate value. Otherwise `nil`. + public func make(alphabeticCode code: String, amount: Decimal) -> Money? { + guard let currencyType = CurrencyMint.lookup(byAlphaCode: code) else { return nil } + return currencyType.init(amount) + } + + /// Attempts to find the appropriate currency type that matches the provided code and initialize it. + /// + /// See `CurrencyMetadata.minorUnits`. + /// - Parameters: + /// - code: The alphabetic ISO 4217 code to search for. + /// - minorUnits: The amount the instance should be set to, in the scale of it's smallest unit. + /// - Returns: An instance of a `Money` type that matches the provided `code`, with the appropriate value. Otherwise `nil`. + public func make(alphabeticCode code: String, minorUnits: Int) -> Money? { + guard let currencyType = CurrencyMint.lookup(byAlphaCode: code) else { return nil } + return currencyType.init(minorUnits: minorUnits) + } + + /// Attempts to find the appropriate currency type that matches the provided code and initialize it. + /// - Parameter code: The numeric ISO 4217 code to search for. + /// - Returns: An instance of a `Money` type that matches the provided `code`, with a `.zero` amount. Otherwise `nil`. + public func make(numericCode code: UInt16) -> Money? { + return self.make(numericCode: code, amount: .zero) + } + + /// Attempts to find the appropriate currency type that matches the provided code and initialize it. + /// - Parameters: + /// - code: The numeric ISO 4217 code to search for. + /// - amount: The amount the instance should be set to. + /// - Returns: An instance of a `Money` type that matches the provided `code`, with the appropriate value. Otherwise `nil`. + public func make(numericCode code: UInt16, amount: Decimal) -> Money? { + guard let currencyType = CurrencyMint.lookup(byNumCode: code) else { return nil } + return currencyType.init(amount) + } + + /// Attempts to find the appropriate currency type that matches the provided code and initialize it. + /// + /// See `CurrencyMetadata.minorUnits`. + /// - Parameters: + /// - code: The numeric ISO 4217 code to search for. + /// - minorUnits: The amount the instance should be set to, in the scale of it's smallest unit. + /// - Returns: An instance of a `Money` type that matches the provided `code`, with the appropriate value. Otherwise `nil`. + public func make(numericCode code: UInt16, minorUnits: Int) -> Money? { + guard let currencyType = CurrencyMint.lookup(byNumCode: code) else { return nil } + return currencyType.init(minorUnits: minorUnits) + } +} + +// Contents following this line are automatically generated, and should not be edited. + + +extension CurrencyMint { + fileprivate static func lookup(byAlphaCode code: String) -> Money.Type? { + switch code { + case "AED": return AED.self + case "AFN": return AFN.self + case "ALL": return ALL.self + case "AMD": return AMD.self + case "ANG": return ANG.self + case "AOA": return AOA.self + case "ARS": return ARS.self + case "AUD": return AUD.self + case "AWG": return AWG.self + case "AZN": return AZN.self + case "BAM": return BAM.self + case "BBD": return BBD.self + case "BDT": return BDT.self + case "BGN": return BGN.self + case "BHD": return BHD.self + case "BIF": return BIF.self + case "BMD": return BMD.self + case "BND": return BND.self + case "BOB": return BOB.self + case "BRL": return BRL.self + case "BSD": return BSD.self + case "BTN": return BTN.self + case "BWP": return BWP.self + case "BYN": return BYN.self + case "BZD": return BZD.self + case "CAD": return CAD.self + case "CDF": return CDF.self + case "CHF": return CHF.self + case "CLP": return CLP.self + case "CNY": return CNY.self + case "COP": return COP.self + case "CRC": return CRC.self + case "CUC": return CUC.self + case "CUP": return CUP.self + case "CVE": return CVE.self + case "CZK": return CZK.self + case "DJF": return DJF.self + case "DKK": return DKK.self + case "DOP": return DOP.self + case "DZD": return DZD.self + case "EGP": return EGP.self + case "ERN": return ERN.self + case "ETB": return ETB.self + case "EUR": return EUR.self + case "FJD": return FJD.self + case "FKP": return FKP.self + case "GBP": return GBP.self + case "GEL": return GEL.self + case "GHS": return GHS.self + case "GIP": return GIP.self + case "GMD": return GMD.self + case "GNF": return GNF.self + case "GTQ": return GTQ.self + case "GYD": return GYD.self + case "HKD": return HKD.self + case "HNL": return HNL.self + case "HRK": return HRK.self + case "HTG": return HTG.self + case "HUF": return HUF.self + case "IDR": return IDR.self + case "ILS": return ILS.self + case "INR": return INR.self + case "IQD": return IQD.self + case "IRR": return IRR.self + case "ISK": return ISK.self + case "JMD": return JMD.self + case "JOD": return JOD.self + case "JPY": return JPY.self + case "KES": return KES.self + case "KGS": return KGS.self + case "KHR": return KHR.self + case "KMF": return KMF.self + case "KPW": return KPW.self + case "KRW": return KRW.self + case "KWD": return KWD.self + case "KYD": return KYD.self + case "KZT": return KZT.self + case "LAK": return LAK.self + case "LBP": return LBP.self + case "LKR": return LKR.self + case "LRD": return LRD.self + case "LSL": return LSL.self + case "LYD": return LYD.self + case "MAD": return MAD.self + case "MDL": return MDL.self + case "MGA": return MGA.self + case "MKD": return MKD.self + case "MMK": return MMK.self + case "MNT": return MNT.self + case "MOP": return MOP.self + case "MRU": return MRU.self + case "MUR": return MUR.self + case "MVR": return MVR.self + case "MWK": return MWK.self + case "MXN": return MXN.self + case "MYR": return MYR.self + case "MZN": return MZN.self + case "NAD": return NAD.self + case "NGN": return NGN.self + case "NIO": return NIO.self + case "NOK": return NOK.self + case "NPR": return NPR.self + case "NZD": return NZD.self + case "OMR": return OMR.self + case "PAB": return PAB.self + case "PEN": return PEN.self + case "PGK": return PGK.self + case "PHP": return PHP.self + case "PKR": return PKR.self + case "PLN": return PLN.self + case "PYG": return PYG.self + case "QAR": return QAR.self + case "RON": return RON.self + case "RSD": return RSD.self + case "RUB": return RUB.self + case "RWF": return RWF.self + case "SAR": return SAR.self + case "SBD": return SBD.self + case "SCR": return SCR.self + case "SDG": return SDG.self + case "SEK": return SEK.self + case "SGD": return SGD.self + case "SHP": return SHP.self + case "SLL": return SLL.self + case "SOS": return SOS.self + case "SRD": return SRD.self + case "SSP": return SSP.self + case "STN": return STN.self + case "SVC": return SVC.self + case "SYP": return SYP.self + case "SZL": return SZL.self + case "THB": return THB.self + case "TJS": return TJS.self + case "TMT": return TMT.self + case "TND": return TND.self + case "TOP": return TOP.self + case "TRY": return TRY.self + case "TTD": return TTD.self + case "TWD": return TWD.self + case "TZS": return TZS.self + case "UAH": return UAH.self + case "UGX": return UGX.self + case "USD": return USD.self + case "UYU": return UYU.self + case "UYW": return UYW.self + case "UZS": return UZS.self + case "VES": return VES.self + case "VND": return VND.self + case "VUV": return VUV.self + case "WST": return WST.self + case "XAF": return XAF.self + case "XCD": return XCD.self + case "XOF": return XOF.self + case "XPF": return XPF.self + case "YER": return YER.self + case "ZAR": return ZAR.self + case "ZMW": return ZMW.self + case "ZWL": return ZWL.self + default: return nil + } + } + + fileprivate static func lookup(byNumCode code: UInt16) -> Money.Type? { + switch code { + case 784: return AED.self + case 971: return AFN.self + case 8: return ALL.self + case 51: return AMD.self + case 532: return ANG.self + case 973: return AOA.self + case 32: return ARS.self + case 36: return AUD.self + case 533: return AWG.self + case 944: return AZN.self + case 977: return BAM.self + case 52: return BBD.self + case 50: return BDT.self + case 975: return BGN.self + case 48: return BHD.self + case 108: return BIF.self + case 60: return BMD.self + case 96: return BND.self + case 68: return BOB.self + case 986: return BRL.self + case 44: return BSD.self + case 64: return BTN.self + case 72: return BWP.self + case 933: return BYN.self + case 84: return BZD.self + case 124: return CAD.self + case 976: return CDF.self + case 756: return CHF.self + case 152: return CLP.self + case 156: return CNY.self + case 170: return COP.self + case 188: return CRC.self + case 931: return CUC.self + case 192: return CUP.self + case 132: return CVE.self + case 203: return CZK.self + case 262: return DJF.self + case 208: return DKK.self + case 214: return DOP.self + case 12: return DZD.self + case 818: return EGP.self + case 232: return ERN.self + case 230: return ETB.self + case 978: return EUR.self + case 242: return FJD.self + case 238: return FKP.self + case 826: return GBP.self + case 981: return GEL.self + case 936: return GHS.self + case 292: return GIP.self + case 270: return GMD.self + case 324: return GNF.self + case 320: return GTQ.self + case 328: return GYD.self + case 344: return HKD.self + case 340: return HNL.self + case 191: return HRK.self + case 332: return HTG.self + case 348: return HUF.self + case 360: return IDR.self + case 376: return ILS.self + case 356: return INR.self + case 368: return IQD.self + case 364: return IRR.self + case 352: return ISK.self + case 388: return JMD.self + case 400: return JOD.self + case 392: return JPY.self + case 404: return KES.self + case 417: return KGS.self + case 116: return KHR.self + case 174: return KMF.self + case 408: return KPW.self + case 410: return KRW.self + case 414: return KWD.self + case 136: return KYD.self + case 398: return KZT.self + case 418: return LAK.self + case 422: return LBP.self + case 144: return LKR.self + case 430: return LRD.self + case 426: return LSL.self + case 434: return LYD.self + case 504: return MAD.self + case 498: return MDL.self + case 969: return MGA.self + case 807: return MKD.self + case 104: return MMK.self + case 496: return MNT.self + case 446: return MOP.self + case 929: return MRU.self + case 480: return MUR.self + case 462: return MVR.self + case 454: return MWK.self + case 484: return MXN.self + case 458: return MYR.self + case 943: return MZN.self + case 516: return NAD.self + case 566: return NGN.self + case 558: return NIO.self + case 578: return NOK.self + case 524: return NPR.self + case 554: return NZD.self + case 512: return OMR.self + case 590: return PAB.self + case 604: return PEN.self + case 598: return PGK.self + case 608: return PHP.self + case 586: return PKR.self + case 985: return PLN.self + case 600: return PYG.self + case 634: return QAR.self + case 946: return RON.self + case 941: return RSD.self + case 643: return RUB.self + case 646: return RWF.self + case 682: return SAR.self + case 90: return SBD.self + case 690: return SCR.self + case 938: return SDG.self + case 752: return SEK.self + case 702: return SGD.self + case 654: return SHP.self + case 694: return SLL.self + case 706: return SOS.self + case 968: return SRD.self + case 728: return SSP.self + case 930: return STN.self + case 222: return SVC.self + case 760: return SYP.self + case 748: return SZL.self + case 764: return THB.self + case 972: return TJS.self + case 934: return TMT.self + case 788: return TND.self + case 776: return TOP.self + case 949: return TRY.self + case 780: return TTD.self + case 901: return TWD.self + case 834: return TZS.self + case 980: return UAH.self + case 800: return UGX.self + case 840: return USD.self + case 858: return UYU.self + case 927: return UYW.self + case 860: return UZS.self + case 928: return VES.self + case 704: return VND.self + case 548: return VUV.self + case 882: return WST.self + case 950: return XAF.self + case 951: return XCD.self + case 952: return XOF.self + case 953: return XPF.self + case 886: return YER.self + case 710: return ZAR.self + case 967: return ZMW.self + case 932: return ZWL.self + default: return nil + } + } +} + diff --git a/Sources/Currency/CurrencyMint.swift.gyb b/Sources/Currency/CurrencyMint.swift.gyb new file mode 100644 index 0000000..22fc4c0 --- /dev/null +++ b/Sources/Currency/CurrencyMint.swift.gyb @@ -0,0 +1,116 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Currency open source project +// +// Copyright (c) 2020 Currency project authors +// Licensed under MIT License +// +// See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Currency project authors +// +// SPDX-License-Identifier: MIT +// +//===----------------------------------------------------------------------===// + +import struct Foundation.Decimal + +/// A generator class that supports lookup of ISO 4217 currencies by their alphabetic and numeric codes. +public final class CurrencyMint { + public init() { } + + /// Attempts to find the appropriate currency type that matches the provided code and intialize it. + /// - Paramter code: The alphabetic ISO 4217 code to search for. + /// - Returns: An instance of a `Money` type that matches the provided `code`, with a `.zero` amount. Otherwise `nil`. + public func make(alphabeticCode code: String) -> Money? { + return self.make(alphabeticCode: code, amount: .zero) + } + + /// Attempts to find the appropriate currency type that matches the provided code and initialize it. + /// - Parameters: + /// - code: The alphabetic ISO 4217 code to search for. + /// - amount: The amount the instance should be set to. + /// - Returns: An instance of a `Money` type that matches the provided `code`, with the appropriate value. Otherwise `nil`. + public func make(alphabeticCode code: String, amount: Decimal) -> Money? { + guard let currencyType = CurrencyMint.lookup(byAlphaCode: code) else { return nil } + return currencyType.init(amount) + } + + /// Attempts to find the appropriate currency type that matches the provided code and initialize it. + /// + /// See `CurrencyMetadata.minorUnits`. + /// - Parameters: + /// - code: The alphabetic ISO 4217 code to search for. + /// - minorUnits: The amount the instance should be set to, in the scale of it's smallest unit. + /// - Returns: An instance of a `Money` type that matches the provided `code`, with the appropriate value. Otherwise `nil`. + public func make(alphabeticCode code: String, minorUnits: Int) -> Money? { + guard let currencyType = CurrencyMint.lookup(byAlphaCode: code) else { return nil } + return currencyType.init(minorUnits: minorUnits) + } + + /// Attempts to find the appropriate currency type that matches the provided code and initialize it. + /// - Parameter code: The numeric ISO 4217 code to search for. + /// - Returns: An instance of a `Money` type that matches the provided `code`, with a `.zero` amount. Otherwise `nil`. + public func make(numericCode code: UInt16) -> Money? { + return self.make(numericCode: code, amount: .zero) + } + + /// Attempts to find the appropriate currency type that matches the provided code and initialize it. + /// - Parameters: + /// - code: The numeric ISO 4217 code to search for. + /// - amount: The amount the instance should be set to. + /// - Returns: An instance of a `Money` type that matches the provided `code`, with the appropriate value. Otherwise `nil`. + public func make(numericCode code: UInt16, amount: Decimal) -> Money? { + guard let currencyType = CurrencyMint.lookup(byNumCode: code) else { return nil } + return currencyType.init(amount) + } + + /// Attempts to find the appropriate currency type that matches the provided code and initialize it. + /// + /// See `CurrencyMetadata.minorUnits`. + /// - Parameters: + /// - code: The numeric ISO 4217 code to search for. + /// - minorUnits: The amount the instance should be set to, in the scale of it's smallest unit. + /// - Returns: An instance of a `Money` type that matches the provided `code`, with the appropriate value. Otherwise `nil`. + public func make(numericCode code: UInt16, minorUnits: Int) -> Money? { + guard let currencyType = CurrencyMint.lookup(byNumCode: code) else { return nil } + return currencyType.init(minorUnits: minorUnits) + } +} + +% warning = "Contents following this line are automatically generated, and should not be edited." +// ${warning} + +%{ import csv }% +% with open('../../Resources/ISO4217.csv') as file: + % reader = csv.DictReader(file) + +extension CurrencyMint { + fileprivate static func lookup(byAlphaCode code: String) -> Money.Type? { + switch code { + % for row in reader: + % alphaCode = row["Ccy"] + % if alphaCode: + case "${alphaCode}": return ${alphaCode}.self + %end + %end + default: return nil + } + } + + fileprivate static func lookup(byNumCode code: UInt16) -> Money.Type? { + switch code { + % file.seek(0) + % next(reader) + % for row in reader: + %{ + alphaCode = row["Ccy"] + numCode = row["CcyNbr"] + }% + case ${numCode}: return ${alphaCode}.self + %end + default: return nil + } + } +} + +%end From 15c4c459602a343e5d2cc84df9e0366c128c340d Mon Sep 17 00:00:00 2001 From: Nathan Harris Date: Thu, 9 Jan 2020 20:48:10 -0800 Subject: [PATCH 5/9] Add unit tests for Money APIs --- Tests/CurrencyTests/MoneyTests.swift | 161 +++++++++++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 Tests/CurrencyTests/MoneyTests.swift diff --git a/Tests/CurrencyTests/MoneyTests.swift b/Tests/CurrencyTests/MoneyTests.swift new file mode 100644 index 0000000..0127694 --- /dev/null +++ b/Tests/CurrencyTests/MoneyTests.swift @@ -0,0 +1,161 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Currency open source project +// +// Copyright (c) 2020 Currency project authors +// Licensed under MIT License +// +// See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Currency project authors +// +// SPDX-License-Identifier: MIT +// +//===----------------------------------------------------------------------===// + +import Currency +import XCTest + +final class MoneyTests: XCTestCase { + override func setUp() { + UserDefaults.standard.set(["en_US"], forKey: "AppleLanguages") + } + + func testInit() { + XCTAssertEqual(USD(30.23).amount, 30.23) + XCTAssertEqual(JPY(100.23).amount, 100) + + let gbp = GBP(02838.29808) + XCTAssertEqual(gbp.amount, 2838.3) + XCTAssertEqual(gbp.rawAmount, 2838.29808) + } + + func testMinorUnits() { + XCTAssertTrue(GBP(minorUnits: 300).isEqual(to: 3.0)) + XCTAssertTrue(JPY(minorUnits: 39820).isEqual(to: 39820)) + } + + func testEquatable() { + let first = USD(30.23) + XCTAssertTrue(first == USD(30.23)) + XCTAssertTrue(first.isEqual(to: 30.23)) + XCTAssertFalse(first.isEqual(to: JPY(300))) + XCTAssertFalse(first == GBP(107.982)) + } + + func testComparable() { + let first: USD = 37.0237 + let second: USD = 198.157 + XCTAssertTrue(second > first) + } + + func testHashable() { + let usd = USD(30.23) + XCTAssertEqual(usd.hashValue, usd.rawAmount.hashValue) + + var hasher = Hasher() + hasher.combine(usd) + XCTAssertEqual(hasher.finalize(), usd.rawAmount.hashValue) + } + + func testAddition() { + let first = USD(300.12) + XCTAssertEqual(first + 30, 330.12) + + var second = USD(32.12) + second += 45 + XCTAssertEqual(second, 77.12) + + let third = USD(75.98) + XCTAssertEqual(third + Decimal(2), 77.98) + + var fourth = USD(1098.23) + fourth += Decimal(10.98) + XCTAssertEqual(fourth, 1109.21) + } + + func testSubtraction() { + let first = USD(300.12) + XCTAssertEqual(first - 30, 270.12) + + var second = USD(32.12) + second -= 45 + XCTAssertEqual(second, -12.88) + + let third = USD(75.98) + XCTAssertEqual(third - Decimal(2), 73.98) + + var fourth = USD(100.45) + fourth -= Decimal(50.30) + XCTAssertEqual(fourth, 50.15) + } + + func testDivision() { + let first = USD(300.12) + XCTAssertEqual(first / USD(30), 10) + + var second = USD(32.12) + second /= USD(45) + XCTAssertEqual(second.amount, 0.71) + + let third = USD(75.98) + XCTAssertEqual(third / Decimal(2), 37.99) + + var fourth = USD(0982.738) + fourth /= Decimal(7.7) + XCTAssertEqual(fourth.amount, 127.63) + } + + func testMultiplication() { + let first = USD(300.12) + XCTAssertEqual(first * USD(30), 9003.6) + + var second = USD(32.12) + second *= USD(45) + XCTAssertEqual(second.amount, 1445.4) + + let third = USD(75.98) + XCTAssertEqual(third * Decimal(2), 151.96) + + var fourth = USD(0982.738) + fourth *= Decimal(7.7) + XCTAssertEqual(fourth.amount, 7567.08) + } + + func testDescription() { + XCTAssertEqual(USD(300.8).description, "300.8 USD") + XCTAssertEqual(JPY(400.98).description, "401 JPY") + } + + func testStringInterpolation_description() { + XCTAssertEqual("\(USD(300.8).description)", "300.8 USD") + } + + func testStringInterpolation_defaultFormatter() { + XCTAssertEqual("\(USD(4321.389))", "$4,321.39") + } + + func testStringInterpolation_customLocale() { + let pounds = GBP(14928.789) + XCTAssertEqual("\(pounds, forLocale: .init(identifier: "en_UK"))", "£14,928.79") + XCTAssertEqual("\(pounds, forLocale: .init(identifier: "de_DE"))", "14.928,79 £") + } + + func testStringInterpolation_customFormatter() { + let pounds = GBP(14928.018) + let formatter = NumberFormatter() + formatter.currencyCode = pounds.currency.alphabeticCode + formatter.numberStyle = .currency + formatter.currencyGroupingSeparator = " " + formatter.currencyDecimalSeparator = "'" + XCTAssertEqual("\(pounds, withFormatter: formatter)", "£14 928'02") + } + + func testStringInterpolation_optional() { + var pounds = Optional.none + XCTAssertEqual("\(pounds)", "nil") + XCTAssertEqual("\(pounds, nilDescription: "N/A")", "N/A") + + pounds = .init(398.983) + XCTAssertEqual("\(pounds)", "£398.98") + } +} From b819fcdd1473a26637f37794ae58721e612954df Mon Sep 17 00:00:00 2001 From: Nathan Harris Date: Thu, 9 Jan 2020 20:48:20 -0800 Subject: [PATCH 6/9] Add unit tests for CurrencyMint --- Tests/CurrencyTests/CurrencyMintTests.swift | 62 +++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 Tests/CurrencyTests/CurrencyMintTests.swift diff --git a/Tests/CurrencyTests/CurrencyMintTests.swift b/Tests/CurrencyTests/CurrencyMintTests.swift new file mode 100644 index 0000000..181ce97 --- /dev/null +++ b/Tests/CurrencyTests/CurrencyMintTests.swift @@ -0,0 +1,62 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Currency open source project +// +// Copyright (c) 2020 Currency project authors +// Licensed under MIT License +// +// See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Currency project authors +// +// SPDX-License-Identifier: MIT +// +//===----------------------------------------------------------------------===// + +import Currency +import XCTest + +final class CurrencyMintTests: XCTestCase { + func testLookupByString_passes() { + let mint = CurrencyMint() + let pounds = mint.make(alphabeticCode: "GBP") + XCTAssertEqual(pounds?.amount, .zero) + } + + func testLookupByString_withAmount() { + let mint = CurrencyMint() + + let yen = mint.make(alphabeticCode: "JPY", amount: 302.98) + XCTAssertEqual(yen?.amount, 303) + + let usd = mint.make(alphabeticCode: "USD", minorUnits: 549) + XCTAssertEqual(usd?.amount, 5.49) + } + + func testLookupByString_fails() { + let mint = CurrencyMint() + let talons = mint.make(alphabeticCode: "KLT") + XCTAssertNil(talons) + } + + func testLookupByNum_passes() { + let mint = CurrencyMint() + let euros = mint.make(numericCode: 978) + XCTAssertEqual(euros?.amount, .zero) + } + + func testLookupByNum_withAmount() { + let mint = CurrencyMint() + + let pesos = mint.make(numericCode: 484, amount: 3098.9823) + XCTAssertEqual(pesos?.amount, 3098.98) + + let omanis = mint.make(numericCode: 512, minorUnits: 198239) + XCTAssertEqual(omanis?.amount, 198.239) + } + + func testLookupByNum_fails() { + let mint = CurrencyMint() + let talons = mint.make(numericCode: 666) + XCTAssertNil(talons) + } +} From 50b3cf5ab2906f5ace073efddce94db081a6777b Mon Sep 17 00:00:00 2001 From: Nathan Harris Date: Thu, 9 Jan 2020 20:49:39 -0800 Subject: [PATCH 7/9] Cleanup files from Swift Package template --- Package.swift | 22 +++--------- Sources/Currency/Currency.swift | 3 -- Tests/CurrencyTests/CurrencyTests.swift | 15 -------- Tests/CurrencyTests/XCTestManifests.swift | 44 +++++++++++++++++++++-- Tests/LinuxMain.swift | 3 +- 5 files changed, 48 insertions(+), 39 deletions(-) delete mode 100644 Sources/Currency/Currency.swift delete mode 100644 Tests/CurrencyTests/CurrencyTests.swift diff --git a/Package.swift b/Package.swift index 3cd514d..3044df3 100644 --- a/Package.swift +++ b/Package.swift @@ -4,25 +4,13 @@ import PackageDescription let package = Package( - name: "Currency", + name: "swift-currency", products: [ - // Products define the executables and libraries produced by a package, and make them visible to other packages. - .library( - name: "Currency", - targets: ["Currency"]), - ], - dependencies: [ - // Dependencies declare other packages that this package depends on. - // .package(url: /* package url */, from: "1.0.0"), + .library(name: "Currency", targets: ["Currency"]), ], + dependencies: [], targets: [ - // Targets are the basic building blocks of a package. A target can define a module or a test suite. - // Targets can depend on other targets in this package, and on products in packages which this package depends on. - .target( - name: "Currency", - dependencies: []), - .testTarget( - name: "CurrencyTests", - dependencies: ["Currency"]), + .target(name: "Currency", dependencies: []), + .testTarget(name: "CurrencyTests", dependencies: ["Currency"]), ] ) diff --git a/Sources/Currency/Currency.swift b/Sources/Currency/Currency.swift deleted file mode 100644 index fcd3e3a..0000000 --- a/Sources/Currency/Currency.swift +++ /dev/null @@ -1,3 +0,0 @@ -struct Currency { - var text = "Hello, World!" -} diff --git a/Tests/CurrencyTests/CurrencyTests.swift b/Tests/CurrencyTests/CurrencyTests.swift deleted file mode 100644 index baf14ec..0000000 --- a/Tests/CurrencyTests/CurrencyTests.swift +++ /dev/null @@ -1,15 +0,0 @@ -import XCTest -@testable import Currency - -final class CurrencyTests: XCTestCase { - func testExample() { - // This is an example of a functional test case. - // Use XCTAssert and related functions to verify your tests produce the correct - // results. - XCTAssertEqual(Currency().text, "Hello, World!") - } - - static var allTests = [ - ("testExample", testExample), - ] -} diff --git a/Tests/CurrencyTests/XCTestManifests.swift b/Tests/CurrencyTests/XCTestManifests.swift index 6303a26..0eb3001 100644 --- a/Tests/CurrencyTests/XCTestManifests.swift +++ b/Tests/CurrencyTests/XCTestManifests.swift @@ -1,9 +1,47 @@ +#if !canImport(ObjectiveC) import XCTest -#if !canImport(ObjectiveC) -public func allTests() -> [XCTestCaseEntry] { +extension CurrencyMintTests { + // DO NOT MODIFY: This is autogenerated, use: + // `swift test --generate-linuxmain` + // to regenerate. + static let __allTests__CurrencyMintTests = [ + ("testLookupByNum_fails", testLookupByNum_fails), + ("testLookupByNum_passes", testLookupByNum_passes), + ("testLookupByNum_withAmount", testLookupByNum_withAmount), + ("testLookupByString_fails", testLookupByString_fails), + ("testLookupByString_passes", testLookupByString_passes), + ("testLookupByString_withAmount", testLookupByString_withAmount), + ] +} + +extension MoneyTests { + // DO NOT MODIFY: This is autogenerated, use: + // `swift test --generate-linuxmain` + // to regenerate. + static let __allTests__MoneyTests = [ + ("testAddition", testAddition), + ("testComparable", testComparable), + ("testDescription", testDescription), + ("testDivision", testDivision), + ("testEquatable", testEquatable), + ("testHashable", testHashable), + ("testInit", testInit), + ("testMinorUnits", testMinorUnits), + ("testMultiplication", testMultiplication), + ("testStringInterpolation_customFormatter", testStringInterpolation_customFormatter), + ("testStringInterpolation_customLocale", testStringInterpolation_customLocale), + ("testStringInterpolation_defaultFormatter", testStringInterpolation_defaultFormatter), + ("testStringInterpolation_description", testStringInterpolation_description), + ("testStringInterpolation_optional", testStringInterpolation_optional), + ("testSubtraction", testSubtraction), + ] +} + +public func __allTests() -> [XCTestCaseEntry] { return [ - testCase(CurrencyTests.allTests), + testCase(CurrencyMintTests.__allTests__CurrencyMintTests), + testCase(MoneyTests.__allTests__MoneyTests), ] } #endif diff --git a/Tests/LinuxMain.swift b/Tests/LinuxMain.swift index 0aba5f7..5d3d605 100644 --- a/Tests/LinuxMain.swift +++ b/Tests/LinuxMain.swift @@ -3,5 +3,6 @@ import XCTest import CurrencyTests var tests = [XCTestCaseEntry]() -tests += CurrencyTests.allTests() +tests += CurrencyTests.__allTests() + XCTMain(tests) From 2e91195416335ea9e064d35d73dd4b3b6b110ac6 Mon Sep 17 00:00:00 2001 From: Nathan Harris Date: Thu, 9 Jan 2020 21:20:49 -0800 Subject: [PATCH 8/9] Drop required compiler version to 5.0 --- Package.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index 3044df3..6e4bc22 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.1 +// swift-tools-version:5.0 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription From f7b62965598825d9ee08e0ceac0fdc26f868c7b1 Mon Sep 17 00:00:00 2001 From: Nathan Harris Date: Sat, 11 Jan 2020 21:01:14 -0800 Subject: [PATCH 9/9] Rename amount properties on Money protocol to clarify values and their usage --- Sources/Currency/ISOCurrencies.swift | 948 ++++++++++---------- Sources/Currency/ISOCurrencies.swift.gyb | 6 +- Sources/Currency/Money.swift | 66 +- Tests/CurrencyTests/CurrencyMintTests.swift | 12 +- Tests/CurrencyTests/MoneyTests.swift | 20 +- 5 files changed, 527 insertions(+), 525 deletions(-) diff --git a/Sources/Currency/ISOCurrencies.swift b/Sources/Currency/ISOCurrencies.swift index d9ba977..37705fd 100644 --- a/Sources/Currency/ISOCurrencies.swift +++ b/Sources/Currency/ISOCurrencies.swift @@ -35,11 +35,11 @@ public struct AED: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 784 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Afghani (AFN). @@ -49,11 +49,11 @@ public struct AFN: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 971 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Lek (ALL). @@ -63,11 +63,11 @@ public struct ALL: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 8 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Armenian Dram (AMD). @@ -77,11 +77,11 @@ public struct AMD: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 51 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Netherlands Antillean Guilder (ANG). @@ -91,11 +91,11 @@ public struct ANG: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 532 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Kwanza (AOA). @@ -105,11 +105,11 @@ public struct AOA: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 973 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Argentine Peso (ARS). @@ -119,11 +119,11 @@ public struct ARS: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 32 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Australian Dollar (AUD). @@ -133,11 +133,11 @@ public struct AUD: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 36 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Aruban Florin (AWG). @@ -147,11 +147,11 @@ public struct AWG: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 533 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Azerbaijan Manat (AZN). @@ -161,11 +161,11 @@ public struct AZN: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 944 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Convertible Mark (BAM). @@ -175,11 +175,11 @@ public struct BAM: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 977 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Barbados Dollar (BBD). @@ -189,11 +189,11 @@ public struct BBD: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 52 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Taka (BDT). @@ -203,11 +203,11 @@ public struct BDT: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 50 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Bulgarian Lev (BGN). @@ -217,11 +217,11 @@ public struct BGN: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 975 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Bahraini Dinar (BHD). @@ -231,11 +231,11 @@ public struct BHD: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 48 } public static var minorUnits: UInt8 { return 3 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Burundi Franc (BIF). @@ -245,11 +245,11 @@ public struct BIF: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 108 } public static var minorUnits: UInt8 { return 0 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Bermudian Dollar (BMD). @@ -259,11 +259,11 @@ public struct BMD: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 60 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Brunei Dollar (BND). @@ -273,11 +273,11 @@ public struct BND: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 96 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Boliviano (BOB). @@ -287,11 +287,11 @@ public struct BOB: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 68 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Brazilian Real (BRL). @@ -301,11 +301,11 @@ public struct BRL: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 986 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Bahamian Dollar (BSD). @@ -315,11 +315,11 @@ public struct BSD: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 44 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Ngultrum (BTN). @@ -329,11 +329,11 @@ public struct BTN: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 64 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Pula (BWP). @@ -343,11 +343,11 @@ public struct BWP: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 72 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Belarusian Ruble (BYN). @@ -357,11 +357,11 @@ public struct BYN: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 933 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Belize Dollar (BZD). @@ -371,11 +371,11 @@ public struct BZD: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 84 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Canadian Dollar (CAD). @@ -385,11 +385,11 @@ public struct CAD: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 124 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Congolese Franc (CDF). @@ -399,11 +399,11 @@ public struct CDF: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 976 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Swiss Franc (CHF). @@ -413,11 +413,11 @@ public struct CHF: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 756 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Chilean Peso (CLP). @@ -427,11 +427,11 @@ public struct CLP: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 152 } public static var minorUnits: UInt8 { return 0 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Yuan Renminbi (CNY). @@ -441,11 +441,11 @@ public struct CNY: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 156 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Colombian Peso (COP). @@ -455,11 +455,11 @@ public struct COP: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 170 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Costa Rican Colon (CRC). @@ -469,11 +469,11 @@ public struct CRC: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 188 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Peso Convertible (CUC). @@ -483,11 +483,11 @@ public struct CUC: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 931 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Cuban Peso (CUP). @@ -497,11 +497,11 @@ public struct CUP: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 192 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Cabo Verde Escudo (CVE). @@ -511,11 +511,11 @@ public struct CVE: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 132 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Czech Koruna (CZK). @@ -525,11 +525,11 @@ public struct CZK: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 203 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Djibouti Franc (DJF). @@ -539,11 +539,11 @@ public struct DJF: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 262 } public static var minorUnits: UInt8 { return 0 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Danish Krone (DKK). @@ -553,11 +553,11 @@ public struct DKK: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 208 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Dominican Peso (DOP). @@ -567,11 +567,11 @@ public struct DOP: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 214 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Algerian Dinar (DZD). @@ -581,11 +581,11 @@ public struct DZD: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 12 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Egyptian Pound (EGP). @@ -595,11 +595,11 @@ public struct EGP: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 818 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Nakfa (ERN). @@ -609,11 +609,11 @@ public struct ERN: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 232 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Ethiopian Birr (ETB). @@ -623,11 +623,11 @@ public struct ETB: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 230 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Euro (EUR). @@ -637,11 +637,11 @@ public struct EUR: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 978 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Fiji Dollar (FJD). @@ -651,11 +651,11 @@ public struct FJD: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 242 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Falkland Islands Pound (FKP). @@ -665,11 +665,11 @@ public struct FKP: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 238 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Pound Sterling (GBP). @@ -679,11 +679,11 @@ public struct GBP: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 826 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Lari (GEL). @@ -693,11 +693,11 @@ public struct GEL: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 981 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Ghana Cedi (GHS). @@ -707,11 +707,11 @@ public struct GHS: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 936 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Gibraltar Pound (GIP). @@ -721,11 +721,11 @@ public struct GIP: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 292 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Dalasi (GMD). @@ -735,11 +735,11 @@ public struct GMD: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 270 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Guinean Franc (GNF). @@ -749,11 +749,11 @@ public struct GNF: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 324 } public static var minorUnits: UInt8 { return 0 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Quetzal (GTQ). @@ -763,11 +763,11 @@ public struct GTQ: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 320 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Guyana Dollar (GYD). @@ -777,11 +777,11 @@ public struct GYD: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 328 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Hong Kong Dollar (HKD). @@ -791,11 +791,11 @@ public struct HKD: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 344 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Lempira (HNL). @@ -805,11 +805,11 @@ public struct HNL: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 340 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Kuna (HRK). @@ -819,11 +819,11 @@ public struct HRK: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 191 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Gourde (HTG). @@ -833,11 +833,11 @@ public struct HTG: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 332 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Forint (HUF). @@ -847,11 +847,11 @@ public struct HUF: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 348 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Rupiah (IDR). @@ -861,11 +861,11 @@ public struct IDR: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 360 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The New Israeli Sheqel (ILS). @@ -875,11 +875,11 @@ public struct ILS: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 376 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Indian Rupee (INR). @@ -889,11 +889,11 @@ public struct INR: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 356 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Iraqi Dinar (IQD). @@ -903,11 +903,11 @@ public struct IQD: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 368 } public static var minorUnits: UInt8 { return 3 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Iranian Rial (IRR). @@ -917,11 +917,11 @@ public struct IRR: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 364 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Iceland Krona (ISK). @@ -931,11 +931,11 @@ public struct ISK: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 352 } public static var minorUnits: UInt8 { return 0 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Jamaican Dollar (JMD). @@ -945,11 +945,11 @@ public struct JMD: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 388 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Jordanian Dinar (JOD). @@ -959,11 +959,11 @@ public struct JOD: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 400 } public static var minorUnits: UInt8 { return 3 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Yen (JPY). @@ -973,11 +973,11 @@ public struct JPY: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 392 } public static var minorUnits: UInt8 { return 0 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Kenyan Shilling (KES). @@ -987,11 +987,11 @@ public struct KES: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 404 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Som (KGS). @@ -1001,11 +1001,11 @@ public struct KGS: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 417 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Riel (KHR). @@ -1015,11 +1015,11 @@ public struct KHR: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 116 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Comorian Franc (KMF). @@ -1029,11 +1029,11 @@ public struct KMF: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 174 } public static var minorUnits: UInt8 { return 0 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The North Korean Won (KPW). @@ -1043,11 +1043,11 @@ public struct KPW: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 408 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Won (KRW). @@ -1057,11 +1057,11 @@ public struct KRW: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 410 } public static var minorUnits: UInt8 { return 0 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Kuwaiti Dinar (KWD). @@ -1071,11 +1071,11 @@ public struct KWD: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 414 } public static var minorUnits: UInt8 { return 3 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Cayman Islands Dollar (KYD). @@ -1085,11 +1085,11 @@ public struct KYD: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 136 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Tenge (KZT). @@ -1099,11 +1099,11 @@ public struct KZT: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 398 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Lao Kip (LAK). @@ -1113,11 +1113,11 @@ public struct LAK: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 418 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Lebanese Pound (LBP). @@ -1127,11 +1127,11 @@ public struct LBP: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 422 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Sri Lanka Rupee (LKR). @@ -1141,11 +1141,11 @@ public struct LKR: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 144 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Liberian Dollar (LRD). @@ -1155,11 +1155,11 @@ public struct LRD: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 430 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Loti (LSL). @@ -1169,11 +1169,11 @@ public struct LSL: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 426 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Libyan Dinar (LYD). @@ -1183,11 +1183,11 @@ public struct LYD: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 434 } public static var minorUnits: UInt8 { return 3 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Moroccan Dirham (MAD). @@ -1197,11 +1197,11 @@ public struct MAD: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 504 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Moldovan Leu (MDL). @@ -1211,11 +1211,11 @@ public struct MDL: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 498 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Malagasy Ariary (MGA). @@ -1225,11 +1225,11 @@ public struct MGA: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 969 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Denar (MKD). @@ -1239,11 +1239,11 @@ public struct MKD: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 807 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Kyat (MMK). @@ -1253,11 +1253,11 @@ public struct MMK: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 104 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Tugrik (MNT). @@ -1267,11 +1267,11 @@ public struct MNT: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 496 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Pataca (MOP). @@ -1281,11 +1281,11 @@ public struct MOP: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 446 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Ouguiya (MRU). @@ -1295,11 +1295,11 @@ public struct MRU: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 929 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Mauritius Rupee (MUR). @@ -1309,11 +1309,11 @@ public struct MUR: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 480 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Rufiyaa (MVR). @@ -1323,11 +1323,11 @@ public struct MVR: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 462 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Malawi Kwacha (MWK). @@ -1337,11 +1337,11 @@ public struct MWK: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 454 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Mexican Peso (MXN). @@ -1351,11 +1351,11 @@ public struct MXN: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 484 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Malaysian Ringgit (MYR). @@ -1365,11 +1365,11 @@ public struct MYR: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 458 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Mozambique Metical (MZN). @@ -1379,11 +1379,11 @@ public struct MZN: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 943 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Namibia Dollar (NAD). @@ -1393,11 +1393,11 @@ public struct NAD: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 516 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Naira (NGN). @@ -1407,11 +1407,11 @@ public struct NGN: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 566 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Cordoba Oro (NIO). @@ -1421,11 +1421,11 @@ public struct NIO: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 558 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Norwegian Krone (NOK). @@ -1435,11 +1435,11 @@ public struct NOK: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 578 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Nepalese Rupee (NPR). @@ -1449,11 +1449,11 @@ public struct NPR: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 524 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The New Zealand Dollar (NZD). @@ -1463,11 +1463,11 @@ public struct NZD: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 554 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Rial Omani (OMR). @@ -1477,11 +1477,11 @@ public struct OMR: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 512 } public static var minorUnits: UInt8 { return 3 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Balboa (PAB). @@ -1491,11 +1491,11 @@ public struct PAB: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 590 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Sol (PEN). @@ -1505,11 +1505,11 @@ public struct PEN: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 604 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Kina (PGK). @@ -1519,11 +1519,11 @@ public struct PGK: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 598 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Philippine Peso (PHP). @@ -1533,11 +1533,11 @@ public struct PHP: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 608 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Pakistan Rupee (PKR). @@ -1547,11 +1547,11 @@ public struct PKR: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 586 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Zloty (PLN). @@ -1561,11 +1561,11 @@ public struct PLN: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 985 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Guarani (PYG). @@ -1575,11 +1575,11 @@ public struct PYG: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 600 } public static var minorUnits: UInt8 { return 0 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Qatari Rial (QAR). @@ -1589,11 +1589,11 @@ public struct QAR: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 634 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Romanian Leu (RON). @@ -1603,11 +1603,11 @@ public struct RON: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 946 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Serbian Dinar (RSD). @@ -1617,11 +1617,11 @@ public struct RSD: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 941 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Russian Ruble (RUB). @@ -1631,11 +1631,11 @@ public struct RUB: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 643 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Rwanda Franc (RWF). @@ -1645,11 +1645,11 @@ public struct RWF: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 646 } public static var minorUnits: UInt8 { return 0 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Saudi Riyal (SAR). @@ -1659,11 +1659,11 @@ public struct SAR: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 682 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Solomon Islands Dollar (SBD). @@ -1673,11 +1673,11 @@ public struct SBD: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 90 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Seychelles Rupee (SCR). @@ -1687,11 +1687,11 @@ public struct SCR: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 690 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Sudanese Pound (SDG). @@ -1701,11 +1701,11 @@ public struct SDG: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 938 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Swedish Krona (SEK). @@ -1715,11 +1715,11 @@ public struct SEK: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 752 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Singapore Dollar (SGD). @@ -1729,11 +1729,11 @@ public struct SGD: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 702 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Saint Helena Pound (SHP). @@ -1743,11 +1743,11 @@ public struct SHP: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 654 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Leone (SLL). @@ -1757,11 +1757,11 @@ public struct SLL: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 694 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Somali Shilling (SOS). @@ -1771,11 +1771,11 @@ public struct SOS: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 706 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Surinam Dollar (SRD). @@ -1785,11 +1785,11 @@ public struct SRD: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 968 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The South Sudanese Pound (SSP). @@ -1799,11 +1799,11 @@ public struct SSP: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 728 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Dobra (STN). @@ -1813,11 +1813,11 @@ public struct STN: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 930 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The El Salvador Colon (SVC). @@ -1827,11 +1827,11 @@ public struct SVC: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 222 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Syrian Pound (SYP). @@ -1841,11 +1841,11 @@ public struct SYP: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 760 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Lilangeni (SZL). @@ -1855,11 +1855,11 @@ public struct SZL: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 748 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Baht (THB). @@ -1869,11 +1869,11 @@ public struct THB: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 764 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Somoni (TJS). @@ -1883,11 +1883,11 @@ public struct TJS: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 972 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Turkmenistan New Manat (TMT). @@ -1897,11 +1897,11 @@ public struct TMT: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 934 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Tunisian Dinar (TND). @@ -1911,11 +1911,11 @@ public struct TND: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 788 } public static var minorUnits: UInt8 { return 3 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Pa’anga (TOP). @@ -1925,11 +1925,11 @@ public struct TOP: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 776 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Turkish Lira (TRY). @@ -1939,11 +1939,11 @@ public struct TRY: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 949 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Trinidad and Tobago Dollar (TTD). @@ -1953,11 +1953,11 @@ public struct TTD: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 780 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The New Taiwan Dollar (TWD). @@ -1967,11 +1967,11 @@ public struct TWD: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 901 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Tanzanian Shilling (TZS). @@ -1981,11 +1981,11 @@ public struct TZS: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 834 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Hryvnia (UAH). @@ -1995,11 +1995,11 @@ public struct UAH: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 980 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Uganda Shilling (UGX). @@ -2009,11 +2009,11 @@ public struct UGX: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 800 } public static var minorUnits: UInt8 { return 0 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The US Dollar (USD). @@ -2023,11 +2023,11 @@ public struct USD: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 840 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Peso Uruguayo (UYU). @@ -2037,11 +2037,11 @@ public struct UYU: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 858 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Unidad Previsional (UYW). @@ -2051,11 +2051,11 @@ public struct UYW: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 927 } public static var minorUnits: UInt8 { return 4 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Uzbekistan Sum (UZS). @@ -2065,11 +2065,11 @@ public struct UZS: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 860 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Bolívar Soberano (VES). @@ -2079,11 +2079,11 @@ public struct VES: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 928 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Dong (VND). @@ -2093,11 +2093,11 @@ public struct VND: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 704 } public static var minorUnits: UInt8 { return 0 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Vatu (VUV). @@ -2107,11 +2107,11 @@ public struct VUV: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 548 } public static var minorUnits: UInt8 { return 0 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Tala (WST). @@ -2121,11 +2121,11 @@ public struct WST: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 882 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The CFA Franc BEAC (XAF). @@ -2135,11 +2135,11 @@ public struct XAF: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 950 } public static var minorUnits: UInt8 { return 0 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The East Caribbean Dollar (XCD). @@ -2149,11 +2149,11 @@ public struct XCD: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 951 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The CFA Franc BCEAO (XOF). @@ -2163,11 +2163,11 @@ public struct XOF: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 952 } public static var minorUnits: UInt8 { return 0 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The CFP Franc (XPF). @@ -2177,11 +2177,11 @@ public struct XPF: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 953 } public static var minorUnits: UInt8 { return 0 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Yemeni Rial (YER). @@ -2191,11 +2191,11 @@ public struct YER: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 886 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Rand (ZAR). @@ -2205,11 +2205,11 @@ public struct ZAR: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 710 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Zambian Kwacha (ZMW). @@ -2219,11 +2219,11 @@ public struct ZMW: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 967 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } /// The Zimbabwe Dollar (ZWL). @@ -2233,10 +2233,10 @@ public struct ZWL: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return 932 } public static var minorUnits: UInt8 { return 2 } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } diff --git a/Sources/Currency/ISOCurrencies.swift.gyb b/Sources/Currency/ISOCurrencies.swift.gyb index 272f49f..1645a79 100644 --- a/Sources/Currency/ISOCurrencies.swift.gyb +++ b/Sources/Currency/ISOCurrencies.swift.gyb @@ -46,11 +46,11 @@ public struct ${alphaCode}: _MoneyUmbrellaProtocol { public static var numericCode: UInt16 { return ${numCode} } public static var minorUnits: UInt8 { return ${minorUnit} } - public var rawAmount: Decimal { return self._rawAmount } + public var exactAmount: Decimal { return self._amount } - public init(_ amount: Decimal) { self._rawAmount = amount } + public init(_ amount: Decimal) { self._amount = amount } - private let _rawAmount: Decimal + private let _amount: Decimal } %end diff --git a/Sources/Currency/Money.swift b/Sources/Currency/Money.swift index f64e584..03846fd 100644 --- a/Sources/Currency/Money.swift +++ b/Sources/Currency/Money.swift @@ -26,22 +26,22 @@ import Foundation /// /// Floating point values are notorious for having precision variance, even when they are equivalent within the precision range a developer desires. /// -/// To overcome this, all equality checks between two given Money values by default will use the rounded `amount`. +/// To overcome this, all equality checks between two given Money values by default will use the `roundedAmount`. public protocol Money { /// The ISO 4217 information about this money's currency. var currency: CurrencyMetadata.Type { get } /// The exact amount of money being represented. - /// - Note: This is likely to be more precise than necessary, so it is recommended to prefer use of `amount` which uses "bankers" rounding. - var rawAmount: Decimal { get } + /// - Note: This is likely to be more precise than necessary, so it is recommended to use `roundedAmount` which uses "bankers" rounding. + var exactAmount: Decimal { get } /// The "bankers" rounded amount of money being represented. /// - /// The `rawAmount` will be rounded to the significant digits as defined by the `currency.minorUnits`. + /// The `exactAmount` will be rounded to the significant digits as defined by the `currency.minorUnits`. /// /// See `CurrencyMetadata.minorUnits` and `Foundation.Decimal.RoundingMode.bankers`. - /// - Note: This is usually the desired value to work with, as it is as precise as usually needed. - var amount: Decimal { get } + /// - Note: This is usually the desired value to work with, as `exactAmount` could be more precise than needed. + var roundedAmount: Decimal { get } /// Initializes a representation of the provided amount. /// - Parameter amount: The exact amount this instance should represent. @@ -57,7 +57,7 @@ fileprivate func round(_ amount: Decimal, to scale: UInt8) -> Decimal { } extension Money { - public var amount: Decimal { return round(self.rawAmount, to: self.currency.minorUnits) } + public var roundedAmount: Decimal { return round(self.exactAmount, to: self.currency.minorUnits) } } extension Money where Self: CurrencyMetadata { @@ -84,19 +84,19 @@ extension Money { extension Money { public static func +(lhs: Self, rhs: Self) -> Self { - return .init(lhs.rawAmount + rhs.rawAmount) + return .init(lhs.exactAmount + rhs.exactAmount) } public static func -(lhs: Self, rhs: Self) -> Self { - return .init(lhs.rawAmount - rhs.rawAmount) + return .init(lhs.exactAmount - rhs.exactAmount) } public static func *(lhs: Self, rhs: Self) -> Self { - return .init(lhs.rawAmount * rhs.rawAmount) + return .init(lhs.exactAmount * rhs.exactAmount) } public static func /(lhs: Self, rhs: Self) -> Self { - return .init(lhs.rawAmount / rhs.rawAmount) + return .init(lhs.exactAmount / rhs.exactAmount) } public static func +=(lhs: inout Self, rhs: Self) { lhs = lhs + rhs } @@ -105,19 +105,19 @@ extension Money { public static func /=(lhs: inout Self, rhs: Self) { lhs = lhs / rhs } public static func +(lhs: Self, rhs: Decimal) -> Self { - return .init(lhs.rawAmount + rhs) + return .init(lhs.exactAmount + rhs) } public static func -(lhs: Self, rhs: Decimal) -> Self { - return .init(lhs.rawAmount - rhs) + return .init(lhs.exactAmount - rhs) } public static func *(lhs: Self, rhs: Decimal) -> Self { - return .init(lhs.rawAmount * rhs) + return .init(lhs.exactAmount * rhs) } public static func /(lhs: Self, rhs: Decimal) -> Self { - return .init(lhs.rawAmount / rhs) + return .init(lhs.exactAmount / rhs) } public static func +=(lhs: inout Self, rhs: Decimal) { lhs = lhs + rhs } @@ -131,29 +131,31 @@ extension Money { extension Money { public static func ==(lhs: Self, rhs: M) -> Bool { guard lhs.currency.alphabeticCode == rhs.currency.alphabeticCode else { return false } - return lhs.amount == rhs.amount + return lhs.roundedAmount == rhs.roundedAmount } - /// Checks if the current `amount` is equivalent to the provided decimal, after rounding. + /// Checks if the current rounded amount is equivalent to the provided value. + /// + /// As floating point type precisions can vary, doing exact comparisons to `exactAmount` values can result in false negatives. /// - /// As floating point type precisions can vary, doing exact comparisons to raw `amount` values has a high degree of false negatives. /// To get around this, the provided `other` amount will be rounded to the same precision as the `minorUnits` of the Money's currency using the "banker" mode. /// - /// See `Money.amount`. - /// - Parameter other: The other amount to "bankers' round, then compare against. + /// See `Money.roundedAmount`. + /// - Parameter other: The other amount to compare against, after "bankers" rounding it. /// - Returns: `true` if the rounded values are equal, otherwise `false`. public func isEqual(to other: Decimal) -> Bool { - return self.amount == round(other, to: self.currency.minorUnits) + return self.roundedAmount == round(other, to: self.currency.minorUnits) } - /// Checks if the current `amount` is equivalent to the provided decimal, after rounding. + /// Checks if the current rounded amount is equivalent to the other instance's. + /// + /// As floating point type precisions can vary, doing exact comparisons to `exactAmount` values can result in false negatives. /// - /// As floating point type precisions can vary, doing exact comparisons to raw `amount` values has a high degree of false negatives. - /// To get around this, the `amount` values will be compared, rather than `rawValues`. + /// To get around this, the `roundedAmount` values will be compared. /// - /// See `Money.amount`. - /// - Parameter other: The other money to check if the amounts are equal. - /// - Returns: `true` if the amounts are equal, otherwise `false`. + /// See `Money.roundedAmount`. + /// - Parameter other: The other money to check if the rounded amounts are equal. + /// - Returns: `true` if the rounded amounts are equal, otherwise `false`. public func isEqual(to other: M) -> Bool { return self == other } } @@ -161,17 +163,17 @@ extension Money { extension Money { public static func <(lhs: Self, rhs: Self) -> Bool { - return lhs.amount < rhs.amount + return lhs.exactAmount < rhs.exactAmount } } // MARK: Hashable extension Money { - public var hashValue: Int { return self.rawAmount.hashValue } + public var hashValue: Int { return self.exactAmount.hashValue } public func hash(into hasher: inout Hasher) { - hasher.combine(self.rawAmount) + hasher.combine(self.exactAmount) } } @@ -196,7 +198,7 @@ extension Money { // MARK: CustomStringCovertible extension Money { - public var description: String { return "\(self.amount.description) \(self.currency.alphabeticCode)" } + public var description: String { return "\(self.roundedAmount.description) \(self.currency.alphabeticCode)" } } // MARK: String Interpolation @@ -235,6 +237,6 @@ extension String.StringInterpolation { withFormatter formatter: NumberFormatter, nilDescription nilValue: String = "nil" ) { - self.appendInterpolation(formatter.string(from: NSDecimalNumber(decimal: money.amount)) ?? nilValue) + self.appendInterpolation(formatter.string(from: NSDecimalNumber(decimal: money.roundedAmount)) ?? nilValue) } } diff --git a/Tests/CurrencyTests/CurrencyMintTests.swift b/Tests/CurrencyTests/CurrencyMintTests.swift index 181ce97..6730976 100644 --- a/Tests/CurrencyTests/CurrencyMintTests.swift +++ b/Tests/CurrencyTests/CurrencyMintTests.swift @@ -19,17 +19,17 @@ final class CurrencyMintTests: XCTestCase { func testLookupByString_passes() { let mint = CurrencyMint() let pounds = mint.make(alphabeticCode: "GBP") - XCTAssertEqual(pounds?.amount, .zero) + XCTAssertEqual(pounds?.roundedAmount, .zero) } func testLookupByString_withAmount() { let mint = CurrencyMint() let yen = mint.make(alphabeticCode: "JPY", amount: 302.98) - XCTAssertEqual(yen?.amount, 303) + XCTAssertEqual(yen?.roundedAmount, 303) let usd = mint.make(alphabeticCode: "USD", minorUnits: 549) - XCTAssertEqual(usd?.amount, 5.49) + XCTAssertEqual(usd?.roundedAmount, 5.49) } func testLookupByString_fails() { @@ -41,17 +41,17 @@ final class CurrencyMintTests: XCTestCase { func testLookupByNum_passes() { let mint = CurrencyMint() let euros = mint.make(numericCode: 978) - XCTAssertEqual(euros?.amount, .zero) + XCTAssertEqual(euros?.roundedAmount, .zero) } func testLookupByNum_withAmount() { let mint = CurrencyMint() let pesos = mint.make(numericCode: 484, amount: 3098.9823) - XCTAssertEqual(pesos?.amount, 3098.98) + XCTAssertEqual(pesos?.roundedAmount, 3098.98) let omanis = mint.make(numericCode: 512, minorUnits: 198239) - XCTAssertEqual(omanis?.amount, 198.239) + XCTAssertEqual(omanis?.roundedAmount, 198.239) } func testLookupByNum_fails() { diff --git a/Tests/CurrencyTests/MoneyTests.swift b/Tests/CurrencyTests/MoneyTests.swift index 0127694..cec4b27 100644 --- a/Tests/CurrencyTests/MoneyTests.swift +++ b/Tests/CurrencyTests/MoneyTests.swift @@ -21,12 +21,12 @@ final class MoneyTests: XCTestCase { } func testInit() { - XCTAssertEqual(USD(30.23).amount, 30.23) - XCTAssertEqual(JPY(100.23).amount, 100) + XCTAssertEqual(USD(30.23).roundedAmount, 30.23) + XCTAssertEqual(JPY(100.23).roundedAmount, 100) let gbp = GBP(02838.29808) - XCTAssertEqual(gbp.amount, 2838.3) - XCTAssertEqual(gbp.rawAmount, 2838.29808) + XCTAssertEqual(gbp.roundedAmount, 2838.3) + XCTAssertEqual(gbp.exactAmount, 2838.29808) } func testMinorUnits() { @@ -50,11 +50,11 @@ final class MoneyTests: XCTestCase { func testHashable() { let usd = USD(30.23) - XCTAssertEqual(usd.hashValue, usd.rawAmount.hashValue) + XCTAssertEqual(usd.hashValue, usd.exactAmount.hashValue) var hasher = Hasher() hasher.combine(usd) - XCTAssertEqual(hasher.finalize(), usd.rawAmount.hashValue) + XCTAssertEqual(hasher.finalize(), usd.exactAmount.hashValue) } func testAddition() { @@ -95,14 +95,14 @@ final class MoneyTests: XCTestCase { var second = USD(32.12) second /= USD(45) - XCTAssertEqual(second.amount, 0.71) + XCTAssertEqual(second.roundedAmount, 0.71) let third = USD(75.98) XCTAssertEqual(third / Decimal(2), 37.99) var fourth = USD(0982.738) fourth /= Decimal(7.7) - XCTAssertEqual(fourth.amount, 127.63) + XCTAssertEqual(fourth.roundedAmount, 127.63) } func testMultiplication() { @@ -111,14 +111,14 @@ final class MoneyTests: XCTestCase { var second = USD(32.12) second *= USD(45) - XCTAssertEqual(second.amount, 1445.4) + XCTAssertEqual(second.roundedAmount, 1445.4) let third = USD(75.98) XCTAssertEqual(third * Decimal(2), 151.96) var fourth = USD(0982.738) fourth *= Decimal(7.7) - XCTAssertEqual(fourth.amount, 7567.08) + XCTAssertEqual(fourth.roundedAmount, 7567.08) } func testDescription() {