diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/home/HomeFragment.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/home/HomeFragment.kt
index b654e094..87209d7e 100644
--- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/home/HomeFragment.kt
+++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/home/HomeFragment.kt
@@ -19,6 +19,7 @@ import net.dankito.banking.ui.android.adapter.AccountTransactionAdapter
import net.dankito.banking.ui.android.di.BankingComponent
import net.dankito.banking.ui.android.extensions.addHorizontalItemDivider
import net.dankito.banking.ui.android.extensions.showAmount
+import net.dankito.banking.ui.model.TransactionsRetrievalState
import net.dankito.banking.ui.model.TypedBankAccount
import net.dankito.banking.ui.model.parameters.TransferMoneyData
import net.dankito.banking.ui.model.responses.GetTransactionsResponse
@@ -93,6 +94,8 @@ class HomeFragment : Fragment() {
setFetchAllTransactionsView()
}
+ rootView.btnRetrieveTransactions.setOnClickListener { fetchTransactions() }
+
return rootView
}
@@ -235,7 +238,6 @@ class HomeFragment : Fragment() {
private fun updateTransactionsToDisplayOnUiThread() {
transactionAdapter.items = presenter.searchSelectedAccountTransactions(appliedTransactionsFilter)
- // TODO: if transactions are filtered calculate and show balance of displayed transactions?
mnitmBalance.title = presenter.formatAmount(presenter.balanceOfSelectedBankAccounts)
mnitmBalance.isVisible = presenter.doSelectedBankAccountsSupportRetrievingBalance
@@ -247,15 +249,35 @@ class HomeFragment : Fragment() {
else transactionAdapter.items.map { it.amount }.sum()
txtTransactionsBalance.showAmount(presenter, sumOfDisplayedTransactions)
+ setRecyclerViewAndNoTransactionsFetchedView()
+
setFetchAllTransactionsView()
}
+ private fun setRecyclerViewAndNoTransactionsFetchedView() {
+ val transactionsRetrievalState = presenter.selectedBankAccountsTransactionRetrievalState
+ val haveTransactionsBeenRetrieved = transactionsRetrievalState == TransactionsRetrievalState.RetrievedTransactions
+
+ rcyvwAccountTransactions.visibility = if (haveTransactionsBeenRetrieved) View.VISIBLE else View.GONE
+ lytNoTransactionsFetched.visibility = if (haveTransactionsBeenRetrieved) View.GONE else View.VISIBLE
+ btnRetrieveTransactions.visibility = if (transactionsRetrievalState == TransactionsRetrievalState.AccountDoesNotSupportFetchingTransactions) View.GONE else View.VISIBLE
+
+ val transactionsRetrievalStateMessageId = when (transactionsRetrievalState) {
+ TransactionsRetrievalState.AccountDoesNotSupportFetchingTransactions -> R.string.fragment_home_transactions_retrieval_state_account_does_not_support_retrieving_transactions
+ TransactionsRetrievalState.NoTransactionsInRetrievedPeriod -> R.string.fragment_home_transactions_retrieval_state_no_transactions_in_retrieved_period
+ TransactionsRetrievalState.NeverRetrievedTransactions -> R.string.fragment_home_transactions_retrieval_state_never_retrieved_transactions
+ else -> null
+ }
+ txtNoTransactionsFetchedMessage.text = transactionsRetrievalStateMessageId?.let { requireContext().getString(transactionsRetrievalStateMessageId) } ?: ""
+ }
+
private fun setFetchAllTransactionsView() {
accountsForWhichNotAllTransactionsHaveBeenFetched = presenter.selectedBankAccountsForWhichNotAllTransactionsHaveBeenFetched
var floatingActionMenuBottomMarginResourceId = R.dimen.fab_margin_bottom_without_toolbar
- if (doNotShowFetchAllTransactionsOverlay || accountsForWhichNotAllTransactionsHaveBeenFetched.isEmpty()) {
+ if (doNotShowFetchAllTransactionsOverlay || accountsForWhichNotAllTransactionsHaveBeenFetched.isEmpty()
+ || presenter.selectedBankAccountsTransactionRetrievalState != TransactionsRetrievalState.RetrievedTransactions) {
lytFetchAllTransactionsOverlay.visibility = View.GONE
}
else {
@@ -268,14 +290,22 @@ class HomeFragment : Fragment() {
}
}
- private fun fetchAllTransactions() {
- accountsForWhichNotAllTransactionsHaveBeenFetched.forEach { account ->
- presenter.fetchAllAccountTransactionsAsync(account) {
- requireActivity().runOnUiThread {
- updateAccountsTransactions()
- }
+
+ private fun fetchTransactions() {
+ presenter.selectedBankAccounts.forEach { account ->
+ if (account.haveAllTransactionsBeenFetched) {
+ presenter.updateBankAccountTransactionsAsync(account)
+ }
+ else {
+ presenter.fetchAllAccountTransactionsAsync(account)
}
}
}
+ private fun fetchAllTransactions() {
+ accountsForWhichNotAllTransactionsHaveBeenFetched.forEach { account ->
+ presenter.fetchAllAccountTransactionsAsync(account)
+ }
+ }
+
}
\ No newline at end of file
diff --git a/ui/BankingAndroidApp/src/main/res/layout/fragment_home.xml b/ui/BankingAndroidApp/src/main/res/layout/fragment_home.xml
index a460fbaa..72a9af38 100644
--- a/ui/BankingAndroidApp/src/main/res/layout/fragment_home.xml
+++ b/ui/BankingAndroidApp/src/main/res/layout/fragment_home.xml
@@ -12,7 +12,7 @@
app:layout_constraintTop_toTopOf="parent"
>
-
@@ -59,10 +60,47 @@
android:id="@+id/rcyvwAccountTransactions"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:layout_below="@+id/lytTransactionsSummary"
+ android:layout_alignParentBottom="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
/>
-
+
+
+
+
+
+
+
+
+
%d Umsätze
Kontoumsätze für \'%1$s\' konnten nicht empfangen werden.\n\nFehlermeldung Ihrer Bank:\n\n%2$s
+ Umsätze abrufen
+ Konto unterstützt Abrufen von Umsätzen nicht
+ Noch keine Umsätze abgerufen
+ Empfangener Zeitraum enthielt keine Umsätze
Neue Überweisung an %s
Neue Überweisung mit gleichen Daten
- Ältere Umsätze laden (erfordert TAN)
+ Ältere Umsätze abrufen (erfordert TAN)
Bank (Suche auch mittels Bankleitzahl oder Ort):
Hinzufügen
diff --git a/ui/BankingAndroidApp/src/main/res/values/dimens.xml b/ui/BankingAndroidApp/src/main/res/values/dimens.xml
index 0a2057dc..18769252 100644
--- a/ui/BankingAndroidApp/src/main/res/values/dimens.xml
+++ b/ui/BankingAndroidApp/src/main/res/values/dimens.xml
@@ -3,6 +3,8 @@
16dp
16dp
+ 18sp
+
8dp
176dp
48dp
@@ -25,6 +27,8 @@
4dp
24dp
+ 40dp
+ 18dp
48dp
20dp
6dp
diff --git a/ui/BankingAndroidApp/src/main/res/values/strings.xml b/ui/BankingAndroidApp/src/main/res/values/strings.xml
index 96f36d4e..61058114 100644
--- a/ui/BankingAndroidApp/src/main/res/values/strings.xml
+++ b/ui/BankingAndroidApp/src/main/res/values/strings.xml
@@ -37,6 +37,10 @@
%d transactions
Could not retrieve account transactions for \'%1$s\'.\n\nError message from your bank:\n\n%2$s
+ Fetch transactions
+ Account does not support retrieving transactions
+ No transactions fetched yet
+ There haven\'t been any transactions in retrieved period
Transfer money to %s
New transfer with same data
Fetch earlier transactions (requires TAN)
diff --git a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/TransactionsRetrievalState.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/TransactionsRetrievalState.kt
new file mode 100644
index 00000000..e8d2a745
--- /dev/null
+++ b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/TransactionsRetrievalState.kt
@@ -0,0 +1,14 @@
+package net.dankito.banking.ui.model
+
+
+enum class TransactionsRetrievalState {
+
+ AccountDoesNotSupportFetchingTransactions,
+
+ NeverRetrievedTransactions,
+
+ NoTransactionsInRetrievedPeriod,
+
+ RetrievedTransactions
+
+}
\ No newline at end of file
diff --git a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/presenter/BankingPresenter.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/presenter/BankingPresenter.kt
index 20b2a415..2a25e7b8 100644
--- a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/presenter/BankingPresenter.kt
+++ b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/presenter/BankingPresenter.kt
@@ -273,10 +273,10 @@ open class BankingPresenter(
}
}
- open fun fetchAllAccountTransactionsAsync(bankAccount: TypedBankAccount,
+ open fun fetchAllAccountTransactionsAsync(account: TypedBankAccount,
callback: ((GetTransactionsResponse) -> Unit)? = null) {
- fetchAccountTransactionsAsync(bankAccount, null, false, callback)
+ fetchAccountTransactionsAsync(account, null, false, callback)
}
open fun fetchAccountTransactionsAsync(account: TypedBankAccount, fromDate: Date?, abortIfTanIsRequired: Boolean = false,
@@ -326,7 +326,7 @@ open class BankingPresenter(
}
}
- protected open fun updateBankAccountTransactionsAsync(bankAccount: TypedBankAccount, abortIfTanIsRequired: Boolean, callback: (GetTransactionsResponse) -> Unit) {
+ open fun updateBankAccountTransactionsAsync(bankAccount: TypedBankAccount, abortIfTanIsRequired: Boolean = false, callback: ((GetTransactionsResponse) -> Unit)? = null) {
val fromDate = bankAccount.lastRetrievedTransactionsTimestamp?.let { Date(it.millisSinceEpoch - OneDayMillis) } // one day before last received transactions
fetchAccountTransactionsAsync(bankAccount, fromDate, abortIfTanIsRequired, callback)
@@ -459,7 +459,7 @@ open class BankingPresenter(
getBankingClientForAccount(account.customer)?.let { client ->
client.transferMoneyAsync(data) { response ->
if (response.successful) {
- updateBankAccountTransactionsAsync(account, true) { }
+ updateBankAccountTransactionsAsync(account, true)
}
callback(response)
@@ -634,6 +634,9 @@ open class BankingPresenter(
open val selectedBankAccountsForWhichNotAllTransactionsHaveBeenFetched: List
get() = selectedBankAccounts.filter { it.haveAllTransactionsBeenFetched == false }
+ open val selectedBankAccountsTransactionRetrievalState: TransactionsRetrievalState
+ get() = getAccountsTransactionRetrievalState(selectedBankAccounts)
+
open val areAllAccountSelected: Boolean
get() = selectedAccountType == SelectedAccountType.AllAccounts
@@ -732,6 +735,40 @@ open class BankingPresenter(
return bankAccounts.flatMap { it.bookedTransactions }.sortedByDescending { it.valueDate.millisSinceEpoch } // TODO: someday add unbooked transactions
}
+ protected open fun getAccountsTransactionRetrievalState(accounts: List): TransactionsRetrievalState {
+ val states = accounts.map { getAccountTransactionRetrievalState(it) }
+
+ if (states.contains(TransactionsRetrievalState.RetrievedTransactions)) {
+ return TransactionsRetrievalState.RetrievedTransactions
+ }
+
+ if (states.contains(TransactionsRetrievalState.NoTransactionsInRetrievedPeriod)) {
+ return TransactionsRetrievalState.NoTransactionsInRetrievedPeriod
+ }
+
+ if (states.contains(TransactionsRetrievalState.NeverRetrievedTransactions)) {
+ return TransactionsRetrievalState.NeverRetrievedTransactions
+ }
+
+ return TransactionsRetrievalState.AccountDoesNotSupportFetchingTransactions
+ }
+
+ protected open fun getAccountTransactionRetrievalState(account: TypedBankAccount): TransactionsRetrievalState {
+ if (account.supportsRetrievingAccountTransactions == false) {
+ return TransactionsRetrievalState.AccountDoesNotSupportFetchingTransactions
+ }
+
+ if (account.bookedTransactions.isNotEmpty()) {
+ return TransactionsRetrievalState.RetrievedTransactions
+ }
+
+ if (account.lastRetrievedTransactionsTimestamp != null) {
+ return TransactionsRetrievalState.NoTransactionsInRetrievedPeriod
+ }
+
+ return TransactionsRetrievalState.NeverRetrievedTransactions
+ }
+
protected open fun getBalanceForAccounts(customers: Collection): BigDecimal {
return customers.map { it.balance }.sum()
}
diff --git a/ui/BankingiOSApp/BankingiOSApp/Base.lproj/Localizable.strings b/ui/BankingiOSApp/BankingiOSApp/Base.lproj/Localizable.strings
index fc4d4df1..8857a38a 100644
--- a/ui/BankingiOSApp/BankingiOSApp/Base.lproj/Localizable.strings
+++ b/ui/BankingiOSApp/BankingiOSApp/Base.lproj/Localizable.strings
@@ -75,14 +75,19 @@
"Fetch all account transactions" = "Fetch earlier transactions (requires TAN)";
+"Fetch transactions" = "Fetch transactions";
+"Account does not support retrieving transactions" = "Account does not support retrieving transactions";
+"No transactions fetched yet" = "No transactions fetched yet";
+"There haven't been any transactions in retrieved period" = "There haven't been any transactions in retrieved period";
+
"Transfer money to %@" = "Transfer money to %@";
"New transfer with same data" = "New transfer with same data";
"Could not fetch latest transactions" = "Could not fetch latest transactions";
"Could not fetch latest transactions for %@. Error message from your bank: %@." = "Could not fetch latest transactions for %@.\nError message from your bank:\n%@.";
-"Could not fetch all transactions" = "Could not fetch all transactions";
-"Could not fetch all transactions for %@. Error message from your bank: %@." = "Could not fetch all transactions for %@.\nError message from your bank:\n%@.";
+"Could not fetch transactions" = "Could not fetch transactions";
+"Could not fetch transactions for %@. Error message from your bank: %@." = "Could not fetch transactions for %@.\nError message from your bank:\n%@.";
/* New action sheet */
diff --git a/ui/BankingiOSApp/BankingiOSApp/de.lproj/Localizable.strings b/ui/BankingiOSApp/BankingiOSApp/de.lproj/Localizable.strings
index dafaa8be..2b864c5b 100644
--- a/ui/BankingiOSApp/BankingiOSApp/de.lproj/Localizable.strings
+++ b/ui/BankingiOSApp/BankingiOSApp/de.lproj/Localizable.strings
@@ -75,14 +75,19 @@
"Fetch all account transactions" = "Ältere Umsätze laden (erfordert TAN)";
+"Fetch transactions" = "Umsätze abrufen";
+"Account does not support retrieving transactions" = "Konto unterstützt Abrufen von Umsätzen nicht";
+"No transactions fetched yet" = "Noch keine Umsätze abgerufen";
+"There haven't been any transactions in retrieved period" = "Empfangener Zeitraum enthielt keine Umsätze";
+
"Transfer money to %@" = "Neue Überweisung an %@";
"New transfer with same data" = "Neue Überweisung mit gleichen Daten";
"Could not fetch latest transactions" = "Umsätze konnte nicht aktualisiert werden";
"Could not fetch latest transactions for %@. Error message from your bank: %@." = "Die Umsätze für %@ konnten nicht aktualisiert werden.\nFehlermeldung Ihrer Bank:\n%@.";
-"Could not fetch all transactions" = "Es konnte nicht all Umsätze geholt werden";
-"Could not fetch all transactions for %@. Error message from your bank: %@." = "Für %@ konnten nicht alle Umsätze geholt werden.\nFehlermeldung Ihrer Bank:\n%@.";
+"Could not fetch transactions" = "Umsätze konnten nicht abgerufen werden";
+"Could not fetch transactions for %@. Error message from your bank: %@." = "Umsätze für %@ konnten nicht abgerufen werden.\nFehlermeldung Ihrer Bank:\n%@.";
/* New action sheet */
diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/AccountTransactionsDialog.swift b/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/AccountTransactionsDialog.swift
index d40b9c13..a45840b3 100644
--- a/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/AccountTransactionsDialog.swift
+++ b/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/AccountTransactionsDialog.swift
@@ -9,23 +9,29 @@ struct AccountTransactionsDialog: View {
private let title: String
- private let allTransactions: [IAccountTransaction]
-
- @State private var balanceOfAllTransactions: CommonBigDecimal
-
- private let areMoreThanOneBanksTransactionsDisplayed: Bool
+ private let showBankIcons: Bool
- @State private var haveAllTransactionsBeenFetched: Bool
+ @State private var haveTransactionsBeenRetrievedForSelectedAccounts = true
- @State private var showFetchAllTransactionsOverlay: Bool
+ @State private var haveAllTransactionsBeenFetched: Bool = false
- @State private var accountsForWhichNotAllTransactionsHaveBeenFetched: [IBankAccount]
+ @State private var showTransactionsList = true
+
+ @State private var noTransactionsFetchedMessage: LocalizedStringKey = ""
+
+ @State private var showFetchTransactionsButton = true
+
+ @State private var showFetchAllTransactionsOverlay: Bool = false
+
+ @State private var accountsForWhichNotAllTransactionsHaveBeenFetched: [IBankAccount] = []
- @State private var filteredTransactions: [IAccountTransaction]
+ @State private var filteredTransactions: [IAccountTransaction] = []
- @State private var balanceOfFilteredTransactions: CommonBigDecimal
+ @State private var balanceOfAllTransactions: CommonBigDecimal = CommonBigDecimal(decimal: "0")
+
+ @State private var balanceOfFilteredTransactions: CommonBigDecimal = CommonBigDecimal(decimal: "0")
@State private var searchText = ""
@@ -46,39 +52,27 @@ struct AccountTransactionsDialog: View {
init(allBanks: [ICustomer]) {
- let allAccounts = allBanks.flatMap { $0.accounts }
-
- self.init("All accounts", allAccounts.flatMap { $0.bookedTransactions }, allBanks.sumBalances(), allAccounts.filter { $0.haveAllTransactionsBeenFetched == false })
+ self.init("All accounts", true)
presenter.selectedAllBankAccounts()
}
init(bank: ICustomer) {
- self.init(bank.displayName, bank.accounts.flatMap { $0.bookedTransactions }, bank.balance, bank.accounts.filter { $0.haveAllTransactionsBeenFetched == false })
+ self.init(bank.displayName, false)
presenter.selectedAccount(customer: bank)
}
init(account: IBankAccount) {
- self.init(account.displayName, account.bookedTransactions, account.balance, account.haveAllTransactionsBeenFetched ? [] : [account])
-
+ self.init(account.displayName, false)
+
presenter.selectedBankAccount(bankAccount: account)
}
- fileprivate init(_ title: String, _ transactions: [IAccountTransaction], _ balance: CommonBigDecimal, _ accountsForWhichNotAllTransactionsHaveBeenFetched: [IBankAccount] = []) {
+ fileprivate init(_ title: String, _ showBankIcons: Bool) {
self.title = title
-
- self.allTransactions = transactions
- self._filteredTransactions = State(initialValue: transactions.sorted { $0.valueDate.date > $1.valueDate.date })
- self._balanceOfAllTransactions = State(initialValue: balance)
- self._balanceOfFilteredTransactions = State(initialValue: balance)
-
- self.areMoreThanOneBanksTransactionsDisplayed = Set(allTransactions.compactMap { $0.bankAccount }.compactMap { $0.customer as! Customer }).count > 1
-
- _accountsForWhichNotAllTransactionsHaveBeenFetched = State(initialValue: accountsForWhichNotAllTransactionsHaveBeenFetched)
- _haveAllTransactionsBeenFetched = State(initialValue: accountsForWhichNotAllTransactionsHaveBeenFetched.isEmpty)
- _showFetchAllTransactionsOverlay = State(initialValue: accountsForWhichNotAllTransactionsHaveBeenFetched.isNotEmpty)
+ self.showBankIcons = showBankIcons
}
@@ -98,13 +92,26 @@ struct AccountTransactionsDialog: View {
}
}
- Section {
- ForEach(filteredTransactions, id: \.technicalId) { transaction in
- AccountTransactionListItem(transaction, self.areMoreThanOneBanksTransactionsDisplayed)
+ if showTransactionsList {
+ Section {
+ ForEach(filteredTransactions, id: \.technicalId) { transaction in
+ AccountTransactionListItem(transaction, self.showBankIcons)
+ }
+ }
+ }
+ else {
+ VStack(alignment: .center) {
+ Text(noTransactionsFetchedMessage)
+ .multilineTextAlignment(.center)
+
+ if showFetchTransactionsButton {
+ Button("Fetch transactions") { self.fetchTransactions() }
+ .padding(.top, 6)
+ }
}
}
- if haveAllTransactionsBeenFetched == false && showFetchAllTransactionsOverlay == false {
+ if haveAllTransactionsBeenFetched == false && showFetchAllTransactionsOverlay == false && haveTransactionsBeenRetrievedForSelectedAccounts {
Section {
HStack {
Spacer()
@@ -148,7 +155,7 @@ struct AccountTransactionsDialog: View {
}
}
.executeMutatingMethod {
- self.showFetchAllTransactionsOverlay = self.shouldShowFetchAllTransactionsOverlay
+ self.setInitialValues()
}
.alert(message: $errorMessage)
.showNavigationBarTitle(LocalizedStringKey(title))
@@ -156,6 +163,30 @@ struct AccountTransactionsDialog: View {
}
+ private func setInitialValues() {
+ self.balanceOfAllTransactions = self.presenter.balanceOfSelectedBankAccounts
+
+ self.filterTransactions("")
+
+ setTransactionsView()
+ }
+
+ private func setTransactionsView() {
+ let transactionsRetrievalState = presenter.selectedBankAccountsTransactionRetrievalState
+ self.haveTransactionsBeenRetrievedForSelectedAccounts = transactionsRetrievalState == .retrievedtransactions
+
+ self.accountsForWhichNotAllTransactionsHaveBeenFetched = presenter.selectedBankAccountsForWhichNotAllTransactionsHaveBeenFetched
+ self.haveAllTransactionsBeenFetched = self.accountsForWhichNotAllTransactionsHaveBeenFetched.isEmpty
+ self.showFetchAllTransactionsOverlay = shouldShowFetchAllTransactionsOverlay && haveTransactionsBeenRetrievedForSelectedAccounts
+
+
+ self.showTransactionsList = haveTransactionsBeenRetrievedForSelectedAccounts
+
+ self.noTransactionsFetchedMessage = getNoTransactionsFetchedMessage(transactionsRetrievalState)
+ self.showFetchTransactionsButton = transactionsRetrievalState != .accountdoesnotsupportfetchingtransactions
+ }
+
+
private var fetchAllTransactionsButton: some View {
Button("Fetch all account transactions") {
self.fetchAllTransactions(self.accountsForWhichNotAllTransactionsHaveBeenFetched)
@@ -180,27 +211,48 @@ struct AccountTransactionsDialog: View {
}
}
- private func fetchAllTransactions(_ accounts: [IBankAccount]) {
- accounts.forEach { account in
- presenter.fetchAllAccountTransactionsAsync(bankAccount: account, callback: self.handleGetAllTransactionsResult)
+ private func fetchTransactions() {
+ for account in presenter.selectedBankAccounts {
+ if account.haveAllTransactionsBeenFetched {
+ presenter.updateBankAccountTransactionsAsync(bankAccount: account, abortIfTanIsRequired: false, callback: self.handleGetTransactionsResult)
+ }
+ else {
+ presenter.fetchAllAccountTransactionsAsync(account: account, callback: self.handleGetTransactionsResult)
+ }
}
}
- private func handleGetAllTransactionsResult(_ response: GetTransactionsResponse) {
- self.accountsForWhichNotAllTransactionsHaveBeenFetched = self.accountsForWhichNotAllTransactionsHaveBeenFetched.filter { $0.haveAllTransactionsBeenFetched == false }
- self.haveAllTransactionsBeenFetched = self.accountsForWhichNotAllTransactionsHaveBeenFetched.isEmpty
- self.showFetchAllTransactionsOverlay = shouldShowFetchAllTransactionsOverlay
+ private func fetchAllTransactions(_ accounts: [IBankAccount]) {
+ accounts.forEach { account in
+ presenter.fetchAllAccountTransactionsAsync(account: account, callback: self.handleGetTransactionsResult)
+ }
+ }
+
+ private func handleGetTransactionsResult(_ response: GetTransactionsResponse) {
+ setTransactionsView()
if response.successful {
self.filterTransactions(self.searchText)
}
else if response.userCancelledAction == false {
if let failedAccount = getAccountThatFailed(response) {
- self.errorMessage = Message(title: Text("Could not fetch all transactions"), message: Text("Could not fetch all transactions for \(failedAccount.displayName). Error message from your bank: \(response.errorToShowToUser ?? "")."))
+ self.errorMessage = Message(title: Text("Could not fetch transactions"), message: Text("Could not fetch transactions for \(failedAccount.displayName). Error message from your bank: \(response.errorToShowToUser ?? "")."))
}
}
}
+ private func getNoTransactionsFetchedMessage(_ state: TransactionsRetrievalState) -> LocalizedStringKey {
+ if state == .neverretrievedtransactions {
+ return "No transactions fetched yet"
+ }
+ else if state == .notransactionsinretrievedperiod {
+ return "There haven't been any transactions in retrieved period"
+ }
+ else {
+ return "Account does not support retrieving transactions"
+ }
+ }
+
private func filterTransactions(_ query: String) {
self.filteredTransactions = presenter.searchSelectedAccountTransactions(query: query).sorted { $0.valueDate.date > $1.valueDate.date }
@@ -236,9 +288,6 @@ struct AccountTransactionsDialog: View {
struct AccountTransactionsDialog_Previews: PreviewProvider {
static var previews: some View {
- AccountTransactionsDialog(previewBanks[0].displayName, [
- AccountTransaction(bankAccount: previewBanks[0].accounts[0] as! BankAccount, amount: CommonBigDecimal(double: 1234.56), currency: "€", unparsedUsage: "Usage", bookingDate: CommonDate(year: 2020, month: 5, day: 7), otherPartyName: "Marieke Musterfrau", otherPartyBankCode: nil, otherPartyAccountId: nil, bookingText: "SEPA Ueberweisung", valueDate: CommonDate(year: 2020, month: 5, day: 7))
- ],
- CommonBigDecimal(double: 84.12))
+ AccountTransactionsDialog(previewBanks[0].displayName, false)
}
}