]> git.ktnx.net Git - mobile-ledger.git/commitdiff
fix saving transaction date when it is null (regression)
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Wed, 27 Nov 2019 06:31:17 +0000 (08:31 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Wed, 27 Nov 2019 06:31:17 +0000 (08:31 +0200)
app/src/main/java/net/ktnx/mobileledger/async/SendTransactionTask.java

index b444e332e3b00580bb1f1b979bdbbb390d009cfe..cfbf5222c30a24ff41c9c1282a664da17e61a46e 100644 (file)
@@ -39,6 +39,8 @@ import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.net.HttpURLConnection;
 import java.nio.charset.StandardCharsets;
+import java.util.Date;
+import java.util.GregorianCalendar;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
@@ -144,7 +146,13 @@ public class SendTransactionTask extends AsyncTask<LedgerTransaction, Void, Void
         params.addPair("_formid", "identify-add");
         if (token != null)
             params.addPair("_token", token);
-        params.addPair("date", Globals.formatLedgerDate(ltr.getDate()));
+
+        Date transactionDate = ltr.getDate();
+        if (transactionDate == null) {
+            transactionDate = new GregorianCalendar().getTime();
+        }
+
+        params.addPair("date", Globals.formatLedgerDate(transactionDate));
         params.addPair("description", ltr.getDescription());
         for (LedgerTransactionAccount acc : ltr.getAccounts()) {
             params.addPair("account", acc.getAccountName());