From e5da3725de7aed54dfd75c34b28ae3b5a7f03ce2 Mon Sep 17 00:00:00 2001 From: dankito Date: Wed, 27 May 2020 12:24:27 +0200 Subject: [PATCH] Not using a random id anymore but constructing it from property values that make an account transaction unique --- .../net/dankito/banking/ui/model/AccountTransaction.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/AccountTransaction.kt b/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/AccountTransaction.kt index 847643d6..f92de7e8 100644 --- a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/AccountTransaction.kt +++ b/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/AccountTransaction.kt @@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonIdentityInfo import com.fasterxml.jackson.annotation.ObjectIdGenerators import java.math.BigDecimal import java.text.DateFormat +import java.text.SimpleDateFormat import java.util.* @@ -48,6 +49,11 @@ open class AccountTransaction( val relatedReferenceNumber: String? ) { + companion object { + val IdDateFormat = SimpleDateFormat("yyyy.MM.dd") + } + + constructor(bankAccount: BankAccount, amount: BigDecimal, unparsedUsage: String, bookingDate: Date, otherPartyName: String?, otherPartyBankCode: String?, otherPartyAccountId: String?, bookingText: String?, valueDate: Date) @@ -61,8 +67,7 @@ open class AccountTransaction( null, "", "", null, null, "", null) - var id: String = UUID.randomUUID().toString() - protected set + var id: String = "${bankAccount.id} ${IdDateFormat.format(bookingDate)} ${IdDateFormat.format(valueDate)} $amount $currency $unparsedUsage $otherPartyName $otherPartyBankCode $otherPartyAccountId" val showOtherPartyName: Boolean