fix NPE in ParsedLedgerTransaction.setTindex
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sat, 30 Nov 2019 14:10:35 +0000 (16:10 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Sat, 30 Nov 2019 14:10:35 +0000 (16:10 +0200)
app/src/main/java/net/ktnx/mobileledger/json/ParsedLedgerTransaction.java

index 81d7647..7ba1421 100644 (file)
@@ -101,20 +101,21 @@ public class ParsedLedgerTransaction {
     }
     public void setTindex(int tindex) {
         this.tindex = tindex;
-        for(ParsedPosting p : tpostings) {
-            p.setPtransaction_(tindex);
-        }
+        if (tpostings != null)
+            for (ParsedPosting p : tpostings) {
+                p.setPtransaction_(tindex);
+            }
     }
     public List<ParsedPosting> getTpostings() {
         return tpostings;
     }
+    public void setTpostings(List<ParsedPosting> tpostings) {
+        this.tpostings = tpostings;
+    }
     public void addPosting(ParsedPosting posting) {
         posting.setPtransaction_(tindex);
         tpostings.add(posting);
     }
-    public void setTpostings(List<ParsedPosting> tpostings) {
-        this.tpostings = tpostings;
-    }
     public LedgerTransaction asLedgerTransaction() throws ParseException {
         Date date = Globals.parseIsoDate(tdate);
         LedgerTransaction tr = new LedgerTransaction(tindex, date, tdescription);