From 30e9a57b969ce73c2531ee756567713aeb30ae7f Mon Sep 17 00:00:00 2001 From: dankito Date: Thu, 5 Sep 2024 19:36:03 +0200 Subject: [PATCH] Fixed setting either sepaReference - in case of structured information - or unparsedReference - in case of unstructured reference. And that reference may is null --- .../banking/fints/mapper/FinTsModelMapper.kt | 4 ++-- .../banking/fints/model/AccountTransaction.kt | 14 +++++--------- .../transactions/Mt940AccountTransactionsParser.kt | 4 ++-- .../banking/client/model/AccountTransaction.kt | 14 +++++--------- 4 files changed, 14 insertions(+), 22 deletions(-) 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 de48333e..bbbe1165 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 @@ -112,7 +112,7 @@ open class FinTsModelMapper { open fun map(transaction: net.codinux.banking.fints.model.AccountTransaction): AccountTransaction { return AccountTransaction( - transaction.amount, transaction.unparsedReference, + transaction.amount, transaction.reference, transaction.bookingDate, transaction.valueDate, transaction.otherPartyName, transaction.otherPartyBankCode, transaction.otherPartyAccountId, @@ -122,7 +122,7 @@ open class FinTsModelMapper { transaction.customerReference, transaction.bankReference, transaction.furtherInformation, transaction.endToEndReference, transaction.mandateReference, transaction.creditorIdentifier, transaction.originatorsIdentificationCode, - transaction.compensationAmount, transaction.originalAmount, transaction.sepaReference, transaction.deviantOriginator, transaction.deviantRecipient, + transaction.compensationAmount, transaction.originalAmount, transaction.deviantOriginator, transaction.deviantRecipient, transaction.referenceWithNoSpecialType, transaction.journalNumber, transaction.textKeyAddition, diff --git a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/model/AccountTransaction.kt b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/model/AccountTransaction.kt index 90e4da32..2c4bfc8d 100644 --- a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/model/AccountTransaction.kt +++ b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/model/AccountTransaction.kt @@ -7,7 +7,7 @@ import net.codinux.banking.fints.extensions.UnixEpochStart open class AccountTransaction( val account: AccountData, val amount: Money, - val unparsedReference: String, + val reference: String?, // that was also new to me that reference may is null val bookingDate: LocalDate, val valueDate: LocalDate, @@ -70,7 +70,6 @@ open class AccountTransaction( * Betrag der ursprünglichen Lastschrift */ val originalAmount: String?, - val sepaReference: String?, /** * Abweichender Überweisender oder Zahlungsempfänger */ @@ -117,16 +116,13 @@ open class AccountTransaction( constructor(account: AccountData, amount: Money, unparsedReference: String, bookingDate: LocalDate, valueDate: LocalDate, otherPartyName: String?, otherPartyBankCode: String?, otherPartyAccountId: String?, postingText: String? = null) : this(account, amount, unparsedReference, bookingDate, valueDate, otherPartyName, otherPartyBankCode, otherPartyAccountId, postingText, 0, null, null, null, - null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, "", null, null, "", null, false) open val showOtherPartyName: Boolean get() = otherPartyName.isNullOrBlank() == false /* && type != "ENTGELTABSCHLUSS" && type != "AUSZAHLUNG" */ // TODO - val reference: String - get() = sepaReference ?: unparsedReference - override fun equals(other: Any?): Boolean { if (this === other) return true @@ -134,7 +130,7 @@ open class AccountTransaction( if (account != other.account) return false if (amount != other.amount) return false - if (unparsedReference != other.unparsedReference) return false + if (reference != other.reference) return false if (bookingDate != other.bookingDate) return false if (otherPartyName != other.otherPartyName) return false if (otherPartyBankCode != other.otherPartyBankCode) return false @@ -148,7 +144,7 @@ open class AccountTransaction( override fun hashCode(): Int { var result = account.hashCode() result = 31 * result + amount.hashCode() - result = 31 * result + unparsedReference.hashCode() + result = 31 * result + reference.hashCode() result = 31 * result + bookingDate.hashCode() result = 31 * result + (otherPartyName?.hashCode() ?: 0) result = 31 * result + (otherPartyBankCode?.hashCode() ?: 0) @@ -160,7 +156,7 @@ open class AccountTransaction( override fun toString(): String { - return "$valueDate $amount $otherPartyName: $unparsedReference" + return "$valueDate $amount $otherPartyName: $reference" } } \ No newline at end of file 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 66cb5558..bd9a2ce1 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 @@ -49,7 +49,8 @@ open class Mt940AccountTransactionsParser( return AccountTransaction( account, Money(mapAmount(transaction.statementLine), currency), - transaction.information?.unparsedReference ?: "", + // either field :86: contains structured information, then sepaReference is a mandatory field, or :86: is unstructured, then the whole field value is the reference + transaction.information?.sepaReference ?: transaction.information?.unparsedReference ?: "", transaction.statementLine.bookingDate ?: statement.closingBalance.bookingDate, transaction.statementLine.valueDate, @@ -76,7 +77,6 @@ open class Mt940AccountTransactionsParser( transaction.information?.originatorsIdentificationCode, transaction.information?.compensationAmount, transaction.information?.originalAmount, - transaction.information?.sepaReference, transaction.information?.deviantOriginator, transaction.information?.deviantRecipient, transaction.information?.referenceWithNoSpecialType, diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/client/model/AccountTransaction.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/client/model/AccountTransaction.kt index efd84781..dc055eda 100644 --- a/fints4k/src/commonMain/kotlin/net/dankito/banking/client/model/AccountTransaction.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/client/model/AccountTransaction.kt @@ -10,7 +10,7 @@ import net.codinux.banking.fints.extensions.UnixEpochStart @Serializable open class AccountTransaction( val amount: Money, // TODO: if we decide to stick with Money, create own type, don't use that one from fints.model (or move over from) - val unparsedReference: String, // alternative names: purpose, reason + val reference: String?, // alternative names: purpose, reason val bookingDate: LocalDate, val valueDate: LocalDate, @@ -36,7 +36,6 @@ open class AccountTransaction( val originatorsIdentificationCode: String?, val compensationAmount: String?, val originalAmount: String?, - val sepaReference: String?, val deviantOriginator: String?, val deviantRecipient: String?, val referenceWithNoSpecialType: String?, @@ -53,23 +52,20 @@ open class AccountTransaction( constructor(amount: Money, unparsedReference: String, bookingDate: LocalDate, valueDate: LocalDate, otherPartyName: String?, otherPartyBankCode: String?, otherPartyAccountId: String?, postingText: String?) : this(amount, unparsedReference, bookingDate, valueDate, otherPartyName, otherPartyBankCode, otherPartyAccountId, postingText, 0, null, null, null, - null, null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null) open val showOtherPartyName: Boolean get() = otherPartyName.isNullOrBlank() == false /* && type != "ENTGELTABSCHLUSS" && type != "AUSZAHLUNG" */ // TODO - val reference: String - get() = sepaReference ?: unparsedReference - override fun equals(other: Any?): Boolean { if (this === other) return true if (other !is AccountTransaction) return false if (amount != other.amount) return false - if (unparsedReference != other.unparsedReference) return false + if (reference != other.reference) return false if (bookingDate != other.bookingDate) return false if (otherPartyName != other.otherPartyName) return false if (otherPartyBankCode != other.otherPartyBankCode) return false @@ -82,7 +78,7 @@ open class AccountTransaction( override fun hashCode(): Int { var result = amount.hashCode() - result = 31 * result + unparsedReference.hashCode() + result = 31 * result + reference.hashCode() result = 31 * result + bookingDate.hashCode() result = 31 * result + (otherPartyName?.hashCode() ?: 0) result = 31 * result + (otherPartyBankCode?.hashCode() ?: 0) @@ -94,7 +90,7 @@ open class AccountTransaction( override fun toString(): String { - return "$valueDate $amount $otherPartyName: $unparsedReference" + return "$valueDate $amount $otherPartyName: $reference" } } \ No newline at end of file