Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
WIP: Fix bugs (terrible code!)
Browse files Browse the repository at this point in the history
  • Loading branch information
ILIYANGERMANOV committed Apr 15, 2023
1 parent d6194eb commit 10ff0ee
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
5 changes: 4 additions & 1 deletion app/src/main/java/com/ivy/wallet/ui/csv/CSVScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -304,13 +304,16 @@ private fun AmountMetadata(
multiplier < 0 -> "/$multiplier"
multiplier > 1 -> "*$multiplier"
else -> "None"
}
},
style = UI.typo.nB2,
color = UI.colors.primary,
)
Spacer8(horizontal = true)
Button(onClick = {
onEvent(
CSVEvent.AmountMultiplier(
when {
multiplier == -10 -> 1
multiplier == -1 -> 10
multiplier > 0 -> multiplier * 10
else -> multiplier / 10
Expand Down
11 changes: 10 additions & 1 deletion app/src/main/java/com/ivy/wallet/ui/csv/domain/ParseStatus.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,16 @@ private fun parseAmountStatus(
): MappingStatus = tryStatus {
val values = rows.values(mapping)
.mapNotNull {
it.toDoubleOrNull()?.plus(mapping.metadata)?.let(::abs)
val multiplier = when (mapping.metadata) {
-1000 -> 0.001
-100 -> 0.01
-10 -> 0.1
10 -> 10.0
100 -> 100.0
1000 -> 1000.0
else -> 1.0
}
it.toDoubleOrNull()?.times(multiplier)?.let(::abs)
}

MappingStatus(
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/ivy/wallet/ui/csv/domain/Parser.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package com.ivy.wallet.ui.csv.domain

0 comments on commit 10ff0ee

Please sign in to comment.