Skip to content

Commit

Permalink
fix wrong amounts being saved, when decimals != 2, closes #79
Browse files Browse the repository at this point in the history
  • Loading branch information
Marmo committed Jan 6, 2022
1 parent 0efab7a commit 4f001f6
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,10 @@ public void onSaveTransactionAction() {

// parse amount
// user is expected to enter something like "10.05"(€/$/...) and we want to store 1005 (format is enforced by AmountTextWatcher)
if (isMonetary) factor *= 100;
// OR "10" 10
// OR "10.1" 101
// OR "10.050" 10050
if (isMonetary) factor *= Math.pow(10, Utilities.getNrOfDecimals(requireContext()));
int amount;
try {
amount = Utilities.nextInt(factor * Utilities.parseAmount(editAmount.getText().toString()));
Expand Down

0 comments on commit 4f001f6

Please sign in to comment.