Started searching for Remittees
This commit is contained in:
parent
878f51ac31
commit
d061e7f81c
|
@ -89,6 +89,30 @@ class CoreDataBankingPersistence: IBankingPersistence, IRemitteeSearcher {
|
||||||
return UserDefaults.standard.data(forKey: filePath)
|
return UserDefaults.standard.data(forKey: filePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func findRemittees(query: String) -> [Remittee] {
|
||||||
|
var transactions: [PersistedAccountTransaction] = []
|
||||||
|
|
||||||
|
do {
|
||||||
|
let request: NSFetchRequest<PersistedAccountTransaction> = PersistedAccountTransaction.fetchRequest()
|
||||||
|
request.returnsObjectsAsFaults = false
|
||||||
|
|
||||||
|
request.predicate = NSPredicate(format: "otherPartyName CONTAINS[c] %@", query)
|
||||||
|
|
||||||
|
request.propertiesToFetch = [ "otherPartyName", "otherPartyBankCode", "otherPartyAccountId" ]
|
||||||
|
request.sortDescriptors = [ NSSortDescriptor(key: "otherPartyName", ascending: true) ]
|
||||||
|
|
||||||
|
try transactions = context.fetch(request)
|
||||||
|
} catch {
|
||||||
|
NSLog("Could not request Customers: \(error)")
|
||||||
|
}
|
||||||
|
|
||||||
|
let remittees = transactions.map( { Remittee(name: $0.otherPartyName ?? "", iban: $0.otherPartyAccountId, bic: $0.otherPartyBankCode, bankName: nil) } )
|
||||||
|
|
||||||
|
let uniqueRemittees = Set<Remittee>(remittees)
|
||||||
|
|
||||||
|
return Array(uniqueRemittees)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
func deleteAll() {
|
func deleteAll() {
|
||||||
do {
|
do {
|
||||||
|
|
|
@ -46,6 +46,13 @@ extension BankInfo : Identifiable {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
extension Remittee : Identifiable {
|
||||||
|
|
||||||
|
public var id: String { name.localizedLowercase + "_" + (iban ?? "") }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
extension TanProcedure : Identifiable {
|
extension TanProcedure : Identifiable {
|
||||||
|
|
||||||
public var id: String { self.bankInternalProcedureCode }
|
public var id: String { self.bankInternalProcedureCode }
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
import SwiftUI
|
||||||
|
import BankingUiSwift
|
||||||
|
|
||||||
|
|
||||||
|
struct RemitteeListItem: View {
|
||||||
|
|
||||||
|
let remittee: Remittee
|
||||||
|
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
VStack {
|
||||||
|
|
||||||
|
HStack {
|
||||||
|
Text(remittee.name)
|
||||||
|
.font(.headline)
|
||||||
|
|
||||||
|
Spacer()
|
||||||
|
}
|
||||||
|
|
||||||
|
HStack {
|
||||||
|
Text(remittee.bankName ?? "")
|
||||||
|
|
||||||
|
Spacer()
|
||||||
|
}
|
||||||
|
.padding(.vertical, 6)
|
||||||
|
|
||||||
|
HStack {
|
||||||
|
Text(remittee.iban ?? "")
|
||||||
|
|
||||||
|
Text(remittee.bic ?? "")
|
||||||
|
|
||||||
|
Spacer()
|
||||||
|
}
|
||||||
|
.padding(.bottom, 6.0)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct RemitteeListItem_Previews: PreviewProvider {
|
||||||
|
|
||||||
|
static var previews: some View {
|
||||||
|
RemitteeListItem(remittee: Remittee(name: "Marieke Musterfrau", iban: "DE12876543211234567890", bic: "ABZODEBBXX", bankName: "Abzockbank Berlin"))
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -17,6 +17,9 @@ struct TransferMoneyDialog: View {
|
||||||
@State private var remitteeName: String = ""
|
@State private var remitteeName: String = ""
|
||||||
@State private var isValidRemitteeNameEntered = false
|
@State private var isValidRemitteeNameEntered = false
|
||||||
|
|
||||||
|
@State private var showRemitteeAutocompleteList = false
|
||||||
|
@State private var remitteeSearchResults = [Remittee]()
|
||||||
|
|
||||||
@State private var remitteeIban: String = ""
|
@State private var remitteeIban: String = ""
|
||||||
@State private var isValidRemitteeIbanEntered = false
|
@State private var isValidRemitteeIbanEntered = false
|
||||||
|
|
||||||
|
@ -49,6 +52,8 @@ struct TransferMoneyDialog: View {
|
||||||
|
|
||||||
@Inject private var presenter: BankingPresenterSwift
|
@Inject private var presenter: BankingPresenterSwift
|
||||||
|
|
||||||
|
@Inject private var persistence: CoreDataBankingPersistence
|
||||||
|
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
self.accountsSupportingTransferringMoney = self.presenter.bankAccounts.filter({ $0.supportsTransferringMoney })
|
self.accountsSupportingTransferringMoney = self.presenter.bankAccounts.filter({ $0.supportsTransferringMoney })
|
||||||
|
|
Loading…
Reference in New Issue