Fixed setting either sepaReference - in case of structured information - or unparsedReference - in case of unstructured reference. And that reference may is null

This commit is contained in:
dankito 2024-09-05 19:36:03 +02:00
parent bf76de4f23
commit 30e9a57b96
4 changed files with 14 additions and 22 deletions

View File

@ -112,7 +112,7 @@ open class FinTsModelMapper {
open fun map(transaction: net.codinux.banking.fints.model.AccountTransaction): AccountTransaction { open fun map(transaction: net.codinux.banking.fints.model.AccountTransaction): AccountTransaction {
return AccountTransaction( return AccountTransaction(
transaction.amount, transaction.unparsedReference, transaction.amount, transaction.reference,
transaction.bookingDate, transaction.valueDate, transaction.bookingDate, transaction.valueDate,
transaction.otherPartyName, transaction.otherPartyBankCode, transaction.otherPartyAccountId, transaction.otherPartyName, transaction.otherPartyBankCode, transaction.otherPartyAccountId,
@ -122,7 +122,7 @@ open class FinTsModelMapper {
transaction.customerReference, transaction.bankReference, transaction.furtherInformation, transaction.customerReference, transaction.bankReference, transaction.furtherInformation,
transaction.endToEndReference, transaction.mandateReference, transaction.creditorIdentifier, transaction.originatorsIdentificationCode, 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.referenceWithNoSpecialType,
transaction.journalNumber, transaction.textKeyAddition, transaction.journalNumber, transaction.textKeyAddition,

View File

@ -7,7 +7,7 @@ import net.codinux.banking.fints.extensions.UnixEpochStart
open class AccountTransaction( open class AccountTransaction(
val account: AccountData, val account: AccountData,
val amount: Money, val amount: Money,
val unparsedReference: String, val reference: String?, // that was also new to me that reference may is null
val bookingDate: LocalDate, val bookingDate: LocalDate,
val valueDate: LocalDate, val valueDate: LocalDate,
@ -70,7 +70,6 @@ open class AccountTransaction(
* Betrag der ursprünglichen Lastschrift * Betrag der ursprünglichen Lastschrift
*/ */
val originalAmount: String?, val originalAmount: String?,
val sepaReference: String?,
/** /**
* Abweichender Überweisender oder Zahlungsempfänger * 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) 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, : this(account, amount, unparsedReference, bookingDate, valueDate, otherPartyName, otherPartyBankCode, otherPartyAccountId, postingText,
0, null, null, null, 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) "", null, null, "", null, false)
open val showOtherPartyName: Boolean open val showOtherPartyName: Boolean
get() = otherPartyName.isNullOrBlank() == false /* && type != "ENTGELTABSCHLUSS" && type != "AUSZAHLUNG" */ // TODO get() = otherPartyName.isNullOrBlank() == false /* && type != "ENTGELTABSCHLUSS" && type != "AUSZAHLUNG" */ // TODO
val reference: String
get() = sepaReference ?: unparsedReference
override fun equals(other: Any?): Boolean { override fun equals(other: Any?): Boolean {
if (this === other) return true if (this === other) return true
@ -134,7 +130,7 @@ open class AccountTransaction(
if (account != other.account) return false if (account != other.account) return false
if (amount != other.amount) 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 (bookingDate != other.bookingDate) return false
if (otherPartyName != other.otherPartyName) return false if (otherPartyName != other.otherPartyName) return false
if (otherPartyBankCode != other.otherPartyBankCode) return false if (otherPartyBankCode != other.otherPartyBankCode) return false
@ -148,7 +144,7 @@ open class AccountTransaction(
override fun hashCode(): Int { override fun hashCode(): Int {
var result = account.hashCode() var result = account.hashCode()
result = 31 * result + amount.hashCode() result = 31 * result + amount.hashCode()
result = 31 * result + unparsedReference.hashCode() result = 31 * result + reference.hashCode()
result = 31 * result + bookingDate.hashCode() result = 31 * result + bookingDate.hashCode()
result = 31 * result + (otherPartyName?.hashCode() ?: 0) result = 31 * result + (otherPartyName?.hashCode() ?: 0)
result = 31 * result + (otherPartyBankCode?.hashCode() ?: 0) result = 31 * result + (otherPartyBankCode?.hashCode() ?: 0)
@ -160,7 +156,7 @@ open class AccountTransaction(
override fun toString(): String { override fun toString(): String {
return "$valueDate $amount $otherPartyName: $unparsedReference" return "$valueDate $amount $otherPartyName: $reference"
} }
} }

View File

@ -49,7 +49,8 @@ open class Mt940AccountTransactionsParser(
return AccountTransaction( return AccountTransaction(
account, account,
Money(mapAmount(transaction.statementLine), currency), 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.bookingDate ?: statement.closingBalance.bookingDate,
transaction.statementLine.valueDate, transaction.statementLine.valueDate,
@ -76,7 +77,6 @@ open class Mt940AccountTransactionsParser(
transaction.information?.originatorsIdentificationCode, transaction.information?.originatorsIdentificationCode,
transaction.information?.compensationAmount, transaction.information?.compensationAmount,
transaction.information?.originalAmount, transaction.information?.originalAmount,
transaction.information?.sepaReference,
transaction.information?.deviantOriginator, transaction.information?.deviantOriginator,
transaction.information?.deviantRecipient, transaction.information?.deviantRecipient,
transaction.information?.referenceWithNoSpecialType, transaction.information?.referenceWithNoSpecialType,

View File

@ -10,7 +10,7 @@ import net.codinux.banking.fints.extensions.UnixEpochStart
@Serializable @Serializable
open class AccountTransaction( 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 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 bookingDate: LocalDate,
val valueDate: LocalDate, val valueDate: LocalDate,
@ -36,7 +36,6 @@ open class AccountTransaction(
val originatorsIdentificationCode: String?, val originatorsIdentificationCode: String?,
val compensationAmount: String?, val compensationAmount: String?,
val originalAmount: String?, val originalAmount: String?,
val sepaReference: String?,
val deviantOriginator: String?, val deviantOriginator: String?,
val deviantRecipient: String?, val deviantRecipient: String?,
val referenceWithNoSpecialType: 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?) 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, : this(amount, unparsedReference, bookingDate, valueDate, otherPartyName, otherPartyBankCode, otherPartyAccountId, postingText,
0, null, null, null, 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) null, null, null, null)
open val showOtherPartyName: Boolean open val showOtherPartyName: Boolean
get() = otherPartyName.isNullOrBlank() == false /* && type != "ENTGELTABSCHLUSS" && type != "AUSZAHLUNG" */ // TODO get() = otherPartyName.isNullOrBlank() == false /* && type != "ENTGELTABSCHLUSS" && type != "AUSZAHLUNG" */ // TODO
val reference: String
get() = sepaReference ?: unparsedReference
override fun equals(other: Any?): Boolean { override fun equals(other: Any?): Boolean {
if (this === other) return true if (this === other) return true
if (other !is AccountTransaction) return false if (other !is AccountTransaction) return false
if (amount != other.amount) 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 (bookingDate != other.bookingDate) return false
if (otherPartyName != other.otherPartyName) return false if (otherPartyName != other.otherPartyName) return false
if (otherPartyBankCode != other.otherPartyBankCode) return false if (otherPartyBankCode != other.otherPartyBankCode) return false
@ -82,7 +78,7 @@ open class AccountTransaction(
override fun hashCode(): Int { override fun hashCode(): Int {
var result = amount.hashCode() var result = amount.hashCode()
result = 31 * result + unparsedReference.hashCode() result = 31 * result + reference.hashCode()
result = 31 * result + bookingDate.hashCode() result = 31 * result + bookingDate.hashCode()
result = 31 * result + (otherPartyName?.hashCode() ?: 0) result = 31 * result + (otherPartyName?.hashCode() ?: 0)
result = 31 * result + (otherPartyBankCode?.hashCode() ?: 0) result = 31 * result + (otherPartyBankCode?.hashCode() ?: 0)
@ -94,7 +90,7 @@ open class AccountTransaction(
override fun toString(): String { override fun toString(): String {
return "$valueDate $amount $otherPartyName: $unparsedReference" return "$valueDate $amount $otherPartyName: $reference"
} }
} }