diff --git a/app/src/main/java/com/ivy/wallet/domain/action/ExchangeAct.kt b/app/src/main/java/com/ivy/wallet/domain/action/ExchangeAct.kt index 016088db4c..d561ca3bb5 100644 --- a/app/src/main/java/com/ivy/wallet/domain/action/ExchangeAct.kt +++ b/app/src/main/java/com/ivy/wallet/domain/action/ExchangeAct.kt @@ -30,7 +30,7 @@ class ExchangeAct @Inject constructor( ) } -fun exchangeActInput( +fun actInput( data: ExchangeData, amount: BigDecimal ): ExchangeAct.Input = ExchangeAct.Input( diff --git a/app/src/main/java/com/ivy/wallet/domain/action/category/CategoriesAct.kt b/app/src/main/java/com/ivy/wallet/domain/action/category/CategoriesAct.kt new file mode 100644 index 0000000000..f0c5869cdd --- /dev/null +++ b/app/src/main/java/com/ivy/wallet/domain/action/category/CategoriesAct.kt @@ -0,0 +1,17 @@ +package com.ivy.wallet.domain.action.category + +import com.ivy.fp.action.FPAction +import com.ivy.fp.action.thenMap +import com.ivy.wallet.domain.data.core.Category +import com.ivy.wallet.io.persistence.dao.CategoryDao +import javax.inject.Inject + +class CategoriesAct @Inject constructor( + private val categoryDao: CategoryDao +) : FPAction>() { + override suspend fun Unit.compose(): suspend () -> List = suspend { + io { + categoryDao.findAll() + } + } thenMap { it.toDomain() } +} \ No newline at end of file diff --git a/app/src/main/java/com/ivy/wallet/domain/action/category/CategoryTrnsBetweenAct.kt b/app/src/main/java/com/ivy/wallet/domain/action/category/CategoryTrnsBetweenAct.kt new file mode 100644 index 0000000000..1303090ac9 --- /dev/null +++ b/app/src/main/java/com/ivy/wallet/domain/action/category/CategoryTrnsBetweenAct.kt @@ -0,0 +1,37 @@ +package com.ivy.wallet.domain.action.category + +import com.ivy.fp.action.FPAction +import com.ivy.fp.action.thenMap +import com.ivy.wallet.domain.data.core.Transaction +import com.ivy.wallet.domain.pure.data.ClosedTimeRange +import com.ivy.wallet.io.persistence.dao.TransactionDao +import java.util.* +import javax.inject.Inject + +class CategoryTrnsBetweenAct @Inject constructor( + private val transactionDao: TransactionDao +) : FPAction>() { + + override suspend fun Input.compose(): suspend () -> List = suspend { + io { + transactionDao.findAllByCategoryAndBetween( + startDate = between.from, + endDate = between.to, + categoryId = categoryId + ) + } + } thenMap { it.toDomain() } + + data class Input( + val categoryId: UUID, + val between: ClosedTimeRange + ) +} + +fun actInput( + categoryId: UUID, + between: ClosedTimeRange +) = CategoryTrnsBetweenAct.Input( + categoryId = categoryId, + between = between +) \ No newline at end of file diff --git a/app/src/main/java/com/ivy/wallet/domain/action/transaction/AddDateDividersAct.kt b/app/src/main/java/com/ivy/wallet/domain/action/transaction/AddDateDividersAct.kt index d990adc4f5..1c657e29ed 100644 --- a/app/src/main/java/com/ivy/wallet/domain/action/transaction/AddDateDividersAct.kt +++ b/app/src/main/java/com/ivy/wallet/domain/action/transaction/AddDateDividersAct.kt @@ -3,7 +3,7 @@ package com.ivy.wallet.domain.action.transaction import com.ivy.fp.action.FPAction import com.ivy.fp.then import com.ivy.wallet.domain.action.ExchangeAct -import com.ivy.wallet.domain.action.exchangeActInput +import com.ivy.wallet.domain.action.actInput import com.ivy.wallet.domain.data.TransactionHistoryItem import com.ivy.wallet.domain.data.core.Transaction import com.ivy.wallet.domain.pure.wallet.withDateDividers @@ -19,7 +19,7 @@ class AddDateDividersAct @Inject constructor( transactions.withDateDividers( baseCurrencyCode = baseCurrency, getAccount = accountDao::findById then { it?.toDomain() }, - exchange = ::exchangeActInput then exchangeAct + exchange = ::actInput then exchangeAct ) } diff --git a/app/src/main/java/com/ivy/wallet/ui/statistic/level2/ItemStatisticViewModel.kt b/app/src/main/java/com/ivy/wallet/ui/statistic/level2/ItemStatisticViewModel.kt index 7a4d302921..ff90c17f5d 100644 --- a/app/src/main/java/com/ivy/wallet/ui/statistic/level2/ItemStatisticViewModel.kt +++ b/app/src/main/java/com/ivy/wallet/ui/statistic/level2/ItemStatisticViewModel.kt @@ -10,16 +10,15 @@ import com.ivy.wallet.domain.data.TransactionType import com.ivy.wallet.domain.data.core.Account import com.ivy.wallet.domain.data.core.Category import com.ivy.wallet.domain.data.core.Transaction -import com.ivy.wallet.domain.logic.* -import com.ivy.wallet.domain.logic.currency.ExchangeRatesLogic +import com.ivy.wallet.domain.deprecated.logic.* +import com.ivy.wallet.domain.deprecated.logic.currency.ExchangeRatesLogic +import com.ivy.wallet.domain.deprecated.sync.uploader.AccountUploader +import com.ivy.wallet.domain.deprecated.sync.uploader.CategoryUploader import com.ivy.wallet.domain.pure.account.calculateAccountBalance import com.ivy.wallet.domain.pure.account.calculateAccountIncomeExpense import com.ivy.wallet.domain.pure.data.WalletDAOs -import com.ivy.wallet.domain.pure.exchangeToBaseCurrency import com.ivy.wallet.domain.pure.wallet.baseCurrencyCode import com.ivy.wallet.domain.pure.wallet.withDateDividers -import com.ivy.wallet.domain.sync.uploader.AccountUploader -import com.ivy.wallet.domain.sync.uploader.CategoryUploader import com.ivy.wallet.io.persistence.dao.* import com.ivy.wallet.stringRes import com.ivy.wallet.ui.ItemStatistic