Fixed back mapping TanMethod

This commit is contained in:
dankito 2021-11-01 18:08:28 +01:00
parent c82611ad6c
commit a9e8e2e96c
1 changed files with 16 additions and 2 deletions

View File

@ -388,7 +388,15 @@ open class fints4kModelMapper(protected val modelCreator: IModelCreator) {
} }
open fun mapTanMethod(tanMethod: TanMethod): net.dankito.banking.fints.model.TanMethod { open fun mapTanMethod(tanMethod: TanMethod, bank: BankData): net.dankito.banking.fints.model.TanMethod {
bank.tanMethodsAvailableForUser.firstOrNull { equals(it, tanMethod) }?.let {
return it
}
bank.tanMethodsSupportedByBank.firstOrNull { equals(it, tanMethod) }?.let {
return it
}
return net.dankito.banking.fints.model.TanMethod( return net.dankito.banking.fints.model.TanMethod(
tanMethod.displayName, tanMethod.displayName,
Sicherheitsfunktion.values().first { it.code == tanMethod.bankInternalMethodCode }, Sicherheitsfunktion.values().first { it.code == tanMethod.bankInternalMethodCode },
@ -396,6 +404,7 @@ open class fints4kModelMapper(protected val modelCreator: IModelCreator) {
null, // TODO: where to get HDD Version from? null, // TODO: where to get HDD Version from?
tanMethod.maxTanInputLength, tanMethod.maxTanInputLength,
mapAllowedTanFormat(tanMethod.allowedTanFormat) mapAllowedTanFormat(tanMethod.allowedTanFormat)
// TODO: also nameOfTanMediumRequired is missing - which is required for some banks like Postbank
) )
} }
@ -422,9 +431,14 @@ open class fints4kModelMapper(protected val modelCreator: IModelCreator) {
} }
} }
private fun equals(tanMethod: net.dankito.banking.fints.model.TanMethod, uiTanMethod: TanMethod): Boolean {
return tanMethod.displayName == uiTanMethod.displayName && tanMethod.securityFunction.code == uiTanMethod.bankInternalMethodCode
}
open fun mapEnterTanResult(result: EnterTanResult, bank: BankData): net.dankito.banking.fints.model.EnterTanResult { open fun mapEnterTanResult(result: EnterTanResult, bank: BankData): net.dankito.banking.fints.model.EnterTanResult {
result.changeTanMethodTo?.let { changeTanMethodTo -> result.changeTanMethodTo?.let { changeTanMethodTo ->
return net.dankito.banking.fints.model.EnterTanResult.userAsksToChangeTanMethod(mapTanMethod(changeTanMethodTo)) return net.dankito.banking.fints.model.EnterTanResult.userAsksToChangeTanMethod(mapTanMethod(changeTanMethodTo, bank))
} }
result.changeTanMediumTo?.let { changeTanMediumTo -> result.changeTanMediumTo?.let { changeTanMediumTo ->