If account type field is not set (as it e.g. comdirect does), trying to extract account type from account name
This commit is contained in:
parent
e78e0e93f9
commit
a59b335316
|
@ -1049,7 +1049,7 @@ open class FinTsClient(
|
||||||
?: run {
|
?: run {
|
||||||
val newAccount = AccountData(accountInfo.accountIdentifier, accountInfo.subAccountAttribute,
|
val newAccount = AccountData(accountInfo.accountIdentifier, accountInfo.subAccountAttribute,
|
||||||
accountInfo.bankCountryCode, accountInfo.bankCode, accountInfo.iban, accountInfo.customerId,
|
accountInfo.bankCountryCode, accountInfo.bankCode, accountInfo.iban, accountInfo.customerId,
|
||||||
accountInfo.accountType, accountInfo.currency, accountHolderName, accountInfo.productName,
|
mapAccountType(accountInfo), accountInfo.currency, accountHolderName, accountInfo.productName,
|
||||||
accountInfo.accountLimit, accountInfo.allowedJobNames)
|
accountInfo.accountLimit, accountInfo.allowedJobNames)
|
||||||
|
|
||||||
bank.addAccount(newAccount)
|
bank.addAccount(newAccount)
|
||||||
|
@ -1237,8 +1237,7 @@ open class FinTsClient(
|
||||||
protected open fun findExistingAccount(bank: BankData, accountInfo: AccountInfo): AccountData? {
|
protected open fun findExistingAccount(bank: BankData, accountInfo: AccountInfo): AccountData? {
|
||||||
bank.accounts.forEach { account ->
|
bank.accounts.forEach { account ->
|
||||||
if (account.accountIdentifier == accountInfo.accountIdentifier
|
if (account.accountIdentifier == accountInfo.accountIdentifier
|
||||||
&& account.productName == accountInfo.productName
|
&& account.productName == accountInfo.productName) {
|
||||||
&& account.accountType == accountInfo.accountType) {
|
|
||||||
|
|
||||||
return account
|
return account
|
||||||
}
|
}
|
||||||
|
@ -1247,4 +1246,20 @@ open class FinTsClient(
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected open fun mapAccountType(accountInfo: AccountInfo): AccountType? {
|
||||||
|
if (accountInfo.accountType == null || accountInfo.accountType == AccountType.Sonstige) {
|
||||||
|
accountInfo.productName?.let { name ->
|
||||||
|
// comdirect doesn't set account type field but names its bank accounts according to them like 'Girokonto', 'Tagesgeldkonto', ...
|
||||||
|
return when {
|
||||||
|
name.contains("Girokonto", true) -> AccountType.Girokonto
|
||||||
|
name.contains("Tagesgeld", true) || name.contains("Festgeld", true) -> AccountType.Festgeldkonto
|
||||||
|
name.contains("Kreditkarte", true) -> AccountType.Kreditkartenkonto
|
||||||
|
else -> accountInfo.accountType
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return accountInfo.accountType
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue