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 getAllTransactionsForBank(bank: BankAccessEntity): List<AccountTransactionEntity> =
|
||||
getAllAccountTransactions().filter { it.userId == bank.id }
|
||||
getAllAccountTransactions().filter { it.bankId == bank.id }
|
||||
|
||||
override fun getTransactionById(transactionId: Long): AccountTransactionEntity? =
|
||||
getAllAccountTransactions().firstOrNull { it.id == transactionId }
|
||||
|
@ -67,10 +67,10 @@ class InMemoryBankingRepository(
|
|||
bank.iconUrl, bank.wrongCredentialsEntered,
|
||||
)
|
||||
|
||||
// TODO: someday may fix and get bankId and bankAccountId
|
||||
private fun map(transaction: AccountTransaction, bankId: Long = nextId++, bankAccountId: Long = nextId++) = AccountTransactionEntity(
|
||||
// TODO: someday may fix and get bankId and accountId
|
||||
private fun map(transaction: AccountTransaction, bankId: Long = nextId++, accountId: Long = nextId++) = AccountTransactionEntity(
|
||||
nextId++,
|
||||
bankId, bankAccountId,
|
||||
bankId, accountId,
|
||||
transaction.amount, transaction.currency, transaction.reference,
|
||||
transaction.bookingDate, transaction.valueDate,
|
||||
transaction.otherPartyName, transaction.otherPartyBankId, transaction.otherPartyAccountId,
|
||||
|
|
|
@ -19,7 +19,7 @@ open class SqliteBankingRepository(
|
|||
|
||||
private val database = BankmeisterDb(sqlDriver)
|
||||
|
||||
private val bankQueries = database.userQueries
|
||||
private val bankQueries = database.bankQueries
|
||||
|
||||
private val accountTransactionQueries = database.accountTransactionQueries
|
||||
|
||||
|
@ -27,14 +27,14 @@ open class SqliteBankingRepository(
|
|||
|
||||
|
||||
override fun getAllBanks(): List<BankAccessEntity> {
|
||||
val bankAccounts = getAllBankAccounts().groupBy { it.userId }
|
||||
val tanMethods = getAllTanMethods().groupBy { it.userId }.mapValues { it.value.toMutableList() }
|
||||
val tanMedia = getAllTanMedia().groupBy { it.userId }.mapValues { it.value.toMutableList() }
|
||||
val holdings = getAllHoldings().groupBy { it.bankAccountId }
|
||||
val bankAccounts = getAllBankAccounts().groupBy { it.bankId }
|
||||
val tanMethods = getAllTanMethods().groupBy { it.bankId }.mapValues { it.value.toMutableList() }
|
||||
val tanMedia = getAllTanMedia().groupBy { it.bankId }.mapValues { it.value.toMutableList() }
|
||||
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(),
|
||||
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()
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ open class SqliteBankingRepository(
|
|||
return bankQueries.transactionWithResult {
|
||||
bankQueries.insertBank(bank.domesticBankCode, bank.loginName, bank.password, bank.bankName, bank.bic,
|
||||
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
|
||||
|
@ -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(
|
||||
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(
|
||||
id,
|
||||
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) {
|
||||
MobilePhoneTanMedium(phoneNumber, concealedPhoneNumber)
|
||||
} else {
|
||||
|
@ -207,21 +207,21 @@ open class SqliteBankingRepository(
|
|||
|
||||
|
||||
protected open fun getAllHoldings(): List<HoldingEntity> =
|
||||
accountTransactionQueries.selectAllHoldings { id, bankId, bankAccountId, 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))
|
||||
accountTransactionQueries.selectAllHoldings { id, bankId, accountId, name, isin, wkn, quantity, currency, totalBalance, marketValue, performancePercentage, totalCostPrice, averageCostPrice, pricingTime, 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()
|
||||
|
||||
override suspend fun persistHoldings(bankAccount: BankAccountEntity, holdings: List<Holding>): List<HoldingEntity> =
|
||||
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~
|
||||
*/
|
||||
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(
|
||||
bankId, bankAccountId,
|
||||
bankId, accountId,
|
||||
|
||||
holding.name, holding.isin, holding.wkn,
|
||||
|
||||
|
@ -234,7 +234,7 @@ open class SqliteBankingRepository(
|
|||
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>) {
|
||||
|
@ -266,16 +266,16 @@ open class SqliteBankingRepository(
|
|||
|
||||
|
||||
override fun getAllAccountTransactionsAsViewModel(): List<AccountTransactionViewModel> =
|
||||
accountTransactionQueries.selectAllTransactionsAsViewModel { id, bankId, bankAccountId, amount, currency, reference, valueDate, otherPartyName, postingText, userSetDisplayName, category ->
|
||||
AccountTransactionViewModel(id, bankId, bankAccountId, mapToAmount(amount), currency, reference, mapToDate(valueDate), otherPartyName, postingText, userSetDisplayName, category)
|
||||
accountTransactionQueries.getAllTransactionsAsViewModel { id, bankId, accountId, amount, currency, reference, valueDate, otherPartyName, postingText, userSetDisplayName, category ->
|
||||
AccountTransactionViewModel(id, bankId, accountId, mapToAmount(amount), currency, reference, mapToDate(valueDate), otherPartyName, postingText, userSetDisplayName, category)
|
||||
}.executeAsList()
|
||||
|
||||
override fun getAllAccountTransactions(): List<AccountTransactionEntity> {
|
||||
return accountTransactionQueries.selectAllTransactions(::mapTransaction).executeAsList()
|
||||
return accountTransactionQueries.getAllTransactions(::mapTransaction).executeAsList()
|
||||
}
|
||||
|
||||
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? =
|
||||
|
@ -285,7 +285,7 @@ open class SqliteBankingRepository(
|
|||
override suspend fun persistTransactions(bankAccount: BankAccountEntity, transactions: List<AccountTransaction>): List<AccountTransactionEntity> {
|
||||
return accountTransactionQueries.transactionWithResult {
|
||||
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~
|
||||
*/
|
||||
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(
|
||||
bankId, bankAccountId,
|
||||
bankId, accountId,
|
||||
|
||||
mapAmount(transaction.amount), transaction.currency, transaction.reference,
|
||||
mapDate(transaction.bookingDate), mapDate(transaction.valueDate),
|
||||
|
@ -326,7 +326,7 @@ open class SqliteBankingRepository(
|
|||
transaction.isReversal
|
||||
)
|
||||
|
||||
return AccountTransactionEntity(getLastInsertedId(), bankId, bankAccountId, transaction)
|
||||
return AccountTransactionEntity(getLastInsertedId(), bankId, accountId, transaction)
|
||||
}
|
||||
|
||||
|
||||
|
@ -335,7 +335,7 @@ open class SqliteBankingRepository(
|
|||
|
||||
|
||||
private fun mapTransaction(
|
||||
id: Long, bankId: Long, bankAccountId: Long,
|
||||
id: Long, bankId: Long, accountId: Long,
|
||||
|
||||
amount: String, currency: String, reference: String?,
|
||||
bookingDate: String, valueDate: String,
|
||||
|
@ -366,7 +366,7 @@ open class SqliteBankingRepository(
|
|||
isReversal: Boolean
|
||||
): AccountTransactionEntity = AccountTransactionEntity(
|
||||
id,
|
||||
bankId, bankAccountId,
|
||||
bankId, accountId,
|
||||
|
||||
Amount(amount), currency, reference,
|
||||
mapToDate(bookingDate), mapToDate(valueDate),
|
||||
|
|
|
@ -6,8 +6,8 @@ import net.codinux.banking.client.model.Amount
|
|||
|
||||
class AccountTransactionEntity(
|
||||
val id: Long,
|
||||
val userId: Long,
|
||||
val bankAccountId: Long,
|
||||
val bankId: Long,
|
||||
val accountId: Long,
|
||||
|
||||
amount: Amount,
|
||||
currency: String,
|
||||
|
@ -82,8 +82,8 @@ class AccountTransactionEntity(
|
|||
|
||||
userSetDisplayName, category, notes
|
||||
) {
|
||||
constructor(id: Long, userId: Long, bankAccountId: Long, transaction: AccountTransaction) : this(
|
||||
id, userId, bankAccountId,
|
||||
constructor(id: Long, bankId: Long, accountId: Long, transaction: AccountTransaction) : this(
|
||||
id, bankId, accountId,
|
||||
transaction.amount, transaction.currency, transaction.reference,
|
||||
transaction.bookingDate, transaction.valueDate,
|
||||
|
||||
|
@ -116,7 +116,7 @@ class AccountTransactionEntity(
|
|||
|
||||
|
||||
override val identifier: String by lazy {
|
||||
"$userId ${super.identifier}"
|
||||
"$bankId ${super.identifier}"
|
||||
}
|
||||
|
||||
}
|
|
@ -6,7 +6,7 @@ import net.codinux.banking.client.model.*
|
|||
|
||||
class BankAccountEntity(
|
||||
val id: Long,
|
||||
val userId: Long,
|
||||
val bankId: Long,
|
||||
|
||||
identifier: String,
|
||||
subAccountNumber: String? = null,
|
||||
|
@ -53,8 +53,8 @@ class BankAccountEntity(
|
|||
userSetDisplayName, displayIndex,
|
||||
hideAccount, includeInAutomaticAccountsUpdate
|
||||
) {
|
||||
constructor(id: Long, userId: Long, account: BankAccount, transactions: List<AccountTransactionEntity> = emptyList(), holdings: List<HoldingEntity> = emptyList()) : this(
|
||||
id, userId,
|
||||
constructor(id: Long, bankId: Long, account: BankAccount, transactions: List<AccountTransactionEntity> = emptyList(), holdings: List<HoldingEntity> = emptyList()) : this(
|
||||
id, bankId,
|
||||
account.identifier, account.subAccountNumber, account.iban, account.productName,
|
||||
|
||||
account.accountHolderName, account.type,
|
||||
|
|
|
@ -7,8 +7,8 @@ import net.codinux.banking.client.model.securitiesaccount.Holding
|
|||
|
||||
class HoldingEntity(
|
||||
val id: Long,
|
||||
val userId: Long,
|
||||
val bankAccountId: Long,
|
||||
val bankId: Long,
|
||||
val accountId: Long,
|
||||
|
||||
name: String,
|
||||
|
||||
|
@ -30,8 +30,8 @@ class HoldingEntity(
|
|||
buyingDate: LocalDate? = null
|
||||
) : Holding(name, isin, wkn, quantity, currency, totalBalance, marketValue, performancePercentage, totalCostPrice, averageCostPrice, pricingTime, buyingDate) {
|
||||
|
||||
constructor(id: Long, userId: Long, bankAccountId: Long, holding: Holding) : this(
|
||||
id, userId, bankAccountId,
|
||||
constructor(id: Long, bankId: Long, accountId: Long, holding: Holding) : this(
|
||||
id, bankId, accountId,
|
||||
|
||||
holding.name, holding.isin, holding.wkn,
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import net.codinux.banking.client.model.tan.*
|
|||
|
||||
class TanMediumEntity(
|
||||
val id: Long,
|
||||
val userId: Long,
|
||||
val bankId: Long,
|
||||
|
||||
type: TanMediumType,
|
||||
mediumName: String?,
|
||||
|
@ -14,7 +14,7 @@ class TanMediumEntity(
|
|||
mobilePhone: MobilePhoneTanMedium? = null
|
||||
) : TanMedium(type, mediumName, status, tanGenerator, mobilePhone) {
|
||||
|
||||
constructor(id: Long, userId: Long, medium: TanMedium)
|
||||
: this(id, userId, medium.type, medium.mediumName, medium.status, medium.tanGenerator, medium.mobilePhone)
|
||||
constructor(id: Long, bankId: Long, medium: TanMedium)
|
||||
: 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(
|
||||
val id: Long,
|
||||
val userId: Long,
|
||||
val bankId: Long,
|
||||
|
||||
displayName: String,
|
||||
type: TanMethodType,
|
||||
|
@ -15,7 +15,7 @@ class TanMethodEntity(
|
|||
allowedTanFormat: AllowedTanFormat = AllowedTanFormat.Alphanumeric
|
||||
) : TanMethod(displayName, type, identifier, maxTanInputLength, allowedTanFormat) {
|
||||
|
||||
constructor(id: Long, userId: Long, tanMethod: TanMethod)
|
||||
: this(id, userId, tanMethod.displayName, tanMethod.type, tanMethod.identifier, tanMethod.maxTanInputLength, tanMethod.allowedTanFormat)
|
||||
constructor(id: Long, bankId: Long, tanMethod: TanMethod)
|
||||
: 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
|
||||
monthTransactions.forEachIndexed { index, transaction ->
|
||||
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)
|
||||
|
||||
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,
|
||||
transactionEntity?.otherPartyBankId,
|
||||
transactionEntity?.otherPartyAccountId,
|
||||
|
|
|
@ -76,7 +76,7 @@ fun TransactionsList(uiState: UiState, uiSettings: UiSettings, isMobile: Boolean
|
|||
|
||||
itemsIndexed(transactionsToDisplay) { index, transaction ->
|
||||
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(
|
||||
val id: Long,
|
||||
val userId: Long,
|
||||
val bankAccountId: Long,
|
||||
val bankId: Long,
|
||||
val accountId: Long,
|
||||
|
||||
val amount: Amount,
|
||||
val currency: String,
|
||||
|
@ -20,8 +20,8 @@ data class AccountTransactionViewModel(
|
|||
val userSetDisplayName: 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)
|
||||
: this(id, userId, bankAccountId, transaction.amount, transaction.currency, transaction.reference, transaction.valueDate, transaction.otherPartyName, transaction.postingText)
|
||||
constructor(id: Long, bankId: Long, accountId: Long, transaction: AccountTransaction)
|
||||
: 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 =
|
||||
accountsFilter.any { (user, bankAccount) ->
|
||||
if (bankAccount != null) {
|
||||
transaction.bankAccountId == bankAccount.id
|
||||
transaction.accountId == bankAccount.id
|
||||
} else {
|
||||
transaction.userId == user.id
|
||||
transaction.bankId == user.id
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,9 +71,9 @@ class AccountTransactionsFilterService {
|
|||
private fun matchesFilter(holding: HoldingEntity, filter: List<BankAccountFilter>): Boolean =
|
||||
filter.any { (user, bankAccount) ->
|
||||
if (bankAccount != null) {
|
||||
holding.bankAccountId == bankAccount.id
|
||||
holding.accountId == bankAccount.id
|
||||
} else {
|
||||
holding.userId == user.id
|
||||
holding.bankId == user.id
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -161,7 +161,7 @@ class BankingService(
|
|||
|
||||
// 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)
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@ import kotlin.Boolean;
|
|||
CREATE TABLE IF NOT EXISTS AccountTransaction (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
|
||||
userId INTEGER NOT NULL,
|
||||
bankAccountId INTEGER NOT NULL,
|
||||
bankId INTEGER NOT NULL,
|
||||
accountId INTEGER NOT NULL,
|
||||
|
||||
amount TEXT NOT NULL,
|
||||
currency TEXT NOT NULL,
|
||||
|
@ -56,7 +56,7 @@ CREATE TABLE IF NOT EXISTS AccountTransaction (
|
|||
|
||||
insertTransaction:
|
||||
INSERT INTO AccountTransaction(
|
||||
userId, bankAccountId,
|
||||
bankId, accountId,
|
||||
|
||||
amount, currency, reference,
|
||||
bookingDate, valueDate,
|
||||
|
@ -118,18 +118,18 @@ VALUES(
|
|||
);
|
||||
|
||||
|
||||
selectAllTransactions:
|
||||
getAllTransactions:
|
||||
SELECT AccountTransaction.*
|
||||
FROM AccountTransaction;
|
||||
|
||||
selectAllTransactionsAsViewModel:
|
||||
SELECT id, userId, bankAccountId, amount, currency, reference, valueDate, otherPartyName, postingText, userSetDisplayName, category
|
||||
getAllTransactionsAsViewModel:
|
||||
SELECT id, bankId, accountId, amount, currency, reference, valueDate, otherPartyName, postingText, userSetDisplayName, category
|
||||
FROM AccountTransaction;
|
||||
|
||||
|
||||
selectAllTransactionsOfUser:
|
||||
getAllTransactionsForBank:
|
||||
SELECT AccountTransaction.*
|
||||
FROM AccountTransaction WHERE userId = ?;
|
||||
FROM AccountTransaction WHERE bankId = ?;
|
||||
|
||||
getTransactionWithId:
|
||||
SELECT AccountTransaction.*
|
||||
|
@ -141,8 +141,8 @@ FROM AccountTransaction WHERE id = ?;
|
|||
CREATE TABLE IF NOT EXISTS Holding (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
|
||||
userId INTEGER NOT NULL,
|
||||
bankAccountId INTEGER NOT NULL,
|
||||
bankId INTEGER NOT NULL,
|
||||
accountId INTEGER NOT NULL,
|
||||
|
||||
name TEXT NOT NULL,
|
||||
isin TEXT,
|
||||
|
@ -166,7 +166,7 @@ CREATE TABLE IF NOT EXISTS Holding (
|
|||
|
||||
insertHolding:
|
||||
INSERT INTO Holding(
|
||||
userId, bankAccountId,
|
||||
bankId, accountId,
|
||||
|
||||
name, isin, wkn,
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import kotlin.Boolean;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS User (
|
||||
CREATE TABLE IF NOT EXISTS BankAccess (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
|
||||
bankCode TEXT NOT NULL,
|
||||
domesticBankCode TEXT NOT NULL,
|
||||
loginName TEXT NOT NULL,
|
||||
password TEXT,
|
||||
|
||||
|
@ -13,12 +13,13 @@ CREATE TABLE IF NOT EXISTS User (
|
|||
customerName TEXT NOT NULL,
|
||||
userId TEXT,
|
||||
|
||||
selectedTanMethodId TEXT,
|
||||
selectedTanMethodIdentifier TEXT,
|
||||
|
||||
selectedTanMediumName TEXT,
|
||||
selectedTanMediumIdentifier TEXT,
|
||||
|
||||
bankingGroup TEXT,
|
||||
serverAddress TEXT,
|
||||
countryCode TEXT NOT NULL,
|
||||
|
||||
clientData TEXT,
|
||||
|
||||
|
@ -32,19 +33,20 @@ CREATE TABLE IF NOT EXISTS User (
|
|||
|
||||
|
||||
insertBank:
|
||||
INSERT INTO User(
|
||||
bankCode, loginName, password,
|
||||
INSERT INTO BankAccess(
|
||||
domesticBankCode, loginName, password,
|
||||
|
||||
bankName, bic,
|
||||
|
||||
customerName, userId,
|
||||
|
||||
selectedTanMethodId,
|
||||
selectedTanMethodIdentifier,
|
||||
|
||||
selectedTanMediumName,
|
||||
selectedTanMediumIdentifier,
|
||||
|
||||
bankingGroup,
|
||||
serverAddress,
|
||||
countryCode,
|
||||
|
||||
clientData,
|
||||
|
||||
|
@ -61,7 +63,7 @@ VALUES(
|
|||
|
||||
?,
|
||||
|
||||
?, ?,
|
||||
?, ?, ?,
|
||||
|
||||
?,
|
||||
|
||||
|
@ -72,16 +74,16 @@ VALUES(
|
|||
);
|
||||
|
||||
|
||||
selectAllBanks:
|
||||
SELECT User.*
|
||||
FROM User;
|
||||
getAllBanks:
|
||||
SELECT BankAccess.*
|
||||
FROM BankAccess;
|
||||
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS BankAccount (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
|
||||
userId INTEGER NOT NULL,
|
||||
bankId INTEGER NOT NULL,
|
||||
|
||||
identifier TEXT NOT NULL,
|
||||
subAccountNumber TEXT,
|
||||
|
@ -112,7 +114,7 @@ CREATE TABLE IF NOT EXISTS BankAccount (
|
|||
|
||||
insertBankAccount:
|
||||
INSERT INTO BankAccount(
|
||||
userId,
|
||||
bankId,
|
||||
|
||||
identifier, accountHolderName, type,
|
||||
iban, subAccountNumber, productName, currency, accountLimit,
|
||||
|
@ -145,7 +147,7 @@ VALUES(
|
|||
);
|
||||
|
||||
|
||||
selectAllBankAccounts:
|
||||
getAllBankAccounts:
|
||||
SELECT BankAccount.*
|
||||
FROM BankAccount;
|
||||
|
||||
|
@ -154,7 +156,7 @@ FROM BankAccount;
|
|||
CREATE TABLE IF NOT EXISTS TanMethod (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
|
||||
userId INTEGER NOT NULL,
|
||||
bankId INTEGER NOT NULL,
|
||||
|
||||
displayName TEXT NOT NULL,
|
||||
type TEXT NOT NULL,
|
||||
|
@ -166,7 +168,7 @@ CREATE TABLE IF NOT EXISTS TanMethod (
|
|||
|
||||
insertTanMethod:
|
||||
INSERT INTO TanMethod(
|
||||
userId,
|
||||
bankId,
|
||||
|
||||
displayName,
|
||||
type,
|
||||
|
@ -185,7 +187,7 @@ VALUES (
|
|||
);
|
||||
|
||||
|
||||
selectAllTanMethods:
|
||||
getAllTanMethods:
|
||||
SELECT TanMethod.*
|
||||
FROM TanMethod;
|
||||
|
||||
|
@ -194,7 +196,7 @@ FROM TanMethod;
|
|||
CREATE TABLE IF NOT EXISTS TanMedium (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
|
||||
userId INTEGER NOT NULL,
|
||||
bankId INTEGER NOT NULL,
|
||||
|
||||
type TEXT NOT NULL,
|
||||
mediumName TEXT,
|
||||
|
@ -215,7 +217,7 @@ CREATE TABLE IF NOT EXISTS TanMedium (
|
|||
|
||||
insertTanMedium:
|
||||
INSERT INTO TanMedium(
|
||||
userId,
|
||||
bankId,
|
||||
|
||||
type,
|
||||
mediumName,
|
||||
|
@ -248,7 +250,7 @@ VALUES (
|
|||
);
|
||||
|
||||
|
||||
selectAllTanMedia:
|
||||
getAllTanMedia:
|
||||
SELECT TanMedium.*
|
||||
FROM TanMedium;
|
||||
|
|
@ -17,8 +17,8 @@ class SqliteBankingRepositoryTest {
|
|||
}
|
||||
|
||||
private val underTest = object : SqliteBankingRepository(sqlDriver) {
|
||||
override public suspend fun persistTransaction(userId: Long, bankAccountId: Long, transaction: AccountTransaction): AccountTransactionEntity =
|
||||
super.persistTransaction(userId, bankAccountId, transaction)
|
||||
override public suspend fun persistTransaction(bankId: Long, accountId: Long, transaction: AccountTransaction): AccountTransactionEntity =
|
||||
super.persistTransaction(bankId, accountId, transaction)
|
||||
}
|
||||
|
||||
|
||||
|
@ -55,7 +55,7 @@ class SqliteBankingRepositoryTest {
|
|||
|
||||
val persistedBankAccount = persisted.accounts.first()
|
||||
assertNotNull(persistedBankAccount.id)
|
||||
assertEquals(persisted.id, persistedBankAccount.userId)
|
||||
assertEquals(persisted.id, persistedBankAccount.bankId)
|
||||
|
||||
assertEquals(bankAccounts.first().identifier, persistedBankAccount.identifier)
|
||||
assertEquals(bankAccounts.first().accountHolderName, persistedBankAccount.accountHolderName)
|
||||
|
|
Loading…
Reference in New Issue