Skip to content

Commit

Permalink
Allow dynamic specification of account for more transaction types
Browse files Browse the repository at this point in the history
  • Loading branch information
Nef10 committed Jul 13, 2024
1 parent 20ac642 commit b600498
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions Sources/SwiftBeanCountWealthsimpleMapper/LedgerLookup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,13 @@ struct LedgerLookup {
key = MetaDataKeys.rounding
}
guard let name = ledger.accounts.first(where: { accountTypes.contains($0.name.accountType) && $0.metaData[key]?.contains(account.number) ?? false })?.name else {
if case .transactionType(.paymentSpend) = type {
return WealthsimpleLedgerMapper.fallbackExpenseAccountName
if case let .transactionType(transactionType) = type {
switch transactionType {
case .onlineBillPayment, .deposit, .paymentSpend, .transferIn, .transferOut, .paymentTransferIn, .paymentTransferOut, .withdrawal:
return WealthsimpleLedgerMapper.fallbackExpenseAccountName
default:
throw WealthsimpleConversionError.missingAccount(key, account.number, accountTypes.map { $0.rawValue }.joined(separator: ", or "))
}
}
throw WealthsimpleConversionError.missingAccount(key, account.number, accountTypes.map { $0.rawValue }.joined(separator: ", or "))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public struct WealthsimpleLedgerMapper { // swiftlint:disable:this type_body_len

/// Fallback account for payments if not account with the correct meta data could be found
///
/// Only used for transaction type payment spend
/// Only used for certain transaction types
public static let fallbackExpenseAccountName = try! AccountName("Expenses:TODO") // swiftlint:disable:this force_try

/// Payee used for fee transactions
Expand Down

0 comments on commit b600498

Please sign in to comment.