]> git.ktnx.net Git - mobile-ledger.git/commitdiff
fu: DB support for comments
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 5 Jan 2020 21:08:24 +0000 (23:08 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 5 Jan 2020 21:08:24 +0000 (23:08 +0200)
app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java
app/src/main/java/net/ktnx/mobileledger/json/v1_14/ParsedPosting.java
app/src/main/java/net/ktnx/mobileledger/json/v1_15/ParsedPosting.java

index 807e43752cffd6aa7b6ef4427d8b438f7c584247..44e916c536b8aa4beb0c6b7060243d930c5fb941 100644 (file)
@@ -371,7 +371,7 @@ public class RetrieveTransactionsTask
                                     if (currency == null) currency = "";
                                     amount = amount.replace(',', '.');
                                     transaction.addAccount(new LedgerTransactionAccount(acc_name,
-                                            Float.valueOf(amount), currency));
+                                            Float.valueOf(amount), currency, null));
                                     L(String.format(Locale.ENGLISH, "%d: %s = %s",
                                             transaction.getId(), acc_name, amount));
                                 }
index f1a6e1ff9975c214f6b0519f86f58f9fe12d2e31..a3667a23b26b4b17dced960c11ba2a6e2bc8a34b 100644 (file)
@@ -135,7 +135,8 @@ public class ParsedPosting {
     public LedgerTransactionAccount asLedgerAccount() {
         ParsedAmount amt = pamount.get(0);
         return new LedgerTransactionAccount(paccount, amt.getAquantity()
-                                                         .asFloat(), amt.getAcommodity());
+                                                         .asFloat(), amt.getAcommodity(),
+                getPcomment());
     }
 
 }
index 0789f0d9fbd8e43fea1c6afec1a1d9699e507f70..a0607512fa3aec4bf71f178f7d8448e7d869a545 100644 (file)
@@ -31,26 +31,53 @@ public class ParsedPosting {
     private String paccount;
     private List<ParsedAmount> pamount;
     private String pdate = null;
-    public String getPdate2() {
-        return pdate2;
-    }
-    public void setPdate2(String pdate2) {
-        this.pdate2 = pdate2;
-    }
     private String pdate2 = null;
     private String ptype = "RegularPosting";
     private String pcomment = "";
     private List<List<String>> ptags = new ArrayList<>();
     private String poriginal = null;
     private int ptransaction_;
+    public ParsedPosting() {
+    }
+    public static ParsedPosting fromLedgerAccount(LedgerTransactionAccount acc) {
+        ParsedPosting result = new ParsedPosting();
+        result.setPaccount(acc.getAccountName());
+
+        String comment = acc.getComment();
+        if (comment == null)
+            comment = "";
+        result.setPcomment(comment);
+
+        ArrayList<ParsedAmount> amounts = new ArrayList<>();
+        ParsedAmount amt = new ParsedAmount();
+        amt.setAcommodity((acc.getCurrency() == null) ? "" : acc.getCurrency());
+        amt.setAismultiplier(false);
+        ParsedQuantity qty = new ParsedQuantity();
+        qty.setDecimalPlaces(2);
+        qty.setDecimalMantissa(Math.round(acc.getAmount() * 100));
+        amt.setAquantity(qty);
+        ParsedStyle style = new ParsedStyle();
+        style.setAscommodityside('L');
+        style.setAscommodityspaced(false);
+        style.setAsprecision(2);
+        style.setAsdecimalpoint('.');
+        amt.setAstyle(style);
+        amounts.add(amt);
+        result.setPamount(amounts);
+        return result;
+    }
+    public String getPdate2() {
+        return pdate2;
+    }
+    public void setPdate2(String pdate2) {
+        this.pdate2 = pdate2;
+    }
     public int getPtransaction_() {
         return ptransaction_;
     }
     public void setPtransaction_(int ptransaction_) {
         this.ptransaction_ = ptransaction_;
     }
-    public ParsedPosting() {
-    }
     public String getPdate() {
         return pdate;
     }
@@ -107,35 +134,9 @@ public class ParsedPosting {
     }
     public LedgerTransactionAccount asLedgerAccount() {
         ParsedAmount amt = pamount.get(0);
-        return new LedgerTransactionAccount(paccount, amt.getAquantity().asFloat(),
-                amt.getAcommodity());
-    }
-    public static ParsedPosting fromLedgerAccount(LedgerTransactionAccount acc) {
-        ParsedPosting result = new ParsedPosting();
-        result.setPaccount(acc.getAccountName());
-
-        String comment = acc.getComment();
-        if (comment == null)
-            comment = "";
-        result.setPcomment(comment);
-
-        ArrayList<ParsedAmount> amounts = new ArrayList<>();
-        ParsedAmount amt = new ParsedAmount();
-        amt.setAcommodity((acc.getCurrency() == null) ? "" : acc.getCurrency());
-        amt.setAismultiplier(false);
-        ParsedQuantity qty = new ParsedQuantity();
-        qty.setDecimalPlaces(2);
-        qty.setDecimalMantissa(Math.round(acc.getAmount() * 100));
-        amt.setAquantity(qty);
-        ParsedStyle style = new ParsedStyle();
-        style.setAscommodityside('L');
-        style.setAscommodityspaced(false);
-        style.setAsprecision(2);
-        style.setAsdecimalpoint('.');
-        amt.setAstyle(style);
-        amounts.add(amt);
-        result.setPamount(amounts);
-        return result;
+        return new LedgerTransactionAccount(paccount, amt.getAquantity()
+                                                         .asFloat(), amt.getAcommodity(),
+                getPcomment());
     }
 
 }