Implemented filtering out duplicate transactions as some banks return some transactions multiple times in MT940 response
This commit is contained in:
parent
3d33af68a1
commit
0e0a7b5207
|
@ -377,7 +377,7 @@ open class FinTsClient(
|
|||
|
||||
val message = messageBuilder.createGetTransactionsMessage(parameter, account, dialogContext)
|
||||
|
||||
val bookedTransactions = mutableListOf<AccountTransaction>()
|
||||
val bookedTransactions = mutableSetOf<AccountTransaction>() // some banks like Postbank return some transactions multiple times -> remove these
|
||||
var remainingMt940String = ""
|
||||
|
||||
dialogContext.abortIfTanIsRequired = parameter.abortIfTanIsRequired
|
||||
|
@ -398,7 +398,7 @@ open class FinTsClient(
|
|||
|
||||
callback(GetTransactionsResponse(
|
||||
response,
|
||||
bookedTransactions,
|
||||
bookedTransactions.toList(),
|
||||
listOf(), // TODO: implement parsing MT942
|
||||
balance
|
||||
)
|
||||
|
|
|
@ -49,6 +49,37 @@ open class AccountTransaction(
|
|||
null, "", "", null, null, "", null)
|
||||
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other !is AccountTransaction) return false
|
||||
|
||||
if (account != other.account) return false
|
||||
if (amount != other.amount) return false
|
||||
if (unparsedUsage != other.unparsedUsage) return false
|
||||
if (bookingDate != other.bookingDate) return false
|
||||
if (otherPartyName != other.otherPartyName) return false
|
||||
if (otherPartyBankCode != other.otherPartyBankCode) return false
|
||||
if (otherPartyAccountId != other.otherPartyAccountId) return false
|
||||
if (bookingText != other.bookingText) return false
|
||||
if (valueDate != other.valueDate) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = account.hashCode()
|
||||
result = 31 * result + amount.hashCode()
|
||||
result = 31 * result + unparsedUsage.hashCode()
|
||||
result = 31 * result + bookingDate.hashCode()
|
||||
result = 31 * result + (otherPartyName?.hashCode() ?: 0)
|
||||
result = 31 * result + (otherPartyBankCode?.hashCode() ?: 0)
|
||||
result = 31 * result + (otherPartyAccountId?.hashCode() ?: 0)
|
||||
result = 31 * result + (bookingText?.hashCode() ?: 0)
|
||||
result = 31 * result + valueDate.hashCode()
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
override fun toString(): String {
|
||||
return "$valueDate $amount $otherPartyName: $unparsedUsage"
|
||||
}
|
||||
|
|
|
@ -8,6 +8,20 @@ open class Currency(
|
|||
internal constructor() : this("") // for object deserializers
|
||||
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other !is Currency) return false
|
||||
|
||||
if (code != other.code) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return code.hashCode()
|
||||
}
|
||||
|
||||
|
||||
override fun toString(): String {
|
||||
return code
|
||||
}
|
||||
|
|
|
@ -9,5 +9,5 @@ open class GetTransactionsParameter(
|
|||
val toDate: Date? = null,
|
||||
val maxCountEntries: Int? = null,
|
||||
val abortIfTanIsRequired: Boolean = false,
|
||||
val retrievedChunkListener: ((List<AccountTransaction>) -> Unit)? = null
|
||||
val retrievedChunkListener: ((Collection<AccountTransaction>) -> Unit)? = null
|
||||
)
|
|
@ -16,6 +16,24 @@ open class Money(
|
|||
get() = "$amount $currency"
|
||||
|
||||
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other !is Money) return false
|
||||
|
||||
if (amount != other.amount) return false
|
||||
if (currency != other.currency) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = amount.hashCode()
|
||||
result = 31 * result + currency.hashCode()
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
override fun toString(): String {
|
||||
return displayString
|
||||
}
|
||||
|
|
|
@ -82,8 +82,9 @@ open class fints4kBankingClient(
|
|||
}
|
||||
else {
|
||||
val mappedParameter = GetTransactionsParameter(parameter.alsoRetrieveBalance, parameter.fromDate,
|
||||
parameter.toDate, null, parameter.abortIfTanIsRequired,
|
||||
{ parameter.retrievedChunkListener?.invoke(mapper.mapTransactions(bankAccount, it)) } )
|
||||
parameter.toDate, null, parameter.abortIfTanIsRequired) {
|
||||
parameter.retrievedChunkListener?.invoke(mapper.mapTransactions(bankAccount, it))
|
||||
}
|
||||
|
||||
doGetTransactionsAsync(mappedParameter, account, bankAccount, callback)
|
||||
}
|
||||
|
|
|
@ -180,7 +180,7 @@ open class fints4kModelMapper(protected val modelCreator: IModelCreator) {
|
|||
}
|
||||
|
||||
|
||||
open fun mapTransactions(bankAccount: TypedBankAccount, transactions: List<net.dankito.banking.fints.model.AccountTransaction>): List<IAccountTransaction> {
|
||||
open fun mapTransactions(bankAccount: TypedBankAccount, transactions: Collection<net.dankito.banking.fints.model.AccountTransaction>): List<IAccountTransaction> {
|
||||
return transactions.map { mapTransaction(bankAccount, it) }
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue