diff --git a/shared/data/core/src/main/java/com/ivy/data/repository/mapper/TransactionMapper.kt b/shared/data/core/src/main/java/com/ivy/data/repository/mapper/TransactionMapper.kt index 70a1c574ee..0004813c82 100644 --- a/shared/data/core/src/main/java/com/ivy/data/repository/mapper/TransactionMapper.kt +++ b/shared/data/core/src/main/java/com/ivy/data/repository/mapper/TransactionMapper.kt @@ -11,18 +11,19 @@ import com.ivy.data.model.AccountId import com.ivy.data.model.CategoryId import com.ivy.data.model.Expense import com.ivy.data.model.Income +import com.ivy.data.model.PositiveValue +import com.ivy.data.model.TagId import com.ivy.data.model.Transaction import com.ivy.data.model.TransactionId import com.ivy.data.model.TransactionMetadata import com.ivy.data.model.Transfer -import com.ivy.data.model.PositiveValue import com.ivy.data.model.getFromAccount import com.ivy.data.model.getToAccount import com.ivy.data.model.primitive.NotBlankTrimmedString import com.ivy.data.model.primitive.PositiveDouble -import com.ivy.data.model.TagId import com.ivy.data.repository.AccountRepository import java.time.Instant +import java.time.ZoneOffset import javax.inject.Inject class TransactionMapper @Inject constructor( @@ -35,10 +36,11 @@ class TransactionMapper @Inject constructor( ): Either = either { val metadata = TransactionMetadata( recurringRuleId = recurringRuleId, - paidForDateTime = paidForDateTime?.atZone(timeProvider.getZoneId())?.toInstant(), + paidForDateTime = paidForDateTime?.toInstant(ZoneOffset.UTC), loanId = loanId, loanRecordId = loanRecordId ) + val settled = dateTime != null val time = mapTime().bind() @@ -132,13 +134,13 @@ class TransactionMapper @Inject constructor( } private fun TransactionEntity.mapTime(): Either = either { - val time = (dateTime ?: dueDate)?.atZone(timeProvider.getZoneId())?.toInstant() + val time = (dateTime ?: dueDate)?.toInstant(ZoneOffset.UTC) ensureNotNull(time) { "Missing transaction time for entity: $this" } time } fun Transaction.toEntity(): TransactionEntity { - val dateTime = time.atZone(timeProvider.getZoneId()).toLocalDateTime() + val dateTime = time.atZone(ZoneOffset.UTC).toLocalDateTime() return TransactionEntity( accountId = getFromAccount().value, type = when (this) {