]> git.ktnx.net Git - mobile-ledger.git/commitdiff
include comments when comparing transaction accounts
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 14 Jun 2020 06:19:52 +0000 (09:19 +0300)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 14 Jun 2020 06:19:52 +0000 (09:19 +0300)
app/src/main/java/net/ktnx/mobileledger/model/LedgerTransaction.java

index cdf2068aac46214df78d7fad234467f1b340a140..4e7ce33ef3750a3de28ce38662d8728ba6852edd 100644 (file)
@@ -23,7 +23,7 @@ import android.database.sqlite.SQLiteDatabase;
 import net.ktnx.mobileledger.utils.Digest;
 import net.ktnx.mobileledger.utils.Globals;
 
-import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.security.NoSuchAlgorithmException;
 import java.text.ParseException;
 import java.util.ArrayList;
@@ -44,6 +44,10 @@ public class LedgerTransaction {
                             .compareTo(o2.getCurrency());
                     if (res != 0)
                         return res;
+                    res = o1.getComment()
+                            .compareTo(o2.getComment());
+                    if (res != 0)
+                        return res;
                     return Float.compare(o1.getAmount(), o2.getAmount());
                 }
             };
@@ -140,7 +144,7 @@ public class LedgerTransaction {
                 data.append(item.getComment());
             }
             sha.update(data.toString()
-                           .getBytes(Charset.forName("UTF-8")));
+                           .getBytes(StandardCharsets.UTF_8));
             dataHash = sha.digestToHexString();
         }
         catch (NoSuchAlgorithmException e) {