From 0553083bd9c34631bf5234da947698ebb14a7e28 Mon Sep 17 00:00:00 2001 From: "mushfiq.salehine" <60137904+Mushfiq1060@users.noreply.github.com> Date: Sun, 29 Sep 2024 15:46:46 +0600 Subject: [PATCH 1/3] Fixes #3432 : recurring expenses not spawn at local time --- .../domain/action/viewmodel/home/DueTrnsInfoAct.kt | 10 +++++++--- .../legacy/legacy/ui/theme/modal/RecurringRuleModal.kt | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/temp/legacy-code/src/main/java/com/ivy/legacy/domain/action/viewmodel/home/DueTrnsInfoAct.kt b/temp/legacy-code/src/main/java/com/ivy/legacy/domain/action/viewmodel/home/DueTrnsInfoAct.kt index e9ce95b125..4cc20312f3 100644 --- a/temp/legacy-code/src/main/java/com/ivy/legacy/domain/action/viewmodel/home/DueTrnsInfoAct.kt +++ b/temp/legacy-code/src/main/java/com/ivy/legacy/domain/action/viewmodel/home/DueTrnsInfoAct.kt @@ -1,10 +1,10 @@ package com.ivy.wallet.domain.action.viewmodel.home +import com.ivy.base.time.TimeConverter import com.ivy.data.model.Transaction import com.ivy.frp.action.FPAction import com.ivy.frp.lambda import com.ivy.frp.then -import com.ivy.legacy.utils.dateNowUTC import com.ivy.wallet.domain.action.account.AccountByIdAct import com.ivy.wallet.domain.action.exchange.ExchangeAct import com.ivy.wallet.domain.action.exchange.actInput @@ -16,20 +16,24 @@ import com.ivy.wallet.domain.pure.exchange.exchangeInBaseCurrency import com.ivy.wallet.domain.pure.transaction.expenses import com.ivy.wallet.domain.pure.transaction.incomes import com.ivy.wallet.domain.pure.transaction.sumTrns +import java.time.Instant import java.time.LocalDate import javax.inject.Inject class DueTrnsInfoAct @Inject constructor( private val dueTrnsAct: DueTrnsAct, private val accountByIdAct: AccountByIdAct, - private val exchangeAct: ExchangeAct + private val exchangeAct: ExchangeAct, + private val timeConverter: TimeConverter ) : FPAction() { override suspend fun Input.compose(): suspend () -> Output = suspend { range } then dueTrnsAct then { trns -> - val dateNow = dateNowUTC() + val dateNow = with(timeConverter) { + Instant.now().toLocalDate() + } trns.filter { this.dueFilter(it, dateNow) } diff --git a/temp/legacy-code/src/main/java/com/ivy/legacy/legacy/ui/theme/modal/RecurringRuleModal.kt b/temp/legacy-code/src/main/java/com/ivy/legacy/legacy/ui/theme/modal/RecurringRuleModal.kt index 68d759ba26..94724d4e3b 100644 --- a/temp/legacy-code/src/main/java/com/ivy/legacy/legacy/ui/theme/modal/RecurringRuleModal.kt +++ b/temp/legacy-code/src/main/java/com/ivy/legacy/legacy/ui/theme/modal/RecurringRuleModal.kt @@ -47,7 +47,7 @@ import com.ivy.legacy.utils.hideKeyboard import com.ivy.legacy.utils.onScreenStart import com.ivy.design.utils.thenIf import com.ivy.legacy.utils.rememberInteractionSource -import com.ivy.legacy.utils.timeNowUTC +import com.ivy.legacy.utils.timeNowLocal import com.ivy.ui.R import com.ivy.wallet.ui.theme.Gradient import com.ivy.wallet.ui.theme.GradientIvy @@ -81,7 +81,7 @@ fun BoxWithConstraintsScope.RecurringRuleModal( onRuleChanged: (LocalDateTime, oneTime: Boolean, Int?, IntervalType?) -> Unit, ) { var startDate by remember(modal) { - mutableStateOf(modal?.initialStartDate ?: timeNowUTC()) + mutableStateOf(modal?.initialStartDate ?: timeNowLocal()) } var oneTime by remember(modal) { mutableStateOf(modal?.initialOneTime ?: false) From 41fddcd2826e1622931ab749d5445bdb7cd61013 Mon Sep 17 00:00:00 2001 From: "mushfiq.salehine" <60137904+Mushfiq1060@users.noreply.github.com> Date: Sun, 29 Sep 2024 19:12:01 +0600 Subject: [PATCH 2/3] Fixes #3432 : refactor the code as per the requested changes --- .../domain/action/viewmodel/home/DueTrnsInfoAct.kt | 9 +++------ .../legacy/legacy/ui/theme/modal/RecurringRuleModal.kt | 5 +++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/temp/legacy-code/src/main/java/com/ivy/legacy/domain/action/viewmodel/home/DueTrnsInfoAct.kt b/temp/legacy-code/src/main/java/com/ivy/legacy/domain/action/viewmodel/home/DueTrnsInfoAct.kt index 4cc20312f3..233e521a85 100644 --- a/temp/legacy-code/src/main/java/com/ivy/legacy/domain/action/viewmodel/home/DueTrnsInfoAct.kt +++ b/temp/legacy-code/src/main/java/com/ivy/legacy/domain/action/viewmodel/home/DueTrnsInfoAct.kt @@ -1,6 +1,6 @@ package com.ivy.wallet.domain.action.viewmodel.home -import com.ivy.base.time.TimeConverter +import com.ivy.base.time.TimeProvider import com.ivy.data.model.Transaction import com.ivy.frp.action.FPAction import com.ivy.frp.lambda @@ -16,7 +16,6 @@ import com.ivy.wallet.domain.pure.exchange.exchangeInBaseCurrency import com.ivy.wallet.domain.pure.transaction.expenses import com.ivy.wallet.domain.pure.transaction.incomes import com.ivy.wallet.domain.pure.transaction.sumTrns -import java.time.Instant import java.time.LocalDate import javax.inject.Inject @@ -24,16 +23,14 @@ class DueTrnsInfoAct @Inject constructor( private val dueTrnsAct: DueTrnsAct, private val accountByIdAct: AccountByIdAct, private val exchangeAct: ExchangeAct, - private val timeConverter: TimeConverter + private val timeProvider: TimeProvider ) : FPAction() { override suspend fun Input.compose(): suspend () -> Output = suspend { range } then dueTrnsAct then { trns -> - val dateNow = with(timeConverter) { - Instant.now().toLocalDate() - } + val dateNow = timeProvider.localDateNow() trns.filter { this.dueFilter(it, dateNow) } diff --git a/temp/legacy-code/src/main/java/com/ivy/legacy/legacy/ui/theme/modal/RecurringRuleModal.kt b/temp/legacy-code/src/main/java/com/ivy/legacy/legacy/ui/theme/modal/RecurringRuleModal.kt index 94724d4e3b..022be44e6e 100644 --- a/temp/legacy-code/src/main/java/com/ivy/legacy/legacy/ui/theme/modal/RecurringRuleModal.kt +++ b/temp/legacy-code/src/main/java/com/ivy/legacy/legacy/ui/theme/modal/RecurringRuleModal.kt @@ -33,6 +33,7 @@ import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.ivy.data.model.IntervalType +import com.ivy.design.api.LocalTimeProvider import com.ivy.design.l0_system.UI import com.ivy.design.l0_system.style import com.ivy.legacy.IvyWalletCtx @@ -47,7 +48,6 @@ import com.ivy.legacy.utils.hideKeyboard import com.ivy.legacy.utils.onScreenStart import com.ivy.design.utils.thenIf import com.ivy.legacy.utils.rememberInteractionSource -import com.ivy.legacy.utils.timeNowLocal import com.ivy.ui.R import com.ivy.wallet.ui.theme.Gradient import com.ivy.wallet.ui.theme.GradientIvy @@ -80,8 +80,9 @@ fun BoxWithConstraintsScope.RecurringRuleModal( dismiss: () -> Unit, onRuleChanged: (LocalDateTime, oneTime: Boolean, Int?, IntervalType?) -> Unit, ) { + val localTimeProvider = LocalTimeProvider.current var startDate by remember(modal) { - mutableStateOf(modal?.initialStartDate ?: timeNowLocal()) + mutableStateOf(modal?.initialStartDate ?: localTimeProvider.localNow()) } var oneTime by remember(modal) { mutableStateOf(modal?.initialOneTime ?: false) From 4e80e244168627fa472457ca2bb2f4ec0674e8f2 Mon Sep 17 00:00:00 2001 From: "mushfiq.salehine" <60137904+Mushfiq1060@users.noreply.github.com> Date: Sun, 29 Sep 2024 19:16:43 +0600 Subject: [PATCH 3/3] Fixes #3432 : refactor code --- .../ivy/legacy/legacy/ui/theme/modal/RecurringRuleModal.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/temp/legacy-code/src/main/java/com/ivy/legacy/legacy/ui/theme/modal/RecurringRuleModal.kt b/temp/legacy-code/src/main/java/com/ivy/legacy/legacy/ui/theme/modal/RecurringRuleModal.kt index 022be44e6e..7c3a027194 100644 --- a/temp/legacy-code/src/main/java/com/ivy/legacy/legacy/ui/theme/modal/RecurringRuleModal.kt +++ b/temp/legacy-code/src/main/java/com/ivy/legacy/legacy/ui/theme/modal/RecurringRuleModal.kt @@ -80,9 +80,9 @@ fun BoxWithConstraintsScope.RecurringRuleModal( dismiss: () -> Unit, onRuleChanged: (LocalDateTime, oneTime: Boolean, Int?, IntervalType?) -> Unit, ) { - val localTimeProvider = LocalTimeProvider.current + val timeProvider = LocalTimeProvider.current var startDate by remember(modal) { - mutableStateOf(modal?.initialStartDate ?: localTimeProvider.localNow()) + mutableStateOf(modal?.initialStartDate ?: timeProvider.localNow()) } var oneTime by remember(modal) { mutableStateOf(modal?.initialOneTime ?: false)