From 9fa83f2685d69a7157ef2ffb84eace730ce05da3 Mon Sep 17 00:00:00 2001 From: dankito Date: Sat, 23 May 2020 19:32:25 +0200 Subject: [PATCH] Added customerId, productName and accountLimit to BankAccount --- .../net/dankito/banking/ui/model/BankAccount.kt | 15 ++++++++++----- .../dankito/banking/mapper/fints4kModelMapper.kt | 5 +++-- .../net/dankito/banking/util/hbci4jModelMapper.kt | 8 +++++++- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/BankAccount.kt b/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/BankAccount.kt index 28b2d362..d58eda7f 100644 --- a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/BankAccount.kt +++ b/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/BankAccount.kt @@ -13,9 +13,12 @@ open class BankAccount @JvmOverloads constructor( var accountHolderName: String, var iban: String?, var subAccountNumber: String?, + val customerId: String, var balance: BigDecimal = BigDecimal.ZERO, var currency: String = "EUR", var type: BankAccountType = BankAccountType.Girokonto, + val productName: String? = null, + val accountLimit: String? = null, var lastRetrievedTransactionsTimestamp: Date? = null, var supportsRetrievingAccountTransactions: Boolean = false, var supportsRetrievingBalance: Boolean = false, @@ -24,7 +27,7 @@ open class BankAccount @JvmOverloads constructor( bookedAccountTransactions: List = listOf() ) { - internal constructor() : this(Account(), "", "", null, null) // for object deserializers + internal constructor() : this(Account(), "", "", null, null, "") // for object deserializers var id: String = UUID.randomUUID().toString() @@ -33,12 +36,14 @@ open class BankAccount @JvmOverloads constructor( val displayName: String get() { - var displayName = identifier - subAccountNumber?.let { - displayName += " ($it)" + val productName = productName ?: subAccountNumber + + if (productName != null) { + return productName + " ($identifier)" } - return displayName + + return identifier } val displayNameIncludingBankName: String diff --git a/ui/fints4kBankingClient/src/main/kotlin/net/dankito/banking/mapper/fints4kModelMapper.kt b/ui/fints4kBankingClient/src/main/kotlin/net/dankito/banking/mapper/fints4kModelMapper.kt index d7e0b0e6..d8258d20 100644 --- a/ui/fints4kBankingClient/src/main/kotlin/net/dankito/banking/mapper/fints4kModelMapper.kt +++ b/ui/fints4kBankingClient/src/main/kotlin/net/dankito/banking/mapper/fints4kModelMapper.kt @@ -103,8 +103,9 @@ open class fints4kModelMapper { open fun mapBankAccount(account: Account, accountData: AccountData): BankAccount { return BankAccount(account, accountData.accountIdentifier, accountData.accountHolderName, accountData.iban, - accountData.subAccountAttribute, BigDecimal.ZERO, accountData.currency ?: "EUR", - mapBankAccountType(accountData.accountType), null, accountData.supportsFeature(AccountFeature.RetrieveAccountTransactions), + accountData.subAccountAttribute, accountData.customerId, BigDecimal.ZERO, accountData.currency ?: "EUR", + mapBankAccountType(accountData.accountType), accountData.productName, accountData.accountLimit, + null, accountData.supportsFeature(AccountFeature.RetrieveAccountTransactions), accountData.supportsFeature(AccountFeature.RetrieveBalance), accountData.supportsFeature(AccountFeature.TransferMoney), accountData.supportsFeature(AccountFeature.InstantPayment)) } diff --git a/ui/hbci4jBankingClient/src/main/kotlin/net/dankito/banking/util/hbci4jModelMapper.kt b/ui/hbci4jBankingClient/src/main/kotlin/net/dankito/banking/util/hbci4jModelMapper.kt index 4c4790b7..f3580bc3 100644 --- a/ui/hbci4jBankingClient/src/main/kotlin/net/dankito/banking/util/hbci4jModelMapper.kt +++ b/ui/hbci4jBankingClient/src/main/kotlin/net/dankito/banking/util/hbci4jModelMapper.kt @@ -8,6 +8,7 @@ import net.dankito.banking.ui.model.parameters.TransferMoneyData import net.dankito.banking.ui.model.tan.TanProcedureType import org.kapott.hbci.passport.HBCIPassport import org.kapott.hbci.structures.Konto +import org.kapott.hbci.structures.Value import java.math.BigDecimal @@ -44,7 +45,8 @@ open class hbci4jModelMapper { BankAccount(account, bankAccount.number, if (bankAccount.name2.isNullOrBlank() == false) bankAccount.name + " " + bankAccount.name2 else bankAccount.name, - iban, bankAccount.subnumber, BigDecimal.ZERO, bankAccount.curr, mapBankAccountType(bankAccount), + iban, bankAccount.subnumber, bankAccount.customerid, BigDecimal.ZERO, bankAccount.curr, mapBankAccountType(bankAccount), + null, bankAccount.limit?.value?.let { mapValue(it).toString() }, null, bankAccount.allowedGVs.contains("HKKAZ"), bankAccount.allowedGVs.contains("HKSAL"), bankAccount.allowedGVs.contains("HKCCS")) } } @@ -67,6 +69,10 @@ open class hbci4jModelMapper { } } + protected open fun mapValue(value: Value): BigDecimal { + return BigDecimal.valueOf(value.longValue).divide(BigDecimal.valueOf(100)) + } + open fun mapTanProcedures(tanProceduresString: String): List { return tanProceduresString.split('|')