From 438772a6a290d64c52cddfd51639848becedbfe8 Mon Sep 17 00:00:00 2001 From: dankl Date: Sat, 25 Jan 2020 16:58:43 +0100 Subject: [PATCH] Added supportsRetrievingAccountTransactions, supportsRetrievingBalance, supportsTransferringMoney to BankAccount and BankData. Enabling features retrieving account transactions and transferring money now only if a bank account supports this. --- .../dankito/banking/ui/model/BankAccount.kt | 4 ++ .../ui/presenter/MainWindowPresenter.kt | 56 +++++++++++++++++-- .../ui/adapter/AccountTransactionAdapter.kt | 2 + .../android/ui/dialogs/AddAccountDialog.kt | 4 +- .../android/ui/dialogs/TransferMoneyDialog.kt | 8 +-- .../android/ui/home/HomeFragment.kt | 16 +++--- .../MainActivityFloatingActionMenuButton.kt | 9 ++- .../banking/mapper/fints4javaModelMapper.kt | 3 +- .../kotlin/net/dankito/fints/FinTsClient.kt | 24 +++++--- .../dankito/fints/messages/MessageBuilder.kt | 53 ++++++++++++++---- .../net/dankito/fints/model/AccountData.kt | 7 ++- .../net/dankito/fints/model/CustomerData.kt | 4 +- 12 files changed, 143 insertions(+), 47 deletions(-) diff --git a/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/BankAccount.kt b/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/BankAccount.kt index d064a1b7..66d390de 100644 --- a/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/BankAccount.kt +++ b/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/BankAccount.kt @@ -15,6 +15,9 @@ open class BankAccount @JvmOverloads constructor( var balance: BigDecimal = BigDecimal.ZERO, var currency: String = "EUR", var type: BankAccountType = BankAccountType.Giro, + var supportsRetrievingAccountTransactions: Boolean = false, + var supportsRetrievingBalance: Boolean = false, + var supportsTransferringMoney: Boolean = false, bookedAccountTransactions: List = listOf() ) { @@ -35,6 +38,7 @@ open class BankAccount @JvmOverloads constructor( val displayNameIncludingBankName: String get() = "${account.bank.name} ${displayName}" + var bookedTransactions: List = bookedAccountTransactions protected set diff --git a/BankingUiCommon/src/main/java/net/dankito/banking/ui/presenter/MainWindowPresenter.kt b/BankingUiCommon/src/main/java/net/dankito/banking/ui/presenter/MainWindowPresenter.kt index e5d8a9d5..f51419f1 100644 --- a/BankingUiCommon/src/main/java/net/dankito/banking/ui/presenter/MainWindowPresenter.kt +++ b/BankingUiCommon/src/main/java/net/dankito/banking/ui/presenter/MainWindowPresenter.kt @@ -153,7 +153,9 @@ open class MainWindowPresenter( callback: (GetTransactionsResponse) -> Unit) { account.bankAccounts.forEach { bankAccount -> - getAccountTransactionsAsync(bankAccount, callback) // TODO: use a synchronous version of getAccountTransactions() so that all bank accounts get handled serially + if (bankAccount.supportsRetrievingAccountTransactions) { + getAccountTransactionsAsync(bankAccount, callback) // TODO: use a synchronous version of getAccountTransactions() so that all bank accounts get handled serially + } } } @@ -179,11 +181,13 @@ open class MainWindowPresenter( open fun updateAccountsTransactionsAsync(callback: (GetTransactionsResponse) -> Unit) { clientsForAccounts.keys.forEach { account -> account.bankAccounts.forEach { bankAccount -> - val today = Date() // TODO: still don't know where this bug is coming from that bank returns a transaction dated at end of year - val lastRetrievedTransactionDate = bankAccount.bookedTransactions.firstOrNull { it.bookingDate <= today }?.bookingDate - val fromDate = lastRetrievedTransactionDate?.let { Date(it.time - OneDayMillis) } // one day before last received transaction + if (bankAccount.supportsRetrievingAccountTransactions) { + val today = Date() // TODO: still don't know where this bug is coming from that bank returns a transaction dated at end of year + val lastRetrievedTransactionDate = bankAccount.bookedTransactions.firstOrNull { it.bookingDate <= today }?.bookingDate + val fromDate = lastRetrievedTransactionDate?.let { Date(it.time - OneDayMillis) } // one day before last received transaction - getAccountTransactionsAsync(bankAccount, fromDate, callback) + getAccountTransactionsAsync(bankAccount, fromDate, callback) + } } } } @@ -349,6 +353,48 @@ open class MainWindowPresenter( get() = getBalanceForAccounts(accounts) + open val bankAccountsSupportingRetrievingAccountTransactions: List + get() = bankAccounts.filter { it.supportsRetrievingAccountTransactions } + + open val hasBankAccountsSupportingRetrievingAccountTransactions: Boolean + get() = doBankAccountsSupportRetrievingAccountTransactions(bankAccounts) + + open val doSelectedBankAccountsSupportRetrievingAccountTransactions: Boolean + get() = doBankAccountsSupportRetrievingAccountTransactions(selectedBankAccounts) + + open fun doBankAccountsSupportRetrievingAccountTransactions(bankAccounts: List): Boolean { + return bankAccounts.firstOrNull { it.supportsRetrievingAccountTransactions } != null + } + + + open val bankAccountsSupportingRetrievingBalance: List + get() = bankAccounts.filter { it.supportsRetrievingBalance } + + open val hasBankAccountsSupportingRetrievingBalance: Boolean + get() = doBankAccountsSupportRetrievingBalance(bankAccounts) + + open val doSelectedBankAccountsSupportRetrievingBalance: Boolean + get() = doBankAccountsSupportRetrievingBalance(selectedBankAccounts) + + open fun doBankAccountsSupportRetrievingBalance(bankAccounts: List): Boolean { + return bankAccounts.firstOrNull { it.supportsRetrievingBalance } != null + } + + + open val bankAccountsSupportingTransferringMoney: List + get() = bankAccounts.filter { it.supportsTransferringMoney } + + open val hasBankAccountsSupportTransferringMoney: Boolean + get() = doBankAccountsSupportTransferringMoney(bankAccounts) + + open val doSelectedBankAccountsSupportTransferringMoney: Boolean + get() = doBankAccountsSupportTransferringMoney(selectedBankAccounts) + + open fun doBankAccountsSupportTransferringMoney(bankAccounts: List): Boolean { + return bankAccounts.firstOrNull { it.supportsTransferringMoney } != null + } + + protected open fun getAccountTransactionsForAccounts(accounts: Collection): List { return accounts.flatMap { it.transactions }.sortedByDescending { it.bookingDate } // TODO: someday add unbooked transactions } diff --git a/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/ui/adapter/AccountTransactionAdapter.kt b/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/ui/adapter/AccountTransactionAdapter.kt index 819b4c4c..b27051eb 100644 --- a/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/ui/adapter/AccountTransactionAdapter.kt +++ b/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/ui/adapter/AccountTransactionAdapter.kt @@ -59,6 +59,8 @@ open class AccountTransactionAdapter selectedTransaction = getItem(viewHolder.adapterPosition) menu.findItem(R.id.mnitmShowTransferMoneyDialog)?.let { mnitmShowTransferMoneyDialog -> + mnitmShowTransferMoneyDialog.isVisible = selectedTransaction?.bankAccount?.supportsTransferringMoney ?: false + val remitteeName = selectedTransaction?.otherPartyName ?: "" mnitmShowTransferMoneyDialog.title = view.context.getString(R.string.fragment_home_transfer_money_to, remitteeName) diff --git a/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/ui/dialogs/AddAccountDialog.kt b/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/ui/dialogs/AddAccountDialog.kt index c2aec1c8..96f368ce 100644 --- a/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/ui/dialogs/AddAccountDialog.kt +++ b/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/ui/dialogs/AddAccountDialog.kt @@ -15,9 +15,9 @@ import android.widget.TextView import kotlinx.android.synthetic.main.dialog_add_account.* import kotlinx.android.synthetic.main.dialog_add_account.view.* import net.dankito.banking.fints4java.android.R -import net.dankito.banking.ui.presenter.MainWindowPresenter import net.dankito.banking.fints4java.android.ui.adapter.BankListAdapter import net.dankito.banking.ui.model.responses.AddAccountResponse +import net.dankito.banking.ui.presenter.MainWindowPresenter import net.dankito.fints.model.BankInfo import net.dankito.utils.android.extensions.asActivity @@ -39,7 +39,7 @@ open class AddAccountDialog : DialogFragment() { fun show(activity: AppCompatActivity, presenter: MainWindowPresenter, fullscreen: Boolean = false) { this.presenter = presenter - presenter.preloadBanksAsync() +// presenter.preloadBanksAsync() this.adapter = BankListAdapter(presenter) val style = if(fullscreen) R.style.FullscreenDialogWithStatusBar else R.style.Dialog diff --git a/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/ui/dialogs/TransferMoneyDialog.kt b/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/ui/dialogs/TransferMoneyDialog.kt index 017a0398..56def84a 100644 --- a/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/ui/dialogs/TransferMoneyDialog.kt +++ b/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/ui/dialogs/TransferMoneyDialog.kt @@ -70,13 +70,13 @@ open class TransferMoneyDialog : DialogFragment() { protected open fun setupUI(rootView: View) { setPreselectedValues(rootView) - val allBankAccounts = presenter.bankAccounts - bankAccount = preselectedBankAccount ?: allBankAccounts.first() + val allBankAccountsSupportingTransferringMoney = presenter.bankAccountsSupportingTransferringMoney + bankAccount = preselectedBankAccount ?: allBankAccountsSupportingTransferringMoney.first() - if (allBankAccounts.size > 1) { + if (allBankAccountsSupportingTransferringMoney.size > 1) { rootView.lytSelectBankAccount.visibility = View.VISIBLE - val adapter = BankAccountsAdapter(allBankAccounts) + val adapter = BankAccountsAdapter(allBankAccountsSupportingTransferringMoney) rootView.spnBankAccounts.adapter = adapter rootView.spnBankAccounts.onItemSelectedListener = ListItemSelectedListener(adapter) { selectedBankAccount -> this.bankAccount = selectedBankAccount diff --git a/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/ui/home/HomeFragment.kt b/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/ui/home/HomeFragment.kt index 0275804f..73c234b4 100644 --- a/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/ui/home/HomeFragment.kt +++ b/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/ui/home/HomeFragment.kt @@ -15,9 +15,7 @@ import android.widget.EditText import net.dankito.banking.fints4java.android.MainActivity import net.dankito.banking.fints4java.android.R import net.dankito.banking.fints4java.android.ui.adapter.AccountTransactionAdapter -import net.dankito.banking.ui.model.Account import net.dankito.banking.ui.model.AccountTransaction -import net.dankito.banking.ui.model.BankAccount import net.dankito.banking.ui.model.parameters.TransferMoneyData import net.dankito.banking.ui.model.responses.GetTransactionsResponse import net.dankito.banking.ui.presenter.MainWindowPresenter @@ -135,9 +133,9 @@ class HomeFragment : Fragment() { } private fun initLogicAfterUiInitialized() { - presenter.addAccountsChangedListener { handleAccountsChanged(it) } + presenter.addAccountsChangedListener { handleAccountsChanged() } - presenter.addSelectedBankAccountsChangedListener { handleSelectedBankAccountsChanged(it) } + presenter.addSelectedBankAccountsChangedListener { handleSelectedBankAccountsChanged() } presenter.addRetrievedAccountTransactionsResponseListener { _, response -> handleGetTransactionsResponse(response) @@ -147,16 +145,16 @@ class HomeFragment : Fragment() { } - private fun handleAccountsChanged(accounts: List) { + private fun handleAccountsChanged() { context?.asActivity()?.let { activity -> activity.runOnUiThread { - mnitmSearchTransactions.isVisible = accounts.isNotEmpty() - mnitmUpdateTransactions.isVisible = accounts.isNotEmpty() + mnitmSearchTransactions.isVisible = presenter.doSelectedBankAccountsSupportRetrievingAccountTransactions + mnitmUpdateTransactions.isVisible = presenter.doSelectedBankAccountsSupportRetrievingAccountTransactions } } } - private fun handleSelectedBankAccountsChanged(selectedBankAccounts: List) { + private fun handleSelectedBankAccountsChanged() { context?.asActivity()?.let { activity -> activity.runOnUiThread { updateTransactionsToDisplayOnUiThread() @@ -220,7 +218,7 @@ class HomeFragment : Fragment() { // TODO: if transactions are filtered calculate and show balance of displayed transactions? mnitmBalance.title = presenter.balanceOfSelectedBankAccounts.toString() - mnitmBalance.isVisible = true + mnitmBalance.isVisible = presenter.doSelectedBankAccountsSupportRetrievingBalance } } \ No newline at end of file diff --git a/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/ui/views/MainActivityFloatingActionMenuButton.kt b/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/ui/views/MainActivityFloatingActionMenuButton.kt index 0c8e0699..67c2f6c7 100644 --- a/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/ui/views/MainActivityFloatingActionMenuButton.kt +++ b/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/ui/views/MainActivityFloatingActionMenuButton.kt @@ -4,7 +4,6 @@ import android.support.v7.app.AppCompatActivity import com.github.clans.fab.FloatingActionButton import com.github.clans.fab.FloatingActionMenu import kotlinx.android.synthetic.main.view_floating_action_button_main.view.* -import net.dankito.banking.ui.model.Account import net.dankito.banking.ui.presenter.MainWindowPresenter @@ -17,10 +16,10 @@ open class MainActivityFloatingActionMenuButton(floatingActionMenu: FloatingActi setupButtons(floatingActionMenu) presenter.addAccountsChangedListener { - checkIfThereAreAccountsThatCanTransferMoney(it) + checkIfThereAreAccountsThatCanTransferMoney() } - checkIfThereAreAccountsThatCanTransferMoney(presenter.accounts) + checkIfThereAreAccountsThatCanTransferMoney() } private fun setupButtons(floatingActionMenu: FloatingActionMenu) { @@ -38,8 +37,8 @@ open class MainActivityFloatingActionMenuButton(floatingActionMenu: FloatingActi } - protected open fun checkIfThereAreAccountsThatCanTransferMoney(accounts: List) { - fabTransferMoney.isEnabled = accounts.isNotEmpty() // TODO: add check if they support transferring money + protected open fun checkIfThereAreAccountsThatCanTransferMoney() { + fabTransferMoney.isEnabled = presenter.hasBankAccountsSupportTransferringMoney } } \ No newline at end of file diff --git a/fints4javaBankingClient/src/main/kotlin/net/dankito/banking/mapper/fints4javaModelMapper.kt b/fints4javaBankingClient/src/main/kotlin/net/dankito/banking/mapper/fints4javaModelMapper.kt index e0edacc2..5b6d6377 100644 --- a/fints4javaBankingClient/src/main/kotlin/net/dankito/banking/mapper/fints4javaModelMapper.kt +++ b/fints4javaBankingClient/src/main/kotlin/net/dankito/banking/mapper/fints4javaModelMapper.kt @@ -81,7 +81,8 @@ open class fints4javaModelMapper { open fun mapBankAccount(account: Account, accountData: AccountData): BankAccount { return BankAccount(account, accountData.accountIdentifier, accountData.accountHolderName, accountData.iban, accountData.subAccountAttribute, BigDecimal.ZERO, accountData.currency ?: "EUR", - mapBankAccountType(accountData.accountType)) + mapBankAccountType(accountData.accountType), accountData.supportsRetrievingAccountTransactions, + accountData.supportsRetrievingBalance, accountData.supportsTransferringMoney) } open fun mapBankAccountType(type: AccountType?): BankAccountType { diff --git a/fints4javaLib/src/main/kotlin/net/dankito/fints/FinTsClient.kt b/fints4javaLib/src/main/kotlin/net/dankito/fints/FinTsClient.kt index 9451313a..fcec6233 100644 --- a/fints4javaLib/src/main/kotlin/net/dankito/fints/FinTsClient.kt +++ b/fints4javaLib/src/main/kotlin/net/dankito/fints/FinTsClient.kt @@ -153,8 +153,14 @@ open class FinTsClient @JvmOverloads constructor( getTanMediaList(bank, customer, TanMedienArtVersion.Alle, TanMediumKlasse.AlleMedien) // also check if retrieving account transactions of last 90 days without tan is supported (and thereby may retrieve first account transactions) - val account = getBestAccountForRetrievingTransactions(customer) - val transactionsOfLast90DaysResponse = if (account != null) tryGetTransactionsOfLast90DaysWithoutTan(bank, customer, account, false) else GetTransactionsResponse(Response(false)) + val transactionsOfLast90DaysResponses = mutableListOf() + customer.accounts.forEach { account -> + if (account.supportsRetrievingAccountTransactions) { + transactionsOfLast90DaysResponses.add( + tryGetTransactionsOfLast90DaysWithoutTan(bank, customer, account, false)) + } + } + val transactionsOfLast90DaysResponse = transactionsOfLast90DaysResponses.firstOrNull { it.isSuccessful } ?: GetTransactionsResponse(Response(false)) if (didOverwriteUserUnselectedTanProcedure) { customer.resetSelectedTanProcedure() @@ -179,14 +185,14 @@ open class FinTsClient @JvmOverloads constructor( val ninetyDaysAgo = Date(Date().time - NinetyDaysAgoMilliseconds) - val response = getTransactions(GetTransactionsParameter(true, ninetyDaysAgo), bank, customer, account) + val response = getTransactions(GetTransactionsParameter(account.supportsRetrievingBalance, ninetyDaysAgo), bank, customer, account) - customer.triedToRetrieveTransactionsOfLast90DaysWithoutTan = true + account.triedToRetrieveTransactionsOfLast90DaysWithoutTan = true if (response.isSuccessful) { if (response.isStrongAuthenticationRequired == false || hasRetrievedTransactionsWithTanJustBefore) { - customer.supportsRetrievingTransactionsOfLast90DaysWithoutTan = !!! response.isStrongAuthenticationRequired + account.supportsRetrievingTransactionsOfLast90DaysWithoutTan = !!! response.isStrongAuthenticationRequired } } @@ -215,7 +221,7 @@ open class FinTsClient @JvmOverloads constructor( var balance: BigDecimal? = null - if (parameter.alsoRetrieveBalance) { + if (parameter.alsoRetrieveBalance && account.supportsRetrievingBalance) { val balanceResponse = getBalanceAfterDialogInit(bank, customer, account, dialogData) if (balanceResponse.successful == false && balanceResponse.couldCreateMessage == true) { // don't break here if required HKSAL message is not implemented @@ -242,7 +248,7 @@ open class FinTsClient @JvmOverloads constructor( response.getFirstSegmentById(InstituteSegmentId.AccountTransactionsMt940)?.let { transactions -> // just retrieved all transactions -> check if retrieving that ones of last 90 days is possible without entering TAN - if (customer.supportsRetrievingTransactionsOfLast90DaysWithoutTan == null && + if (account.supportsRetrievingTransactionsOfLast90DaysWithoutTan == null && response.successful && transactions.bookedTransactionsString.isNotEmpty() && parameter.fromDate == null) { tryGetTransactionsOfLast90DaysWithoutTan(bank, customer, account, true) } @@ -872,6 +878,10 @@ open class FinTsClient @JvmOverloads constructor( } account.allowedJobs = allowedJobsForAccount + + account.supportsRetrievingAccountTransactions = messageBuilder.supportsGetTransactions(account) + account.supportsRetrievingBalance = messageBuilder.supportsGetBalance(account) + account.supportsTransferringMoney = messageBuilder.supportsBankTransfer(account) } protected open fun mapToTanProcedures(tanInfo: TanInfo): List { diff --git a/fints4javaLib/src/main/kotlin/net/dankito/fints/messages/MessageBuilder.kt b/fints4javaLib/src/main/kotlin/net/dankito/fints/messages/MessageBuilder.kt index c4db7618..1066fcc4 100644 --- a/fints4javaLib/src/main/kotlin/net/dankito/fints/messages/MessageBuilder.kt +++ b/fints4javaLib/src/main/kotlin/net/dankito/fints/messages/MessageBuilder.kt @@ -110,7 +110,7 @@ open class MessageBuilder(protected val generator: ISegmentNumberGenerator = Seg open fun createGetTransactionsMessage(parameter: GetTransactionsParameter, bank: BankData, customer: CustomerData, account: AccountData, product: ProductData, dialogData: DialogData): MessageBuilderResult { - val result = getSupportedVersionsOfJob(CustomerSegmentId.AccountTransactionsMt940, account, listOf(5, 6, 7)) + val result = supportsGetTransactionsMt940(account) if (result.isJobVersionSupported) { val transactionsJob = if (result.isAllowed(7)) KontoumsaetzeZeitraumMt940Version7(generator.resetSegmentNumber(2), parameter, bank, account) @@ -128,9 +128,18 @@ open class MessageBuilder(protected val generator: ISegmentNumberGenerator = Seg return result } + open fun supportsGetTransactions(account: AccountData): Boolean { + return supportsGetTransactionsMt940(account).isJobVersionSupported + } + + protected open fun supportsGetTransactionsMt940(account: AccountData): MessageBuilderResult { + return getSupportedVersionsOfJob(CustomerSegmentId.AccountTransactionsMt940, account, listOf(5, 6, 7)) + } + + open fun createGetBalanceMessage(bank: BankData, customer: CustomerData, account: AccountData, product: ProductData, dialogData: DialogData): MessageBuilderResult { - val result = getSupportedVersionsOfJob(CustomerSegmentId.Balance, account, listOf(5)) + val result = supportsGetBalanceMessage(account) if (result.isJobVersionSupported) { val segments = listOf( @@ -144,6 +153,14 @@ open class MessageBuilder(protected val generator: ISegmentNumberGenerator = Seg return result } + open fun supportsGetBalance(account: AccountData): Boolean { + return supportsGetBalanceMessage(account).isJobVersionSupported + } + + protected open fun supportsGetBalanceMessage(account: AccountData): MessageBuilderResult { + return getSupportedVersionsOfJob(CustomerSegmentId.Balance, account, listOf(5)) + } + open fun createGetTanMediaListMessage(bank: BankData, customer: CustomerData, dialogData: DialogData, tanMediaKind: TanMedienArtVersion = TanMedienArtVersion.Alle, @@ -193,23 +210,39 @@ open class MessageBuilder(protected val generator: ISegmentNumberGenerator = Seg open fun createBankTransferMessage(bankTransferData: BankTransferData, bank: BankData, customer: CustomerData, account: AccountData, dialogData: DialogData): MessageBuilderResult { + val messageBuilderResultAndNullableUrn = supportsBankTransferAndSepaVersion(account) + val result = messageBuilderResultAndNullableUrn.first + val urn = messageBuilderResultAndNullableUrn.second + + if (result.isJobVersionSupported && urn != null) { + val segments = listOf( + SepaEinzelueberweisung(generator.resetSegmentNumber(2), urn, customer, account, bank.bic, bankTransferData), + ZweiSchrittTanEinreichung(generator.getNextSegmentNumber(), TanProcess.TanProcess4, CustomerSegmentId.SepaBankTransfer) + ) + + return createMessageBuilderResult(bank, customer, dialogData, segments) + } + + return result + } + + open fun supportsBankTransfer(account: AccountData): Boolean { + return supportsBankTransferAndSepaVersion(account).first.isJobVersionSupported + } + + protected open fun supportsBankTransferAndSepaVersion(account: AccountData): Pair { val result = getSupportedVersionsOfJob(CustomerSegmentId.SepaBankTransfer, account, listOf(1)) if (result.isJobVersionSupported) { getSepaUrnFor(CustomerSegmentId.SepaAccountInfoParameters, account, "pain.001.001.03")?.let { urn -> - val segments = listOf( - SepaEinzelueberweisung(generator.resetSegmentNumber(2), urn, customer, account, bank.bic, bankTransferData), - ZweiSchrittTanEinreichung(generator.getNextSegmentNumber(), TanProcess.TanProcess4, CustomerSegmentId.SepaBankTransfer) - ) - - return createMessageBuilderResult(bank, customer, dialogData, segments) + return Pair(result, urn) } - return MessageBuilderResult(true, false, result.allowedVersions, result.supportedVersions, null) // TODO: how to tell that we don't support required SEPA pain version? + return Pair(MessageBuilderResult(true, false, result.allowedVersions, result.supportedVersions, null), null) // TODO: how to tell that we don't support required SEPA pain version? } - return result + return Pair(result, null) } diff --git a/fints4javaLib/src/main/kotlin/net/dankito/fints/model/AccountData.kt b/fints4javaLib/src/main/kotlin/net/dankito/fints/model/AccountData.kt index 29e037f2..3ff6c84e 100644 --- a/fints4javaLib/src/main/kotlin/net/dankito/fints/model/AccountData.kt +++ b/fints4javaLib/src/main/kotlin/net/dankito/fints/model/AccountData.kt @@ -17,7 +17,12 @@ open class AccountData( val productName: String?, val accountLimit: String?, val allowedJobNames: List, - var allowedJobs: List = listOf() + var allowedJobs: List = listOf(), + var supportsRetrievingAccountTransactions: Boolean = false, + var supportsRetrievingBalance: Boolean = false, + var supportsTransferringMoney: Boolean = false, + var supportsRetrievingTransactionsOfLast90DaysWithoutTan: Boolean? = null, + var triedToRetrieveTransactionsOfLast90DaysWithoutTan: Boolean = false ) { override fun toString(): String { diff --git a/fints4javaLib/src/main/kotlin/net/dankito/fints/model/CustomerData.kt b/fints4javaLib/src/main/kotlin/net/dankito/fints/model/CustomerData.kt index ad942c7b..8e757f94 100644 --- a/fints4javaLib/src/main/kotlin/net/dankito/fints/model/CustomerData.kt +++ b/fints4javaLib/src/main/kotlin/net/dankito/fints/model/CustomerData.kt @@ -17,9 +17,7 @@ open class CustomerData( var tanMedia: List = listOf(), var selectedLanguage: Dialogsprache = Dialogsprache.Default, var customerSystemId: String = KundensystemID.Anonymous, - var customerSystemStatus: KundensystemStatusWerte = KundensystemStatus.SynchronizingCustomerSystemId, - var supportsRetrievingTransactionsOfLast90DaysWithoutTan: Boolean? = null, - var triedToRetrieveTransactionsOfLast90DaysWithoutTan: Boolean = false + var customerSystemStatus: KundensystemStatusWerte = KundensystemStatus.SynchronizingCustomerSystemId ) { companion object {