Fixed that when an account gets deleting its BankingClient data didn't get deleted
This commit is contained in:
parent
40bbb2b8f5
commit
6f354724be
|
@ -26,4 +26,6 @@ interface IBankingClient {
|
||||||
|
|
||||||
fun dataChanged(customer: TypedCustomer)
|
fun dataChanged(customer: TypedCustomer)
|
||||||
|
|
||||||
|
fun deletedAccount(customer: TypedCustomer, wasLastAccountWithThisCredentials: Boolean)
|
||||||
|
|
||||||
}
|
}
|
|
@ -246,7 +246,7 @@ open class BankingPresenter constructor(
|
||||||
val wasSelected = isSingleSelectedAccount(customer) or // either account or one of its bank accounts is currently selected
|
val wasSelected = isSingleSelectedAccount(customer) or // either account or one of its bank accounts is currently selected
|
||||||
(customer.accounts.firstOrNull { isSingleSelectedBankAccount(it) } != null)
|
(customer.accounts.firstOrNull { isSingleSelectedBankAccount(it) } != null)
|
||||||
|
|
||||||
bankingClientsForAccounts.remove(customer)
|
val client = bankingClientsForAccounts.remove(customer)
|
||||||
|
|
||||||
val displayIndex = customer.displayIndex
|
val displayIndex = customer.displayIndex
|
||||||
|
|
||||||
|
@ -259,6 +259,8 @@ open class BankingPresenter constructor(
|
||||||
accountDisplayIndexUpdated(bank)
|
accountDisplayIndexUpdated(bank)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
client?.deletedAccount(customer, customers.firstOrNull { it.customerId == customer.customerId && it.bankCode == customer.bankCode} == null)
|
||||||
|
|
||||||
callAccountsChangedListeners()
|
callAccountsChangedListeners()
|
||||||
|
|
||||||
if (wasSelected || areAllAccountSelected) { // to update displayed account transactions as transactions of yet deleted accounts have to be removed
|
if (wasSelected || areAllAccountSelected) { // to update displayed account transactions as transactions of yet deleted accounts have to be removed
|
||||||
|
|
|
@ -137,6 +137,12 @@ open class fints4kBankingClient(
|
||||||
mapper.mapChangesFromUiToClientModel(customer, bank)
|
mapper.mapChangesFromUiToClientModel(customer, bank)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun deletedAccount(customer: TypedCustomer, wasLastAccountWithThisCredentials: Boolean) {
|
||||||
|
if (wasLastAccountWithThisCredentials) {
|
||||||
|
getFints4kClientDataFile(customer).delete()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected open fun findAccountForBankAccount(bankAccount: TypedBankAccount, findAccountResult: (AccountData?, error: String?) -> Unit) {
|
protected open fun findAccountForBankAccount(bankAccount: TypedBankAccount, findAccountResult: (AccountData?, error: String?) -> Unit) {
|
||||||
val mappedAccount = mapper.findAccountForBankAccount(bank, bankAccount)
|
val mappedAccount = mapper.findAccountForBankAccount(bank, bankAccount)
|
||||||
|
@ -176,7 +182,7 @@ open class fints4kBankingClient(
|
||||||
|
|
||||||
protected open fun restoreData(customer: TypedCustomer): BankData? {
|
protected open fun restoreData(customer: TypedCustomer): BankData? {
|
||||||
try {
|
try {
|
||||||
return serializer.deserializeObject(getFints4kClientDataFile(customer.bankCode, customer.customerId), BankData::class)
|
return serializer.deserializeObject(getFints4kClientDataFile(customer), BankData::class)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
log.warn(e) { "Could not deserialize bank data of $customer (which is ok if bank is just about to be added)" }
|
log.warn(e) { "Could not deserialize bank data of $customer (which is ok if bank is just about to be added)" }
|
||||||
}
|
}
|
||||||
|
@ -194,6 +200,10 @@ open class fints4kBankingClient(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected open fun getFints4kClientDataFile(customer: TypedCustomer): File {
|
||||||
|
return getFints4kClientDataFile(customer.bankCode, customer.customerId)
|
||||||
|
}
|
||||||
|
|
||||||
protected open fun getFints4kClientDataFile(bankCode: String, customerId: String): File {
|
protected open fun getFints4kClientDataFile(bankCode: String, customerId: String): File {
|
||||||
val folder = File(dataFolder, "fints4k-client")
|
val folder = File(dataFolder, "fints4k-client")
|
||||||
|
|
||||||
|
|
|
@ -283,6 +283,10 @@ open class hbci4jBankingClient(
|
||||||
credentials.password = customer.password
|
credentials.password = customer.password
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun deletedAccount(customer: TypedCustomer, wasLastAccountWithThisCredentials: Boolean) {
|
||||||
|
getPassportFile(credentials).delete()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected open fun connect(): ConnectResult {
|
protected open fun connect(): ConnectResult {
|
||||||
return connect(credentials, HBCIVersion.HBCI_300)
|
return connect(credentials, HBCIVersion.HBCI_300)
|
||||||
|
|
Loading…
Reference in New Issue