]> git.ktnx.net Git - mobile-ledger.git/commitdiff
DB support for transaction account comments
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 5 Jan 2020 21:05:29 +0000 (23:05 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 5 Jan 2020 21:05:29 +0000 (23:05 +0200)
app/src/main/java/net/ktnx/mobileledger/model/LedgerTransaction.java
app/src/main/java/net/ktnx/mobileledger/model/LedgerTransactionAccount.java
app/src/main/java/net/ktnx/mobileledger/model/MobileLedgerProfile.java

index 2f23eff0a082a5d4c8866e498f99f348cf599337..24527892d580306b51af1eeeb19f8161935f54ac 100644 (file)
@@ -171,7 +171,7 @@ public class LedgerTransaction {
                 }
                 description = cTr.getString(1);
 
-                try (Cursor cAcc = db.rawQuery("SELECT account_name, amount, currency FROM " +
+                try (Cursor cAcc = db.rawQuery("SELECT account_name, amount, currency, comment FROM " +
                                                "transaction_accounts WHERE " +
                                                "profile=? AND transaction_id = ?",
                         new String[]{profile, String.valueOf(id)}))
@@ -181,7 +181,7 @@ public class LedgerTransaction {
 //                                String.format("Loaded %d: %s %1.2f %s", id, cAcc.getString(0),
 //                                        cAcc.getFloat(1), cAcc.getString(2)));
                         addAccount(new LedgerTransactionAccount(cAcc.getString(0), cAcc.getFloat(1),
-                                cAcc.getString(2)));
+                                cAcc.getString(2), cAcc.getString(3)));
                     }
 
                     finishLoading();
index 4a83b185a00ac7da9046244fc1efd7b26762753b..59e1dab00fb90d69b8d28ec45f465d9574db74a4 100644 (file)
@@ -26,14 +26,13 @@ public class LedgerTransactionAccount {
     private boolean amountSet = false;
     private String currency;
     private String comment;
-    public LedgerTransactionAccount(String accountName, float amount) {
-        this(accountName, amount, null);
-    }
-    public LedgerTransactionAccount(String accountName, float amount, String currency) {
+    public LedgerTransactionAccount(String accountName, float amount, String currency,
+                                    String comment) {
         this.setAccountName(accountName);
         this.amount = amount;
         this.amountSet = true;
         this.currency = currency;
+        this.comment = comment;
     }
     public LedgerTransactionAccount(String accountName) {
         this.accountName = accountName;
index 53896db045391996dd6d3d0d526dc343530cc435..347e1142408e22ff99c71902938846140dd26722 100644 (file)
@@ -260,9 +260,9 @@ public final class MobileLedgerProfile {
 
         for (LedgerTransactionAccount item : tr.getAccounts()) {
             db.execSQL("INSERT INTO transaction_accounts(profile, transaction_id, " +
-                       "account_name, amount, currency) values(?, ?, ?, ?, ?)",
+                       "account_name, amount, currency, comment) values(?, ?, ?, ?, ?, ?)",
                     new Object[]{uuid, tr.getId(), item.getAccountName(), item.getAmount(),
-                                 item.getCurrency()
+                                 item.getCurrency(), item.getComment()
                     });
         }
 //        debug("profile", String.format("Transaction %d stored", tr.getId()));