Adjusted to updated model that bankCode has been renamed to domesticBankCode and countryCode got added

This commit is contained in:
dankito 2024-09-16 23:21:20 +02:00
parent d7a9acbe56
commit 96c8cf59cd
7 changed files with 18 additions and 17 deletions

View File

@ -59,10 +59,10 @@ class InMemoryBankingRepository(
private fun map(bank: BankAccess) = BankAccessEntity( private fun map(bank: BankAccess) = BankAccessEntity(
nextId++, nextId++,
bank.bankCode, bank.loginName, bank.password, bank.bankName, bank.bic, bank.customerName, bank.userId, bank.domesticBankCode, bank.loginName, bank.password, bank.bankName, bank.bic, bank.customerName, bank.userId,
// TODO: may fix someday and also add BankAccounts // TODO: may fix someday and also add BankAccounts
emptyList(), bank.selectedTanMethodIdentifier, emptyList(), bank.selectedTanMediumIdentifier, emptyList(), emptyList(), bank.selectedTanMethodIdentifier, emptyList(), bank.selectedTanMediumIdentifier, emptyList(),
bank.bankingGroup, bank.serverAddress, bank.bankingGroup, bank.serverAddress, bank.countryCode,
bank.userSetDisplayName, bank.displayIndex, bank.userSetDisplayName, bank.displayIndex,
bank.iconUrl, bank.wrongCredentialsEntered, bank.iconUrl, bank.wrongCredentialsEntered,
) )

View File

@ -32,9 +32,9 @@ open class SqliteBankingRepository(
val tanMedia = getAllTanMedia().groupBy { it.userId } val tanMedia = getAllTanMedia().groupBy { it.userId }
val holdings = getAllHoldings().groupBy { it.bankAccountId } val holdings = getAllHoldings().groupBy { it.bankAccountId }
return bankQueries.selectAllBanks { id, bankCode, loginName, password, bankName, bic, customerName, userId, selectedTanMethodIdentifier, selectedTanMediumIdentifier, bankingGroup, serverAddress, userSetDisplayName, clientData, displayIndex, iconUrl, wrongCredentialsEntered -> return bankQueries.selectAllBanks { id, domesticBankCode, loginName, password, bankName, bic, customerName, userId, selectedTanMethodIdentifier, selectedTanMediumIdentifier, bankingGroup, serverAddress, userSetDisplayName, clientData, displayIndex, iconUrl, wrongCredentialsEntered ->
BankAccessEntity(id, bankCode, loginName, password, bankName, bic, customerName, userId, getAccountsOfBank(id, bankAccounts, holdings), selectedTanMethodIdentifier, tanMethods[id] ?: emptyList(), selectedTanMediumIdentifier, tanMedia[id] ?: emptyList(), BankAccessEntity(id, domesticBankCode, loginName, password, bankName, bic, customerName, userId, getAccountsOfBank(id, bankAccounts, holdings), selectedTanMethodIdentifier, tanMethods[id] ?: emptyList(), selectedTanMediumIdentifier, tanMedia[id] ?: emptyList(),
bankingGroup?.let { BankingGroup.valueOf(it) }, serverAddress, userSetDisplayName, displayIndex.toInt(), iconUrl, wrongCredentialsEntered) bankingGroup?.let { BankingGroup.valueOf(it) }, serverAddress, "de", userSetDisplayName, displayIndex.toInt(), iconUrl, wrongCredentialsEntered)
}.executeAsList() }.executeAsList()
} }
@ -46,7 +46,7 @@ open class SqliteBankingRepository(
override suspend fun persistBank(bank: BankAccess): BankAccessEntity { override suspend fun persistBank(bank: BankAccess): BankAccessEntity {
return bankQueries.transactionWithResult { return bankQueries.transactionWithResult {
bankQueries.insertBank(bank.bankCode, bank.loginName, bank.password, bank.bankName, bank.bic, bankQueries.insertBank(bank.domesticBankCode, bank.loginName, bank.password, bank.bankName, bank.bic,
bank.customerName, bank.userId, bank.selectedTanMethodIdentifier, bank.selectedTanMediumIdentifier, bank.customerName, bank.userId, bank.selectedTanMethodIdentifier, bank.selectedTanMediumIdentifier,
bank.bankingGroup?.name, bank.serverAddress, null, bank.userSetDisplayName, bank.displayIndex.toLong(), bank.iconUrl, bank.wrongCredentialsEntered bank.bankingGroup?.name, bank.serverAddress, null, bank.userSetDisplayName, bank.displayIndex.toLong(), bank.iconUrl, bank.wrongCredentialsEntered
) )

View File

@ -7,7 +7,7 @@ import net.codinux.banking.client.model.tan.TanMedium
class BankAccessEntity( class BankAccessEntity(
val id: Long, val id: Long,
bankCode: String, domesticBankCode: String,
loginName: String, loginName: String,
password: String?, password: String?,
@ -27,13 +27,14 @@ class BankAccessEntity(
bankingGroup: BankingGroup? = null, bankingGroup: BankingGroup? = null,
serverAddress: String? = null, serverAddress: String? = null,
countryCode: String = "de",
userSetDisplayName: String? = null, userSetDisplayName: String? = null,
displayIndex: Int = 0, displayIndex: Int = 0,
iconUrl: String? = null, iconUrl: String? = null,
wrongCredentialsEntered: Boolean = false wrongCredentialsEntered: Boolean = false
) : BankAccess(bankCode, loginName, password, bankName, bic, customerName, userId, accounts, selectedTanMethodIdentifier, tanMethods, selectedTanMediumIdentifier, tanMedia, bankingGroup, serverAddress) { ) : BankAccess(domesticBankCode, loginName, password, bankName, bic, customerName, userId, accounts, selectedTanMethodIdentifier, tanMethods, selectedTanMediumIdentifier, tanMedia, bankingGroup, serverAddress, countryCode) {
init { init {
this.userSetDisplayName = userSetDisplayName this.userSetDisplayName = userSetDisplayName
@ -46,10 +47,10 @@ class BankAccessEntity(
constructor(id: Long, bank: BankAccess, bankAccounts: List<BankAccountEntity>, tanMethods: List<TanMethodEntity>, tanMedia: List<TanMediumEntity>) : this( constructor(id: Long, bank: BankAccess, bankAccounts: List<BankAccountEntity>, tanMethods: List<TanMethodEntity>, tanMedia: List<TanMediumEntity>) : this(
id, id,
bank.bankCode, bank.loginName, bank.password, bank.bankName, bank.bic, bank.customerName, bank.userId, bank.domesticBankCode, bank.loginName, bank.password, bank.bankName, bank.bic, bank.customerName, bank.userId,
bankAccounts, bankAccounts,
bank.selectedTanMethodIdentifier, tanMethods, bank.selectedTanMediumIdentifier, tanMedia, bank.selectedTanMethodIdentifier, tanMethods, bank.selectedTanMediumIdentifier, tanMedia,
bank.bankingGroup, bank.serverAddress, bank.bankingGroup, bank.serverAddress, bank.countryCode,
bank.userSetDisplayName, bank.displayIndex, bank.userSetDisplayName, bank.displayIndex,
bank.iconUrl, bank.wrongCredentialsEntered, bank.iconUrl, bank.wrongCredentialsEntered,
) )

View File

@ -136,7 +136,7 @@ fun AddAccountDialog(
} }
Row(Modifier.fillMaxWidth().padding(top = 6.dp)) { Row(Modifier.fillMaxWidth().padding(top = 6.dp)) {
Text(bank.bankCode, color = textColor) Text(bank.domesticBankCode, color = textColor)
Text("${bank.postalCode} ${bank.city}", Modifier.weight(1f).padding(start = 8.dp), color = if (supportsFinTs) Color.Gray else textColor) Text("${bank.postalCode} ${bank.city}", Modifier.weight(1f).padding(start = 8.dp), color = if (supportsFinTs) Color.Gray else textColor)
} }

View File

@ -6,7 +6,7 @@ import kotlinx.serialization.Serializable
@Serializable @Serializable
class BankInfo( class BankInfo(
val name: String, val name: String,
val bankCode: String, val domesticBankCode: String,
val bic: String = "", val bic: String = "",
val postalCode: String, val postalCode: String,
val city: String, val city: String,
@ -23,5 +23,5 @@ class BankInfo(
get() = pinTanVersion == "FinTS V3.0" get() = pinTanVersion == "FinTS V3.0"
override fun toString() = "$bankCode $name $city" override fun toString() = "$domesticBankCode $name $city"
} }

View File

@ -36,7 +36,7 @@ class BankFinder {
return getBankList(maxItems) return getBankList(maxItems)
} }
return getBankList().asSequence().filter { it.bankCode.startsWith(query) } return getBankList().asSequence().filter { it.domesticBankCode.startsWith(query) }
.max(maxItems) .max(maxItems)
} }
@ -69,7 +69,7 @@ class BankFinder {
val bankCode = iban.substring(4) // first two letters are the country code, third and fourth char are the checksum, bank code starts at 5th char val bankCode = iban.substring(4) // first two letters are the country code, third and fourth char are the checksum, bank code starts at 5th char
val result = getBankList().asSequence().filter { it.bankCode.startsWith(bankCode) }.max(2) val result = getBankList().asSequence().filter { it.domesticBankCode.startsWith(bankCode) }.max(2)
return if (result.size > 1) { // non unique result, but should actually never happen for BICs return if (result.size > 1) { // non unique result, but should actually never happen for BICs
null null

View File

@ -72,7 +72,7 @@ class BankingService(
suspend fun addAccount(bank: BankInfo, loginName: String, password: String, retrieveAllTransactions: Boolean = false): Boolean { suspend fun addAccount(bank: BankInfo, loginName: String, password: String, retrieveAllTransactions: Boolean = false): Boolean {
try { try {
val retrieveTransactions = if (retrieveAllTransactions) RetrieveTransactions.All else RetrieveTransactions.OfLast90Days val retrieveTransactions = if (retrieveAllTransactions) RetrieveTransactions.All else RetrieveTransactions.OfLast90Days
val response = client.getAccountDataAsync(GetAccountDataRequest(bank.bankCode, loginName, password, GetAccountDataOptions(retrieveTransactions), mapBankInfo(bank))) val response = client.getAccountDataAsync(GetAccountDataRequest(bank.domesticBankCode, loginName, password, GetAccountDataOptions(retrieveTransactions), mapBankInfo(bank)))
if (response.type == ResponseType.Success && response.data != null) { if (response.type == ResponseType.Success && response.data != null) {
handleSuccessfulGetAccountDataResponse(response.data!!) handleSuccessfulGetAccountDataResponse(response.data!!)
@ -239,7 +239,7 @@ class BankingService(
recipientName: String, recipientAccountIdentifier: String, amount: Amount, currency: String, recipientName: String, recipientAccountIdentifier: String, amount: Amount, currency: String,
paymentReference: String? = null, instantTransfer: Boolean = false, recipientBankIdentifier: String? = null): Boolean { paymentReference: String? = null, instantTransfer: Boolean = false, recipientBankIdentifier: String? = null): Boolean {
val response = client.transferMoneyAsync(TransferMoneyRequestForUser( val response = client.transferMoneyAsync(TransferMoneyRequestForUser(
bank.bankCode, bank.loginName, bank.password!!, bank.domesticBankCode, bank.loginName, bank.password!!,
BankAccountIdentifier(account.identifier, account.subAccountNumber, account.iban), // TODO: use BankingClient's one BankAccountIdentifier(account.identifier, account.subAccountNumber, account.iban), // TODO: use BankingClient's one
recipientName, recipientAccountIdentifier, recipientBankIdentifier, recipientName, recipientAccountIdentifier, recipientBankIdentifier,
amount, "EUR", amount, "EUR",