From c2682dc904d2b3095310e53f13f19b72d3a460aa Mon Sep 17 00:00:00 2001 From: Charlotte Van Petegem Date: Fri, 15 Sep 2023 13:19:33 +0200 Subject: [PATCH] Fix formatting of posting when no amount was entered (#42) --- .../main/java/be/chvp/nanoledger/ui/add/AddViewModel.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/be/chvp/nanoledger/ui/add/AddViewModel.kt b/app/src/main/java/be/chvp/nanoledger/ui/add/AddViewModel.kt index 6e482ec..562a112 100644 --- a/app/src/main/java/be/chvp/nanoledger/ui/add/AddViewModel.kt +++ b/app/src/main/java/be/chvp/nanoledger/ui/add/AddViewModel.kt @@ -113,12 +113,16 @@ class AddViewModel @Inject constructor( } transaction.append(" ${payee.value}") if (note.value!! != "") { - transaction.append("| ${note.value}") + transaction.append(" | ${note.value}") } transaction.append('\n') // Drop last element, it should always be an empty posting for (posting in postings.value!!.dropLast(1)) { - if (preferencesDataSource.getCurrencyBeforeAmount()) { + if (posting.third == "") { + transaction.append( + " ${posting.first}\n" + ) + } else if (preferencesDataSource.getCurrencyBeforeAmount()) { transaction.append( " ${posting.first} ${posting.second} ${posting.third}\n" )