Adjusted names according to English Translation of DFÜ-Abkommen Anlage_3_Datenformate_V3.8.pdf (Appendix_3-Data_Formats_V3-8.pdf)

This commit is contained in:
dankito 2024-09-05 18:16:22 +02:00
parent f90e280b74
commit 47e2b851b9
4 changed files with 30 additions and 30 deletions

View File

@ -53,10 +53,10 @@ open class Mt940AccountTransactionsParser(
transaction.information?.otherPartyName, transaction.information?.otherPartyName,
transaction.information?.otherPartyBankCode, transaction.information?.otherPartyBankCode,
transaction.information?.otherPartyAccountId, transaction.information?.otherPartyAccountId,
transaction.information?.bookingText, transaction.information?.postingText,
transaction.statementLine.valueDate, transaction.statementLine.valueDate,
statement.statementNumber, 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.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 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?.deviantOriginator,
transaction.information?.deviantRecipient, transaction.information?.deviantRecipient,
transaction.information?.referenceWithNoSpecialType, transaction.information?.referenceWithNoSpecialType,
transaction.information?.primaNotaNumber, transaction.information?.journalNumber,
transaction.information?.textKeySupplement, transaction.information?.textKeyAddition,
transaction.statementLine.currencyType, transaction.statementLine.currencyType,
transaction.statementLine.bookingKey, transaction.statementLine.postingKey,
transaction.statementLine.referenceForTheAccountOwner, transaction.statementLine.customerReference,
transaction.statementLine.referenceOfTheAccountServicingInstitution, transaction.statementLine.bankReference,
transaction.statementLine.supplementaryDetails, transaction.statementLine.furtherInformationOriginalAmountAndCharges,
statement.transactionReferenceNumber, statement.orderReferenceNumber,
statement.relatedReferenceNumber statement.referenceNumber
) )
} }

View File

