From 592803265bf5a0f6ea2da27dd061c9829ce2bf20 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Sun, 5 Jan 2020 23:05:29 +0200 Subject: [PATCH] DB support for transaction account comments --- .../net/ktnx/mobileledger/model/LedgerTransaction.java | 4 ++-- .../ktnx/mobileledger/model/LedgerTransactionAccount.java | 7 +++---- .../net/ktnx/mobileledger/model/MobileLedgerProfile.java | 4 ++-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/net/ktnx/mobileledger/model/LedgerTransaction.java b/app/src/main/java/net/ktnx/mobileledger/model/LedgerTransaction.java index 2f23eff0..24527892 100644 --- a/app/src/main/java/net/ktnx/mobileledger/model/LedgerTransaction.java +++ b/app/src/main/java/net/ktnx/mobileledger/model/LedgerTransaction.java @@ -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(); diff --git a/app/src/main/java/net/ktnx/mobileledger/model/LedgerTransactionAccount.java b/app/src/main/java/net/ktnx/mobileledger/model/LedgerTransactionAccount.java index 4a83b185..59e1dab0 100644 --- a/app/src/main/java/net/ktnx/mobileledger/model/LedgerTransactionAccount.java +++ b/app/src/main/java/net/ktnx/mobileledger/model/LedgerTransactionAccount.java @@ -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; diff --git a/app/src/main/java/net/ktnx/mobileledger/model/MobileLedgerProfile.java b/app/src/main/java/net/ktnx/mobileledger/model/MobileLedgerProfile.java index 53896db0..347e1142 100644 --- a/app/src/main/java/net/ktnx/mobileledger/model/MobileLedgerProfile.java +++ b/app/src/main/java/net/ktnx/mobileledger/model/MobileLedgerProfile.java @@ -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())); -- 2.39.5