diff --git a/fints4k/src/main/kotlin/net/dankito/fints/FinTsClient.kt b/fints4k/src/main/kotlin/net/dankito/fints/FinTsClient.kt index 0255d786..4ea8929a 100644 --- a/fints4k/src/main/kotlin/net/dankito/fints/FinTsClient.kt +++ b/fints4k/src/main/kotlin/net/dankito/fints/FinTsClient.kt @@ -899,13 +899,13 @@ open class FinTsClient @JvmOverloads constructor( val supportedJobs = response.supportedJobs if (supportedJobs.isNotEmpty()) { // if allowedJobsForBank is empty than bank didn't send any allowed job for (account in customer.accounts) { - setAllowedJobsForAccount(account, supportedJobs) + setAllowedJobsForAccount(bank, account, supportedJobs) } } else if (bank.supportedJobs.isNotEmpty()) { for (account in customer.accounts) { if (account.allowedJobs.isEmpty()) { - setAllowedJobsForAccount(account, bank.supportedJobs) + setAllowedJobsForAccount(bank, account, bank.supportedJobs) } } } @@ -919,7 +919,7 @@ open class FinTsClient @JvmOverloads constructor( return bank.supportedTanProcedures.firstOrNull { it.securityFunction == securityFunction } } - protected open fun setAllowedJobsForAccount(account: AccountData, supportedJobs: List) { + protected open fun setAllowedJobsForAccount(bank: BankData, account: AccountData, supportedJobs: List) { val allowedJobsForAccount = mutableListOf() for (job in supportedJobs) { @@ -932,8 +932,8 @@ open class FinTsClient @JvmOverloads constructor( account.setSupportsFeature(AccountFeature.RetrieveAccountTransactions, messageBuilder.supportsGetTransactions(account)) account.setSupportsFeature(AccountFeature.RetrieveBalance, messageBuilder.supportsGetBalance(account)) - account.setSupportsFeature(AccountFeature.TransferMoney, messageBuilder.supportsBankTransfer(account)) - account.setSupportsFeature(AccountFeature.InstantPayment, messageBuilder.supportsSepaInstantPaymentBankTransfer(account)) + account.setSupportsFeature(AccountFeature.TransferMoney, messageBuilder.supportsBankTransfer(bank, account)) + account.setSupportsFeature(AccountFeature.InstantPayment, messageBuilder.supportsSepaInstantPaymentBankTransfer(bank, account)) } protected open fun mapToTanProcedures(tanInfo: TanInfo): List { diff --git a/fints4k/src/main/kotlin/net/dankito/fints/messages/MessageBuilder.kt b/fints4k/src/main/kotlin/net/dankito/fints/messages/MessageBuilder.kt index 14290cb6..b4815916 100644 --- a/fints4k/src/main/kotlin/net/dankito/fints/messages/MessageBuilder.kt +++ b/fints4k/src/main/kotlin/net/dankito/fints/messages/MessageBuilder.kt @@ -201,7 +201,7 @@ open class MessageBuilder(protected val generator: ISegmentNumberGenerator = Seg val segmentId = if (data.instantPayment) CustomerSegmentId.SepaInstantPaymentBankTransfer else CustomerSegmentId.SepaBankTransfer - val messageBuilderResultAndNullableUrn = supportsBankTransferAndSepaVersion(account, segmentId) + val messageBuilderResultAndNullableUrn = supportsBankTransferAndSepaVersion(dialogContext.bank, account, segmentId) val result = messageBuilderResultAndNullableUrn.first val urn = messageBuilderResultAndNullableUrn.second @@ -217,24 +217,24 @@ open class MessageBuilder(protected val generator: ISegmentNumberGenerator = Seg return result } - open fun supportsBankTransfer(account: AccountData): Boolean { - return supportsBankTransferAndSepaVersion(account, CustomerSegmentId.SepaBankTransfer).first.isJobVersionSupported + open fun supportsBankTransfer(bank: BankData, account: AccountData): Boolean { + return supportsBankTransferAndSepaVersion(bank, account, CustomerSegmentId.SepaBankTransfer).first.isJobVersionSupported } - open fun supportsSepaInstantPaymentBankTransfer(account: AccountData): Boolean { - return supportsBankTransferAndSepaVersion(account, CustomerSegmentId.SepaInstantPaymentBankTransfer).first.isJobVersionSupported + open fun supportsSepaInstantPaymentBankTransfer(bank: BankData, account: AccountData): Boolean { + return supportsBankTransferAndSepaVersion(bank, account, CustomerSegmentId.SepaInstantPaymentBankTransfer).first.isJobVersionSupported } - protected open fun supportsBankTransferAndSepaVersion(account: AccountData, segmentId: CustomerSegmentId): Pair { + protected open fun supportsBankTransferAndSepaVersion(bank: BankData, account: AccountData, segmentId: CustomerSegmentId): Pair { val result = getSupportedVersionsOfJob(segmentId, account, listOf(1)) if (result.isJobVersionSupported) { - getSepaUrnFor(CustomerSegmentId.SepaAccountInfoParameters, account, "pain.001.001.03")?.let { urn -> + getSepaUrnFor(CustomerSegmentId.SepaAccountInfoParameters, bank, "pain.001.001.03")?.let { urn -> return Pair(result, urn) } - getSepaUrnFor(CustomerSegmentId.SepaAccountInfoParameters, account, "pain.001.003.03")?.let { urn -> + getSepaUrnFor(CustomerSegmentId.SepaAccountInfoParameters, bank, "pain.001.003.03")?.let { urn -> return Pair(result, urn) } @@ -411,9 +411,9 @@ open class MessageBuilder(protected val generator: ISegmentNumberGenerator = Seg ?: false // TODO: actually in this case it's not allowed to execute job via PIN/TAN at all } - protected open fun getSepaUrnFor(segmentId: CustomerSegmentId, account: AccountData, sepaDataFormat: String): String? { + protected open fun getSepaUrnFor(segmentId: CustomerSegmentId, bank: BankData, sepaDataFormat: String): String? { - return getAllowedJobs(segmentId, account) + return bank.supportedJobs .filterIsInstance() .sortedByDescending { it.segmentVersion } .flatMap { it.supportedSepaFormats }