Fix transaction querying
The requested date ranges were a little off
This commit is contained in:
parent
e533d98a07
commit
0e7da4c40a
2 changed files with 3 additions and 6 deletions
|
@ -8,7 +8,6 @@ import com.wbrawner.budget.common.budget.BudgetRepository
|
|||
import com.wbrawner.budget.common.transaction.Transaction
|
||||
import com.wbrawner.budget.common.transaction.TransactionRepository
|
||||
import com.wbrawner.budget.launch
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
||||
class TransactionListViewModel : ViewModel(), AsyncViewModel<List<Transaction>> {
|
||||
|
@ -20,15 +19,13 @@ class TransactionListViewModel : ViewModel(), AsyncViewModel<List<Transaction>>
|
|||
override val state: MutableLiveData<AsyncState<List<Transaction>>> = MutableLiveData(AsyncState.Loading)
|
||||
|
||||
fun getTransactions(
|
||||
categoryId: String? = null,
|
||||
start: Calendar? = null,
|
||||
end: Calendar? = null
|
||||
categoryId: String? = null
|
||||
) {
|
||||
budgetRepository.currentBudget.observeForever { budget ->
|
||||
val budgets = budget?.id?.let { listOf(it) }
|
||||
val categories = categoryId?.let { listOf(it) }
|
||||
launch {
|
||||
transactionRepo.findAll(budgets, categories, start, end).toList()
|
||||
transactionRepo.findAll(budgets, categories).toList()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import java.util.*
|
|||
import javax.inject.Inject
|
||||
|
||||
class NetworkTransactionRepository @Inject constructor(private val apiService: TwigsApiService) : TransactionRepository {
|
||||
private val dateFormatter = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.ENGLISH)
|
||||
private val dateFormatter = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ", Locale.ENGLISH)
|
||||
|
||||
override suspend fun create(newItem: Transaction): Transaction = apiService.newTransaction(newItem)
|
||||
|
||||
|
|
Loading…
Reference in a new issue