Amount
public struct Amount
extension Amount: CustomStringConvertible
extension Amount: MultiCurrencyAmountRepresentable
extension Amount: Equatable
extension Amount: Hashable
Represents an Amount - a number with a commodity
-
Mumeric value of the amount
Declaration
Swift
public let number: Decimal
-
CommoditySymbol the number is in
Declaration
Swift
public let commoditySymbol: CommoditySymbol
-
Number of decimal digits the number has
This is used to maintain the accuracy the number was recorded in to correctly print it and do checks with the correct tolerance.
Declaration
Swift
public let decimalDigits: Int
-
Creates an amount with the given parameters
Declaration
Swift
public init(number: Decimal, commoditySymbol: CommoditySymbol, decimalDigits: Int = 0)
Parameters
number
numeric value
commodity
decimalDigits
number of decimal digits the number has
-
Returns a
String
for the ledger which contains the number with the correct number of decimal digits as well as thecommodity
Declaration
Swift
public var description: String { get }
-
the ammount represented as
MultiCurrencyAmount
Declaration
Swift
public var multiCurrencyAmount: MultiCurrencyAmount { get }
-
Compares two
Amount
sNote that the number of decimal digits is compared as well. This means 1.0 and 1.00 is not the same.
Declaration
Swift
public static func == (lhs: Amount, rhs: Amount) -> Bool
Parameters
lhs
first amount
rhs
second amount
Return Value
True if the amounts are the same, false otherwise
-
Declaration
Swift
public func hash(into hasher: inout Hasher)