Skip to content

Commit

Permalink
codinguser#876 - ** when editing transaction, display 2 decimals but …
Browse files Browse the repository at this point in the history
…not currency symbol because it shall be evaluated (in order to allows arithmetic expressions as value)
  • Loading branch information
JeanGarf committed Jun 7, 2021
1 parent 13b3baf commit 8cca2e3
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions app/src/main/java/org/gnucash/android/model/AccountType.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ public TransactionType getDefaultTransactionType() {
* @param shallDisplayCurrency if true will display Currency as well as amount (usefull when displaying balance in
* TransactionListFragment, BalanceSheetFragment...)
* else will not display Currency (usefull in SplitEditorFragment or TransactionFormFragment)
* because this allows the value to be an arithmetic expression (ex. 130.67+3) that can be
* evluated when loosing focus
*/
public void displayBalance(final TextView balanceTextView,
final Money balance,
Expand All @@ -134,7 +136,7 @@ public void displayBalance(final TextView balanceTextView,
final Money balanceToDisplay = getBalanceWithSignumForDisplay(balance);

if (shallDisplayCurrency) {
// Shall currency
// Shall display currency

// Display currency
balanceTextView.setText(!shallDisplayNegativeSignum
Expand All @@ -143,19 +145,21 @@ public void displayBalance(final TextView balanceTextView,
: balanceToDisplay.formattedString());

} else {
// Shall not display currency
// Shall not display currency, because the value may be an aritmetic expression (ex. 130.67+3)
// and must not contain currency to be evaluated

// Shall display value in all other cases than zero balance and shall not display zero balance
final boolean shallDisplayValue = !(balanceToDisplay.isAmountZero() && !shallDisplayZero);

if (shallDisplayValue) {
// Shall display balance

// Display value without currency and without decimals
// Display value without currency but with 2 decimals, in order to be able to be evaluated
// in the case where the value is an arithmetic expression like 130.67+3
balanceTextView.setText(!shallDisplayNegativeSignum
? balanceToDisplay.abs()
.toShortString()
: balanceToDisplay.toShortString());
.toLocaleString()
: balanceToDisplay.toLocaleString());

} else {
// Shall not display balance
Expand Down

0 comments on commit 8cca2e3

Please sign in to comment.