]> git.ktnx.net Git - mobile-ledger.git/commitdiff
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 81d76475072dfcd82ca13f92496bc55749d79716..7ba1421cb8db54374df420456b168e00b77916f0 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);