final String accFilter = model[0].getAccountFilter()
.getValue();
if (accFilter == null) {
- sql = "SELECT id, year, month, day FROM transactions WHERE profile=? ORDER BY " +
+ sql = "SELECT id, year, month, day FROM transactions WHERE profile_id=? ORDER BY " +
"year desc, month desc, day desc, id desc";
params = new String[]{String.valueOf(profile_id)};
else {
sql = "SELECT distinct tr.id, tr.year, tr.month, tr.day from transactions tr " +
"JOIN " + "transaction_accounts ta " +
- "ON ta.transaction_id=tr.id AND ta.profile=tr.profile WHERE tr.profile=? " +
+ "ON ta.transaction_id=tr.id AND ta.profile=tr.profile WHERE tr.profile_id=?" +
+ " " +
"and ta.account_name LIKE ?||'%' AND ta" +
".amount <> 0 ORDER BY tr.year desc, tr.month desc, tr.day desc, tr.id " +
"desc";
return;
try (Cursor cTr = db.rawQuery(
- "SELECT year, month, day, description, comment from transactions WHERE profile=? " +
- "AND id=?", new String[]{String.valueOf(profile), String.valueOf(id)}))
+ "SELECT year, month, day, description, comment from transactions WHERE id=?",
+ new String[]{String.valueOf(id)}))
{
if (cTr.moveToFirst()) {
date = new SimpleDate(cTr.getInt(0), cTr.getInt(1), cTr.getInt(2));
try (Cursor cAcc = db.rawQuery(
"SELECT account_name, amount, currency, comment FROM " +
- "transaction_accounts WHERE profile=? AND transaction_id = ?",
- new String[]{String.valueOf(profile), String.valueOf(id)}))
+ "transaction_accounts WHERE transaction_id = ?",
+ new String[]{String.valueOf(id)}))
{
while (cAcc.moveToNext()) {
// debug("transactions",
}
public String getOption(String name, String default_value) {
SQLiteDatabase db = App.getDatabase();
- try (Cursor cursor = db.rawQuery("select value from options where profile = ? and name=?",
+ try (Cursor cursor = db.rawQuery(
+ "select value from options where profile_id = ? and name=?",
new String[]{String.valueOf(id), name}))
{
if (cursor.moveToFirst()) {
ArrayList<LedgerAccount> list = new ArrayList<>();
HashMap<String, LedgerAccount> map = new HashMap<>();
- String sql = "SELECT a.name, a.expanded, a.amounts_expanded";
- sql += " from accounts a WHERE a.profile = ?";
+ String sql = "SELECT a.name, a.expanded, a.amounts_expanded, a.id";
+ sql += " from accounts a WHERE a.profile_id = ?";
sql += " ORDER BY a.name";
SQLiteDatabase db = App.getDatabase();
if (isInterrupted())
return;
+ final long accId = cursor.getLong(3);
final String accName = cursor.getString(0);
// debug("accounts",
// String.format("Read account '%s' from DB [%s]", accName,
acc.setHasSubAccounts(false);
try (Cursor c2 = db.rawQuery(
- "SELECT value, currency FROM account_values WHERE profile = ?" + " " +
- "AND account = ?", new String[]{String.valueOf(profileId), accName}))
+ "SELECT value, currency FROM account_values WHERE account_id = ?",
+ new String[]{String.valueOf(accId)}))
{
while (c2.moveToNext()) {
acc.addAmount(c2.getFloat(0), c2.getString(1));
.rotation(mAccount.isExpanded() ? 0 : 180);
model.updateDisplayedAccounts();
- DbOpQueue.add("update accounts set expanded=? where name=? and profile=?",
+ DbOpQueue.add("update accounts set expanded=? where name=? and profile_id=?",
new Object[]{mAccount.isExpanded(), mAccount.getName(), profile.getId()
});
insert into transaction_accounts_new(transaction_id, order_no, account_name,
currency, amount, comment, generation)
-select ta.transaction_id, ta.order_no, ta.account_name, ta.currency, ta.amount, ta.comment, ta.generation
-from transaction_accounts ta;
+select t.id, ta.order_no, ta.account_name, ta.currency, ta.amount, ta.comment, ta.generation
+from transaction_accounts ta
+join profiles p in ta.profile=p.deprecated_uuid
+join transactions t on ta.transaction_id = t.ledger_id and t.profile_id=p.id;
drop table transaction_accounts;
alter table transaction_accounts_new rename to transaction_accounts;