]> git.ktnx.net Git - mobile-ledger.git/commitdiff
LedgerTransaction.asParsedTransaction: handle null date defaulting to today
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Tue, 26 Nov 2019 21:57:13 +0000 (23:57 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Tue, 26 Nov 2019 21:57:13 +0000 (23:57 +0200)
app/src/main/java/net/ktnx/mobileledger/model/LedgerTransaction.java

index fd900efa1851c5cf1135cebc2a8da5f715f405b6..252b32f41ed7f1fe1ae8fbad7afbefde7c7127e7 100644 (file)
@@ -31,6 +31,7 @@ import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.Comparator;
 import java.util.Date;
+import java.util.GregorianCalendar;
 
 public class LedgerTransaction {
     private static final String DIGEST_TYPE = "SHA-256";
@@ -201,7 +202,11 @@ public class LedgerTransaction {
         }
 
         result.setTpostings(postings);
-        result.setTdate(Globals.formatIsoDate(date));
+        Date transactionDate = date;
+        if (transactionDate == null) {
+            transactionDate = new GregorianCalendar().getTime();
+        }
+        result.setTdate(Globals.formatIsoDate(transactionDate));
         result.setTdate2(null);
         result.setTindex(1);
         result.setTdescription(description);