Updated database model to updated data model
This commit is contained in:
parent
4cd727b5c0
commit
e883713eba
|
@ -51,7 +51,7 @@ class InMemoryBankingRepository(
|
||||||
override fun getAllAccountTransactions(): List<AccountTransactionEntity> = transactions.toList()
|
override fun getAllAccountTransactions(): List<AccountTransactionEntity> = transactions.toList()
|
||||||
|
|
||||||
override fun getAllTransactionsForBank(bank: BankAccessEntity): List<AccountTransactionEntity> =
|
override fun getAllTransactionsForBank(bank: BankAccessEntity): List<AccountTransactionEntity> =
|
||||||
getAllAccountTransactions().filter { it.userId == bank.id }
|
getAllAccountTransactions().filter { it.bankId == bank.id }
|
||||||
|
|
||||||
override fun getTransactionById(transactionId: Long): AccountTransactionEntity? =
|
override fun getTransactionById(transactionId: Long): AccountTransactionEntity? =
|
||||||
getAllAccountTransactions().firstOrNull { it.id == transactionId }
|
getAllAccountTransactions().firstOrNull { it.id == transactionId }
|
||||||
|
@ -67,10 +67,10 @@ class InMemoryBankingRepository(
|
||||||
bank.iconUrl, bank.wrongCredentialsEntered,
|
bank.iconUrl, bank.wrongCredentialsEntered,
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: someday may fix and get bankId and bankAccountId
|
// TODO: someday may fix and get bankId and accountId
|
||||||
private fun map(transaction: AccountTransaction, bankId: Long = nextId++, bankAccountId: Long = nextId++) = AccountTransactionEntity(
|
private fun map(transaction: AccountTransaction, bankId: Long = nextId++, accountId: Long = nextId++) = AccountTransactionEntity(
|
||||||
nextId++,
|
nextId++,
|
||||||
bankId, bankAccountId,
|
bankId, accountId,
|
||||||
transaction.amount, transaction.currency, transaction.reference,
|
transaction.amount, transaction.currency, transaction.reference,
|
||||||
transaction.bookingDate, transaction.valueDate,
|
transaction.bookingDate, transaction.valueDate,
|
||||||
transaction.otherPartyName, transaction.otherPartyBankId, transaction.otherPartyAccountId,
|
transaction.otherPartyName, transaction.otherPartyBankId, transaction.otherPartyAccountId,
|
||||||
|
|
|
@ -19,7 +19,7 @@ open class SqliteBankingRepository(
|
||||||
|
|
||||||
private val database = BankmeisterDb(sqlDriver)
|
private val database = BankmeisterDb(sqlDriver)
|
||||||
|
|
||||||
private val bankQueries = database.userQueries
|
private val bankQueries = database.bankQueries
|
||||||
|
|
||||||
private val accountTransactionQueries = database.accountTransactionQueries
|
private val accountTransactionQueries = database.accountTransactionQueries
|
||||||
|
|
||||||
|
@ -27,14 +27,14 @@ open class SqliteBankingRepository(
|
||||||
|
|
||||||
|
|
||||||
override fun getAllBanks(): List<BankAccessEntity> {
|
override fun getAllBanks(): List<BankAccessEntity> {
|
||||||
val bankAccounts = getAllBankAccounts().groupBy { it.userId }
|
val bankAccounts = getAllBankAccounts().groupBy { it.bankId }
|
||||||
val tanMethods = getAllTanMethods().groupBy { it.userId }.mapValues { it.value.toMutableList() }
|
val tanMethods = getAllTanMethods().groupBy { it.bankId }.mapValues { it.value.toMutableList() }
|
||||||
val tanMedia = getAllTanMedia().groupBy { it.userId }.mapValues { it.value.toMutableList() }
|
val tanMedia = getAllTanMedia().groupBy { it.bankId }.mapValues { it.value.toMutableList() }
|
||||||
val holdings = getAllHoldings().groupBy { it.bankAccountId }
|
val holdings = getAllHoldings().groupBy { it.accountId }
|
||||||
|
|
||||||
return bankQueries.selectAllBanks { id, domesticBankCode, loginName, password, bankName, bic, customerName, userId, selectedTanMethodIdentifier, selectedTanMediumIdentifier, bankingGroup, serverAddress, userSetDisplayName, clientData, displayIndex, iconUrl, wrongCredentialsEntered ->
|
return bankQueries.getAllBanks { id, domesticBankCode, loginName, password, bankName, bic, customerName, userId, selectedTanMethodIdentifier, selectedTanMediumIdentifier, bankingGroup, serverAddress, countryCode, userSetDisplayName, clientData, displayIndex, iconUrl, wrongCredentialsEntered ->
|
||||||
BankAccessEntity(id, domesticBankCode, loginName, password, bankName, bic, customerName, userId, getAccountsOfBank(id, bankAccounts, holdings), selectedTanMethodIdentifier, tanMethods[id] ?: mutableListOf(), selectedTanMediumIdentifier, tanMedia[id] ?: mutableListOf(),
|
BankAccessEntity(id, domesticBankCode, loginName, password, bankName, bic, customerName, userId, getAccountsOfBank(id, bankAccounts, holdings), selectedTanMethodIdentifier, tanMethods[id] ?: mutableListOf(), selectedTanMediumIdentifier, tanMedia[id] ?: mutableListOf(),
|
||||||
bankingGroup?.let { BankingGroup.valueOf(it) }, serverAddress, "de", userSetDisplayName, displayIndex.toInt(), iconUrl, wrongCredentialsEntered)
|
bankingGroup?.let { BankingGroup.valueOf(it) }, serverAddress, countryCode, userSetDisplayName, displayIndex.toInt(), iconUrl, wrongCredentialsEntered)
|
||||||
}.executeAsList()
|
}.executeAsList()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ open class SqliteBankingRepository(
|
||||||
return bankQueries.transactionWithResult {
|
return bankQueries.transactionWithResult {
|
||||||
bankQueries.insertBank(bank.domesticBankCode, 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, bank.countryCode, null, bank.userSetDisplayName, bank.displayIndex.toLong(), bank.iconUrl, bank.wrongCredentialsEntered
|
||||||
)
|
)
|
||||||
|
|
||||||
val bankId = getLastInsertedId() // getLastInsertedId() / last_insert_rowid() has to be called in a transaction with the insert operation, otherwise it will not work
|
val bankId = getLastInsertedId() // getLastInsertedId() / last_insert_rowid() has to be called in a transaction with the insert operation, otherwise it will not work
|
||||||
|
@ -63,7 +63,7 @@ open class SqliteBankingRepository(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun getAllBankAccounts(): List<BankAccountEntity> = bankQueries.selectAllBankAccounts { id, bankId, identifier, subAccountNumber, iban, productName, accountHolderName, type, currency, accountLimit, isAccountTypeSupportedByApplication, features, balance, serverTransactionsRetentionDays, lastAccountUpdateTime, retrievedTransactionsFrom, userSetDisplayName, displayIndex, hideAccount, includeInAutomaticAccountsUpdate ->
|
fun getAllBankAccounts(): List<BankAccountEntity> = bankQueries.getAllBankAccounts { id, bankId, identifier, subAccountNumber, iban, productName, accountHolderName, type, currency, accountLimit, isAccountTypeSupportedByApplication, features, balance, serverTransactionsRetentionDays, lastAccountUpdateTime, retrievedTransactionsFrom, userSetDisplayName, displayIndex, hideAccount, includeInAutomaticAccountsUpdate ->
|
||||||
BankAccountEntity(
|
BankAccountEntity(
|
||||||
id, bankId,
|
id, bankId,
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ open class SqliteBankingRepository(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun getAllTanMethods(): List<TanMethodEntity> = bankQueries.selectAllTanMethods { id, bankId, displayName, type, identifier, maxTanInputLength, allowedTanFormat ->
|
private fun getAllTanMethods(): List<TanMethodEntity> = bankQueries.getAllTanMethods { id, bankId, displayName, type, identifier, maxTanInputLength, allowedTanFormat ->
|
||||||
TanMethodEntity(
|
TanMethodEntity(
|
||||||
id,
|
id,
|
||||||
bankId,
|
bankId,
|
||||||
|
@ -153,7 +153,7 @@ open class SqliteBankingRepository(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun getAllTanMedia(): List<TanMediumEntity> = bankQueries.selectAllTanMedia { id, bankId, type, mediumName, status, phoneNumber, concealedPhoneNumber, cardNumber, cardSequenceNumber, cardType, validFrom, validTo ->
|
private fun getAllTanMedia(): List<TanMediumEntity> = bankQueries.getAllTanMedia { id, bankId, type, mediumName, status, phoneNumber, concealedPhoneNumber, cardNumber, cardSequenceNumber, cardType, validFrom, validTo ->
|
||||||
val mobilePhone = if (phoneNumber != null || concealedPhoneNumber != null) {
|
val mobilePhone = if (phoneNumber != null || concealedPhoneNumber != null) {
|
||||||
MobilePhoneTanMedium(phoneNumber, concealedPhoneNumber)
|
MobilePhoneTanMedium(phoneNumber, concealedPhoneNumber)
|
||||||
} else {
|
} else {
|
||||||
|
@ -207,21 +207,21 @@ open class SqliteBankingRepository(
|
||||||
|
|
||||||
|
|
||||||
protected open fun getAllHoldings(): List<HoldingEntity> =
|
protected open fun getAllHoldings(): List<HoldingEntity> =
|
||||||
accountTransactionQueries.selectAllHoldings { id, bankId, bankAccountId, name, isin, wkn, quantity, currency, totalBalance, marketValue, performancePercentage, totalCostPrice, averageCostPrice, pricingTime, buyingDate ->
|
accountTransactionQueries.selectAllHoldings { id, bankId, accountId, name, isin, wkn, quantity, currency, totalBalance, marketValue, performancePercentage, totalCostPrice, averageCostPrice, pricingTime, buyingDate ->
|
||||||
HoldingEntity(id, bankId, bankAccountId, name, isin, wkn, mapToInt(quantity), currency, mapToAmount(totalBalance), mapToAmount(marketValue), performancePercentage?.toFloat(), mapToAmount(totalCostPrice), mapToAmount(averageCostPrice), mapToInstant(pricingTime), mapToDate(buyingDate))
|
HoldingEntity(id, bankId, accountId, name, isin, wkn, mapToInt(quantity), currency, mapToAmount(totalBalance), mapToAmount(marketValue), performancePercentage?.toFloat(), mapToAmount(totalCostPrice), mapToAmount(averageCostPrice), mapToInstant(pricingTime), mapToDate(buyingDate))
|
||||||
}.executeAsList()
|
}.executeAsList()
|
||||||
|
|
||||||
override suspend fun persistHoldings(bankAccount: BankAccountEntity, holdings: List<Holding>): List<HoldingEntity> =
|
override suspend fun persistHoldings(bankAccount: BankAccountEntity, holdings: List<Holding>): List<HoldingEntity> =
|
||||||
accountTransactionQueries.transactionWithResult {
|
accountTransactionQueries.transactionWithResult {
|
||||||
holdings.map { persistHolding(bankAccount.userId, bankAccount.id, it) }
|
holdings.map { persistHolding(bankAccount.bankId, bankAccount.id, it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Has to be executed in a transaction in order that getting persisted Holding's id works~
|
* Has to be executed in a transaction in order that getting persisted Holding's id works~
|
||||||
*/
|
*/
|
||||||
protected open suspend fun persistHolding(bankId: Long, bankAccountId: Long, holding: Holding): HoldingEntity {
|
protected open suspend fun persistHolding(bankId: Long, accountId: Long, holding: Holding): HoldingEntity {
|
||||||
accountTransactionQueries.insertHolding(
|
accountTransactionQueries.insertHolding(
|
||||||
bankId, bankAccountId,
|
bankId, accountId,
|
||||||
|
|
||||||
holding.name, holding.isin, holding.wkn,
|
holding.name, holding.isin, holding.wkn,
|
||||||
|
|
||||||
|
@ -234,7 +234,7 @@ open class SqliteBankingRepository(
|
||||||
mapInstant(holding.pricingTime), mapDate(holding.buyingDate)
|
mapInstant(holding.pricingTime), mapDate(holding.buyingDate)
|
||||||
)
|
)
|
||||||
|
|
||||||
return HoldingEntity(getLastInsertedId(), bankId, bankAccountId, holding)
|
return HoldingEntity(getLastInsertedId(), bankId, accountId, holding)
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun updateHoldings(holdings: List<HoldingEntity>) {
|
override suspend fun updateHoldings(holdings: List<HoldingEntity>) {
|
||||||
|
@ -266,16 +266,16 @@ open class SqliteBankingRepository(
|
||||||
|
|
||||||
|
|
||||||
override fun getAllAccountTransactionsAsViewModel(): List<AccountTransactionViewModel> =
|
override fun getAllAccountTransactionsAsViewModel(): List<AccountTransactionViewModel> =
|
||||||
accountTransactionQueries.selectAllTransactionsAsViewModel { id, bankId, bankAccountId, amount, currency, reference, valueDate, otherPartyName, postingText, userSetDisplayName, category ->
|
accountTransactionQueries.getAllTransactionsAsViewModel { id, bankId, accountId, amount, currency, reference, valueDate, otherPartyName, postingText, userSetDisplayName, category ->
|
||||||
AccountTransactionViewModel(id, bankId, bankAccountId, mapToAmount(amount), currency, reference, mapToDate(valueDate), otherPartyName, postingText, userSetDisplayName, category)
|
AccountTransactionViewModel(id, bankId, accountId, mapToAmount(amount), currency, reference, mapToDate(valueDate), otherPartyName, postingText, userSetDisplayName, category)
|
||||||
}.executeAsList()
|
}.executeAsList()
|
||||||
|
|
||||||
override fun getAllAccountTransactions(): List<AccountTransactionEntity> {
|
override fun getAllAccountTransactions(): List<AccountTransactionEntity> {
|
||||||
return accountTransactionQueries.selectAllTransactions(::mapTransaction).executeAsList()
|
return accountTransactionQueries.getAllTransactions(::mapTransaction).executeAsList()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getAllTransactionsForBank(bank: BankAccessEntity): List<AccountTransactionEntity> {
|
override fun getAllTransactionsForBank(bank: BankAccessEntity): List<AccountTransactionEntity> {
|
||||||
return accountTransactionQueries.selectAllTransactionsOfUser(bank.id, ::mapTransaction).executeAsList()
|
return accountTransactionQueries.getAllTransactionsForBank(bank.id, ::mapTransaction).executeAsList()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getTransactionById(transactionId: Long): AccountTransactionEntity? =
|
override fun getTransactionById(transactionId: Long): AccountTransactionEntity? =
|
||||||
|
@ -285,7 +285,7 @@ open class SqliteBankingRepository(
|
||||||
override suspend fun persistTransactions(bankAccount: BankAccountEntity, transactions: List<AccountTransaction>): List<AccountTransactionEntity> {
|
override suspend fun persistTransactions(bankAccount: BankAccountEntity, transactions: List<AccountTransaction>): List<AccountTransactionEntity> {
|
||||||
return accountTransactionQueries.transactionWithResult {
|
return accountTransactionQueries.transactionWithResult {
|
||||||
transactions.map { transaction ->
|
transactions.map { transaction ->
|
||||||
persistTransaction(bankAccount.userId, bankAccount.id, transaction)
|
persistTransaction(bankAccount.bankId, bankAccount.id, transaction)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -293,9 +293,9 @@ open class SqliteBankingRepository(
|
||||||
/**
|
/**
|
||||||
* Has to be executed in a transaction in order that getting persisted AccountTransaction's id works~
|
* Has to be executed in a transaction in order that getting persisted AccountTransaction's id works~
|
||||||
*/
|
*/
|
||||||
protected open suspend fun persistTransaction(bankId: Long, bankAccountId: Long, transaction: AccountTransaction): AccountTransactionEntity {
|
protected open suspend fun persistTransaction(bankId: Long, accountId: Long, transaction: AccountTransaction): AccountTransactionEntity {
|
||||||
accountTransactionQueries.insertTransaction(
|
accountTransactionQueries.insertTransaction(
|
||||||
bankId, bankAccountId,
|
bankId, accountId,
|
||||||
|
|
||||||
mapAmount(transaction.amount), transaction.currency, transaction.reference,
|
mapAmount(transaction.amount), transaction.currency, transaction.reference,
|
||||||
mapDate(transaction.bookingDate), mapDate(transaction.valueDate),
|
mapDate(transaction.bookingDate), mapDate(transaction.valueDate),
|
||||||
|
@ -326,7 +326,7 @@ open class SqliteBankingRepository(
|
||||||
transaction.isReversal
|
transaction.isReversal
|
||||||
)
|
)
|
||||||
|
|
||||||
return AccountTransactionEntity(getLastInsertedId(), bankId, bankAccountId, transaction)
|
return AccountTransactionEntity(getLastInsertedId(), bankId, accountId, transaction)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -335,7 +335,7 @@ open class SqliteBankingRepository(
|
||||||
|
|
||||||
|
|
||||||
private fun mapTransaction(
|
private fun mapTransaction(
|
||||||
id: Long, bankId: Long, bankAccountId: Long,
|
id: Long, bankId: Long, accountId: Long,
|
||||||
|
|
||||||
amount: String, currency: String, reference: String?,
|
amount: String, currency: String, reference: String?,
|
||||||
bookingDate: String, valueDate: String,
|
bookingDate: String, valueDate: String,
|
||||||
|
@ -366,7 +366,7 @@ open class SqliteBankingRepository(
|
||||||
isReversal: Boolean
|
isReversal: Boolean
|
||||||
): AccountTransactionEntity = AccountTransactionEntity(
|
): AccountTransactionEntity = AccountTransactionEntity(
|
||||||
id,
|
id,
|
||||||
bankId, bankAccountId,
|
bankId, accountId,
|
||||||
|
|
||||||
Amount(amount), currency, reference,
|
Amount(amount), currency, reference,
|
||||||
mapToDate(bookingDate), mapToDate(valueDate),
|
mapToDate(bookingDate), mapToDate(valueDate),
|
||||||
|
|
|
@ -6,8 +6,8 @@ import net.codinux.banking.client.model.Amount
|
||||||
|
|
||||||
class AccountTransactionEntity(
|
class AccountTransactionEntity(
|
||||||
val id: Long,
|
val id: Long,
|
||||||
val userId: Long,
|
val bankId: Long,
|
||||||
val bankAccountId: Long,
|
val accountId: Long,
|
||||||
|
|
||||||
amount: Amount,
|
amount: Amount,
|
||||||
currency: String,
|
currency: String,
|
||||||
|
@ -82,8 +82,8 @@ class AccountTransactionEntity(
|
||||||
|
|
||||||
userSetDisplayName, category, notes
|
userSetDisplayName, category, notes
|
||||||
) {
|
) {
|
||||||
constructor(id: Long, userId: Long, bankAccountId: Long, transaction: AccountTransaction) : this(
|
constructor(id: Long, bankId: Long, accountId: Long, transaction: AccountTransaction) : this(
|
||||||
id, userId, bankAccountId,
|
id, bankId, accountId,
|
||||||
transaction.amount, transaction.currency, transaction.reference,
|
transaction.amount, transaction.currency, transaction.reference,
|
||||||
transaction.bookingDate, transaction.valueDate,
|
transaction.bookingDate, transaction.valueDate,
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ class AccountTransactionEntity(
|
||||||
|
|
||||||
|
|
||||||
override val identifier: String by lazy {
|
override val identifier: String by lazy {
|
||||||
"$userId ${super.identifier}"
|
"$bankId ${super.identifier}"
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -6,7 +6,7 @@ import net.codinux.banking.client.model.*
|
||||||
|
|
||||||
class BankAccountEntity(
|
class BankAccountEntity(
|
||||||
val id: Long,
|
val id: Long,
|
||||||
val userId: Long,
|
val bankId: Long,
|
||||||
|
|
||||||
identifier: String,
|
identifier: String,
|
||||||
subAccountNumber: String? = null,
|
subAccountNumber: String? = null,
|
||||||
|
@ -53,8 +53,8 @@ class BankAccountEntity(
|
||||||
userSetDisplayName, displayIndex,
|
userSetDisplayName, displayIndex,
|
||||||
hideAccount, includeInAutomaticAccountsUpdate
|
hideAccount, includeInAutomaticAccountsUpdate
|
||||||
) {
|
) {
|
||||||
constructor(id: Long, userId: Long, account: BankAccount, transactions: List<AccountTransactionEntity> = emptyList(), holdings: List<HoldingEntity> = emptyList()) : this(
|
constructor(id: Long, bankId: Long, account: BankAccount, transactions: List<AccountTransactionEntity> = emptyList(), holdings: List<HoldingEntity> = emptyList()) : this(
|
||||||
id, userId,
|
id, bankId,
|
||||||
account.identifier, account.subAccountNumber, account.iban, account.productName,
|
account.identifier, account.subAccountNumber, account.iban, account.productName,
|
||||||
|
|
||||||
account.accountHolderName, account.type,
|
account.accountHolderName, account.type,
|
||||||
|
|
|
@ -7,8 +7,8 @@ import net.codinux.banking.client.model.securitiesaccount.Holding
|
||||||
|
|
||||||
class HoldingEntity(
|
class HoldingEntity(
|
||||||
val id: Long,
|
val id: Long,
|
||||||
val userId: Long,
|
val bankId: Long,
|
||||||
val bankAccountId: Long,
|
val accountId: Long,
|
||||||
|
|
||||||
name: String,
|
name: String,
|
||||||
|
|
||||||
|
@ -30,8 +30,8 @@ class HoldingEntity(
|
||||||
buyingDate: LocalDate? = null
|
buyingDate: LocalDate? = null
|
||||||
) : Holding(name, isin, wkn, quantity, currency, totalBalance, marketValue, performancePercentage, totalCostPrice, averageCostPrice, pricingTime, buyingDate) {
|
) : Holding(name, isin, wkn, quantity, currency, totalBalance, marketValue, performancePercentage, totalCostPrice, averageCostPrice, pricingTime, buyingDate) {
|
||||||
|
|
||||||
constructor(id: Long, userId: Long, bankAccountId: Long, holding: Holding) : this(
|
constructor(id: Long, bankId: Long, accountId: Long, holding: Holding) : this(
|
||||||
id, userId, bankAccountId,
|
id, bankId, accountId,
|
||||||
|
|
||||||
holding.name, holding.isin, holding.wkn,
|
holding.name, holding.isin, holding.wkn,
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import net.codinux.banking.client.model.tan.*
|
||||||
|
|
||||||
class TanMediumEntity(
|
class TanMediumEntity(
|
||||||
val id: Long,
|
val id: Long,
|
||||||
val userId: Long,
|
val bankId: Long,
|
||||||
|
|
||||||
type: TanMediumType,
|
type: TanMediumType,
|
||||||
mediumName: String?,
|
mediumName: String?,
|
||||||
|
@ -14,7 +14,7 @@ class TanMediumEntity(
|
||||||
mobilePhone: MobilePhoneTanMedium? = null
|
mobilePhone: MobilePhoneTanMedium? = null
|
||||||
) : TanMedium(type, mediumName, status, tanGenerator, mobilePhone) {
|
) : TanMedium(type, mediumName, status, tanGenerator, mobilePhone) {
|
||||||
|
|
||||||
constructor(id: Long, userId: Long, medium: TanMedium)
|
constructor(id: Long, bankId: Long, medium: TanMedium)
|
||||||
: this(id, userId, medium.type, medium.mediumName, medium.status, medium.tanGenerator, medium.mobilePhone)
|
: this(id, bankId, medium.type, medium.mediumName, medium.status, medium.tanGenerator, medium.mobilePhone)
|
||||||
|
|
||||||
}
|
}
|
|
@ -6,7 +6,7 @@ import net.codinux.banking.client.model.tan.TanMethodType
|
||||||
|
|
||||||
class TanMethodEntity(
|
class TanMethodEntity(
|
||||||
val id: Long,
|
val id: Long,
|
||||||
val userId: Long,
|
val bankId: Long,
|
||||||
|
|
||||||
displayName: String,
|
displayName: String,
|
||||||
type: TanMethodType,
|
type: TanMethodType,
|
||||||
|
@ -15,7 +15,7 @@ class TanMethodEntity(
|
||||||
allowedTanFormat: AllowedTanFormat = AllowedTanFormat.Alphanumeric
|
allowedTanFormat: AllowedTanFormat = AllowedTanFormat.Alphanumeric
|
||||||
) : TanMethod(displayName, type, identifier, maxTanInputLength, allowedTanFormat) {
|
) : TanMethod(displayName, type, identifier, maxTanInputLength, allowedTanFormat) {
|
||||||
|
|
||||||
constructor(id: Long, userId: Long, tanMethod: TanMethod)
|
constructor(id: Long, bankId: Long, tanMethod: TanMethod)
|
||||||
: this(id, userId, tanMethod.displayName, tanMethod.type, tanMethod.identifier, tanMethod.maxTanInputLength, tanMethod.allowedTanFormat)
|
: this(id, bankId, tanMethod.displayName, tanMethod.type, tanMethod.identifier, tanMethod.maxTanInputLength, tanMethod.allowedTanFormat)
|
||||||
|
|
||||||
}
|
}
|
|
@ -90,7 +90,7 @@ fun GroupedTransactionsListItems(
|
||||||
Column(Modifier.background(Color.White)) { // LazyColumn inside LazyColumn is not allowed
|
Column(Modifier.background(Color.White)) { // LazyColumn inside LazyColumn is not allowed
|
||||||
monthTransactions.forEachIndexed { index, transaction ->
|
monthTransactions.forEachIndexed { index, transaction ->
|
||||||
key(transaction.id) {
|
key(transaction.id) {
|
||||||
TransactionListItem(banksById[transaction.userId], transaction, index, monthTransactions.size)
|
TransactionListItem(banksById[transaction.bankId], transaction, index, monthTransactions.size)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ fun TransactionListItem(bank: BankAccess?, transaction: AccountTransactionViewMo
|
||||||
val transactionEntity = DI.bankingService.getTransaction(transaction.id)
|
val transactionEntity = DI.bankingService.getTransaction(transaction.id)
|
||||||
|
|
||||||
DI.uiState.showTransferMoneyDialogData.value = ShowTransferMoneyDialogData(
|
DI.uiState.showTransferMoneyDialogData.value = ShowTransferMoneyDialogData(
|
||||||
DI.uiState.banks.value.firstNotNullOf { it.accounts.firstOrNull { it.id == transaction.bankAccountId } },
|
DI.uiState.banks.value.firstNotNullOf { it.accounts.firstOrNull { it.id == transaction.accountId } },
|
||||||
transaction.otherPartyName,
|
transaction.otherPartyName,
|
||||||
transactionEntity?.otherPartyBankId,
|
transactionEntity?.otherPartyBankId,
|
||||||
transactionEntity?.otherPartyAccountId,
|
transactionEntity?.otherPartyAccountId,
|
||||||
|
|
|
@ -76,7 +76,7 @@ fun TransactionsList(uiState: UiState, uiSettings: UiSettings, isMobile: Boolean
|
||||||
|
|
||||||
itemsIndexed(transactionsToDisplay) { index, transaction ->
|
itemsIndexed(transactionsToDisplay) { index, transaction ->
|
||||||
key(transaction.id) {
|
key(transaction.id) {
|
||||||
TransactionListItem(banksById[transaction.userId], transaction, index, transactionsToDisplay.size)
|
TransactionListItem(banksById[transaction.bankId], transaction, index, transactionsToDisplay.size)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,8 @@ import net.codinux.banking.dataaccess.entities.AccountTransactionEntity
|
||||||
|
|
||||||
data class AccountTransactionViewModel(
|
data class AccountTransactionViewModel(
|
||||||
val id: Long,
|
val id: Long,
|
||||||
val userId: Long,
|
val bankId: Long,
|
||||||
val bankAccountId: Long,
|
val accountId: Long,
|
||||||
|
|
||||||
val amount: Amount,
|
val amount: Amount,
|
||||||
val currency: String,
|
val currency: String,
|
||||||
|
@ -20,8 +20,8 @@ data class AccountTransactionViewModel(
|
||||||
val userSetDisplayName: String? = null,
|
val userSetDisplayName: String? = null,
|
||||||
val category: String? = null
|
val category: String? = null
|
||||||
) {
|
) {
|
||||||
constructor(entity: AccountTransactionEntity) : this(entity.id, entity.userId, entity.bankAccountId, entity)
|
constructor(entity: AccountTransactionEntity) : this(entity.id, entity.bankId, entity.accountId, entity)
|
||||||
|
|
||||||
constructor(id: Long, userId: Long, bankAccountId: Long, transaction: AccountTransaction)
|
constructor(id: Long, bankId: Long, accountId: Long, transaction: AccountTransaction)
|
||||||
: this(id, userId, bankAccountId, transaction.amount, transaction.currency, transaction.reference, transaction.valueDate, transaction.otherPartyName, transaction.postingText)
|
: this(id, bankId, accountId, transaction.amount, transaction.currency, transaction.reference, transaction.valueDate, transaction.otherPartyName, transaction.postingText)
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,9 +38,9 @@ class AccountTransactionsFilterService {
|
||||||
private fun matchesFilter(transaction: AccountTransactionViewModel, accountsFilter: List<BankAccountFilter>): Boolean =
|
private fun matchesFilter(transaction: AccountTransactionViewModel, accountsFilter: List<BankAccountFilter>): Boolean =
|
||||||
accountsFilter.any { (user, bankAccount) ->
|
accountsFilter.any { (user, bankAccount) ->
|
||||||
if (bankAccount != null) {
|
if (bankAccount != null) {
|
||||||
transaction.bankAccountId == bankAccount.id
|
transaction.accountId == bankAccount.id
|
||||||
} else {
|
} else {
|
||||||
transaction.userId == user.id
|
transaction.bankId == user.id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,9 +71,9 @@ class AccountTransactionsFilterService {
|
||||||
private fun matchesFilter(holding: HoldingEntity, filter: List<BankAccountFilter>): Boolean =
|
private fun matchesFilter(holding: HoldingEntity, filter: List<BankAccountFilter>): Boolean =
|
||||||
filter.any { (user, bankAccount) ->
|
filter.any { (user, bankAccount) ->
|
||||||
if (bankAccount != null) {
|
if (bankAccount != null) {
|
||||||
holding.bankAccountId == bankAccount.id
|
holding.accountId == bankAccount.id
|
||||||
} else {
|
} else {
|
||||||
holding.userId == user.id
|
holding.bankId == user.id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -161,7 +161,7 @@ class BankingService(
|
||||||
|
|
||||||
// TODO: update BankAccount and may updated Transactions in database
|
// TODO: update BankAccount and may updated Transactions in database
|
||||||
|
|
||||||
val existingAccountTransactions = transactionsForBank.filter { it.bankAccountId == account.id }
|
val existingAccountTransactions = transactionsForBank.filter { it.accountId == account.id }
|
||||||
|
|
||||||
val newTransactions = modelService.findNewTransactions(response.bookedTransactions, existingAccountTransactions)
|
val newTransactions = modelService.findNewTransactions(response.bookedTransactions, existingAccountTransactions)
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,8 @@ import kotlin.Boolean;
|
||||||
CREATE TABLE IF NOT EXISTS AccountTransaction (
|
CREATE TABLE IF NOT EXISTS AccountTransaction (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
|
||||||
userId INTEGER NOT NULL,
|
bankId INTEGER NOT NULL,
|
||||||
bankAccountId INTEGER NOT NULL,
|
accountId INTEGER NOT NULL,
|
||||||
|
|
||||||
amount TEXT NOT NULL,
|
amount TEXT NOT NULL,
|
||||||
currency TEXT NOT NULL,
|
currency TEXT NOT NULL,
|
||||||
|
@ -56,7 +56,7 @@ CREATE TABLE IF NOT EXISTS AccountTransaction (
|
||||||
|
|
||||||
insertTransaction:
|
insertTransaction:
|
||||||
INSERT INTO AccountTransaction(
|
INSERT INTO AccountTransaction(
|
||||||
userId, bankAccountId,
|
bankId, accountId,
|
||||||
|
|
||||||
amount, currency, reference,
|
amount, currency, reference,
|
||||||
bookingDate, valueDate,
|
bookingDate, valueDate,
|
||||||
|
@ -118,18 +118,18 @@ VALUES(
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
selectAllTransactions:
|
getAllTransactions:
|
||||||
SELECT AccountTransaction.*
|
SELECT AccountTransaction.*
|
||||||
FROM AccountTransaction;
|
FROM AccountTransaction;
|
||||||
|
|
||||||
selectAllTransactionsAsViewModel:
|
getAllTransactionsAsViewModel:
|
||||||
SELECT id, userId, bankAccountId, amount, currency, reference, valueDate, otherPartyName, postingText, userSetDisplayName, category
|
SELECT id, bankId, accountId, amount, currency, reference, valueDate, otherPartyName, postingText, userSetDisplayName, category
|
||||||
FROM AccountTransaction;
|
FROM AccountTransaction;
|
||||||
|
|
||||||
|
|
||||||
selectAllTransactionsOfUser:
|
getAllTransactionsForBank:
|
||||||
SELECT AccountTransaction.*
|
SELECT AccountTransaction.*
|
||||||
FROM AccountTransaction WHERE userId = ?;
|
FROM AccountTransaction WHERE bankId = ?;
|
||||||
|
|
||||||
getTransactionWithId:
|
getTransactionWithId:
|
||||||
SELECT AccountTransaction.*
|
SELECT AccountTransaction.*
|
||||||
|
@ -141,8 +141,8 @@ FROM AccountTransaction WHERE id = ?;
|
||||||
CREATE TABLE IF NOT EXISTS Holding (
|
CREATE TABLE IF NOT EXISTS Holding (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
|
||||||
userId INTEGER NOT NULL,
|
bankId INTEGER NOT NULL,
|
||||||
bankAccountId INTEGER NOT NULL,
|
accountId INTEGER NOT NULL,
|
||||||
|
|
||||||
name TEXT NOT NULL,
|
name TEXT NOT NULL,
|
||||||
isin TEXT,
|
isin TEXT,
|
||||||
|
@ -166,7 +166,7 @@ CREATE TABLE IF NOT EXISTS Holding (
|
||||||
|
|
||||||
insertHolding:
|
insertHolding:
|
||||||
INSERT INTO Holding(
|
INSERT INTO Holding(
|
||||||
userId, bankAccountId,
|
bankId, accountId,
|
||||||
|
|
||||||
name, isin, wkn,
|
name, isin, wkn,
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import kotlin.Boolean;
|
import kotlin.Boolean;
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS User (
|
CREATE TABLE IF NOT EXISTS BankAccess (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
|
||||||
bankCode TEXT NOT NULL,
|
domesticBankCode TEXT NOT NULL,
|
||||||
loginName TEXT NOT NULL,
|
loginName TEXT NOT NULL,
|
||||||
password TEXT,
|
password TEXT,
|
||||||
|
|
||||||
|
@ -13,12 +13,13 @@ CREATE TABLE IF NOT EXISTS User (
|
||||||
customerName TEXT NOT NULL,
|
customerName TEXT NOT NULL,
|
||||||
userId TEXT,
|
userId TEXT,
|
||||||
|
|
||||||
selectedTanMethodId TEXT,
|
selectedTanMethodIdentifier TEXT,
|
||||||
|
|
||||||
selectedTanMediumName TEXT,
|
selectedTanMediumIdentifier TEXT,
|
||||||
|
|
||||||
bankingGroup TEXT,
|
bankingGroup TEXT,
|
||||||
serverAddress TEXT,
|
serverAddress TEXT,
|
||||||
|
countryCode TEXT NOT NULL,
|
||||||
|
|
||||||
clientData TEXT,
|
clientData TEXT,
|
||||||
|
|
||||||
|
@ -32,19 +33,20 @@ CREATE TABLE IF NOT EXISTS User (
|
||||||
|
|
||||||
|
|
||||||
insertBank:
|
insertBank:
|
||||||
INSERT INTO User(
|
INSERT INTO BankAccess(
|
||||||
bankCode, loginName, password,
|
domesticBankCode, loginName, password,
|
||||||
|
|
||||||
bankName, bic,
|
bankName, bic,
|
||||||
|
|
||||||
customerName, userId,
|
customerName, userId,
|
||||||
|
|
||||||
selectedTanMethodId,
|
selectedTanMethodIdentifier,
|
||||||
|
|
||||||
selectedTanMediumName,
|
selectedTanMediumIdentifier,
|
||||||
|
|
||||||
bankingGroup,
|
bankingGroup,
|
||||||
serverAddress,
|
serverAddress,
|
||||||
|
countryCode,
|
||||||
|
|
||||||
clientData,
|
clientData,
|
||||||
|
|
||||||
|
@ -61,7 +63,7 @@ VALUES(
|
||||||
|
|
||||||
?,
|
?,
|
||||||
|
|
||||||
?, ?,
|
?, ?, ?,
|
||||||
|
|
||||||
?,
|
?,
|
||||||
|
|
||||||
|
@ -72,16 +74,16 @@ VALUES(
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
selectAllBanks:
|
getAllBanks:
|
||||||
SELECT User.*
|
SELECT BankAccess.*
|
||||||
FROM User;
|
FROM BankAccess;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS BankAccount (
|
CREATE TABLE IF NOT EXISTS BankAccount (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
|
||||||
userId INTEGER NOT NULL,
|
bankId INTEGER NOT NULL,
|
||||||
|
|
||||||
identifier TEXT NOT NULL,
|
identifier TEXT NOT NULL,
|
||||||
subAccountNumber TEXT,
|
subAccountNumber TEXT,
|
||||||
|
@ -112,7 +114,7 @@ CREATE TABLE IF NOT EXISTS BankAccount (
|
||||||
|
|
||||||
insertBankAccount:
|
insertBankAccount:
|
||||||
INSERT INTO BankAccount(
|
INSERT INTO BankAccount(
|
||||||
userId,
|
bankId,
|
||||||
|
|
||||||
identifier, accountHolderName, type,
|
identifier, accountHolderName, type,
|
||||||
iban, subAccountNumber, productName, currency, accountLimit,
|
iban, subAccountNumber, productName, currency, accountLimit,
|
||||||
|
@ -145,7 +147,7 @@ VALUES(
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
selectAllBankAccounts:
|
getAllBankAccounts:
|
||||||
SELECT BankAccount.*
|
SELECT BankAccount.*
|
||||||
FROM BankAccount;
|
FROM BankAccount;
|
||||||
|
|
||||||
|
@ -154,7 +156,7 @@ FROM BankAccount;
|
||||||
CREATE TABLE IF NOT EXISTS TanMethod (
|
CREATE TABLE IF NOT EXISTS TanMethod (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
|
||||||
userId INTEGER NOT NULL,
|
bankId INTEGER NOT NULL,
|
||||||
|
|
||||||
displayName TEXT NOT NULL,
|
displayName TEXT NOT NULL,
|
||||||
type TEXT NOT NULL,
|
type TEXT NOT NULL,
|
||||||
|
@ -166,7 +168,7 @@ CREATE TABLE IF NOT EXISTS TanMethod (
|
||||||
|
|
||||||
insertTanMethod:
|
insertTanMethod:
|
||||||
INSERT INTO TanMethod(
|
INSERT INTO TanMethod(
|
||||||
userId,
|
bankId,
|
||||||
|
|
||||||
displayName,
|
displayName,
|
||||||
type,
|
type,
|
||||||
|
@ -185,7 +187,7 @@ VALUES (
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
selectAllTanMethods:
|
getAllTanMethods:
|
||||||
SELECT TanMethod.*
|
SELECT TanMethod.*
|
||||||
FROM TanMethod;
|
FROM TanMethod;
|
||||||
|
|
||||||
|
@ -194,7 +196,7 @@ FROM TanMethod;
|
||||||
CREATE TABLE IF NOT EXISTS TanMedium (
|
CREATE TABLE IF NOT EXISTS TanMedium (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
|
||||||
userId INTEGER NOT NULL,
|
bankId INTEGER NOT NULL,
|
||||||
|
|
||||||
type TEXT NOT NULL,
|
type TEXT NOT NULL,
|
||||||
mediumName TEXT,
|
mediumName TEXT,
|
||||||
|
@ -215,7 +217,7 @@ CREATE TABLE IF NOT EXISTS TanMedium (
|
||||||
|
|
||||||
insertTanMedium:
|
insertTanMedium:
|
||||||
INSERT INTO TanMedium(
|
INSERT INTO TanMedium(
|
||||||
userId,
|
bankId,
|
||||||
|
|
||||||
type,
|
type,
|
||||||
mediumName,
|
mediumName,
|
||||||
|
@ -248,7 +250,7 @@ VALUES (
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
selectAllTanMedia:
|
getAllTanMedia:
|
||||||
SELECT TanMedium.*
|
SELECT TanMedium.*
|
||||||
FROM TanMedium;
|
FROM TanMedium;
|
||||||
|
|
|
@ -17,8 +17,8 @@ class SqliteBankingRepositoryTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private val underTest = object : SqliteBankingRepository(sqlDriver) {
|
private val underTest = object : SqliteBankingRepository(sqlDriver) {
|
||||||
override public suspend fun persistTransaction(userId: Long, bankAccountId: Long, transaction: AccountTransaction): AccountTransactionEntity =
|
override public suspend fun persistTransaction(bankId: Long, accountId: Long, transaction: AccountTransaction): AccountTransactionEntity =
|
||||||
super.persistTransaction(userId, bankAccountId, transaction)
|
super.persistTransaction(bankId, accountId, transaction)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ class SqliteBankingRepositoryTest {
|
||||||
|
|
||||||
val persistedBankAccount = persisted.accounts.first()
|
val persistedBankAccount = persisted.accounts.first()
|
||||||
assertNotNull(persistedBankAccount.id)
|
assertNotNull(persistedBankAccount.id)
|
||||||
assertEquals(persisted.id, persistedBankAccount.userId)
|
assertEquals(persisted.id, persistedBankAccount.bankId)
|
||||||
|
|
||||||
assertEquals(bankAccounts.first().identifier, persistedBankAccount.identifier)
|
assertEquals(bankAccounts.first().identifier, persistedBankAccount.identifier)
|
||||||
assertEquals(bankAccounts.first().accountHolderName, persistedBankAccount.accountHolderName)
|
assertEquals(bankAccounts.first().accountHolderName, persistedBankAccount.accountHolderName)
|
||||||
|
|
Loading…
Reference in New Issue