diff --git a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/transactions/Mt940AccountTransactionsParser.kt b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/transactions/Mt940AccountTransactionsParser.kt index 0c6ccba8..ae587147 100644 --- a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/transactions/Mt940AccountTransactionsParser.kt +++ b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/transactions/Mt940AccountTransactionsParser.kt @@ -53,10 +53,10 @@ open class Mt940AccountTransactionsParser( transaction.information?.otherPartyName, transaction.information?.otherPartyBankCode, transaction.information?.otherPartyAccountId, - transaction.information?.bookingText, + transaction.information?.postingText, transaction.statementLine.valueDate, statement.statementNumber, - statement.sequenceNumber, + statement.sheetNumber, Money(mapAmount(statement.openingBalance), currency), // TODO: that's not true, these are the opening and closing balance of Money(mapAmount(statement.closingBalance), currency), // all transactions of this day, not this specific transaction's ones @@ -71,17 +71,17 @@ open class Mt940AccountTransactionsParser( transaction.information?.deviantOriginator, transaction.information?.deviantRecipient, transaction.information?.referenceWithNoSpecialType, - transaction.information?.primaNotaNumber, - transaction.information?.textKeySupplement, + transaction.information?.journalNumber, + transaction.information?.textKeyAddition, transaction.statementLine.currencyType, - transaction.statementLine.bookingKey, - transaction.statementLine.referenceForTheAccountOwner, - transaction.statementLine.referenceOfTheAccountServicingInstitution, - transaction.statementLine.supplementaryDetails, + transaction.statementLine.postingKey, + transaction.statementLine.customerReference, + transaction.statementLine.bankReference, + transaction.statementLine.furtherInformationOriginalAmountAndCharges, - statement.transactionReferenceNumber, - statement.relatedReferenceNumber + statement.orderReferenceNumber, + statement.referenceNumber ) } diff --git a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/transactions/mt940/Mt940Parser.kt b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/transactions/mt940/Mt940Parser.kt index 82de5478..617e06e1 100644 --- a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/transactions/mt940/Mt940Parser.kt +++ b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/transactions/mt940/Mt940Parser.kt @@ -34,9 +34,9 @@ open class Mt940Parser( val AccountStatementFieldSeparatorRegex = Regex("(? 1) accountIdentification[1] else null, statementAndMaySequenceNumber[0].toInt(), @@ -210,7 +210,7 @@ open class Mt940Parser( val statementLine = parseStatementLine(pair.second) val nextPair = if (index < fieldsByCode.size - 1) fieldsByCode.get(index + 1) else null - val information = if (nextPair?.first == InformationToAccountOwnerCode) parseNullableInformationToAccountOwner(nextPair.second) else null + val information = if (nextPair?.first == RemittanceInformationFieldCode) parseNullableRemittanceInformationField(nextPair.second) else null transactions.add(Transaction(statementLine, information)) } @@ -295,24 +295,24 @@ open class Mt940Parser( customerReference, bankReference, furtherInformation) } - protected open fun parseNullableInformationToAccountOwner(informationToAccountOwnerString: String): InformationToAccountOwner? { + protected open fun parseNullableRemittanceInformationField(remittanceInformationFieldString: String): RemittanceInformationField? { try { - val information = parseInformationToAccountOwner(informationToAccountOwnerString) + val information = parseRemittanceInformationField(remittanceInformationFieldString) mapReference(information) return information } catch (e: Exception) { - logError("Could not parse InformationToAccountOwner from field value '$informationToAccountOwnerString'", e) + logError("Could not parse RemittanceInformationField from field value '$remittanceInformationFieldString'", e) } return null } - protected open fun parseInformationToAccountOwner(informationToAccountOwnerString: String): InformationToAccountOwner { + protected open fun parseRemittanceInformationField(remittanceInformationFieldString: String): RemittanceInformationField { // e. g. starts with 0 -> Inlandszahlungsverkehr, starts with '3' -> Wertpapiergeschäft // see Finanzdatenformate p. 209 - 215 - val geschaeftsvorfallCode = informationToAccountOwnerString.substring(0, 2) // TODO: may map + val geschaeftsvorfallCode = remittanceInformationFieldString.substring(0, 2) // TODO: may map val referenceParts = mutableListOf() val otherPartyName = StringBuilder() @@ -322,11 +322,11 @@ open class Mt940Parser( var primaNotaNumber: String? = null var textKeySupplement: String? = null - val subFieldMatches = InformationToAccountOwnerSubFieldRegex.findAll(informationToAccountOwnerString).toList() + val subFieldMatches = RemittanceInformationSubFieldRegex.findAll(remittanceInformationFieldString).toList() subFieldMatches.forEachIndexed { index, matchResult -> val fieldCode = matchResult.value.substring(1, 3).toInt() - val endIndex = if (index + 1 < subFieldMatches.size) subFieldMatches[index + 1].range.start else informationToAccountOwnerString.length - val fieldValue = informationToAccountOwnerString.substring(matchResult.range.last + 1, endIndex) + val endIndex = if (index + 1 < subFieldMatches.size) subFieldMatches[index + 1].range.start else remittanceInformationFieldString.length + val fieldValue = remittanceInformationFieldString.substring(matchResult.range.last + 1, endIndex) when (fieldCode) { 0 -> bookingText = fieldValue @@ -345,7 +345,7 @@ open class Mt940Parser( val otherPartyNameString = if (otherPartyName.isBlank()) null else otherPartyName.toString() - return InformationToAccountOwner( + return RemittanceInformationField( reference, otherPartyNameString, otherPartyBankCode, otherPartyAccountId, bookingText, primaNotaNumber, textKeySupplement ) @@ -396,7 +396,7 @@ open class Mt940Parser( * * Weitere 4 Verwendungszwecke können zu den Feldschlüsseln 60 bis 63 eingestellt werden. */ - protected open fun mapReference(information: InformationToAccountOwner) { + protected open fun mapReference(information: RemittanceInformationField) { val referenceParts = getReferenceParts(information.unparsedReference) referenceParts.forEach { entry -> @@ -431,7 +431,7 @@ open class Mt940Parser( } // TODO: there are more. See .pdf from Deutsche Bank - protected open fun setReferenceLineValue(information: InformationToAccountOwner, referenceType: String, typeValue: String) { + protected open fun setReferenceLineValue(information: RemittanceInformationField, referenceType: String, typeValue: String) { when (referenceType) { EndToEndReferenceKey -> information.endToEndReference = typeValue CustomerReferenceKey -> information.customerReference = typeValue diff --git a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/transactions/mt940/model/InformationToAccountOwner.kt b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/transactions/mt940/model/RemittanceInformationField.kt similarity index 98% rename from fints4k/src/commonMain/kotlin/net/codinux/banking/fints/transactions/mt940/model/InformationToAccountOwner.kt rename to fints4k/src/commonMain/kotlin/net/codinux/banking/fints/transactions/mt940/model/RemittanceInformationField.kt index f76a4d1f..acf664df 100644 --- a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/transactions/mt940/model/InformationToAccountOwner.kt +++ b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/transactions/mt940/model/RemittanceInformationField.kt @@ -1,6 +1,6 @@ package net.codinux.banking.fints.transactions.mt940.model -open class InformationToAccountOwner( +open class RemittanceInformationField( val unparsedReference: String, /** * AT 02 Name des Überweisenden diff --git a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/transactions/mt940/model/Transaction.kt b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/transactions/mt940/model/Transaction.kt index bb37ec34..da26d6c8 100644 --- a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/transactions/mt940/model/Transaction.kt +++ b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/transactions/mt940/model/Transaction.kt @@ -4,7 +4,7 @@ package net.codinux.banking.fints.transactions.mt940.model open class Transaction( val statementLine: StatementLine, - val information: InformationToAccountOwner? = null + val information: RemittanceInformationField? = null ) {