Fixed identifying TAN media as e.g. Sparkasse named all their TanGenerator media "SparkassenCard (Debitkarte)" - so it was not possible to differentiate between them
This commit is contained in:
parent
5bfe492ada
commit
a9ebad0793
|
@ -4,6 +4,10 @@ import kotlinx.datetime.LocalDate
|
|||
import net.codinux.banking.client.model.config.NoArgConstructor
|
||||
|
||||
@NoArgConstructor
|
||||
/**
|
||||
* 'TanGenerator' is in most cases a debit card, but can also be something like "BestSign" app (Postbank).
|
||||
* In latter case [cardNumber] can also be, contrary to specification, be an empty string.
|
||||
*/
|
||||
open class TanGeneratorTanMedium(
|
||||
val cardNumber: String,
|
||||
val cardSequenceNumber: String? = null,
|
||||
|
|
|
@ -16,5 +16,49 @@ open class TanMedium(
|
|||
*/
|
||||
val mobilePhone: MobilePhoneTanMedium? = null
|
||||
) {
|
||||
|
||||
/**
|
||||
* Using only [mediumName] as identifier does not work as e.g. Sparkasse names all their TanGenerator TAN media
|
||||
* "SparkassenCard (Debitkarte)" - so it's not possible to differentiate between them solely by medium name.
|
||||
*/
|
||||
val identifier: String by lazy {
|
||||
// TODO: translate
|
||||
var id = mediumName ?: when (type) {
|
||||
TanMediumType.MobilePhone -> "Mobiltelefon"
|
||||
TanMediumType.TanGenerator -> "Tan Generator"
|
||||
TanMediumType.Generic -> "Unbenanntes TAN Medium"
|
||||
}
|
||||
|
||||
if (mobilePhone != null) {
|
||||
id += " " + (mobilePhone.concealedPhoneNumber ?: mobilePhone.phoneNumber)
|
||||
}
|
||||
if (tanGenerator != null) {
|
||||
if (tanGenerator.cardNumber.isNotBlank()) {
|
||||
id += " " + tanGenerator.cardNumber
|
||||
}
|
||||
if (tanGenerator.cardSequenceNumber.isNullOrBlank() == false) {
|
||||
id += " " + tanGenerator.cardSequenceNumber
|
||||
}
|
||||
|
||||
if (tanGenerator.validFrom != null && tanGenerator.validTo != null) {
|
||||
id += ", gültig von " + tanGenerator.validFrom.let { "${it.dayOfMonth}.${it.monthNumber}${it.year}" } +
|
||||
" - " + tanGenerator.validTo.let { "${it.dayOfMonth}.${it.monthNumber}${it.year}" }
|
||||
} else if (tanGenerator.validTo != null) {
|
||||
id += ", gültig bis " + tanGenerator.validTo.let { "${it.dayOfMonth}.${it.monthNumber}${it.year}" }
|
||||
}
|
||||
}
|
||||
|
||||
id
|
||||
}
|
||||
|
||||
val displayName: String by lazy {
|
||||
identifier + " " + when (status) {
|
||||
TanMediumStatus.Used -> "Aktive"
|
||||
TanMediumStatus.Available -> "Verfügbar"
|
||||
TanMediumStatus.ActiveFollowUpCard -> " Folgekarte, aktiv bei erster Nutzung"
|
||||
TanMediumStatus.AvailableFollowUpCard -> " Folgekarte, die erst aktiviert werden muss"
|
||||
}
|
||||
}
|
||||
|
||||
override fun toString() = "$mediumName $status"
|
||||
}
|
|
@ -191,7 +191,8 @@ open class FinTs4kMapper {
|
|||
val selectedTanMethodId = challenge.tanMethod.securityFunction.code
|
||||
|
||||
val tanMedia = challenge.bank.tanMedia.map { mapTanMedium(it) }
|
||||
val selectedTanMediumName = challenge.bank.selectedTanMedium?.mediumName
|
||||
// TanMedium has not natural id in FinTS model so we have to create our own one
|
||||
val selectedTanMediumName = challenge.bank.selectedTanMedium?.let { selected -> tanMedia.firstOrNull { it == selected } }?.identifier
|
||||
|
||||
val user = mapToUserAccountViewInfo(challenge.bank)
|
||||
val account = challenge.account?.let { mapToBankAccountViewInfo(it) }
|
||||
|
|
Loading…
Reference in New Issue