Fixed that if balance should not get fetched that we did abort instead of continuing with retrieving transactions
This commit is contained in:
parent
fad4c48b41
commit
e8e35a3fe2
|
@ -196,7 +196,7 @@ open class FinTsJobExecutor(
|
||||||
else {
|
else {
|
||||||
mayGetBalance(parameter, dialogContext) { balanceResponse ->
|
mayGetBalance(parameter, dialogContext) { balanceResponse ->
|
||||||
if (dialogContext.didBankCloseDialog) {
|
if (dialogContext.didBankCloseDialog) {
|
||||||
callback(GetTransactionsResponse(balanceResponse, RetrievedAccountData.unsuccessfulList(parameter.account)))
|
callback(GetTransactionsResponse(balanceResponse ?: initDialogResponse, RetrievedAccountData.unsuccessfulList(parameter.account)))
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
getTransactionsAfterInitAndGetBalance(parameter, dialogContext, balanceResponse, callback)
|
getTransactionsAfterInitAndGetBalance(parameter, dialogContext, balanceResponse, callback)
|
||||||
|
@ -207,8 +207,8 @@ open class FinTsJobExecutor(
|
||||||
}
|
}
|
||||||
|
|
||||||
protected open fun getTransactionsAfterInitAndGetBalance(parameter: GetTransactionsParameter, dialogContext: DialogContext,
|
protected open fun getTransactionsAfterInitAndGetBalance(parameter: GetTransactionsParameter, dialogContext: DialogContext,
|
||||||
balanceResponse: BankResponse, callback: (GetTransactionsResponse) -> Unit) {
|
balanceResponse: BankResponse?, callback: (GetTransactionsResponse) -> Unit) {
|
||||||
var balance: Money? = balanceResponse.getFirstSegmentById<BalanceSegment>(InstituteSegmentId.Balance)?.let {
|
var balance: Money? = balanceResponse?.getFirstSegmentById<BalanceSegment>(InstituteSegmentId.Balance)?.let {
|
||||||
Money(it.balance, it.currency)
|
Money(it.balance, it.currency)
|
||||||
}
|
}
|
||||||
val bookedTransactions = mutableSetOf<AccountTransaction>()
|
val bookedTransactions = mutableSetOf<AccountTransaction>()
|
||||||
|
@ -255,7 +255,7 @@ open class FinTsJobExecutor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected open fun mayGetBalance(parameter: GetTransactionsParameter, dialogContext: DialogContext, callback: (BankResponse) -> Unit) {
|
protected open fun mayGetBalance(parameter: GetTransactionsParameter, dialogContext: DialogContext, callback: (BankResponse?) -> Unit) {
|
||||||
if (parameter.alsoRetrieveBalance && parameter.account.supportsRetrievingBalance) {
|
if (parameter.alsoRetrieveBalance && parameter.account.supportsRetrievingBalance) {
|
||||||
val message = messageBuilder.createGetBalanceMessage(parameter.account, dialogContext)
|
val message = messageBuilder.createGetBalanceMessage(parameter.account, dialogContext)
|
||||||
|
|
||||||
|
@ -264,8 +264,7 @@ open class FinTsJobExecutor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
callback(BankResponse(false, errorMessage = "Either not requested to get balance or account does not support retrieving balance. " +
|
callback(null)
|
||||||
"Should retrieve balance = ${parameter.alsoRetrieveBalance}, account supports retrieving balance = ${parameter.account.supportsRetrievingBalance}."))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue