]> git.ktnx.net Git - mobile-ledger.git/commitdiff
helper method for getting transaction item (currency + amount) as string
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sat, 15 Dec 2018 19:36:27 +0000 (19:36 +0000)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Sat, 15 Dec 2018 19:36:27 +0000 (19:36 +0000)
app/src/main/java/net/ktnx/mobileledger/model/LedgerTransactionItem.java

index de43058067f193216674c1f09634db7f2f958331..108425846dd7d16baa1036870593e716b36dccc5 100644 (file)
@@ -17,6 +17,8 @@
 
 package net.ktnx.mobileledger.model;
 
+import android.support.annotation.NonNull;
+
 public class LedgerTransactionItem {
     private String accountName;
     private float amount;
@@ -71,4 +73,17 @@ public class LedgerTransactionItem {
     public String getCurrency() {
         return currency;
     }
+    @NonNull
+    public String toString() {
+        if (!amountSet) return "";
+
+        StringBuilder sb = new StringBuilder();
+        if (currency != null) {
+            sb.append(currency);
+            sb.append(' ');
+        }
+        sb.append(String.format("%,1.2f", amount));
+
+        return sb.toString();
+    }
 }