Renamed isSuccessful to successful

This commit is contained in:
dankito 2020-09-19 03:37:30 +02:00
parent 6ed4acd8f2
commit d8739cf193
20 changed files with 45 additions and 39 deletions

View File

@ -160,7 +160,7 @@ open class FinTsClient(
// TODO: this is only a quick fix. Find a better and general solution // TODO: this is only a quick fix. Find a better and general solution
protected open fun getBankAndCustomerInfoForNewUserViaAnonymousDialog(bank: BankData, callback: (AddAccountResponse) -> Unit) { protected open fun getBankAndCustomerInfoForNewUserViaAnonymousDialog(bank: BankData, callback: (AddAccountResponse) -> Unit) {
getAnonymousBankInfo(bank) { anonymousBankInfoResponse -> getAnonymousBankInfo(bank) { anonymousBankInfoResponse ->
if (anonymousBankInfoResponse.isSuccessful == false) { if (anonymousBankInfoResponse.successful == false) {
callback(AddAccountResponse(anonymousBankInfoResponse.toResponse(), bank)) callback(AddAccountResponse(anonymousBankInfoResponse.toResponse(), bank))
} }
else if (bank.tanProceduresSupportedByBank.isEmpty()) { // should only be a theoretical error else if (bank.tanProceduresSupportedByBank.isEmpty()) { // should only be a theoretical error
@ -238,7 +238,7 @@ open class FinTsClient(
getUsersTanProcedures(bank) { newUserInfoResponse -> getUsersTanProcedures(bank) { newUserInfoResponse ->
if (newUserInfoResponse.isSuccessful == false) { // bank parameter (FinTS server address, ...) already seem to be wrong if (newUserInfoResponse.successful == false) { // bank parameter (FinTS server address, ...) already seem to be wrong
callback(newUserInfoResponse) callback(newUserInfoResponse)
return@getUsersTanProcedures return@getUsersTanProcedures
} }
@ -266,7 +266,7 @@ open class FinTsClient(
getAccounts(bank) { getAccountsResponse -> getAccounts(bank) { getAccountsResponse ->
if (getAccountsResponse.isSuccessful == false) { if (getAccountsResponse.successful == false) {
callback(getAccountsResponse) callback(getAccountsResponse)
return@getAccounts return@getAccounts
} }
@ -580,7 +580,7 @@ open class FinTsClient(
protected open fun ensureBasicBankDataRetrieved(bank: BankData, callback: (Response) -> Unit) { protected open fun ensureBasicBankDataRetrieved(bank: BankData, callback: (Response) -> Unit) {
if (bank.tanProceduresSupportedByBank.isEmpty() || bank.supportedJobs.isEmpty()) { if (bank.tanProceduresSupportedByBank.isEmpty() || bank.supportedJobs.isEmpty()) {
getUsersTanProcedures(bank) { getBankInfoResponse -> getUsersTanProcedures(bank) { getBankInfoResponse ->
if (getBankInfoResponse.isSuccessful == false || bank.tanProceduresSupportedByBank.isEmpty() if (getBankInfoResponse.successful == false || bank.tanProceduresSupportedByBank.isEmpty()
|| bank.supportedJobs.isEmpty()) { || bank.supportedJobs.isEmpty()) {
callback(Response(false, errorMessage = callback(Response(false, errorMessage =
@ -910,7 +910,7 @@ open class FinTsClient(
changeTanMedium(changeTanMediumTo, dialogContext.bank) { changeTanMediumResponse -> changeTanMedium(changeTanMediumTo, dialogContext.bank) { changeTanMediumResponse ->
changeTanMediumResultCallback?.invoke(changeTanMediumResponse) changeTanMediumResultCallback?.invoke(changeTanMediumResponse)
if (changeTanMediumResponse.isSuccessful == false || lastCreatedMessage == null) { if (changeTanMediumResponse.successful == false || lastCreatedMessage == null) {
callback(changeTanMediumResponse.toResponse()) callback(changeTanMediumResponse.toResponse())
} }
else { else {

View File

@ -10,7 +10,7 @@ open class AddAccountResponse(
retrievedData: List<RetrievedAccountData> = listOf() retrievedData: List<RetrievedAccountData> = listOf()
) : GetTransactionsResponse(response, retrievedData) { ) : GetTransactionsResponse(response, retrievedData) {
override val isSuccessful: Boolean override val successful: Boolean
get() = super.isSuccessful && bank.accounts.isNotEmpty() get() = super.successful && bank.accounts.isNotEmpty()
} }

View File

@ -6,7 +6,7 @@ import net.dankito.banking.fints.response.segments.TanResponse
open class FinTsClientResponse( open class FinTsClientResponse(
open val isSuccessful: Boolean, // TODO: rename to successful open val successful: Boolean,
open val noTanProcedureSelected: Boolean, open val noTanProcedureSelected: Boolean,
@ -41,7 +41,7 @@ open class FinTsClientResponse(
open fun toResponse(): Response { open fun toResponse(): Response {
return Response(this.isSuccessful) return Response(this.successful)
} }
@ -58,7 +58,7 @@ open class FinTsClientResponse(
return "Error: Job version is not supported. Supported versions are $supportedVersions" return "Error: Job version is not supported. Supported versions are $supportedVersions"
} }
return "isSuccessful = $isSuccessful" return "successful = $successful"
} }
} }

View File

@ -13,7 +13,7 @@ open class GetTransactionsResponse(
open var isSettingMaxCountEntriesAllowedByBank: Boolean? = null open var isSettingMaxCountEntriesAllowedByBank: Boolean? = null
) : FinTsClientResponse(response) { ) : FinTsClientResponse(response) {
override val isSuccessful: Boolean override val successful: Boolean
get() = super.isSuccessful && retrievedData.isNotEmpty() && retrievedData.none { it.successfullyRetrievedData == false } get() = super.successful && retrievedData.isNotEmpty() && retrievedData.none { it.successfullyRetrievedData == false }
} }

View File

@ -133,7 +133,7 @@ open class AddAccountDialog : DialogFragment() {
protected open fun handleAccountCheckResponseOnUiThread(response: AddAccountResponse) { protected open fun handleAccountCheckResponseOnUiThread(response: AddAccountResponse) {
context?.let { context -> context?.let { context ->
if (response.isSuccessful) { if (response.successful) {
this.dismiss() this.dismiss()
showMessageForSuccessfullyAddedAccount(context, response) showMessageForSuccessfullyAddedAccount(context, response)

View File

@ -230,7 +230,7 @@ open class EnterTanDialog : DialogFragment() {
} }
protected open fun handleChangeTanMediumResponseOnUiThread(context: Context, newUsedTanMedium: TanMedium, response: BankingClientResponse) { protected open fun handleChangeTanMediumResponseOnUiThread(context: Context, newUsedTanMedium: TanMedium, response: BankingClientResponse) {
if (response.isSuccessful) { if (response.successful) {
AlertDialog.Builder(context) AlertDialog.Builder(context)
.setMessage(context.getString(R.string.dialog_enter_tan_tan_medium_successfully_changed, newUsedTanMedium.displayName)) .setMessage(context.getString(R.string.dialog_enter_tan_tan_medium_successfully_changed, newUsedTanMedium.displayName))
.setPositiveButton(android.R.string.ok) { dialog, _ -> .setPositiveButton(android.R.string.ok) { dialog, _ ->

View File

@ -41,7 +41,6 @@ import net.dankito.utils.android.extensions.asActivity
import net.dankito.utils.android.extensions.getDimension import net.dankito.utils.android.extensions.getDimension
import java.math.BigDecimal import java.math.BigDecimal
import java.text.DecimalFormatSymbols import java.text.DecimalFormatSymbols
import java.text.NumberFormat
import java.util.* import java.util.*
import javax.inject.Inject import javax.inject.Inject
import kotlin.concurrent.schedule import kotlin.concurrent.schedule
@ -316,7 +315,7 @@ open class TransferMoneyDialog : DialogFragment() {
protected open fun handleTransferMoneyResultOnUiThread(transferData: TransferMoneyData, response: BankingClientResponse) { protected open fun handleTransferMoneyResultOnUiThread(transferData: TransferMoneyData, response: BankingClientResponse) {
context?.let { context -> context?.let { context ->
if (response.userCancelledAction == false) { if (response.userCancelledAction == false) {
val message = if (response.isSuccessful) { val message = if (response.successful) {
context.getString(R.string.dialog_transfer_money_message_transfer_successful, context.getString(R.string.dialog_transfer_money_message_transfer_successful,
String.format("%.02f", transferData.amount), "", transferData.creditorName) // TODO: where to get currency from? String.format("%.02f", transferData.amount), "", transferData.creditorName) // TODO: where to get currency from?
} }
@ -333,7 +332,7 @@ open class TransferMoneyDialog : DialogFragment() {
.show() .show()
} }
if (response.isSuccessful || response.userCancelledAction) { // do not close dialog if an error occurred if (response.successful || response.userCancelledAction) { // do not close dialog if an error occurred
this.dismiss() this.dismiss()
} }
} }

View File

@ -252,7 +252,7 @@ open class AddAccountDialog(protected val presenter: BankingPresenter) : Window(
protected open fun handleAddAccountResultOnUiThread(response: AddAccountResponse) { protected open fun handleAddAccountResultOnUiThread(response: AddAccountResponse) {
checkCredentialsButton.resetIsProcessing() checkCredentialsButton.resetIsProcessing()
if (response.isSuccessful) { if (response.successful) {
handleSuccessfullyAddedAccountResultOnUiThread(response) handleSuccessfullyAddedAccountResultOnUiThread(response)
} }
else { else {

View File

@ -369,7 +369,7 @@ open class TransferMoneyDialog @JvmOverloads constructor(
protected open fun handleTransferMoneyResultOnUiThread(bankAccount: TypedBankAccount, transferData: TransferMoneyData, response: BankingClientResponse) { protected open fun handleTransferMoneyResultOnUiThread(bankAccount: TypedBankAccount, transferData: TransferMoneyData, response: BankingClientResponse) {
val currency = bankAccount.currency val currency = bankAccount.currency
if (response.isSuccessful) { if (response.successful) {
dialogService.showInfoMessage(String.format(messages["transfer.money.dialog.message.transfer.cash.success"], dialogService.showInfoMessage(String.format(messages["transfer.money.dialog.message.transfer.cash.success"],
transferData.amount, currency, transferData.creditorName), null, currentStage) transferData.amount, currency, transferData.creditorName), null, currentStage)
} }
@ -378,7 +378,7 @@ open class TransferMoneyDialog @JvmOverloads constructor(
transferData.amount, currency, transferData.creditorName, response.errorToShowToUser), null, null, currentStage) transferData.amount, currency, transferData.creditorName, response.errorToShowToUser), null, null, currentStage)
} }
if (response.isSuccessful || response.userCancelledAction) { // do not close dialog if an error occurred if (response.successful || response.userCancelledAction) { // do not close dialog if an error occurred
close() close()
} }
} }

View File

@ -227,7 +227,7 @@ open class EnterTanDialog(
} }
protected open fun handleChangeTanMediumResponseOnUiThread(newUsedTanMedium: TanMedium, response: BankingClientResponse) { protected open fun handleChangeTanMediumResponseOnUiThread(newUsedTanMedium: TanMedium, response: BankingClientResponse) {
if (response.isSuccessful) { if (response.successful) {
dialogService.showInfoMessageOnUiThread(String.format(messages["enter.tan.dialog.tan.medium.successfully.changed"], dialogService.showInfoMessageOnUiThread(String.format(messages["enter.tan.dialog.tan.medium.successfully.changed"],
newUsedTanMedium.displayName), null, currentStage) newUsedTanMedium.displayName), null, currentStage)

View File

@ -1,7 +1,6 @@
package net.dankito.banking.ui.model.responses package net.dankito.banking.ui.model.responses
import net.dankito.banking.ui.model.* import net.dankito.banking.ui.model.*
import net.dankito.utils.multiplatform.BigDecimal
open class AddAccountResponse( open class AddAccountResponse(
@ -14,8 +13,8 @@ open class AddAccountResponse(
constructor(customer: TypedCustomer, errorToShowToUser: String?) : this(customer, listOf(), errorToShowToUser) constructor(customer: TypedCustomer, errorToShowToUser: String?) : this(customer, listOf(), errorToShowToUser)
override val isSuccessful: Boolean override val successful: Boolean
get() = super.isSuccessful && customer.accounts.isNotEmpty() get() = super.successful && customer.accounts.isNotEmpty()
open val supportsRetrievingTransactionsOfLast90DaysWithoutTan: Boolean open val supportsRetrievingTransactionsOfLast90DaysWithoutTan: Boolean
get() = retrievedData.isNotEmpty() && retrievedData.any { it.successfullyRetrievedData } get() = retrievedData.isNotEmpty() && retrievedData.any { it.successfullyRetrievedData }

View File

@ -2,14 +2,14 @@ package net.dankito.banking.ui.model.responses
open class BankingClientResponse( open class BankingClientResponse(
open val isSuccessful: Boolean, open val successful: Boolean,
open val errorToShowToUser: String?, open val errorToShowToUser: String?,
open val userCancelledAction: Boolean = false // TODO: not implemented in hbci4jBankingClient yet open val userCancelledAction: Boolean = false // TODO: not implemented in hbci4jBankingClient yet
) { ) {
override fun toString(): String { override fun toString(): String {
return if (isSuccessful) { return if (successful) {
"Successful" "Successful"
} }
else { else {

View File

@ -18,7 +18,7 @@ open class GetTransactionsResponse(
constructor(retrievedData: List<RetrievedAccountData>) : this(retrievedData, null) constructor(retrievedData: List<RetrievedAccountData>) : this(retrievedData, null)
override val isSuccessful: Boolean override val successful: Boolean
get() = errorToShowToUser == null && retrievedData.isNotEmpty() && retrievedData.none { it.successfullyRetrievedData == false } get() = errorToShowToUser == null && retrievedData.isNotEmpty() && retrievedData.none { it.successfullyRetrievedData == false }
} }

View File

@ -151,7 +151,7 @@ open class BankingPresenter(
val account = response.customer val account = response.customer
account.displayIndex = customers.size account.displayIndex = customers.size
if (response.isSuccessful) { if (response.successful) {
addClientForAccount(account, newClient) addClientForAccount(account, newClient)
selectedAccount(account) selectedAccount(account)
@ -333,7 +333,7 @@ open class BankingPresenter(
} }
protected open fun retrievedAccountTransactions(response: GetTransactionsResponse, startDate: Date, didFetchAllTransactions: Boolean) { protected open fun retrievedAccountTransactions(response: GetTransactionsResponse, startDate: Date, didFetchAllTransactions: Boolean) {
if (response.isSuccessful) { if (response.successful) {
response.retrievedData.forEach { retrievedData -> response.retrievedData.forEach { retrievedData ->
retrievedData.account.lastRetrievedTransactionsTimestamp = startDate retrievedData.account.lastRetrievedTransactionsTimestamp = startDate
@ -443,7 +443,7 @@ open class BankingPresenter(
getBankingClientForAccount(account.customer)?.let { client -> getBankingClientForAccount(account.customer)?.let { client ->
client.transferMoneyAsync(data) { response -> client.transferMoneyAsync(data) { response ->
if (response.isSuccessful) { if (response.successful) {
updateBankAccountTransactionsAsync(account, true) { } updateBankAccountTransactionsAsync(account, true) { }
} }

View File

@ -164,11 +164,13 @@ struct AccountTransactionsDialog: View {
presenter.updateSelectedBankAccountTransactionsAsync { response in presenter.updateSelectedBankAccountTransactionsAsync { response in
executingDone() executingDone()
if response.isSuccessful { if response.successful {
self.filterTransactions(self.searchText) self.filterTransactions(self.searchText)
} }
else if response.userCancelledAction == false { else if response.userCancelledAction == false {
self.errorMessage = Message(title: Text("Could not fetch latest transactions"), message: Text("Could not fetch latest transactions for \(response.bankAccount.displayName). Error message from your bank: \(response.errorToShowToUser ?? "").")) if let failedAccount = getAccountThatFailed(response) {
self.errorMessage = Message(title: Text("Could not fetch latest transactions"), message: Text("Could not fetch latest transactions for \(failedAccount.displayName). Error message from your bank: \(response.errorToShowToUser ?? "")."))
}
} }
} }
} }
@ -184,11 +186,13 @@ struct AccountTransactionsDialog: View {
self.haveAllTransactionsBeenFetched = self.accountsForWhichNotAllTransactionsHaveBeenFetched.isEmpty self.haveAllTransactionsBeenFetched = self.accountsForWhichNotAllTransactionsHaveBeenFetched.isEmpty
self.showFetchAllTransactionsOverlay = shouldShowFetchAllTransactionsOverlay self.showFetchAllTransactionsOverlay = shouldShowFetchAllTransactionsOverlay
if response.isSuccessful { if response.successful {
self.filterTransactions(self.searchText) self.filterTransactions(self.searchText)
} }
else if response.userCancelledAction == false { else if response.userCancelledAction == false {
self.errorMessage = Message(title: Text("Could not fetch all transactions"), message: Text("Could not fetch all transactions for \(response.bankAccount.displayName). Error message from your bank: \(response.errorToShowToUser ?? "").")) 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 ?? "")."))
}
} }
} }
@ -198,6 +202,10 @@ struct AccountTransactionsDialog: View {
self.balanceOfFilteredTransactions = query.isBlank ? balanceOfAllTransactions : filteredTransactions.sumAmounts() self.balanceOfFilteredTransactions = query.isBlank ? balanceOfAllTransactions : filteredTransactions.sumAmounts()
} }
private func getAccountThatFailed(_ response: GetTransactionsResponse) -> IBankAccount? {
return response.retrievedData.first { $0.successfullyRetrievedData == false }?.account
}
private func doNotShowFetchAllTransactionsOverlayAnymore() { private func doNotShowFetchAllTransactionsOverlayAnymore() {
for account in accountsForWhichNotAllTransactionsHaveBeenFetched { for account in accountsForWhichNotAllTransactionsHaveBeenFetched {

View File

@ -94,7 +94,7 @@ struct AddAccountDialog: View {
func handleAddAccountResponse(_ response: AddAccountResponse) { func handleAddAccountResponse(_ response: AddAccountResponse) {
isTryingToAddAccount = false isTryingToAddAccount = false
if (response.isSuccessful) { if (response.successful) {
DispatchQueue.main.async { // dispatch async as may EnterTanDialog is still displayed so dismiss() won't dismiss this view DispatchQueue.main.async { // dispatch async as may EnterTanDialog is still displayed so dismiss() won't dismiss this view
self.closeDialog() self.closeDialog()

View File

@ -168,7 +168,7 @@ struct EnterTanDialog: View {
} }
private func handleChangeTanMediumResponse(_ newTanMedium: TanMedium, _ changeTanMediumResponse: BankingClientResponse) { private func handleChangeTanMediumResponse(_ newTanMedium: TanMedium, _ changeTanMediumResponse: BankingClientResponse) {
if (changeTanMediumResponse.isSuccessful) { if (changeTanMediumResponse.successful) {
self.errorMessage = Message(title: Text("TAN medium change"), message: Text("TAN medium successfully changed to \(newTanMedium.displayName).")) self.errorMessage = Message(title: Text("TAN medium change"), message: Text("TAN medium successfully changed to \(newTanMedium.displayName)."))
} }
else { else {

View File

@ -402,7 +402,7 @@ struct TransferMoneyDialog: View {
private func handleTransferMoneyResponse(_ data: TransferMoneyData, _ response: BankingClientResponse) { private func handleTransferMoneyResponse(_ data: TransferMoneyData, _ response: BankingClientResponse) {
isTransferringMoney = false isTransferringMoney = false
if (response.isSuccessful) { if (response.successful) {
self.transferMoneyResponseMessage = Message(message: Text("Successfully transferred \(data.amount) \("") to \(data.creditorName)."), primaryButton: .ok { self.transferMoneyResponseMessage = Message(message: Text("Successfully transferred \(data.amount) \("") to \(data.creditorName)."), primaryButton: .ok {
self.presentation.wrappedValue.dismiss() self.presentation.wrappedValue.dismiss()
}) })

View File

@ -153,7 +153,7 @@ open class fints4kBankingClient(
} }
else if (didTryToGetAccountDataFromBank == false) { // then try to get account data by fetching data from bank else if (didTryToGetAccountDataFromBank == false) { // then try to get account data by fetching data from bank
addAccountAsync { response -> addAccountAsync { response ->
didTryToGetAccountDataFromBank = !!! response.isSuccessful didTryToGetAccountDataFromBank = !!! response.successful
findAccountResult(mapper.findAccountForBankAccount(bank, bankAccount), findAccountResult(mapper.findAccountForBankAccount(bank, bankAccount),
response.errorToShowToUser) response.errorToShowToUser)

View File

@ -25,7 +25,7 @@ open class fints4kModelMapper(protected val modelCreator: IModelCreator) {
open fun mapResponse(response: FinTsClientResponse): BankingClientResponse { open fun mapResponse(response: FinTsClientResponse): BankingClientResponse {
return BankingClientResponse(response.isSuccessful, mapErrorToShowToUser(response), response.userCancelledAction) return BankingClientResponse(response.successful, mapErrorToShowToUser(response), response.userCancelledAction)
} }
open fun mapResponse(customer: TypedCustomer, response: net.dankito.banking.fints.response.client.AddAccountResponse): AddAccountResponse { open fun mapResponse(customer: TypedCustomer, response: net.dankito.banking.fints.response.client.AddAccountResponse): AddAccountResponse {