-
-
Notifications
You must be signed in to change notification settings - Fork 33
Money
An amount of money in a given currency.
public struct Money<Currency: CurrencyType>: Equatable, Hashable
Codable
, Comparable
, CustomStringConvertible
, Equatable
, ExpressibleByFloatLiteral
, ExpressibleByIntegerLiteral
, ExpressibleByStringLiteral
, Hashable
, LosslessStringConvertible
Creates an amount of money with a given decimal number.
public init(_ amount: Decimal)
public init?(_ description: String)
public init(integerLiteral value: Int)
Creates a new value from the given floating-point literal.
public init(floatLiteral value: Double)
public init(unicodeScalarLiteral value: Unicode.Scalar)
public init(extendedGraphemeClusterLiteral value: Character)
public init(stringLiteral value: String)
public init(from decoder: Decoder) throws
The amount of money.
var amount: Decimal
The currency type.
var currency: CurrencyType.Type
A monetary amount rounded to the number of places of the minor currency unit.
var rounded: Money<Currency>
var description: String
public static func <(lhs: Money<Currency>, rhs: Money<Currency>) -> Bool
The sum of two monetary amounts.
public static func +(lhs: Money<Currency>, rhs: Money<Currency>) -> Money<Currency>
Adds one monetary amount to another.
public static func +=(lhs: inout Money<Currency>, rhs: Money<Currency>)
The difference between two monetary amounts.
public static func -(lhs: Money<Currency>, rhs: Money<Currency>) -> Money<Currency>
Subtracts one monetary amount from another.
public static func -=(lhs: inout Money<Currency>, rhs: Money<Currency>)
Subtracts one monetary amount from another.
public static prefix func -(value: Money<Currency>) -> Money<Currency>
The product of a monetary amount and a scalar value.
public static func *(lhs: Money<Currency>, rhs: Decimal) -> Money<Currency>
The product of a monetary amount and a scalar value.
public static func *(lhs: Money<Currency>, rhs: Double) -> Money<Currency>
The product of a monetary amount and a scalar value.
public static func *(lhs: Money<Currency>, rhs: Int) -> Money<Currency>
The product of a monetary amount and a scalar value.
public static func *(lhs: Decimal, rhs: Money<Currency>) -> Money<Currency>
The product of a monetary amount and a scalar value.
public static func *(lhs: Double, rhs: Money<Currency>) -> Money<Currency>
The product of a monetary amount and a scalar value.
public static func *(lhs: Int, rhs: Money<Currency>) -> Money<Currency>
Multiplies a monetary amount by a scalar value.
public static func *=(lhs: inout Money<Currency>, rhs: Decimal)
Multiplies a monetary amount by a scalar value.
public static func *=(lhs: inout Money<Currency>, rhs: Double)
Multiplies a monetary amount by a scalar value.
- Important: Multiplying a monetary amount by a floating-point number
results in an amount rounded to the number of places
of the minor currency unit.
To produce a smaller fractional monetary amount,
multiply by a `Decimal` value instead.
Multiplies a monetary amount by a scalar value.
public static func *=(lhs: inout Money<Currency>, rhs: Int)
public func encode(to encoder: Encoder) throws
Generated at 2020-10-30T17:09:26+0000 using swift-doc 1.0.0-beta.5.
Types
- AED
- AFN
- ALL
- AMD
- ANG
- AOA
- ARS
- AUD
- AWG
- AZN
- BAM
- BBD
- BDT
- BGN
- BHD
- BIF
- BMD
- BND
- BOB
- BOV
- BRL
- BSD
- BTN
- BWP
- BYN
- BZD
- CAD
- CDF
- CHE
- CHF
- CHW
- CLF
- CLP
- CNY
- COP
- COU
- CRC
- CUC
- CUP
- CVE
- CZK
- DJF
- DKK
- DOP
- DZD
- EGP
- ERN
- ETB
- EUR
- FJD
- FKP
- GBP
- GEL
- GHS
- GIP
- GMD
- GNF
- GTQ
- GYD
- HKD
- HNL
- HRK
- HTG
- HUF
- IDR
- ILS
- INR
- IQD
- IRR
- ISK
- JMD
- JOD
- JPY
- KES
- KGS
- KHR
- KMF
- KPW
- KRW
- KWD
- KYD
- KZT
- LAK
- LBP
- LKR
- LRD
- LSL
- LYD
- MAD
- MDL
- MGA
- MKD
- MMK
- MNT
- MOP
- MRU
- MUR
- MVR
- MWK
- MXN
- MXV
- MYR
- MZN
- Money
- MoneyDecodingOptions
- MoneyEncodingOptions
- NAD
- NGN
- NIO
- NOK
- NPR
- NZD
- OMR
- PAB
- PEN
- PGK
- PHP
- PKR
- PLN
- PYG
- QAR
- RON
- RSD
- RUB
- RWF
- SAR
- SBD
- SCR
- SDG
- SEK
- SGD
- SHP
- SLL
- SOS
- SRD
- SSP
- STN
- SVC
- SYP
- SZL
- THB
- TJS
- TMT
- TND
- TOP
- TRY
- TTD
- TWD
- TZS
- UAH
- UGX
- USD
- UYI
- UYU
- UZS
- VEF
- VND
- VUV
- WST
- XCD
- YER
- ZAR
- ZMW
- ZWL