From da86ec65607023296a2efb284997d476fcb85e41 Mon Sep 17 00:00:00 2001 From: Mushfiq1060 <60137904+Mushfiq1060@users.noreply.github.com> Date: Mon, 30 Sep 2024 14:24:31 +0600 Subject: [PATCH] Fix #3432 Recurring expenses spawn at UTC timing instead of local time (#3570) * Fixes #3432 : recurring expenses not spawn at local time * Fixes #3432 : refactor the code as per the requested changes * Fixes #3432 : refactor code --- .../legacy/domain/action/viewmodel/home/DueTrnsInfoAct.kt | 7 ++++--- .../ivy/legacy/legacy/ui/theme/modal/RecurringRuleModal.kt | 5 +++-- 2 files changed, 7 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..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,10 +1,10 @@ package com.ivy.wallet.domain.action.viewmodel.home +import com.ivy.base.time.TimeProvider 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 @@ -22,14 +22,15 @@ 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 timeProvider: TimeProvider ) : FPAction() { override suspend fun Input.compose(): suspend () -> Output = suspend { range } then dueTrnsAct then { trns -> - val dateNow = dateNowUTC() + 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 68d759ba26..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 @@ -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.timeNowUTC 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 timeProvider = LocalTimeProvider.current var startDate by remember(modal) { - mutableStateOf(modal?.initialStartDate ?: timeNowUTC()) + mutableStateOf(modal?.initialStartDate ?: timeProvider.localNow()) } var oneTime by remember(modal) { mutableStateOf(modal?.initialOneTime ?: false)