lastAccount = profile.loadAccount(acct_name);
if (lastAccount == null) {
lastAccount = new LedgerAccount(acct_name);
- profile.storeAccount(lastAccount);
+ profile.storeAccount(db, lastAccount);
}
// make sure the parent account(s) are present,
accountList.add(acc);
L(String.format("gap-filling with %s", aName));
accountNames.put(aName, null);
- profile.storeAccount(acc);
+ profile.storeAccount(db, acc);
}
}
if (currency == null) currency = "";
value = value.replace(',', '.');
L("curr=" + currency + ", value=" + value);
- profile.storeAccountValue(lastAccount.getName(), currency,
+ profile.storeAccountValue(db, lastAccount.getName(), currency,
Float.valueOf(value));
lastAccount.addAmount(Float.parseFloat(value), currency);
}
}
}
else {
- profile.storeTransaction(transaction);
+ profile.storeTransaction(db, transaction);
matchedTransactionsCount = 0;
progress.setTotal(maxTransactionId);
}
if (parsedAccount == null) break;
LedgerAccount acc = new LedgerAccount(parsedAccount.getAname());
- profile.storeAccount(acc);
+ profile.storeAccount(db, acc);
for (ParsedBalance b : parsedAccount.getAebalance()) {
- profile.storeAccountValue(acc.getName(), b.getAcommodity(),
+ profile.storeAccountValue(db, acc.getName(), b.getAcommodity(),
b.getAquantity().asFloat());
}
}
}
else {
- profile.storeTransaction(transaction);
+ profile.storeTransaction(db, transaction);
matchedTransactionsCount = 0;
progress.setTotal(maxTransactionId);
}
db.endTransaction();
}
}
- public void storeAccount(LedgerAccount acc) {
- SQLiteDatabase db = MLDB.getWritableDatabase();
-
+ public void storeAccount(SQLiteDatabase db, LedgerAccount acc) {
// replace into is a bad idea because it would reset hidden to its default value
// we like the default, but for new accounts only
db.execSQL("update accounts set level = ?, keep = 1 where profile=? and name = ?",
acc.getLevel()
});
}
- public void storeAccountValue(String name, String currency, Float amount) {
- SQLiteDatabase db = MLDB.getWritableDatabase();
+ public void storeAccountValue(SQLiteDatabase db, String name, String currency, Float amount) {
db.execSQL("replace into account_values(profile, account, " +
"currency, value, keep) values(?, ?, ?, ?, 1);",
new Object[]{uuid, name, currency, amount});
}
- public void storeTransaction(LedgerTransaction tr) {
- SQLiteDatabase db = MLDB.getWritableDatabase();
+ public void storeTransaction(SQLiteDatabase db, LedgerTransaction tr) {
tr.fillDataHash();
db.execSQL("DELETE from transactions WHERE profile=? and id=?",
new Object[]{uuid, tr.getId()});