]> git.ktnx.net Git - mobile-ledger.git/commitdiff
two fallouts after transaction date reorganisation and 'go to date' feature
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Wed, 17 Jun 2020 18:32:49 +0000 (21:32 +0300)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Wed, 17 Jun 2020 18:57:03 +0000 (18:57 +0000)
app/src/main/java/net/ktnx/mobileledger/json/v1_14/ParsedLedgerTransaction.java
app/src/main/java/net/ktnx/mobileledger/json/v1_15/ParsedLedgerTransaction.java
app/src/main/java/net/ktnx/mobileledger/model/LedgerTransaction.java
app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionItemsAdapter.java

index 5b9b399b30406e6211aa9edf667c02be62e8efe9..eec404b8326c32216aa8f73d3cfbea4694756ea5 100644 (file)
@@ -59,7 +59,7 @@ public class ParsedLedgerTransaction implements net.ktnx.mobileledger.json.Parse
         }
 
         result.setTpostings(postings);
         }
 
         result.setTpostings(postings);
-        SimpleDate transactionDate = tr.getDate();
+        SimpleDate transactionDate = tr.getDateIfAny();
         if (transactionDate == null) {
             transactionDate = SimpleDate.today();
         }
         if (transactionDate == null) {
             transactionDate = SimpleDate.today();
         }
index 225f162b0fe8b41d00cad60ec559e2cf88e3b0ca..8b1fab78d4eea93c744bf87bf01600856d622666 100644 (file)
@@ -57,7 +57,7 @@ public class ParsedLedgerTransaction implements net.ktnx.mobileledger.json.Parse
         }
 
         result.setTpostings(postings);
         }
 
         result.setTpostings(postings);
-        SimpleDate transactionDate = tr.getDate();
+        SimpleDate transactionDate = tr.getDateIfAny();
         if (transactionDate == null) {
             transactionDate = SimpleDate.today();
         }
         if (transactionDate == null) {
             transactionDate = SimpleDate.today();
         }
index 5bc8456bb4b81b8939e3b088ad1c9470ad8db0ca..04b63b64169f03b11ac0ab7e747abfab51a17431 100644 (file)
@@ -21,6 +21,7 @@ import android.database.Cursor;
 import android.database.sqlite.SQLiteDatabase;
 
 import androidx.annotation.NonNull;
 import android.database.sqlite.SQLiteDatabase;
 
 import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
 
 import net.ktnx.mobileledger.App;
 import net.ktnx.mobileledger.utils.Digest;
 
 import net.ktnx.mobileledger.App;
 import net.ktnx.mobileledger.utils.Digest;
@@ -101,6 +102,10 @@ public class LedgerTransaction {
         accounts.add(item);
         dataHash = null;
     }
         accounts.add(item);
         dataHash = null;
     }
+    @Nullable
+    public SimpleDate getDateIfAny() {
+        return date;
+    }
     @NonNull
     public SimpleDate getDate() {
         loadData(App.getDatabase());
     @NonNull
     public SimpleDate getDate() {
         loadData(App.getDatabase());
index c684b79fe0a3d70f70af8ba8b8b0c84d9a68e8bf..80deaf27281315af7974e05f2c7def6fd9bb1cae 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright © 2019 Damyan Ivanov.
+ * Copyright © 2020 Damyan Ivanov.
  * This file is part of MoLe.
  * MoLe is free software: you can distribute it and/or modify it
  * under the term of the GNU General Public License as published by
  * This file is part of MoLe.
  * MoLe is free software: you can distribute it and/or modify it
  * under the term of the GNU General Public License as published by
@@ -209,7 +209,7 @@ class NewTransactionItemsAdapter extends RecyclerView.Adapter<NewTransactionItem
             params.add(accFilter);
         }
 
             params.add(accFilter);
         }
 
-        sb.append(" ORDER BY t.date DESC LIMIT 1");
+        sb.append(" ORDER BY t.year desc, t.month desc, t.day desc LIMIT 1");
 
         final String sql = sb.toString();
         debug("descr", sql);
 
         final String sql = sb.toString();
         debug("descr", sql);
@@ -242,7 +242,7 @@ class NewTransactionItemsAdapter extends RecyclerView.Adapter<NewTransactionItem
 
                 final String broaderSql =
                         "select t.profile, t.id from transactions t where t.description=?" +
 
                 final String broaderSql =
                         "select t.profile, t.id from transactions t where t.description=?" +
-                        " ORDER BY date desc LIMIT 1";
+                        " ORDER BY year desc, month desc, day desc LIMIT 1";
                 params.remove(1);
                 debug("descr", broaderSql);
                 debug("descr", description);
                 params.remove(1);
                 debug("descr", broaderSql);
                 debug("descr", description);