From 70c1082531492fc252ceb14b24382eb6432f5e28 Mon Sep 17 00:00:00 2001 From: dankito Date: Thu, 5 Sep 2024 21:53:00 +0200 Subject: [PATCH] Renamed countDaysForWhichTransactionsAreKept to transactionsRetentionDays --- .../codinux/banking/fints/FinTsJobExecutor.kt | 2 +- .../banking/fints/mapper/FinTsModelMapper.kt | 2 +- .../codinux/banking/fints/model/AccountData.kt | 6 +++++- .../banking/fints/model/mapper/ModelMapper.kt | 2 +- .../banking/fints/response/ResponseParser.kt | 8 ++++---- .../RetrieveAccountTransactionsParameters.kt | 2 +- .../banking/client/model/BankAccount.kt | 2 +- .../fints/response/ResponseParserTest.kt | 18 +++++++++--------- 8 files changed, 23 insertions(+), 19 deletions(-) diff --git a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/FinTsJobExecutor.kt b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/FinTsJobExecutor.kt index 7f7dce9b..0cd7d684 100644 --- a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/FinTsJobExecutor.kt +++ b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/FinTsJobExecutor.kt @@ -240,7 +240,7 @@ open class FinTsJobExecutor( val successful = response.tanRequiredButWeWereToldToAbortIfSo || (response.successful && (parameter.alsoRetrieveBalance == false || balance != null)) val fromDate = parameter.fromDate - ?: parameter.account.countDaysForWhichTransactionsAreKept?.let { LocalDate.todayAtSystemDefaultTimeZone().minusDays(it) } + ?: parameter.account.transactionsRetentionDays?.let { LocalDate.todayAtSystemDefaultTimeZone().minusDays(it) } ?: bookedTransactions.minByOrNull { it.valueDate }?.valueDate val retrievedData = RetrievedAccountData(parameter.account, successful, balance, bookedTransactions, unbookedTransactions, startTime, fromDate, parameter.toDate ?: LocalDate.todayAtEuropeBerlin(), response.internalError) diff --git a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/mapper/FinTsModelMapper.kt b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/mapper/FinTsModelMapper.kt index bbbe1165..7850ae9b 100644 --- a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/mapper/FinTsModelMapper.kt +++ b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/mapper/FinTsModelMapper.kt @@ -55,7 +55,7 @@ open class FinTsModelMapper { open fun map(account: AccountData): BankAccount { return BankAccount(account.accountIdentifier, account.subAccountAttribute, account.iban, account.accountHolderName, map(account.accountType), account.productName, - account.currency ?: Currency.DefaultCurrencyCode, account.accountLimit, account.countDaysForWhichTransactionsAreKept, account.isAccountTypeSupportedByApplication, + account.currency ?: Currency.DefaultCurrencyCode, account.accountLimit, account.transactionsRetentionDays, account.isAccountTypeSupportedByApplication, account.supportsRetrievingAccountTransactions, account.supportsRetrievingBalance, account.supportsTransferringMoney, account.supportsRealTimeTransfer) } diff --git a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/model/AccountData.kt b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/model/AccountData.kt index fd7864fc..5aef0b22 100644 --- a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/model/AccountData.kt +++ b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/model/AccountData.kt @@ -32,7 +32,11 @@ open class AccountData( || allowedJobNames.contains(CustomerSegmentId.AccountTransactionsMt940.id) - open var countDaysForWhichTransactionsAreKept: Int? = null + + /** + * Count days for which transactions are stored on bank server (if available). + */ + open var transactionsRetentionDays: Int? = null protected open val _supportedFeatures = mutableSetOf() diff --git a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/model/mapper/ModelMapper.kt b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/model/mapper/ModelMapper.kt index 95f2c297..5c1dc466 100644 --- a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/model/mapper/ModelMapper.kt +++ b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/model/mapper/ModelMapper.kt @@ -102,7 +102,7 @@ open class ModelMapper( accountInfo.accountLimit, accountInfo.allowedJobNames) bank.supportedJobs.filterIsInstance().sortedByDescending { it.segmentVersion }.firstOrNull { newAccount.allowedJobNames.contains(it.jobName) }?.let { transactionsParameters -> - newAccount.countDaysForWhichTransactionsAreKept = transactionsParameters.countDaysForWhichTransactionsAreKept + newAccount.transactionsRetentionDays = transactionsParameters.transactionsRetentionDays } bank.addAccount(newAccount) diff --git a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/response/ResponseParser.kt b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/response/ResponseParser.kt index 94ff5252..e0329aca 100644 --- a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/response/ResponseParser.kt +++ b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/response/ResponseParser.kt @@ -748,11 +748,11 @@ open class ResponseParser( val transactionsParameterIndex = if (jobParameters.segmentVersion >= 6) 4 else 3 val dataElements = getDataElements(dataElementGroups[transactionsParameterIndex]) - val countDaysForWhichTransactionsAreKept = parseInt(dataElements[0]) + val transactionsRetentionDays = parseInt(dataElements[0]) val settingCountEntriesAllowed = parseBoolean(dataElements[1]) val settingAllAccountAllowed = if (dataElements.size > 2) parseBoolean(dataElements[2]) else false - return RetrieveAccountTransactionsParameters(jobParameters, countDaysForWhichTransactionsAreKept, settingCountEntriesAllowed, settingAllAccountAllowed) + return RetrieveAccountTransactionsParameters(jobParameters, transactionsRetentionDays, settingCountEntriesAllowed, settingAllAccountAllowed) } @@ -805,11 +805,11 @@ open class ResponseParser( val transactionsParameterIndex = if (jobParameters.segmentVersion >= 2) 4 else 3 // TODO: check if at segment version 1 the transactions parameter are the third data elements group val dataElements = getDataElements(dataElementGroups[transactionsParameterIndex]) - val countDaysForWhichTransactionsAreKept = parseInt(dataElements[0]) + val transactionsRetentionDays = parseInt(dataElements[0]) val settingCountEntriesAllowed = parseBoolean(dataElements[1]) val settingAllAccountAllowed = if (dataElements.size > 2) parseBoolean(dataElements[2]) else false - return RetrieveAccountTransactionsParameters(jobParameters, countDaysForWhichTransactionsAreKept, settingCountEntriesAllowed, settingAllAccountAllowed) + return RetrieveAccountTransactionsParameters(jobParameters, transactionsRetentionDays, settingCountEntriesAllowed, settingAllAccountAllowed) } diff --git a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/response/segments/RetrieveAccountTransactionsParameters.kt b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/response/segments/RetrieveAccountTransactionsParameters.kt index 4637dc65..b4dfbd12 100644 --- a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/response/segments/RetrieveAccountTransactionsParameters.kt +++ b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/response/segments/RetrieveAccountTransactionsParameters.kt @@ -3,7 +3,7 @@ package net.codinux.banking.fints.response.segments open class RetrieveAccountTransactionsParameters( parameters: JobParameters, - open val countDaysForWhichTransactionsAreKept: Int, + open val transactionsRetentionDays: Int, open val settingCountEntriesAllowed: Boolean, open val settingAllAccountAllowed: Boolean ) : JobParameters(parameters) { diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/client/model/BankAccount.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/client/model/BankAccount.kt index d2618344..9b828012 100644 --- a/fints4k/src/commonMain/kotlin/net/dankito/banking/client/model/BankAccount.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/client/model/BankAccount.kt @@ -18,7 +18,7 @@ open class BankAccount( open val currency: String = Currency.DefaultCurrencyCode, // TODO: may parse to a value object open val accountLimit: String? = null, - open val countDaysForWhichTransactionsAreKept: Int? = null, + open val transactionsRetentionDays: Int? = null, open val isAccountTypeSupportedByApplication: Boolean = false, // TODO: create an enum AccountCapabilities [ RetrieveBalance, RetrieveTransactions, TransferMoney / MoneyTransfer(?), InstantPayment ] open val supportsRetrievingTransactions: Boolean = false, diff --git a/fints4k/src/commonTest/kotlin/net/codinux/banking/fints/response/ResponseParserTest.kt b/fints4k/src/commonTest/kotlin/net/codinux/banking/fints/response/ResponseParserTest.kt index 289f18f3..f44beecb 100644 --- a/fints4k/src/commonTest/kotlin/net/codinux/banking/fints/response/ResponseParserTest.kt +++ b/fints4k/src/commonTest/kotlin/net/codinux/banking/fints/response/ResponseParserTest.kt @@ -1189,16 +1189,16 @@ class ResponseParserTest : FinTsTestBase() { fun parseAccountTransactionsMt940Parameters_Version4() { // given - val countDaysForWhichTransactionsAreKept = 90 + val transactionsRetentionDays = 90 // when - val result = underTest.parse("HIKAZS:21:4:4+20+1+$countDaysForWhichTransactionsAreKept:N'") + val result = underTest.parse("HIKAZS:21:4:4+20+1+$transactionsRetentionDays:N'") // then assertSuccessfullyParsedSegment(result, InstituteSegmentId.AccountTransactionsMt940Parameters, 21, 4, 4) result.getFirstSegmentById(InstituteSegmentId.AccountTransactionsMt940Parameters)?.let { segment -> - assertEquals(countDaysForWhichTransactionsAreKept, segment.countDaysForWhichTransactionsAreKept) + assertEquals(transactionsRetentionDays, segment.transactionsRetentionDays) assertFalse(segment.settingCountEntriesAllowed) assertFalse(segment.settingAllAccountAllowed) } @@ -1209,16 +1209,16 @@ class ResponseParserTest : FinTsTestBase() { fun parseAccountTransactionsMt940Parameters_Version6() { // given - val countDaysForWhichTransactionsAreKept = 90 + val transactionsRetentionDays = 90 // when - val result = underTest.parse("HIKAZS:23:6:4+20+1+1+$countDaysForWhichTransactionsAreKept:N:N'") + val result = underTest.parse("HIKAZS:23:6:4+20+1+1+$transactionsRetentionDays:N:N'") // then assertSuccessfullyParsedSegment(result, InstituteSegmentId.AccountTransactionsMt940Parameters, 23, 6, 4) result.getFirstSegmentById(InstituteSegmentId.AccountTransactionsMt940Parameters)?.let { segment -> - assertEquals(countDaysForWhichTransactionsAreKept, segment.countDaysForWhichTransactionsAreKept) + assertEquals(transactionsRetentionDays, segment.transactionsRetentionDays) assertFalse(segment.settingCountEntriesAllowed) assertFalse(segment.settingAllAccountAllowed) } @@ -1290,16 +1290,16 @@ class ResponseParserTest : FinTsTestBase() { fun parseCreditCardAccountTransactionsParameters() { // given - val countDaysForWhichTransactionsAreKept = 9999 + val transactionsRetentionDays = 9999 // when - val result = underTest.parse("DIKKUS:15:2:4+999+1+0+$countDaysForWhichTransactionsAreKept:J:J'") + val result = underTest.parse("DIKKUS:15:2:4+999+1+0+$transactionsRetentionDays:J:J'") // then assertSuccessfullyParsedSegment(result, InstituteSegmentId.CreditCardTransactionsParameters, 15, 2, 4) result.getFirstSegmentById(InstituteSegmentId.CreditCardTransactionsParameters)?.let { segment -> - assertEquals(countDaysForWhichTransactionsAreKept, segment.countDaysForWhichTransactionsAreKept) + assertEquals(transactionsRetentionDays, segment.transactionsRetentionDays) assertTrue(segment.settingCountEntriesAllowed) assertTrue(segment.settingAllAccountAllowed) }