Implemented that TAN media und procedures get updated and its changes persisted

This commit is contained in:
dankl 2020-01-19 16:22:43 +01:00 committed by dankito
parent 906557b480
commit 954db89e2f
3 changed files with 35 additions and 9 deletions

View File

@ -53,6 +53,8 @@ open class MainWindowPresenter(
protected var selectedBankAccountsField = mutableListOf<BankAccount>()
protected var saveAccountOnNextEnterTanInvocation = false
protected val accountsChangedListeners = mutableListOf<(List<Account>) -> Unit>()
@ -64,7 +66,18 @@ open class MainWindowPresenter(
protected val callback: BankingClientCallback = object : BankingClientCallback {
override fun enterTan(account: Account, tanChallenge: TanChallenge): EnterTanResult {
return router.getTanFromUserFromNonUiThread(account, tanChallenge, this@MainWindowPresenter)
if (saveAccountOnNextEnterTanInvocation) {
persistAccount(account)
saveAccountOnNextEnterTanInvocation = false
}
val result = router.getTanFromUserFromNonUiThread(account, tanChallenge, this@MainWindowPresenter)
if (result.changeTanProcedureTo != null || result.changeTanMediumTo != null) { // then either selected TAN medium or procedure will change -> save account on next call to enterTan() as then changes will be visible
saveAccountOnNextEnterTanInvocation = true
}
return result
}
override fun enterTanGeneratorAtc(tanMedium: TanGeneratorTanMedium): EnterTanGeneratorAtcResult {

View File

@ -45,12 +45,16 @@ open class fints4javaBankingClient(
protected val client = FinTsClientForCustomer(bank, customer, webClient, base64Service, threadPool, object : FinTsClientCallback {
override fun enterTan(customer: CustomerData, tanChallenge: TanChallenge): EnterTanResult {
mapper.updateTanMediaAndProcedures(account, customer)
val result = callback.enterTan(account, mapper.mapTanChallenge(tanChallenge))
return mapper.mapEnterTanResult(result, customer)
}
override fun enterTanGeneratorAtc(customer: CustomerData, tanMedium: TanGeneratorTanMedium): EnterTanGeneratorAtcResult {
mapper.updateTanMediaAndProcedures(account, customer)
val result = callback.enterTanGeneratorAtc(mapper.mapTanMedium(tanMedium))
return mapper.mapEnterTanGeneratorAtcResult(result)
@ -84,4 +88,5 @@ open class fints4javaBankingClient(
callback(mapper.mapResponse(response))
}
}
}

View File

@ -64,14 +64,8 @@ open class fints4javaModelMapper {
val account = Account(mappedBank, customer.customerId, customer.pin, customer.name, customer.userId)
account.bankAccounts = mapBankAccounts(account, customer.accounts)
account.supportedTanProcedures = mapTanProcedures(customer.supportedTanProcedures)
if (customer.isTanProcedureSelected) {
account.selectedTanProcedure = findMappedTanProcedure(account, customer.selectedTanProcedure)
}
else {
account.selectedTanProcedure = null
}
account.tanMedia = mapTanMediums(customer.tanMedia)
updateTanMediaAndProcedures(account, customer)
return account
}
@ -117,6 +111,20 @@ open class fints4javaModelMapper {
}
open fun updateTanMediaAndProcedures(account: Account, customer: CustomerData) {
account.supportedTanProcedures = mapTanProcedures(customer.supportedTanProcedures)
if (customer.isTanProcedureSelected) {
account.selectedTanProcedure = findMappedTanProcedure(account, customer.selectedTanProcedure)
}
else {
account.selectedTanProcedure = null
}
account.tanMedia = mapTanMediums(customer.tanMedia)
}
open fun mapTanProcedures(tanProcedures: List<net.dankito.fints.model.TanProcedure>): List<TanProcedure> {
return tanProcedures.map { mapTanProcedure(it) }
}