Updated to new data model (Customer as been renamed to User and BankingGroup and category have been added)
This commit is contained in:
parent
55aad5242a
commit
e8e304f574
|
@ -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<UserAccountEntity>
|
||||
|
||||
suspend fun persistUserAccount(userAccount: CustomerAccount): Long
|
||||
suspend fun persistUserAccount(userAccount: UserAccount): Long
|
||||
|
||||
|
||||
fun getAllAccountTransactions(): List<AccountTransactionEntity>
|
||||
|
|
|
@ -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<CustomerAccount> = emptyList(),
|
||||
userAccounts: Collection<UserAccount> = emptyList(),
|
||||
transactions: Collection<AccountTransaction> = emptyList()
|
||||
) : BankingRepository {
|
||||
|
||||
|
@ -19,7 +19,7 @@ class InMemoryBankingRepository(
|
|||
|
||||
override fun getAllUserAccounts(): List<UserAccountEntity> = 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(),
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
)
|
|
@ -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(),
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package net.codinux.banking.ui.model
|
||||
|
||||
import net.codinux.banking.client.model.BankingGroup
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
|
|
|
@ -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
|
||||
}
|
|
@ -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}" }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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) { }) { }
|
||||
}
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue