Skip to content

Commit

Permalink
refs #1086: Fix skip, skip all and pay buttons on Reports screen (#2797)
Browse files Browse the repository at this point in the history
  • Loading branch information
MaratKhakim committed Oct 19, 2023
1 parent 9fe7ff9 commit e50c806
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
8 changes: 7 additions & 1 deletion screen-reports/src/main/java/com/ivy/reports/ReportScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,13 @@ private fun BoxWithConstraintsScope.UI(
onEventHandler.invoke(ReportScreenEvent.OnPayOrGet(transaction = it))
},
emptyStateTitle = stringRes(R.string.no_transactions),
emptyStateText = stringRes(R.string.no_transactions_for_your_filter)
emptyStateText = stringRes(R.string.no_transactions_for_your_filter),
onSkipTransaction = {
onEventHandler.invoke(ReportScreenEvent.SkipTransaction(transaction = it))
},
onSkipAllTransactions = {
onEventHandler.invoke(ReportScreenEvent.SkipTransactions(transactions = it))
}
)
} else {
item {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ sealed class ReportScreenEvent {
data class OnFilter(val filter: ReportFilter?) : ReportScreenEvent()
data class OnExport(val context: Context) : ReportScreenEvent()
data class OnPayOrGet(val transaction: Transaction) : ReportScreenEvent()
data class SkipTransaction(val transaction: Transaction) : ReportScreenEvent()
data class SkipTransactions(val transactions: List<Transaction>) : ReportScreenEvent()
data class OnUpcomingExpanded(val upcomingExpanded: Boolean) : ReportScreenEvent()
data class OnOverdueExpanded(val overdueExpanded: Boolean) : ReportScreenEvent()
data class OnFilterOverlayVisible(val filterOverlayVisible: Boolean) : ReportScreenEvent()
Expand Down
27 changes: 27 additions & 0 deletions screen-reports/src/main/java/com/ivy/reports/ReportViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ class ReportViewModel @Inject constructor(
is ReportScreenEvent.OnFilter -> setFilter(event.filter)
is ReportScreenEvent.OnExport -> export(event.context)
is ReportScreenEvent.OnPayOrGet -> payOrGet(event.transaction)
is ReportScreenEvent.SkipTransaction -> skipTransaction(event.transaction)
is ReportScreenEvent.SkipTransactions -> skipTransactions(event.transactions)
is ReportScreenEvent.OnOverdueExpanded -> setOverdueExpanded(event.overdueExpanded)
is ReportScreenEvent.OnUpcomingExpanded -> setUpcomingExpanded(event.upcomingExpanded)
is ReportScreenEvent.OnFilterOverlayVisible -> setFilterOverlayVisible(event.filterOverlayVisible)
Expand Down Expand Up @@ -404,6 +406,7 @@ class ReportViewModel @Inject constructor(
uiThread {
plannedPaymentsLogic.payOrGet(transaction = transaction) {
start()
setFilter(filter.value)
}
}
}
Expand All @@ -419,4 +422,28 @@ class ReportViewModel @Inject constructor(
if (transfersAsIncExp) historyIncomeExpense.value.transferExpense.toDouble() else 0.0
treatTransfersAsIncExp.value = transfersAsIncExp
}

private suspend fun skipTransaction(transaction: Transaction) {
uiThread {
plannedPaymentsLogic.payOrGet(
transaction = transaction,
skipTransaction = true
) {
start()
setFilter(filter.value)
}
}
}

private suspend fun skipTransactions(transactions: List<Transaction>) {
uiThread {
plannedPaymentsLogic.payOrGet(
transactions = transactions,
skipTransaction = true
) {
start()
setFilter(filter.value)
}
}
}
}

0 comments on commit e50c806

Please sign in to comment.