import net.ktnx.mobileledger.json.AccountListParser;
import net.ktnx.mobileledger.json.ParsedBalance;
import net.ktnx.mobileledger.json.ParsedLedgerAccount;
import net.ktnx.mobileledger.json.AccountListParser;
import net.ktnx.mobileledger.json.ParsedBalance;
import net.ktnx.mobileledger.json.ParsedLedgerAccount;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
context.onRetrieveDone(null);
}
private String retrieveTransactionListLegacy(MobileLedgerProfile profile)
context.onRetrieveDone(null);
}
private String retrieveTransactionListLegacy(MobileLedgerProfile profile)
Progress progress = new Progress();
int maxTransactionId = Progress.INDETERMINATE;
ArrayList<LedgerAccount> accountList = new ArrayList<>();
Progress progress = new Progress();
int maxTransactionId = Progress.INDETERMINATE;
ArrayList<LedgerAccount> accountList = new ArrayList<>();
HttpURLConnection http = NetworkUtil.prepareConnection(profile, "journal");
http.setAllowUserInteraction(false);
publishProgress(progress);
HttpURLConnection http = NetworkUtil.prepareConnection(profile, "journal");
http.setAllowUserInteraction(false);
publishProgress(progress);
try (SQLiteDatabase db = MLDB.getWritableDatabase()) {
try (InputStream resp = http.getInputStream()) {
if (http.getResponseCode() != 200)
try (SQLiteDatabase db = MLDB.getWritableDatabase()) {
try (InputStream resp = http.getInputStream()) {
if (http.getResponseCode() != 200)
acct_name = acct_name.replace("\"", "");
L(String.format("found account: %s", acct_name));
acct_name = acct_name.replace("\"", "");
L(String.format("found account: %s", acct_name));
- lastAccount = profile.loadAccount(acct_name);
- if (lastAccount == null) {
+ lastAccount = profile.tryLoadAccount(db, acct_name);
+ if (lastAccount == null)
// make sure the parent account(s) are present,
// synthesising them if necessary
// make sure the parent account(s) are present,
// synthesising them if necessary
while (!toAppend.isEmpty()) {
String aName = toAppend.pop();
LedgerAccount acc = new LedgerAccount(aName);
while (!toAppend.isEmpty()) {
String aName = toAppend.pop();
LedgerAccount acc = new LedgerAccount(aName);
- acc.setHidden(lastAccount.isHidden());
- if (!onlyStarred || !acc.isHidden())
- accountList.add(acc);
+ acc.setHiddenByStar(lastAccount.isHiddenByStar());
+ if ((!onlyStarred || !acc.isHiddenByStar()) &&
+ acc.isVisible(accountList)) accountList.add(acc);
L(String.format("gap-filling with %s", aName));
accountNames.put(aName, null);
L(String.format("gap-filling with %s", aName));
accountNames.put(aName, null);
accountList.add(lastAccount);
accountNames.put(acct_name, null);
accountList.add(lastAccount);
accountNames.put(acct_name, null);
if (currency == null) currency = "";
value = value.replace(',', '.');
L("curr=" + currency + ", value=" + value);
if (currency == null) currency = "";
value = value.replace(',', '.');
L("curr=" + currency + ", value=" + value);
- profile.storeAccountValue(lastAccount.getName(), currency,
+ profile.storeAccountValue(db, lastAccount.getName(), currency,
new String[]{profile.getUuid()});
db.execSQL("update accounts set keep=0 where profile=?;", new String[]{profile.getUuid()});
}
new String[]{profile.getUuid()});
db.execSQL("update accounts set keep=0 where profile=?;", new String[]{profile.getUuid()});
}
Progress progress = new Progress();
HttpURLConnection http = NetworkUtil.prepareConnection(profile, "accounts");
http.setAllowUserInteraction(false);
Progress progress = new Progress();
HttpURLConnection http = NetworkUtil.prepareConnection(profile, "accounts");
http.setAllowUserInteraction(false);
publishProgress(progress);
try (SQLiteDatabase db = MLDB.getWritableDatabase()) {
try (InputStream resp = http.getInputStream()) {
publishProgress(progress);
try (SQLiteDatabase db = MLDB.getWritableDatabase()) {
try (InputStream resp = http.getInputStream()) {
- LedgerAccount acc = new LedgerAccount(parsedAccount.getAname());
- profile.storeAccount(acc);
+ LedgerAccount acc = profile.tryLoadAccount(db, parsedAccount.getAname());
+ if (acc == null) acc = new LedgerAccount(parsedAccount.getAname());
+ else acc.removeAmounts();
+
+ profile.storeAccount(db, acc);
- profile.storeAccountValue(acc.getName(), b.getAcommodity(),
+ profile.storeAccountValue(db, acc.getName(), b.getAcommodity(),
Progress progress = new Progress();
int maxTransactionId = Progress.INDETERMINATE;
HttpURLConnection http = NetworkUtil.prepareConnection(profile, "transactions");
http.setAllowUserInteraction(false);
publishProgress(progress);
Progress progress = new Progress();
int maxTransactionId = Progress.INDETERMINATE;
HttpURLConnection http = NetworkUtil.prepareConnection(profile, "transactions");
http.setAllowUserInteraction(false);
publishProgress(progress);
try (SQLiteDatabase db = MLDB.getWritableDatabase()) {
try (InputStream resp = http.getInputStream()) {
if (http.getResponseCode() != 200)
try (SQLiteDatabase db = MLDB.getWritableDatabase()) {
try (InputStream resp = http.getInputStream()) {
if (http.getResponseCode() != 200)