Fixed updating account data after retrieving transactions
This commit is contained in:
parent
cd8f8a32e6
commit
390d529be0
|
@ -31,9 +31,9 @@ interface BankingRepository {
|
|||
|
||||
suspend fun updateBank(bank: BankAccessEntity, loginName: String, password: String, bankName: String?)
|
||||
|
||||
suspend fun updateAccount(bank: BankAccountEntity, userSetDisplayName: String?, hideAccount: Boolean, includeInAutomaticAccountsUpdate: Boolean)
|
||||
suspend fun updateAccount(account: BankAccountEntity, userSetDisplayName: String?, hideAccount: Boolean, includeInAutomaticAccountsUpdate: Boolean)
|
||||
|
||||
suspend fun updateAccount(account: BankAccountEntity, balance: Amount?, lastAccountUpdateTime: Instant, retrievedTransactionsFrom: LocalDate?)
|
||||
suspend fun updateAccount(account: BankAccountEntity, balance: Amount, lastAccountUpdateTime: Instant, retrievedTransactionsFrom: LocalDate?)
|
||||
|
||||
suspend fun deleteBank(bank: BankAccessEntity)
|
||||
|
||||
|
|
|
@ -55,11 +55,11 @@ class InMemoryBankingRepository(
|
|||
// no-op
|
||||
}
|
||||
|
||||
override suspend fun updateAccount(bank: BankAccountEntity, userSetDisplayName: String?, hideAccount: Boolean, includeInAutomaticAccountsUpdate: Boolean) {
|
||||
override suspend fun updateAccount(account: BankAccountEntity, userSetDisplayName: String?, hideAccount: Boolean, includeInAutomaticAccountsUpdate: Boolean) {
|
||||
// no-op
|
||||
}
|
||||
|
||||
override suspend fun updateAccount(account: BankAccountEntity, balance: Amount?, lastAccountUpdateTime: Instant, retrievedTransactionsFrom: LocalDate?) {
|
||||
override suspend fun updateAccount(account: BankAccountEntity, balance: Amount, lastAccountUpdateTime: Instant, retrievedTransactionsFrom: LocalDate?) {
|
||||
// no-op
|
||||
}
|
||||
|
||||
|
|
|
@ -157,18 +157,8 @@ open class SqliteBankingRepository : BankingRepository {
|
|||
}
|
||||
}
|
||||
|
||||
override suspend fun updateAccount(account: BankAccountEntity, balance: Amount?, lastAccountUpdateTime: Instant, retrievedTransactionsFrom: LocalDate?) {
|
||||
bankQueries.transaction {
|
||||
if (balance != null && account.balance != balance) {
|
||||
bankQueries.updateBankAccountBalance(mapAmount(balance), account.id)
|
||||
}
|
||||
|
||||
bankQueries.updateBankAccountLastAccountUpdateTime(mapInstant(lastAccountUpdateTime), account.id)
|
||||
|
||||
if (retrievedTransactionsFrom != null && (account.retrievedTransactionsFrom == null || account.retrievedTransactionsFrom!! > retrievedTransactionsFrom)) {
|
||||
bankQueries.updateBankAccountRetrievedTransactionsFrom(mapDate(retrievedTransactionsFrom), account.id)
|
||||
}
|
||||
}
|
||||
override suspend fun updateAccount(account: BankAccountEntity, balance: Amount, lastAccountUpdateTime: Instant, retrievedTransactionsFrom: LocalDate?) {
|
||||
bankQueries.updateBankAccount(mapAmount(balance), mapInstant(lastAccountUpdateTime), mapDate(retrievedTransactionsFrom), account.id)
|
||||
}
|
||||
|
||||
override suspend fun deleteBank(bank: BankAccessEntity) {
|
||||
|
|
|
@ -187,20 +187,10 @@ SELECT BankAccount.*
|
|||
FROM BankAccount;
|
||||
|
||||
|
||||
updateBankAccountBalance:
|
||||
updateBankAccount:
|
||||
UPDATE BankAccount
|
||||
SET balance = ?
|
||||
WHERE id = ?;
|
||||
|
||||
updateBankAccountLastAccountUpdateTime:
|
||||
UPDATE BankAccount
|
||||
SET lastAccountUpdateTime = ?
|
||||
WHERE id = ?;
|
||||
|
||||
updateBankAccountRetrievedTransactionsFrom:
|
||||
UPDATE BankAccount
|
||||
SET retrievedTransactionsFrom = ?
|
||||
WHERE id = ?;
|
||||
SET balance = :balance, lastAccountUpdateTime = :lastAccountUpdateTime, retrievedTransactionsFrom = :retrievedTransactionsFrom
|
||||
WHERE id = :accountId;
|
||||
|
||||
|
||||
updateBankAccountUserSetDisplayName:
|
||||
|
|
|
@ -276,7 +276,7 @@ class BankingService(
|
|||
val transactionsViewModel = updateTransactionsInUi(newTransactionsEntities)
|
||||
uiState.dispatchNewTransactionsRetrieved(AccountTransactionsRetrievedEvent(bank, account, transactionsViewModel, response.holdings))
|
||||
|
||||
bankingRepository.updateAccount(account, response.balance, response.transactionsRetrievalTime, response.retrievedTransactionsFrom)
|
||||
bankingRepository.updateAccount(account, response.balance ?: account.balance, response.transactionsRetrievalTime, response.retrievedTransactionsFrom ?: account.retrievedTransactionsFrom)
|
||||
}
|
||||
|
||||
notifyBanksListUpdated() // notify about updated values like account balance
|
||||
|
|
Loading…
Reference in New Issue