diff --git a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/response/InstituteSegmentId.kt b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/response/InstituteSegmentId.kt index 6a95f9eb..f30ba0f5 100644 --- a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/response/InstituteSegmentId.kt +++ b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/response/InstituteSegmentId.kt @@ -41,6 +41,10 @@ enum class InstituteSegmentId(override val id: String) : ISegmentId { AccountTransactionsMt940Parameters(AccountTransactionsMt940.id + "S"), + AccountTransactionsCamt("HICAZ"), + + AccountTransactionsCamtParameters(AccountTransactionsCamt.id + "S"), + CreditCardTransactions("DIKKU"), CreditCardTransactionsParameters(CreditCardTransactions.id + "S"), 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 f59206da..1479d32b 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 @@ -124,6 +124,9 @@ open class ResponseParser( InstituteSegmentId.AccountTransactionsMt940.id -> parseMt940AccountTransactions(segment, dataElementGroups) InstituteSegmentId.AccountTransactionsMt940Parameters.id -> parseMt940AccountTransactionsParameters(segment, segmentId, dataElementGroups) +// InstituteSegmentId.AccountTransactionsCamt.id -> parseCamtAccountTransactions(segment, dataElementGroups) + InstituteSegmentId.AccountTransactionsCamtParameters.id -> parseCamtAccountTransactionsParameters(segment, segmentId, dataElementGroups) + InstituteSegmentId.CreditCardTransactions.id -> parseCreditCardTransactions(segment, dataElementGroups) InstituteSegmentId.CreditCardTransactionsParameters.id -> parseCreditCardTransactionsParameters(segment, segmentId, dataElementGroups) @@ -766,6 +769,20 @@ open class ResponseParser( return RetrieveAccountTransactionsParameters(jobParameters, serverTransactionsRetentionDays, settingCountEntriesAllowed, settingAllAccountAllowed) } + protected open fun parseCamtAccountTransactionsParameters(segment: String, segmentId: String, dataElementGroups: List): RetrieveAccountTransactionsParameters { + val jobParameters = parseJobParameters(segment, segmentId, dataElementGroups) + + val dataElements = getDataElements(dataElementGroups[4]) + + val serverTransactionsRetentionDays = parseInt(dataElements[0]) + val settingCountEntriesAllowed = parseBoolean(dataElements[1]) + val settingAllAccountAllowed = parseBoolean(dataElements[2]) + + val supportedCamtDataFormats = dataElements.subList(3, dataElements.size) + + return RetrieveAccountTransactionsParameters(jobParameters, serverTransactionsRetentionDays, settingCountEntriesAllowed, settingAllAccountAllowed, supportedCamtDataFormats) + } + protected open fun parseCreditCardTransactions(segment: String, dataElementGroups: List): ReceivedCreditCardTransactionsAndBalance { val balance = parseBalance(dataElementGroups[3]) 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 2acff059..fbfaf822 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 @@ -5,9 +5,14 @@ open class RetrieveAccountTransactionsParameters( parameters: JobParameters, open val serverTransactionsRetentionDays: Int, open val settingCountEntriesAllowed: Boolean, - open val settingAllAccountAllowed: Boolean + open val settingAllAccountAllowed: Boolean, + open val supportedCamtDataFormats: List = emptyList() ) : JobParameters(parameters) { internal constructor() : this(JobParameters(), -1, false, false) // for object deserializers + // for languages not supporting default parameters + constructor(parameters: JobParameters, serverTransactionsRetentionDays: Int, settingCountEntriesAllowed: Boolean, settingAllAccountAllowed: Boolean) : + this(parameters, serverTransactionsRetentionDays, settingCountEntriesAllowed, settingAllAccountAllowed, emptyList()) + } \ No newline at end of file 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 59de76e3..79f021d7 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 @@ -1226,6 +1226,24 @@ class ResponseParserTest : FinTsTestBase() { } + @Test + fun parseAccountTransactionsCamtParameters() { + val result = underTest.parse("HICAZS:56:1:3+1+1+1+740:N:N:urn?:iso?:std?:iso?:20022?:tech?:xsd?:camt.052.001.02:urn?:iso?:std?:iso?:20022?:tech?:xsd?:camt.052.001.08'") + + // then + assertSuccessfullyParsedSegment(result, InstituteSegmentId.AccountTransactionsCamtParameters, 56, 1, 3) + + result.getFirstSegmentById(InstituteSegmentId.AccountTransactionsCamtParameters)?.let { segment -> + assertEquals(740, segment.serverTransactionsRetentionDays) + assertFalse(segment.settingCountEntriesAllowed) + assertFalse(segment.settingAllAccountAllowed) + + assertContainsExactly(segment.supportedCamtDataFormats, "urn:iso:std:iso:20022:tech:xsd:camt.052.001.02", "urn:iso:std:iso:20022:tech:xsd:camt.052.001.08") + } + ?: run { fail("No segment of type AccountTransactionsCamtParameters found in ${result.receivedSegments}") } + } + + @Test fun parseCreditCardAccountTransactions() {