From 2ca6117ac139998ad49a8f77de38f95e09568533 Mon Sep 17 00:00:00 2001 From: Kumar Rishi Date: Fri, 31 May 2024 15:11:25 +0530 Subject: [PATCH] [FEATURE] Added a $MONTH variable to ta recurring monthly payment (#3215) * [FEATURE] Added a $MONTH variable to ta recurring monthly payment * [FEATURE] Issue 3209, Changes made to take care timezone and TransactionMetaData * [FEATURE] Issue 3209, Detekt and Lint Updates * [FEATURE] Issue 3209,Unit test updates * Add Compose Stability baseline * Update Screenshots for Paparazzi tests * [FEATURE] compose stability baseline file addition * [FEATURE] Checking for compose stability * [FEATURE] Checking for compose stability * [FEATURE] Paparazzi update * [FEATURE] Naming conventions, unnecessary UI Spacing, Paparazzi screenshot updates --- .../ivy-compose-stability-baseline.txt | 1 + .../transaction/EditTransactionViewModel.kt | 4 ++++ ...est_snapshot Transactions Screen[Dark].png | Bin 62531 -> 62528 bytes ...st_snapshot Transactions Screen[Light].png | Bin 62176 -> 62173 bytes .../java/com/ivy/base/legacy/Transaction.kt | 4 ++++ .../java/com/ivy/data/db/IvyRoomDatabase.kt | 6 ++++-- .../ivy/data/db/entity/TransactionEntity.kt | 4 ++++ .../Migration127to128_PaidForDateRecord.kt | 11 ++++++++++ .../repository/mapper/TransactionMapper.kt | 8 ++++--- .../java/com/ivy/data/ArbTransactionEntity.kt | 6 ++++++ .../mapper/TransactionMapperTest.kt | 13 ++++++++++++ .../ivy/data/model/testing/ArbTransaction.kt | 3 +++ .../kotlin/com/ivy/data/model/Transaction.kt | 1 + .../data/model/primitive/TransactionTest.kt | 3 +++ .../ui/core/src/main/res/values/strings.xml | 1 + .../ivy/legacy/datamodel/TransactionExt.kt | 1 + .../legacy/datamodel/temp/TransactionExt.kt | 1 + .../logic/PlannedPaymentsGenerator.kt | 1 - .../deprecated/logic/PlannedPaymentsLogic.kt | 1 + .../component/transaction/TransactionCard.kt | 20 ++++++++++++++++-- 20 files changed, 81 insertions(+), 8 deletions(-) create mode 100644 shared/data/core/src/main/java/com/ivy/data/db/migration/Migration127to128_PaidForDateRecord.kt diff --git a/ci-actions/compose-stability/ivy-compose-stability-baseline.txt b/ci-actions/compose-stability/ivy-compose-stability-baseline.txt index 1e6ac0c4a2..bcc0026ea8 100644 --- a/ci-actions/compose-stability/ivy-compose-stability-baseline.txt +++ b/ci-actions/compose-stability/ivy-compose-stability-baseline.txt @@ -14,6 +14,7 @@ com.ivy.design.utils.keyboardVisibleState com.ivy.legacy.ivyWalletCtx com.ivy.legacy.rootView com.ivy.legacy.rootActivity +com.ivy.legacy.ui.component.transaction.getTransactionDescription com.ivy.legacy.rootScreen com.ivy.frp.view.FRP com.ivy.wallet.ui.theme.pureBlur diff --git a/screen/edit-transaction/src/main/java/com/ivy/transaction/EditTransactionViewModel.kt b/screen/edit-transaction/src/main/java/com/ivy/transaction/EditTransactionViewModel.kt index 11505c271c..b7db3dda8d 100644 --- a/screen/edit-transaction/src/main/java/com/ivy/transaction/EditTransactionViewModel.kt +++ b/screen/edit-transaction/src/main/java/com/ivy/transaction/EditTransactionViewModel.kt @@ -113,6 +113,7 @@ class EditTransactionViewModel @Inject constructor( private val description = mutableStateOf(null) private val dateTime = mutableStateOf(null) private val dueDate = mutableStateOf(null) + private val paidHistory = mutableStateOf(null) private val date = MutableStateFlow(null) private val time = MutableStateFlow(null) private val accounts = mutableStateOf>(persistentListOf()) @@ -373,6 +374,7 @@ class EditTransactionViewModel @Inject constructor( dateTime.value = transaction.dateTime description.value = transaction.description dueDate.value = transaction.dueDate + paidHistory.value = transaction.paidFor val selectedAccount = accountByIdAct(transaction.accountId)!! account.value = selectedAccount toAccount.value = transaction.toAccountId?.let { @@ -578,6 +580,7 @@ class EditTransactionViewModel @Inject constructor( syncTransaction = false ) { paidTransaction -> loadedTransaction = paidTransaction + paidHistory.value = paidTransaction.paidFor dueDate.value = paidTransaction.dueDate dateTime.value = paidTransaction.dateTime @@ -674,6 +677,7 @@ class EditTransactionViewModel @Inject constructor( amount = amount, type = transactionType.value, dueDate = dueDate.value, + paidFor = paidHistory.value, dateTime = when { loadedTransaction().dateTime == null && dueDate.value == null -> { diff --git a/screen/transactions/src/test/snapshots/images/com.ivy.transactions_TransactionsPaparazziTest_snapshot Transactions Screen[Dark].png b/screen/transactions/src/test/snapshots/images/com.ivy.transactions_TransactionsPaparazziTest_snapshot Transactions Screen[Dark].png index 634cfe08f0e1066ba0601d26da1eada327bf09c8..42ea518c91ddbbfb828775d192795edf78f5b9f4 100644 GIT binary patch delta 962 zcmV;z13mo1=mWs$1F$fF0sFHtfF5vv^>9;{|Dac_9#TDe^sv=q#XY15O%z2BB(;a@ zp8ERhuWhFvcN-r%j!LPz$JE18a$cfq^b$`6{(o02t`6|ve z*IZ+E?AT$$R~^>e^*C@5n%PHamOwX=y7;SVRu4IqHg!X4^6c5OXWKDIc4QkIxCqVcBQ!lJ40Qutd+oL6{rBHb ze$!Vqo7$<)JMTPu!x5S&iDm%`zI>@|Q>9OLn{*VIYHJUML23TlvUDaw{vkB8kI*b7 z-Gq9>gkChQiME6GP7O_e(d;a03nesBoM0SqFlmOW`)|4B7Spt8)5x}>(y7`%r%jt? zw->z;g;#{Z6%I|k4M$(d^o71O^lT$Ei$-Y1q|O-a+O;#!JoAiwd9ZF$Jr58?Ka=7?E;V=Eb(dFvU<#p$ zqUeG2@y8$A`%2+imeABxdpeHBcM_Ti5SrOXXr`fu(8P%o&DO13li~UH+i#moFTFHv zJ7yR|PEZuxJCi0&viHU}-+WW1>e&}wc)=cL*|KF+&mt*Pp{ZGc2+i~e%`|l5v~Jzn z4kwv4YgTexoTfX|4XN>RMTIASB~29P;fEi#_mXf*1eSv}-b+SCoH$+KtAo^8i}%!R+{Q_@6n zbgxXEI@R7E>Yc5bq}*+aqkB>JodQ!+H=cd=*^zB<;371$kI?j_Fw_ln?X}mM_uqd% z`AuKdY-*=E@4WNu4M%9AB$@>%`0}N;O_e^~ZPHO-s;xa32BrCH%hH($`G?TVK0>pU zbQ9_g6ME6KCfW|#J2f&z3ZU z5@hh8Q~lxZ46@s*>&4v7;F}bf|qlYcLVJs>gy7sHVzOX|sFx?zXy&z(jFW z3#NASJMOr{^y<|s7Bv@~amE>uV}sDlD796cbIv*D&O7h4V>}sj4j(~{g@!j>ef8C* zprF8x=Tud#W~b7N1N5bgZ~gG4FY>xy;$rM?(Fn~9(*sZ$;hAm>Cr}*SJ9=2Dq@WV0 n{?!AFk|j`i5R>8ROcwqhsbxXxi>tzg00000NkvXXu0mjfKWglD diff --git a/screen/transactions/src/test/snapshots/images/com.ivy.transactions_TransactionsPaparazziTest_snapshot Transactions Screen[Light].png b/screen/transactions/src/test/snapshots/images/com.ivy.transactions_TransactionsPaparazziTest_snapshot Transactions Screen[Light].png index e4944156c633d1448e11d1953a7e4f8a8f62980d..64b9aa773755bbff3680120b298c6327ae2bec6a 100644 GIT binary patch delta 972 zcmV;-12g>KpYHTyZev4^Bc)Wi$E3HTe1S8!LCHjD#vY*=LC20A-Ktn=capZuNL8_s5Sqw| zJdm9B$byy-hYcI1k8|qODOIOV9p8GCOoV3a5tZZJ@=!W(;D8!1V1QMBUF&C|y@c<>ej8R zhm&mEw#^+EC)1tD4JqU0atcp>N}9;c=+UF~y(GO~W!4{ay$uOl8Q&@Qm`tR>WbSZ8 zD>Nx-=8VwHg;dElY0^ZE9XnQkqn8`e`F1bWW09(CDQO}%GUP#x7+@Rbg0=6aM|gl6m!nt70$NV@n-)vP?^q_inFq)eXu#TQ?H=rMENZ~Bxp zksG;JKKbMmeSb*rY?(>Q+$J}2FUoxk`n#haH0_1%8lD17LeVW@uB7rGw?anYLnZLFmor#cm2+i0d zH1kPrLV3f4yl7e`+IHH1J7s8!%+4Zhp@b%Kxs0bzpRR+`sqU9Imq=T=yc$gIEeT4QP~)SIK62ZCL4|~;j2jNp9*V>! z_r&bkv)y||zSQTJJjY~TnJ!e`uw$O1q$4y7KyFZZ_({9e#~*(j_Fxmdgc`Y#2U1c} zk}hdFB}nH%Ct>QmfZ8Edy6?R6j@uMq9uE-G&qBV)OA}I1GTiRN4?oOz^=?T(Xhwmw zD@nC%@7}$2X+a);dUE5*qzLA=fR|LsKK=C5YUa$D`u(iVMC?*M=9EBXsyr!e_UO?= zSCmMH&*@o_t#@Q8FUUCPK|{O zZ|cyYgBmnwkRHz|RkboZmAp7WzLfE;AGYL+yxcEAG4?kgXM|>y$pcWrGtwANAUAUF u$iqrX3Q_`126pDe-AURqBUQylLTDl< z@<4LhBMVwW95!s2KF+CAr&OIfb$shlG7*}wM`%VMZJ2V?$wTSDfdgv5fB{y2fhh=0 zKCI_mzZaK|)ie+LPnR_)bC-4ni~b2+auOA+&VqQg!z1SvNfY{qKLPHf`EO zY{&Fs$O&>H_s+6q%k;gmfB*ghRnN|wH%}ku;K74b&%zb0(3Dw$2+ha{%?RYisav8Z0%PBm6DQO}%qeqX{_mcE}m05qx^)@7IWqhaHV=|EjlexnY ztTnKME&7g8nLq)8JscI;UFjb3g<=i9whk437orKE}6$dD6hhm`wc!GZ-je)-Bx zr%s*JufP7P!&iFan(I+=5t^|_Xy!p~BI)8URkQMtlhUT#kTQAp7himTp~uX5zv)xb zL~i6>`Q(#N^!*{dvt=eJbDP}Ay(ssc1g1>g*r-t>-!>?@2+i0dG%ZOO$_><|OBc0f z%^LTczErbGJ5|%BP4x{&Xd*8%3y|~WOWHQ2^l5Gri3Fy!wL8P0Wd7QMbS6ULAv9x; z(99>f3FQqF@}g;(XxnLj@06h_GCPa3g%X;`ja2JPwW>2|hE(_W>eWkCtyezr49b+REkCU~+HCj6pJ?#z!B2edM--3JFgcHyorr z6p2mliP^JfyZ4HGsn0KYj>*0<#M`#v++@SLClXj_(KmIuE!6tYKHF6^l zq@<)IUD9+)kj{fn!qj;IwL_|O-+AX9w<*9p9w4Njg?y2hCZwQbxZQ^zewgp--I9RN zi~?y_l4{xBy?g6_(tt18cJqGy`l(l6eKiniE@;r8f$!KLG^0w|sv0+Ltorxwug7>Y=o~hj z8VecT)S*KMHE7TvJ)TplYGrmRd2xVzDdSr|Y{?gSxnF`LV(f3u2+b&y2cU#!q%oX8 yZsgvPhn18Rqy#Ge$^(p&B~W}2lOXC$7XBXtKtFg4{2gKd0000 = either { val metadata = TransactionMetadata( recurringRuleId = recurringRuleId, + paidForDateTime = paidForDateTime?.atZone(timeProvider.getZoneId())?.toInstant(), loanId = loanId, loanRecordId = loanRecordId ) @@ -68,7 +69,7 @@ class TransactionMapper @Inject constructor( metadata = metadata, lastUpdated = Instant.EPOCH, removed = isDeleted, - tags = tags + tags = tags, ) } @@ -85,7 +86,7 @@ class TransactionMapper @Inject constructor( metadata = metadata, lastUpdated = Instant.EPOCH, removed = isDeleted, - tags = tags + tags = tags, ) } @@ -124,7 +125,7 @@ class TransactionMapper @Inject constructor( fromValue = fromValue, toAccount = toAccountId, toValue = toValue, - tags = tags + tags = tags, ) } } @@ -161,6 +162,7 @@ class TransactionMapper @Inject constructor( dateTime = dateTime.takeIf { settled }, categoryId = category?.value, dueDate = dateTime.takeIf { !settled }, + paidForDateTime = metadata.paidForDateTime?.atZone(timeProvider.getZoneId())?.toLocalDateTime(), recurringRuleId = metadata.recurringRuleId, attachmentUrl = null, loanId = metadata.loanId, diff --git a/shared/data/core/src/test/java/com/ivy/data/ArbTransactionEntity.kt b/shared/data/core/src/test/java/com/ivy/data/ArbTransactionEntity.kt index b5afb1d165..2010b5cd92 100644 --- a/shared/data/core/src/test/java/com/ivy/data/ArbTransactionEntity.kt +++ b/shared/data/core/src/test/java/com/ivy/data/ArbTransactionEntity.kt @@ -74,6 +74,9 @@ fun Arb.Companion.validTransfer(): Arb = arbitrary { dueDate = Arb.localDateTime().bind().takeIf { isPlannedPayment || Arb.boolean().bind() }, + paidForDateTime = Arb.localDateTime().bind().takeIf { + !isPlannedPayment || Arb.boolean().bind() + }, categoryId = Arb.maybe(Arb.uuid()).bind(), recurringRuleId = Arb.maybe(Arb.uuid()).bind(), attachmentUrl = Arb.maybe(Arb.string()).bind(), @@ -128,6 +131,9 @@ fun Arb.Companion.validIncomeOrExpense(): Arb = arbitrary { dueDate = Arb.localDateTime().bind().takeIf { isPlannedPayment || Arb.boolean().bind() }, + paidForDateTime = Arb.localDateTime().bind().takeIf { + !isPlannedPayment || Arb.boolean().bind() + }, categoryId = Arb.maybe(Arb.uuid()).bind(), recurringRuleId = Arb.maybe(Arb.uuid()).bind(), attachmentUrl = Arb.maybe(Arb.string()).bind(), diff --git a/shared/data/core/src/test/java/com/ivy/data/repository/mapper/TransactionMapperTest.kt b/shared/data/core/src/test/java/com/ivy/data/repository/mapper/TransactionMapperTest.kt index 562608b612..5feaa7fc3c 100644 --- a/shared/data/core/src/test/java/com/ivy/data/repository/mapper/TransactionMapperTest.kt +++ b/shared/data/core/src/test/java/com/ivy/data/repository/mapper/TransactionMapperTest.kt @@ -74,6 +74,7 @@ class TransactionMapperTest { metadata = TransactionMetadata( recurringRuleId = RecurringRuleId, loanId = LoanId, + paidForDateTime = PaidForDateTime, loanRecordId = LoanRecordId ), lastUpdated = InstantNow, @@ -102,6 +103,7 @@ class TransactionMapperTest { dateTime = dateTime.takeIf { settled }, categoryId = CategoryId.value, dueDate = dateTime.takeIf { !settled }, + paidForDateTime = PaidForDateTime.atZone(timeProvider.getZoneId()).toLocalDateTime(), recurringRuleId = RecurringRuleId, attachmentUrl = null, loanId = LoanId, @@ -128,6 +130,7 @@ class TransactionMapperTest { metadata = TransactionMetadata( recurringRuleId = RecurringRuleId, loanId = LoanId, + paidForDateTime = PaidForDateTime, loanRecordId = LoanRecordId ), lastUpdated = Instant.EPOCH, @@ -156,6 +159,7 @@ class TransactionMapperTest { dateTime = dateTime.takeIf { settled }, categoryId = CategoryId.value, dueDate = dateTime.takeIf { !settled }, + paidForDateTime = PaidForDateTime.atZone(timeProvider.getZoneId()).toLocalDateTime(), recurringRuleId = RecurringRuleId, attachmentUrl = null, loanId = LoanId, @@ -182,6 +186,7 @@ class TransactionMapperTest { metadata = TransactionMetadata( recurringRuleId = RecurringRuleId, loanId = LoanId, + paidForDateTime = PaidForDateTime, loanRecordId = LoanRecordId ), lastUpdated = Instant.EPOCH, @@ -215,6 +220,7 @@ class TransactionMapperTest { dateTime = dateTime.takeIf { settled }, categoryId = CategoryId.value, dueDate = dateTime.takeIf { !settled }, + paidForDateTime = PaidForDateTime.atZone(timeProvider.getZoneId()).toLocalDateTime(), recurringRuleId = RecurringRuleId, attachmentUrl = null, loanId = LoanId, @@ -254,6 +260,7 @@ class TransactionMapperTest { metadata = TransactionMetadata( recurringRuleId = RecurringRuleId, loanId = LoanId, + paidForDateTime = PaidForDateTime, loanRecordId = LoanRecordId ), lastUpdated = Instant.EPOCH, @@ -380,6 +387,7 @@ class TransactionMapperTest { metadata = TransactionMetadata( recurringRuleId = RecurringRuleId, loanId = LoanId, + paidForDateTime = PaidForDateTime, loanRecordId = LoanRecordId ), lastUpdated = Instant.EPOCH, @@ -511,6 +519,7 @@ class TransactionMapperTest { metadata = TransactionMetadata( recurringRuleId = RecurringRuleId, loanId = LoanId, + paidForDateTime = PaidForDateTime, loanRecordId = LoanRecordId ), lastUpdated = Instant.EPOCH, @@ -691,6 +700,7 @@ class TransactionMapperTest { val ToAccountId = AccountId(UUID.randomUUID()) val CategoryId = CategoryId(UUID.randomUUID()) val RecurringRuleId = UUID.randomUUID() + val PaidForDateTime: Instant = Instant.now() val LoanId = UUID.randomUUID() val LoanRecordId = UUID.randomUUID() val TransactionId = TransactionId(UUID.randomUUID()) @@ -707,6 +717,7 @@ class TransactionMapperTest { dateTime = DateTime, categoryId = CategoryId.value, dueDate = null, + paidForDateTime = PaidForDateTime.atZone(ZoneId.of("UTC")).toLocalDateTime(), recurringRuleId = RecurringRuleId, attachmentUrl = null, loanId = LoanId, @@ -727,6 +738,7 @@ class TransactionMapperTest { dateTime = DateTime, categoryId = CategoryId.value, dueDate = null, + paidForDateTime = PaidForDateTime.atZone(ZoneId.of("UTC")).toLocalDateTime(), recurringRuleId = RecurringRuleId, attachmentUrl = null, loanId = LoanId, @@ -747,6 +759,7 @@ class TransactionMapperTest { dateTime = DateTime, categoryId = CategoryId.value, dueDate = null, + paidForDateTime = PaidForDateTime.atZone(ZoneId.of("UTC")).toLocalDateTime(), recurringRuleId = RecurringRuleId, attachmentUrl = null, loanId = LoanId, diff --git a/shared/data/model-testing/src/main/java/com/ivy/data/model/testing/ArbTransaction.kt b/shared/data/model-testing/src/main/java/com/ivy/data/model/testing/ArbTransaction.kt index 9ea9f811c0..6f8c1380c1 100644 --- a/shared/data/model-testing/src/main/java/com/ivy/data/model/testing/ArbTransaction.kt +++ b/shared/data/model-testing/src/main/java/com/ivy/data/model/testing/ArbTransaction.kt @@ -47,6 +47,7 @@ fun Arb.Companion.income( metadata = TransactionMetadata( recurringRuleId = null, loanId = null, + paidForDateTime = null, loanRecordId = null ), lastUpdated = Instant.EPOCH, @@ -77,6 +78,7 @@ fun Arb.Companion.expense( metadata = TransactionMetadata( recurringRuleId = null, loanId = null, + paidForDateTime = null, loanRecordId = null ), lastUpdated = Instant.EPOCH, @@ -111,6 +113,7 @@ fun Arb.Companion.transfer( metadata = TransactionMetadata( recurringRuleId = null, loanId = null, + paidForDateTime = null, loanRecordId = null ), lastUpdated = Instant.EPOCH, diff --git a/shared/data/model/src/main/kotlin/com/ivy/data/model/Transaction.kt b/shared/data/model/src/main/kotlin/com/ivy/data/model/Transaction.kt index 0422008427..b6464968e4 100644 --- a/shared/data/model/src/main/kotlin/com/ivy/data/model/Transaction.kt +++ b/shared/data/model/src/main/kotlin/com/ivy/data/model/Transaction.kt @@ -72,6 +72,7 @@ data class Transfer( @Suppress("DataClassTypedIDs") data class TransactionMetadata( val recurringRuleId: UUID?, + val paidForDateTime: Instant?, // This refers to the loan id that is linked with a transaction val loanId: UUID? = null, // This refers to the loan record id that is linked with a transaction diff --git a/shared/data/model/src/test/java/com/ivy/data/model/primitive/TransactionTest.kt b/shared/data/model/src/test/java/com/ivy/data/model/primitive/TransactionTest.kt index a174ed703d..ded621141b 100644 --- a/shared/data/model/src/test/java/com/ivy/data/model/primitive/TransactionTest.kt +++ b/shared/data/model/src/test/java/com/ivy/data/model/primitive/TransactionTest.kt @@ -139,6 +139,7 @@ class TransactionTest { metadata = TransactionMetadata( recurringRuleId = null, loanId = null, + paidForDateTime = null, loanRecordId = null ), lastUpdated = Instant.EPOCH, @@ -161,6 +162,7 @@ class TransactionTest { metadata = TransactionMetadata( recurringRuleId = null, loanId = null, + paidForDateTime = null, loanRecordId = null ), lastUpdated = Instant.EPOCH, @@ -183,6 +185,7 @@ class TransactionTest { metadata = TransactionMetadata( recurringRuleId = null, loanId = null, + paidForDateTime = null, loanRecordId = null ), lastUpdated = Instant.EPOCH, diff --git a/shared/ui/core/src/main/res/values/strings.xml b/shared/ui/core/src/main/res/values/strings.xml index da05666a8c..2ee5a264d6 100644 --- a/shared/ui/core/src/main/res/values/strings.xml +++ b/shared/ui/core/src/main/res/values/strings.xml @@ -487,4 +487,5 @@ Continue "\n!!!⚠️WARNING: Importing may duplicate transactions!!!\nDuplicate transactions can NOT be easily deleted and you'll need to remove manually each one of them! \nReason: We can't parse transaction ids because Ivy Wallet works only with UUID and other apps don't.\nIf you're starting fresh, no worries - kindly ignore this message." Select Tags + Your bill for %1$s %2$d has been paid diff --git a/temp/legacy-code/src/main/java/com/ivy/legacy/datamodel/TransactionExt.kt b/temp/legacy-code/src/main/java/com/ivy/legacy/datamodel/TransactionExt.kt index ba394263ef..221c6d6e48 100644 --- a/temp/legacy-code/src/main/java/com/ivy/legacy/datamodel/TransactionExt.kt +++ b/temp/legacy-code/src/main/java/com/ivy/legacy/datamodel/TransactionExt.kt @@ -15,6 +15,7 @@ fun Transaction.toEntity(): TransactionEntity = TransactionEntity( categoryId = categoryId, dueDate = dueDate, recurringRuleId = recurringRuleId, + paidForDateTime = paidFor, attachmentUrl = attachmentUrl, loanId = loanId, loanRecordId = loanRecordId, diff --git a/temp/legacy-code/src/main/java/com/ivy/legacy/datamodel/temp/TransactionExt.kt b/temp/legacy-code/src/main/java/com/ivy/legacy/datamodel/temp/TransactionExt.kt index 7c0a544e02..edc3743549 100644 --- a/temp/legacy-code/src/main/java/com/ivy/legacy/datamodel/temp/TransactionExt.kt +++ b/temp/legacy-code/src/main/java/com/ivy/legacy/datamodel/temp/TransactionExt.kt @@ -28,6 +28,7 @@ fun TransactionEntity.toLegacyDomain( categoryId = categoryId, dueDate = dueDate, recurringRuleId = recurringRuleId, + paidFor = paidForDateTime, attachmentUrl = attachmentUrl, loanId = loanId, loanRecordId = loanRecordId, diff --git a/temp/legacy-code/src/main/java/com/ivy/legacy/domain/deprecated/logic/PlannedPaymentsGenerator.kt b/temp/legacy-code/src/main/java/com/ivy/legacy/domain/deprecated/logic/PlannedPaymentsGenerator.kt index 103f6c0298..c565ce7cde 100644 --- a/temp/legacy-code/src/main/java/com/ivy/legacy/domain/deprecated/logic/PlannedPaymentsGenerator.kt +++ b/temp/legacy-code/src/main/java/com/ivy/legacy/domain/deprecated/logic/PlannedPaymentsGenerator.kt @@ -86,7 +86,6 @@ class PlannedPaymentsGenerator @Inject constructor( dueDate = dueDate, dateTime = null, toAccountId = null, - isSynced = false ).toEntity() ) diff --git a/temp/legacy-code/src/main/java/com/ivy/legacy/domain/deprecated/logic/PlannedPaymentsLogic.kt b/temp/legacy-code/src/main/java/com/ivy/legacy/domain/deprecated/logic/PlannedPaymentsLogic.kt index e52aefaa83..fc8d928d5e 100644 --- a/temp/legacy-code/src/main/java/com/ivy/legacy/domain/deprecated/logic/PlannedPaymentsLogic.kt +++ b/temp/legacy-code/src/main/java/com/ivy/legacy/domain/deprecated/logic/PlannedPaymentsLogic.kt @@ -165,6 +165,7 @@ class PlannedPaymentsLogic @Inject constructor( if (transaction.dueDate == null || transaction.dateTime != null) return val paidTransaction = transaction.copy( + paidFor = transaction.dueDate, dueDate = null, dateTime = timeNowUTC(), isSynced = false, diff --git a/temp/legacy-code/src/main/java/com/ivy/legacy/ui/component/transaction/TransactionCard.kt b/temp/legacy-code/src/main/java/com/ivy/legacy/ui/component/transaction/TransactionCard.kt index 4ffd8b49dc..597b5a67c4 100644 --- a/temp/legacy-code/src/main/java/com/ivy/legacy/ui/component/transaction/TransactionCard.kt +++ b/temp/legacy-code/src/main/java/com/ivy/legacy/ui/component/transaction/TransactionCard.kt @@ -45,6 +45,7 @@ import com.ivy.design.l1_buildingBlocks.SpacerHor import com.ivy.legacy.IvyWalletPreview import com.ivy.legacy.data.AppBaseData import com.ivy.legacy.datamodel.Account +import com.ivy.legacy.utils.capitalizeLocal import com.ivy.legacy.utils.dateNowUTC import com.ivy.legacy.utils.format import com.ivy.legacy.utils.formatNicely @@ -117,6 +118,8 @@ fun TransactionCard( baseData.accounts.find { it.id == transaction.toAccountId }?.currency ?: baseData.baseCurrency + val transactionDescription = getTransactionDescription(transaction) + Spacer(Modifier.height(20.dp)) TransactionHeaderRow( @@ -162,7 +165,7 @@ fun TransactionCard( ) } - if (transaction.description.isNotNullOrBlank()) { + if (transactionDescription.isNotNullOrBlank()) { Spacer( Modifier.height( if (transaction.title.isNotNullOrBlank()) 4.dp else 8.dp @@ -170,7 +173,7 @@ fun TransactionCard( ) Text( - text = transaction.description!!, + text = transactionDescription!!, modifier = Modifier.padding(horizontal = 24.dp), style = UI.typo.nC.style( color = UI.colors.gray, @@ -367,6 +370,19 @@ fun CategoryBadgeDisplay( } } +@Composable +private fun getTransactionDescription(transaction: Transaction): String? { + return when { + transaction.description.isNotNullOrBlank() -> transaction.description!! + transaction.recurringRuleId != null && transaction.dueDate == null -> stringResource( + R.string.bill_paid, + transaction.paidFor?.month?.name?.lowercase()?.capitalizeLocal() ?: "", + transaction.paidFor?.year ?: "" + ) + else -> null + } +} + @Composable private fun TransactionBadge( text: String,