This repository has been archived by the owner on Nov 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 712
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5b4343f
commit 63837c4
Showing
5 changed files
with
61 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
app/src/main/java/com/ivy/wallet/domain/action/category/CategoriesAct.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Unit, List<Category>>() { | ||
override suspend fun Unit.compose(): suspend () -> List<Category> = suspend { | ||
io { | ||
categoryDao.findAll() | ||
} | ||
} thenMap { it.toDomain() } | ||
} |
37 changes: 37 additions & 0 deletions
37
app/src/main/java/com/ivy/wallet/domain/action/category/CategoryTrnsBetweenAct.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<CategoryTrnsBetweenAct.Input, List<Transaction>>() { | ||
|
||
override suspend fun Input.compose(): suspend () -> List<Transaction> = 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 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters