]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/model/LedgerTransaction.java
Data: migrate profile to a private variable, provide methods for accessing it
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / model / LedgerTransaction.java
index 04b63b64169f03b11ac0ab7e747abfab51a17431..e31d1582c4cfe551b83d0aa6dc32f7654396cc7a 100644 (file)
@@ -78,7 +78,7 @@ public class LedgerTransaction {
         dataLoaded = false;
     }
     public LedgerTransaction(Integer id, SimpleDate date, String description) {
-        this(id, date, description, Data.profile.getValue());
+        this(id, date, description, Data.getProfile());
     }
     public LedgerTransaction(SimpleDate date, String description) {
         this(null, date, description);
@@ -219,4 +219,27 @@ public class LedgerTransaction {
     public void finishLoading() {
         dataLoaded = true;
     }
+    @Override
+    public boolean equals(@Nullable Object obj) {
+        if (obj == null)
+            return false;
+        if (!obj.getClass()
+                .equals(this.getClass()))
+            return false;
+
+        return ((LedgerTransaction) obj).getDataHash()
+                                        .equals(getDataHash());
+    }
+
+    public boolean hasAccountNamedLike(String name) {
+        name = name.toUpperCase();
+        for (LedgerTransactionAccount acc : accounts) {
+            if (acc.getAccountName()
+                   .toUpperCase()
+                   .contains(name))
+                return true;
+        }
+
+        return false;
+    }
 }