Implemented that TAN media und procedures get updated and its changes persisted
This commit is contained in:
parent
906557b480
commit
954db89e2f
|
@ -53,6 +53,8 @@ open class MainWindowPresenter(
|
||||||
|
|
||||||
protected var selectedBankAccountsField = mutableListOf<BankAccount>()
|
protected var selectedBankAccountsField = mutableListOf<BankAccount>()
|
||||||
|
|
||||||
|
protected var saveAccountOnNextEnterTanInvocation = false
|
||||||
|
|
||||||
|
|
||||||
protected val accountsChangedListeners = mutableListOf<(List<Account>) -> Unit>()
|
protected val accountsChangedListeners = mutableListOf<(List<Account>) -> Unit>()
|
||||||
|
|
||||||
|
@ -64,7 +66,18 @@ open class MainWindowPresenter(
|
||||||
protected val callback: BankingClientCallback = object : BankingClientCallback {
|
protected val callback: BankingClientCallback = object : BankingClientCallback {
|
||||||
|
|
||||||
override fun enterTan(account: Account, tanChallenge: TanChallenge): EnterTanResult {
|
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 {
|
override fun enterTanGeneratorAtc(tanMedium: TanGeneratorTanMedium): EnterTanGeneratorAtcResult {
|
||||||
|
|
|
@ -45,12 +45,16 @@ open class fints4javaBankingClient(
|
||||||
|
|
||||||
protected val client = FinTsClientForCustomer(bank, customer, webClient, base64Service, threadPool, object : FinTsClientCallback {
|
protected val client = FinTsClientForCustomer(bank, customer, webClient, base64Service, threadPool, object : FinTsClientCallback {
|
||||||
override fun enterTan(customer: CustomerData, tanChallenge: TanChallenge): EnterTanResult {
|
override fun enterTan(customer: CustomerData, tanChallenge: TanChallenge): EnterTanResult {
|
||||||
|
mapper.updateTanMediaAndProcedures(account, customer)
|
||||||
|
|
||||||
val result = callback.enterTan(account, mapper.mapTanChallenge(tanChallenge))
|
val result = callback.enterTan(account, mapper.mapTanChallenge(tanChallenge))
|
||||||
|
|
||||||
return mapper.mapEnterTanResult(result, customer)
|
return mapper.mapEnterTanResult(result, customer)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun enterTanGeneratorAtc(customer: CustomerData, tanMedium: TanGeneratorTanMedium): EnterTanGeneratorAtcResult {
|
override fun enterTanGeneratorAtc(customer: CustomerData, tanMedium: TanGeneratorTanMedium): EnterTanGeneratorAtcResult {
|
||||||
|
mapper.updateTanMediaAndProcedures(account, customer)
|
||||||
|
|
||||||
val result = callback.enterTanGeneratorAtc(mapper.mapTanMedium(tanMedium))
|
val result = callback.enterTanGeneratorAtc(mapper.mapTanMedium(tanMedium))
|
||||||
|
|
||||||
return mapper.mapEnterTanGeneratorAtcResult(result)
|
return mapper.mapEnterTanGeneratorAtcResult(result)
|
||||||
|
@ -84,4 +88,5 @@ open class fints4javaBankingClient(
|
||||||
callback(mapper.mapResponse(response))
|
callback(mapper.mapResponse(response))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -64,14 +64,8 @@ open class fints4javaModelMapper {
|
||||||
val account = Account(mappedBank, customer.customerId, customer.pin, customer.name, customer.userId)
|
val account = Account(mappedBank, customer.customerId, customer.pin, customer.name, customer.userId)
|
||||||
|
|
||||||
account.bankAccounts = mapBankAccounts(account, customer.accounts)
|
account.bankAccounts = mapBankAccounts(account, customer.accounts)
|
||||||
account.supportedTanProcedures = mapTanProcedures(customer.supportedTanProcedures)
|
|
||||||
if (customer.isTanProcedureSelected) {
|
updateTanMediaAndProcedures(account, customer)
|
||||||
account.selectedTanProcedure = findMappedTanProcedure(account, customer.selectedTanProcedure)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
account.selectedTanProcedure = null
|
|
||||||
}
|
|
||||||
account.tanMedia = mapTanMediums(customer.tanMedia)
|
|
||||||
|
|
||||||
return account
|
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> {
|
open fun mapTanProcedures(tanProcedures: List<net.dankito.fints.model.TanProcedure>): List<TanProcedure> {
|
||||||
return tanProcedures.map { mapTanProcedure(it) }
|
return tanProcedures.map { mapTanProcedure(it) }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue