diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/dataaccess/BankingRepository.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/dataaccess/BankingRepository.kt index 2dfcd98..28a6fc8 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/dataaccess/BankingRepository.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/dataaccess/BankingRepository.kt @@ -1,7 +1,7 @@ package net.codinux.banking.dataaccess import net.codinux.banking.client.model.AccountTransaction -import net.codinux.banking.client.model.CustomerAccount +import net.codinux.banking.client.model.UserAccount import net.codinux.banking.dataaccess.entities.AccountTransactionEntity import net.codinux.banking.dataaccess.entities.UserAccountEntity @@ -9,7 +9,7 @@ interface BankingRepository { fun getAllUserAccounts(): List - suspend fun persistUserAccount(userAccount: CustomerAccount): Long + suspend fun persistUserAccount(userAccount: UserAccount): Long fun getAllAccountTransactions(): List diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/dataaccess/InMemoryBankingRepository.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/dataaccess/InMemoryBankingRepository.kt index e882d71..f1d0dad 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/dataaccess/InMemoryBankingRepository.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/dataaccess/InMemoryBankingRepository.kt @@ -1,12 +1,12 @@ package net.codinux.banking.dataaccess import net.codinux.banking.client.model.AccountTransaction -import net.codinux.banking.client.model.CustomerAccount +import net.codinux.banking.client.model.UserAccount import net.codinux.banking.dataaccess.entities.AccountTransactionEntity import net.codinux.banking.dataaccess.entities.UserAccountEntity class InMemoryBankingRepository( - userAccounts: Collection = emptyList(), + userAccounts: Collection = emptyList(), transactions: Collection = emptyList() ) : BankingRepository { @@ -19,7 +19,7 @@ class InMemoryBankingRepository( override fun getAllUserAccounts(): List = userAccounts.toList() - override suspend fun persistUserAccount(userAccount: CustomerAccount): Long { + override suspend fun persistUserAccount(userAccount: UserAccount): Long { val entity = map(userAccount) this.userAccounts.add(entity) return entity.id @@ -33,7 +33,7 @@ class InMemoryBankingRepository( } - private fun map(account: CustomerAccount) = UserAccountEntity( + private fun map(account: UserAccount) = UserAccountEntity( nextId++, account.bankCode, account.loginName, account.password, account.bankName, account.bic, account.customerName, account.userId, emptyList(), account.selectedTanMethodId, emptyList(), account.selectedTanMediumName, emptyList(), diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/dataaccess/SqliteBankingRepository.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/dataaccess/SqliteBankingRepository.kt index 5dcd64d..a9c155b 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/dataaccess/SqliteBankingRepository.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/dataaccess/SqliteBankingRepository.kt @@ -30,7 +30,7 @@ class SqliteBankingRepository( }.executeAsList() } - override suspend fun persistUserAccount(userAccount: CustomerAccount): Long { + override suspend fun persistUserAccount(userAccount: UserAccount): Long { return userAccountQueries.transactionWithResult { userAccountQueries.insertUserAccount(userAccount.bankCode, userAccount.loginName, userAccount.password, userAccount.bankName, userAccount.bic, userAccount.customerName, userAccount.userId, userAccount.selectedTanMethodId, userAccount.selectedTanMediumName, diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/dataaccess/entities/AccountTransactionEntity.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/dataaccess/entities/AccountTransactionEntity.kt index 54798cb..eb31e78 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/dataaccess/entities/AccountTransactionEntity.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/dataaccess/entities/AccountTransactionEntity.kt @@ -21,7 +21,7 @@ class AccountTransactionEntity( bookingText: String? = null, userSetDisplayName: String? = null, - val category: String? = null, // TODO: add to AccountTransaction + category: String? = null, notes: String? = null, information: String? = null, @@ -77,5 +77,5 @@ class AccountTransactionEntity( transactionReferenceNumber, relatedReferenceNumber, - userSetDisplayName, notes + userSetDisplayName, category, notes ) \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/dataaccess/entities/UserAccountEntity.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/dataaccess/entities/UserAccountEntity.kt index 0b49030..40cdc57 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/dataaccess/entities/UserAccountEntity.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/dataaccess/entities/UserAccountEntity.kt @@ -1,7 +1,7 @@ package net.codinux.banking.dataaccess.entities import net.codinux.banking.client.model.BankingGroup -import net.codinux.banking.client.model.CustomerAccount +import net.codinux.banking.client.model.UserAccount import net.codinux.banking.client.model.tan.TanMedium import net.codinux.banking.client.model.tan.TanMethod @@ -33,7 +33,7 @@ class UserAccountEntity( userSetDisplayName: String? = null, displayIndex: Int = 0 -) : CustomerAccount(bankCode, loginName, password, bankName, bic, customerName, userId, accounts, selectedTanMethodId, tanMethods, selectedTanMediumName, tanMedia, bankingGroup, iconUrl) { +) : UserAccount(bankCode, loginName, password, bankName, bic, customerName, userId, accounts, selectedTanMethodId, tanMethods, selectedTanMediumName, tanMedia, bankingGroup, iconUrl) { init { this.wrongCredentialsEntered = wrongCredentialsEntered @@ -42,7 +42,7 @@ class UserAccountEntity( } - constructor(id: Long, user: CustomerAccount) : this( + constructor(id: Long, user: UserAccount) : this( id, user.bankCode, user.loginName, user.password, user.bankName, user.bic, user.customerName, user.userId, emptyList(), user.selectedTanMethodId, emptyList(), user.selectedTanMediumName, emptyList(), diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/model/BankInfo.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/model/BankInfo.kt index b80d0a4..0748fd7 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/model/BankInfo.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/model/BankInfo.kt @@ -1,5 +1,6 @@ package net.codinux.banking.ui.model +import net.codinux.banking.client.model.BankingGroup import kotlinx.serialization.Serializable @Serializable diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/model/BankingGroup.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/model/BankingGroup.kt deleted file mode 100644 index 5f5bbda..0000000 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/model/BankingGroup.kt +++ /dev/null @@ -1,27 +0,0 @@ -package net.codinux.banking.ui.model - -enum class BankingGroup { - Sparkasse, - DKB, - OldenburgischeLandesbank, - VolksUndRaiffeisenbanken, - Sparda, - PSD, - GLS, - SonstigeGenossenschaftsbank, - DeutscheBank, - Postbank, - Commerzbank, - Comdirect, - Unicredit, - Targobank, - ING, - Santander, - Norisbank, - Degussa, - Oberbank, - Bundesbank, - KfW, - N26, - Consors -} \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/service/BankingService.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/service/BankingService.kt index 570d1ae..5452eca 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/service/BankingService.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/service/BankingService.kt @@ -53,7 +53,7 @@ class BankingService( suspend fun addAccount(bank: BankInfo, loginName: String, password: String): Boolean { try { - val response = client.getAccountDataAsync(GetAccountDataRequest(bank.bankCode, loginName, password, GetAccountDataOptions(retrieveTransactions = RetrieveTransactions.All))) + val response = client.getAccountDataAsync(GetAccountDataRequest(bank.bankCode, loginName, password, GetAccountDataOptions())) if (response.type == ResponseType.Success && response.data != null) { handleSuccessfulGetAccountDataResponse(response.data!!) @@ -85,15 +85,15 @@ class BankingService( } try { - val newUserAccountId = bankingRepository.persistUserAccount(response.customer) + val newUserAccountId = bankingRepository.persistUserAccount(response.user) - log.info { "Saved user account ${response.customer}" } + log.info { "Saved user account ${response.user}" } val userAccounts = uiState.userAccounts.value.toMutableList() - userAccounts.add(UserAccountEntity(newUserAccountId, response.customer)) + userAccounts.add(UserAccountEntity(newUserAccountId, response.user)) uiState.userAccounts.value = userAccounts } catch (e: Throwable) { - log.error(e) { "Could not save user account ${response.customer}" } + log.error(e) { "Could not save user account ${response.user}" } } } diff --git a/composeApp/src/desktopMain/kotlin/net/codinux/banking/ui/dialogs/EnterTanDialogPreview.kt b/composeApp/src/desktopMain/kotlin/net/codinux/banking/ui/dialogs/EnterTanDialogPreview.kt index eb5bcb1..58a5be6 100644 --- a/composeApp/src/desktopMain/kotlin/net/codinux/banking/ui/dialogs/EnterTanDialogPreview.kt +++ b/composeApp/src/desktopMain/kotlin/net/codinux/banking/ui/dialogs/EnterTanDialogPreview.kt @@ -2,7 +2,7 @@ package net.codinux.banking.ui.dialogs import androidx.compose.desktop.ui.tooling.preview.Preview import androidx.compose.runtime.Composable -import net.codinux.banking.client.model.CustomerAccountViewInfo +import net.codinux.banking.client.model.UserAccountViewInfo import net.codinux.banking.client.model.tan.* import net.codinux.banking.ui.model.TanChallengeReceived @@ -10,8 +10,8 @@ import net.codinux.banking.ui.model.TanChallengeReceived @Composable fun EnterTanDialogPreview_EnterTan() { val tanMethods = listOf(TanMethod("Zeig mich an", TanMethodType.AppTan, "902")) - val customer = CustomerAccountViewInfo("12345678", "SupiDupiNutzer", "Abzockbank") - val tanChallenge = TanChallenge(TanChallengeType.EnterTan, ActionRequiringTan.GetAccountInfo, "Geben Sie die TAN ein", tanMethods.first().identifier, tanMethods, customer = customer) + val user = UserAccountViewInfo("12345678", "SupiDupiNutzer", "Abzockbank") + val tanChallenge = TanChallenge(TanChallengeType.EnterTan, ActionRequiringTan.GetAccountInfo, "Geben Sie die TAN ein", tanMethods.first().identifier, tanMethods, user = user) EnterTanDialog(TanChallengeReceived(tanChallenge) { }) { } } @@ -24,9 +24,9 @@ fun EnterTanDialogPreview_TanImage() { val tanMethod = TanMethod("photoTAN-Verfahren", TanMethodType.photoTan, "902", 6, AllowedTanFormat.Numeric) val tanImage = TanImage("image/png", tanImageBytes) - val customer = CustomerAccountViewInfo("10010010", "Ihr krasser Login Name", "Phantasie Bank") + val user = UserAccountViewInfo("10010010", "Ihr krasser Login Name", "Phantasie Bank") - val tanChallenge = TanChallenge(TanChallengeType.Image, ActionRequiringTan.GetAccountInfo, "Geben Sie die TAN ein", tanMethod.identifier, listOf(tanMethod), null, emptyList(), tanImage, null, customer) + val tanChallenge = TanChallenge(TanChallengeType.Image, ActionRequiringTan.GetAccountInfo, "Geben Sie die TAN ein", tanMethod.identifier, listOf(tanMethod), null, emptyList(), tanImage, null, user) EnterTanDialog(TanChallengeReceived(tanChallenge) { }) { } } \ No newline at end of file diff --git a/composeApp/src/desktopTest/kotlin/net/codinux/banking/dataaccess/SqliteBankingRepositoryTest.kt b/composeApp/src/desktopTest/kotlin/net/codinux/banking/dataaccess/SqliteBankingRepositoryTest.kt index 3691166..874a398 100644 --- a/composeApp/src/desktopTest/kotlin/net/codinux/banking/dataaccess/SqliteBankingRepositoryTest.kt +++ b/composeApp/src/desktopTest/kotlin/net/codinux/banking/dataaccess/SqliteBankingRepositoryTest.kt @@ -23,7 +23,7 @@ class SqliteBankingRepositoryTest { val bankAccounts = listOf( BankAccount("12345", "Monika Tester", BankAccountType.CheckingAccount, balance = Amount("12.34"), retrievedTransactionsTo = LocalDate(2024, 5, 7), features = setOf(BankAccountFeatures.RetrieveBalance, BankAccountFeatures.InstantPayment), countDaysForWhichTransactionsAreKept = 320) ) - val userAccount = CustomerAccount("12345678", "SupiDupiUser", "geheim", "Abzock-Bank", "ABCDDEBBXXX", "Monika Tester", accounts = bankAccounts, bankingGroup = BankingGroup.DKB).apply { + val userAccount = UserAccount("12345678", "SupiDupiUser", "geheim", "Abzock-Bank", "ABCDDEBBXXX", "Monika Tester", accounts = bankAccounts, bankingGroup = BankingGroup.DKB).apply { wrongCredentialsEntered = true displayIndex = 99 }