@ -34,9 +34,9 @@ open class Mt940Parser(
val AccountStatementFieldSeparatorRegex = Regex("(?<!T\\d\\d(:\\d\\d)?):\\d\\d\\w?:") val AccountStatementFieldSeparatorRegex = Regex("(?<!T\\d\\d(:\\d\\d)?):\\d\\d\\w?:")
const val TransactionReferenceNumberCode = "20" const val OrderReferenceNumberCode = "20"
const val RelatedReferenceNumberCode = "21" const val ReferenceNumberCode = "21"
const val AccountIdentificationCode = "25" const val AccountIdentificationCode = "25"
@ -46,7 +46,7 @@ open class Mt940Parser(
const val StatementLineCode = "61" const val StatementLineCode = "61"
const val InformationToAccountOwnerCode = "86" const val RemittanceInformationFieldCode = "86"
const val ClosingBalanceCode = "62" const val ClosingBalanceCode = "62"
@ -61,7 +61,7 @@ open class Mt940Parser(
val ReferenceTypeRegex = Regex("[A-Z]{4}\\+") val ReferenceTypeRegex = Regex("[A-Z]{4}\\+")
val InformationToAccountOwnerSubFieldRegex = Regex("\\?\\d\\d") val RemittanceInformationSubFieldRegex = Regex("\\?\\d\\d")
const val EndToEndReferenceKey = "EREF+" const val EndToEndReferenceKey = "EREF+"
@ -169,8 +169,8 @@ open class Mt940Parser(
val closingBalancePair = fieldsByCode.first { it.first.startsWith(ClosingBalanceCode) } val closingBalancePair = fieldsByCode.first { it.first.startsWith(ClosingBalanceCode) }
return AccountStatement( return AccountStatement(
getFieldValue(fieldsByCode, TransactionReferenceNumberCode), getFieldValue(fieldsByCode, OrderReferenceNumberCode),
getOptionalFieldValue(fieldsByCode, RelatedReferenceNumberCode), getOptionalFieldValue(fieldsByCode, ReferenceNumberCode),
accountIdentification[0], accountIdentification[0],
if (accountIdentification.size > 1) accountIdentification[1] else null, if (accountIdentification.size > 1) accountIdentification[1] else null,
statementAndMaySequenceNumber[0].toInt(), statementAndMaySequenceNumber[0].toInt(),
@ -210,7 +210,7 @@ open class Mt940Parser(
val statementLine = parseStatementLine(pair.second) val statementLine = parseStatementLine(pair.second)
val nextPair = if (index < fieldsByCode.size - 1) fieldsByCode.get(index + 1) else null 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)) transactions.add(Transaction(statementLine, information))
} }
@ -295,24 +295,24 @@ open class Mt940Parser(
customerReference, bankReference, furtherInformation) customerReference, bankReference, furtherInformation)
} }
protected open fun parseNullableInformationToAccountOwner(informationToAccountOwnerString: String): InformationToAccountOwner? { protected open fun parseNullableRemittanceInformationField(remittanceInformationFieldString: String): RemittanceInformationField? {
try { try {
val information = parseInformationToAccountOwner(informationToAccountOwnerString) val information = parseRemittanceInformationField(remittanceInformationFieldString)
mapReference(information) mapReference(information)
return information return information
} catch (e: Exception) { } 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 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 // e. g. starts with 0 -> Inlandszahlungsverkehr, starts with '3' -> Wertpapiergeschäft
// see Finanzdatenformate p. 209 - 215 // 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<String>() val referenceParts = mutableListOf<String>()
val otherPartyName = StringBuilder() val otherPartyName = StringBuilder()
@ -322,11 +322,11 @@ open class Mt940Parser(
var primaNotaNumber: String? = null var primaNotaNumber: String? = null
var textKeySupplement: String? = null var textKeySupplement: String? = null
val subFieldMatches = InformationToAccountOwnerSubFieldRegex.findAll(informationToAccountOwnerString).toList() val subFieldMatches = RemittanceInformationSubFieldRegex.findAll(remittanceInformationFieldString).toList()
subFieldMatches.forEachIndexed { index, matchResult -> subFieldMatches.forEachIndexed { index, matchResult ->
val fieldCode = matchResult.value.substring(1, 3).toInt() val fieldCode = matchResult.value.substring(1, 3).toInt()
val endIndex = if (index + 1 < subFieldMatches.size) subFieldMatches[index + 1].range.start else informationToAccountOwnerString.length val endIndex = if (index + 1 < subFieldMatches.size) subFieldMatches[index + 1].range.start else remittanceInformationFieldString.length
val fieldValue = informationToAccountOwnerString.substring(matchResult.range.last + 1, endIndex) val fieldValue = remittanceInformationFieldString.substring(matchResult.range.last + 1, endIndex)
when (fieldCode) { when (fieldCode) {
0 -> bookingText = fieldValue 0 -> bookingText = fieldValue
@ -345,7 +345,7 @@ open class Mt940Parser(
val otherPartyNameString = if (otherPartyName.isBlank()) null else otherPartyName.toString() val otherPartyNameString = if (otherPartyName.isBlank()) null else otherPartyName.toString()
return InformationToAccountOwner( return RemittanceInformationField(
reference, otherPartyNameString, otherPartyBankCode, otherPartyAccountId, reference, otherPartyNameString, otherPartyBankCode, otherPartyAccountId,
bookingText, primaNotaNumber, textKeySupplement bookingText, primaNotaNumber, textKeySupplement
) )
@ -396,7 +396,7 @@ open class Mt940Parser(
* *
* Weitere 4 Verwendungszwecke können zu den Feldschlüsseln 60 bis 63 eingestellt werden. * 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) val referenceParts = getReferenceParts(information.unparsedReference)
referenceParts.forEach { entry -> referenceParts.forEach { entry ->
@ -431,7 +431,7 @@ open class Mt940Parser(
} }
// TODO: there are more. See .pdf from Deutsche Bank // 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) { when (referenceType) {
EndToEndReferenceKey -> information.endToEndReference = typeValue EndToEndReferenceKey -> information.endToEndReference = typeValue
CustomerReferenceKey -> information.customerReference = typeValue CustomerReferenceKey -> information.customerReference = typeValue

View File

@ -1,6 +1,6 @@
package net.codinux.banking.fints.transactions.mt940.model package net.codinux.banking.fints.transactions.mt940.model
open class InformationToAccountOwner( open class RemittanceInformationField(
val unparsedReference: String, val unparsedReference: String,
/** /**
* AT 02 Name des Überweisenden * AT 02 Name des Überweisenden

View File

@ -4,7 +4,7 @@ package net.codinux.banking.fints.transactions.mt940.model
open class Transaction( open class Transaction(
val statementLine: StatementLine, val statementLine: StatementLine,
val information: InformationToAccountOwner? = null val information: RemittanceInformationField? = null
) { ) {