Implemented equals() so that we only show each transaction once in UI even though it has been retrieved multiple times
This commit is contained in:
parent
ff456ccf32
commit
3c76bbd93c
|
@ -21,6 +21,37 @@ open class AccountTransaction(
|
|||
internal constructor() : this(0.toBigDecimal(),"", "", Date(), null, null, null, null, BankAccount())
|
||||
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other !is AccountTransaction) return false
|
||||
|
||||
if (amount.compareTo(other.amount) != 0) return false
|
||||
if (currency != other.currency) return false
|
||||
if (usage != other.usage) 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 (bankAccount != other.bankAccount) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = amount.hashCode()
|
||||
result = 31 * result + currency.hashCode()
|
||||
result = 31 * result + usage.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 + bankAccount.hashCode()
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
override fun toString(): String {
|
||||
return "${DateFormat.getDateInstance(DateFormat.MEDIUM).format(bookingDate)} $amount $otherPartyName: $usage"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue