Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
mtotschnig committed Sep 24, 2024
1 parent fb69e1c commit 9e317ff
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions myExpenses/src/main/java/org/totschnig/myexpenses/compose/Debt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -177,18 +177,23 @@ fun DebtRenderer(
)
val count = transactions.size
transactions.forEachIndexed { index, transaction ->
val runningTotal =
if (showEquivalentAmount.value) transaction.equivalentRunningTotal else transaction.runningTotal
val previousBalance =
if (index == 0) start else with(transactions[index - 1]) {
if (showEquivalentAmount.value) equivalentRunningTotal else this.runningTotal
}

val trend =
if (previousBalance.sign * runningTotal.sign == -1)
0
else
runningTotal.absoluteValue.compareTo(previousBalance.absoluteValue)
val runningTotal = if (showEquivalentAmount.value)
transaction.equivalentRunningTotal
else
transaction.runningTotal

val previousBalance = if (index == 0)
start
else with(transactions[index - 1]) {
if (showEquivalentAmount.value) equivalentRunningTotal else runningTotal
}

val trend = if (previousBalance.sign * runningTotal.sign == -1)
0
else
runningTotal.absoluteValue.compareTo(previousBalance.absoluteValue)

val trendIcon = when {
runningTotal == 0L -> R.drawable.ic_check
trend > 0 -> R.drawable.ic_debt_up
Expand Down

0 comments on commit 9e317ff

Please sign in to comment.