]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/json/ParsedLedgerTransaction.java
fix NPE in ParsedLedgerTransaction.setTindex
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / json / ParsedLedgerTransaction.java
index 62cf1d0a83fa0b662cb14f774461e413b4d6fe9b..7ba1421cb8db54374df420456b168e00b77916f0 100644 (file)
@@ -23,16 +23,55 @@ import net.ktnx.mobileledger.model.LedgerTransaction;
 import net.ktnx.mobileledger.utils.Globals;
 
 import java.text.ParseException;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
 @JsonIgnoreProperties(ignoreUnknown = true)
 public class ParsedLedgerTransaction {
-    private String tdate, tdate2, tdescription, tcomment;
+    private String tdate;
+    private String tdate2 = null;
+    private String tdescription;
+    private String tcomment;
+    private String tcode = "";
+    private String tstatus = "Unmarked";
+    private String tprecedingcomment = "";
     private int tindex;
     private List<ParsedPosting> tpostings;
+    private List<List<String>> ttags = new ArrayList<>();
+    private ParsedSourcePos tsourcepos = new ParsedSourcePos();
     public ParsedLedgerTransaction() {
     }
+    public String getTcode() {
+        return tcode;
+    }
+    public void setTcode(String tcode) {
+        this.tcode = tcode;
+    }
+    public String getTstatus() {
+        return tstatus;
+    }
+    public void setTstatus(String tstatus) {
+        this.tstatus = tstatus;
+    }
+    public List<List<String>> getTtags() {
+        return ttags;
+    }
+    public void setTtags(List<List<String>> ttags) {
+        this.ttags = ttags;
+    }
+    public ParsedSourcePos getTsourcepos() {
+        return tsourcepos;
+    }
+    public void setTsourcepos(ParsedSourcePos tsourcepos) {
+        this.tsourcepos = tsourcepos;
+    }
+    public String getTprecedingcomment() {
+        return tprecedingcomment;
+    }
+    public void setTprecedingcomment(String tprecedingcomment) {
+        this.tprecedingcomment = tprecedingcomment;
+    }
     public String getTdate() {
         return tdate;
     }
@@ -62,6 +101,10 @@ public class ParsedLedgerTransaction {
     }
     public void setTindex(int tindex) {
         this.tindex = tindex;
+        if (tpostings != null)
+            for (ParsedPosting p : tpostings) {
+                p.setPtransaction_(tindex);
+            }
     }
     public List<ParsedPosting> getTpostings() {
         return tpostings;
@@ -69,6 +112,10 @@ public class ParsedLedgerTransaction {
     public void setTpostings(List<ParsedPosting> tpostings) {
         this.tpostings = tpostings;
     }
+    public void addPosting(ParsedPosting posting) {
+        posting.setPtransaction_(tindex);
+        tpostings.add(posting);
+    }
     public LedgerTransaction asLedgerTransaction() throws ParseException {
         Date date = Globals.parseIsoDate(tdate);
         LedgerTransaction tr = new LedgerTransaction(tindex, date, tdescription);