fix: sort stats per day
This commit is contained in:
@@ -88,7 +88,6 @@ fun StatisticsScreen(navController: NavController) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.O)
|
|
||||||
@Composable
|
@Composable
|
||||||
fun StatisticsScreen(
|
fun StatisticsScreen(
|
||||||
summaryPerCategoryList: List<SummaryPerCategory>,
|
summaryPerCategoryList: List<SummaryPerCategory>,
|
||||||
@@ -124,7 +123,7 @@ fun StatisticsScreen(
|
|||||||
modifier = Modifier.heightIn(max = 300.dp),
|
modifier = Modifier.heightIn(max = 300.dp),
|
||||||
summaryPerCategoryList = summaryPerCategoryList
|
summaryPerCategoryList = summaryPerCategoryList
|
||||||
)
|
)
|
||||||
SummaryPerDayCard(modifier = Modifier.height(300.dp), summaryPerDayList = summaryPerDayList, onDayClicked = onDayClicked)
|
SummaryPerDayCard(modifier = Modifier.height(300.dp), summaryPerDayList = summaryPerDayList.sortedBy { it.day }, onDayClicked = onDayClicked)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -98,7 +98,6 @@ open class ExpenseAndCategoryViewModel @Inject constructor(
|
|||||||
): Flow<List<ExpenseDto>> =
|
): Flow<List<ExpenseDto>> =
|
||||||
expenseRepo.getExpensesDto(tripId, search, filter)
|
expenseRepo.getExpensesDto(tripId, search, filter)
|
||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.O)
|
|
||||||
fun save(expense: Expense, trip: Trip, onComplete: (Int) -> Unit) {
|
fun save(expense: Expense, trip: Trip, onComplete: (Int) -> Unit) {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
val rate = exchangeRateRepository.getRate(
|
val rate = exchangeRateRepository.getRate(
|
||||||
@@ -133,7 +132,6 @@ open class ExpenseAndCategoryViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.O)
|
|
||||||
suspend fun generateCSVToFile(tripId: Int, file: File) {
|
suspend fun generateCSVToFile(tripId: Int, file: File) {
|
||||||
file.writer().use { writer ->
|
file.writer().use { writer ->
|
||||||
CSVPrinter(
|
CSVPrinter(
|
||||||
@@ -153,7 +151,6 @@ open class ExpenseAndCategoryViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.O)
|
|
||||||
fun getDailySums(tripId: Int, search: String, filter: Filter): Flow<Map<LocalDate, Double>> {
|
fun getDailySums(tripId: Int, search: String, filter: Filter): Flow<Map<LocalDate, Double>> {
|
||||||
return getExpensesDto(tripId, search, filter)
|
return getExpensesDto(tripId, search, filter)
|
||||||
.map { expenses ->
|
.map { expenses ->
|
||||||
@@ -164,14 +161,12 @@ open class ExpenseAndCategoryViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.O)
|
|
||||||
fun getSummaryAmount(tripId: Int): Flow<Double> {
|
fun getSummaryAmount(tripId: Int): Flow<Double> {
|
||||||
return getExpensesDto(tripId).map { list ->
|
return getExpensesDto(tripId).map { list ->
|
||||||
list.sumOf { it.expense.amount * it.expense.rate }
|
list.sumOf { it.expense.amount * it.expense.rate }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.O)
|
|
||||||
fun getSummaryPerCategory(tripId: Int): Flow<List<SummaryPerCategory>> {
|
fun getSummaryPerCategory(tripId: Int): Flow<List<SummaryPerCategory>> {
|
||||||
val tripFlow = tripRepo.getTrip(tripId)
|
val tripFlow = tripRepo.getTrip(tripId)
|
||||||
val expensesFlow = getExpensesDto(tripId)
|
val expensesFlow = getExpensesDto(tripId)
|
||||||
@@ -194,7 +189,6 @@ open class ExpenseAndCategoryViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.O)
|
|
||||||
fun getSummaryPerDay(tripId: Int): Flow<List<SummaryPerDay>> {
|
fun getSummaryPerDay(tripId: Int): Flow<List<SummaryPerDay>> {
|
||||||
val tripFlow = tripRepo.getTrip(tripId)
|
val tripFlow = tripRepo.getTrip(tripId)
|
||||||
val expensesFlow = getExpensesDto(tripId)
|
val expensesFlow = getExpensesDto(tripId)
|
||||||
@@ -220,14 +214,12 @@ open class ExpenseAndCategoryViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.O)
|
|
||||||
fun clearOldRates() {
|
fun clearOldRates() {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
exchangeRateRepository.clearOldRates()
|
exchangeRateRepository.clearOldRates()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.O)
|
|
||||||
sealed class ExpenseListItemUi {
|
sealed class ExpenseListItemUi {
|
||||||
data class Item(val expenseDto: ExpenseDto) : ExpenseListItemUi()
|
data class Item(val expenseDto: ExpenseDto) : ExpenseListItemUi()
|
||||||
data class Header(val date: LocalDate, val sum: Double, val currency: String) :
|
data class Header(val date: LocalDate, val sum: Double, val currency: String) :
|
||||||
|
|||||||
Reference in New Issue
Block a user