Transaction
public class Transaction
extension Transaction: CustomStringConvertible
extension Transaction: Equatable
extension Transaction: Hashable
extension Transaction: Comparable
A Transaction has meta data as well as multiple postings
-
Meta data of the Transaction
Declaration
Swift
public let metaData: TransactionMetaData
-
Arrary of the
Posting
s of the transaction.Should at least have two elements, otherwise the Transaction is not valid
Declaration
Swift
public var postings: [TransactionPosting] { get }
-
Creates a transaction
Declaration
Swift
public init(metaData: TransactionMetaData, postings: [Posting])
Parameters
metaData
postings
Postings
-
Gets the balance of a transaction, should be zero (within tolerance)
This method just adds up the balances of the individual postings
Throws
if the balances cannot be calculatedDeclaration
Swift
public func balance(in ledger: Ledger) throws -> MultiCurrencyAmount
Parameters
ledger
ledger to calculate in
Return Value
MultiCurrencyAmount
-
Returns the effect (income + expenses) a transaction has
This methods adds up the amount of all postings from income and expense accounts in the transaction
Throws
if the effect cannot be calculatedDeclaration
Swift
public func effect(in ledger: Ledger) throws -> MultiCurrencyAmount
Parameters
ledger
ledger to calculate in
Return Value
MultiCurrencyAmount
-
the `String representation of this transaction for the ledger file
Declaration
Swift
public var description: String { get }
-
Declaration
Swift
public static func == (lhs: Transaction, rhs: Transaction) -> Bool
Parameters
lhs
first transaction
rhs
second transaction
Return Value
if they are the same
-
Declaration
Swift
public func hash(into hasher: inout Hasher)
-
Declaration
Swift
public static func < (lhs: Transaction, rhs: Transaction) -> Bool