From 36e7161b2e1c56b25d59cf483094496515514d8a Mon Sep 17 00:00:00 2001 From: dankito Date: Thu, 6 Aug 2020 01:32:18 +0200 Subject: [PATCH] Fixed that in derived classes bankAccount initially may is not set --- .../dankito/banking/ui/model/AccountTransaction.kt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/AccountTransaction.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/AccountTransaction.kt index 5fe89ad3..5ff95a5b 100644 --- a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/AccountTransaction.kt +++ b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/AccountTransaction.kt @@ -69,10 +69,16 @@ open class AccountTransaction( 0, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, "", "", null, null, "", null) - open val technicalId: String = createDefaultId() + open var technicalId: String = createDefaultId() - protected fun createDefaultId() = - "${bankAccount.technicalId} ${IdDateFormat.format(bookingDate)} ${IdDateFormat.format(valueDate)} $amount $currency $unparsedUsage $otherPartyName $otherPartyBankCode $otherPartyAccountId" + protected fun createDefaultId() : String { + if (bankAccount != null) { + return "${bankAccount.technicalId} ${IdDateFormat.format(bookingDate)} ${IdDateFormat.format(valueDate)} $amount $currency $unparsedUsage $otherPartyName $otherPartyBankCode $otherPartyAccountId" + } + else { // happens for derived classes during initialization. These have to set technicalId after initialization by themselves + return " ${IdDateFormat.format(bookingDate)} ${IdDateFormat.format(valueDate)} $amount $currency $unparsedUsage $otherPartyName $otherPartyBankCode $otherPartyAccountId" + } + } open val showOtherPartyName: Boolean