SwiftBeanCountCompassCardMapper

public struct SwiftBeanCountCompassCardMapper

Mapper to map downloaded accounts and transactions to BeanCoutModel objects

  • AccountName for the other leg of a transaction

    Declaration

    Swift

    public let defaultExpenseAccountName: AccountName
  • AccountName for the other leg of a load transaction

    Declaration

    Swift

    public let defaultAssetAccountName: AccountName
  • Creates a mapper

    Declaration

    Swift

    public init(ledger: Ledger)

    Parameters

    ledger

    Ledger which will be used to look up things like account names

  • Creates a balance assertions from the downloaded string

    Declaration

    Swift

    public func createBalance(cardNumber: String, balance: String, date inputDate: Date? = nil) throws -> Balance

    Parameters

    cardNumber

    String with the compass card number

    balance

    String with the balance

    date

    Date to balance assertion should use, if nil defaults to tomorrow

    Return Value

    Array of Balances

  • Creates Transactions from the downloaded CSV String

    Note: This method filters out transactions already existing in the ledger

    Declaration

    Swift

    public func createTransactions(cardNumber: String, transactions: String) throws -> [Transaction]

    Parameters

    cardNumber

    String with the compass card number

    transactions

    String of the transaction CSV

    Return Value

    Array of transactions

  • Creates Transactions from a provided CSVReader

    Note: This method filters out transactions already existing in the ledger

    Declaration

    Swift

    public func createTransactions(account: AccountName, reader: CSVReader) throws -> [Transaction]

    Parameters

    account

    AccountName of asset account in the ledger

    reader

    CSVReader with the transaction CSV

    Return Value

    Array of transactions

  • Gets the correct account for the Compass Card from the ledger based on the card number

    Declaration

    Swift

    public func ledgerCardAccountName(cardNumber: String) throws -> AccountName

    Parameters

    cardNumber

    Compass Card Number

    Return Value

    AccountName from the ledger