X-Git-Url: https://git.ktnx.net/?p=mobile-ledger.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fasync%2FRetrieveTransactionsTask.java;h=062c93361d5cba27c7027896e9c993390ca8415e;hp=965c1f982fc98db94458dfb1109d9e4eabd07c67;hb=a999dc7cb0bb71e7b88ce8e3c79a1884487355ef;hpb=9020bea97b9666c71964b48cfcad11c966edb0e0 diff --git a/app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java b/app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java index 965c1f98..062c9336 100644 --- a/app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java +++ b/app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java @@ -166,7 +166,7 @@ public class RetrieveTransactionsTask 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, @@ -188,7 +188,7 @@ public class RetrieveTransactionsTask accountList.add(acc); L(String.format("gap-filling with %s", aName)); accountNames.put(aName, null); - profile.storeAccount(acc); + profile.storeAccount(db, acc); } } @@ -213,7 +213,7 @@ public class RetrieveTransactionsTask 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); } @@ -284,14 +284,15 @@ public class RetrieveTransactionsTask if (matchedTransactionsCount == MATCHING_TRANSACTIONS_LIMIT) { - profile.markTransactionsBeforeTransactionAsPresent(db, transaction); + profile.markTransactionsBeforeTransactionAsPresent(db, + transaction); progress.setTotal(progress.getProgress()); publishProgress(progress); break LINES; } } else { - profile.storeTransaction(transaction); + profile.storeTransaction(db, transaction); matchedTransactionsCount = 0; progress.setTotal(maxTransactionId); } @@ -372,6 +373,7 @@ public class RetrieveTransactionsTask profile.markAccountsAsNotPresent(db); AccountListParser parser = new AccountListParser(resp); + ArrayList accountList = new ArrayList<>(); while (true) { throwIfCancelled(); @@ -379,17 +381,20 @@ public class RetrieveTransactionsTask 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()); } + + accountList.add(acc); } throwIfCancelled(); profile.deleteNotPresentAccounts(db); throwIfCancelled(); db.setTransactionSuccessful(); + Data.accounts.set(accountList); } finally { db.endTransaction(); @@ -441,7 +446,7 @@ public class RetrieveTransactionsTask } } else { - profile.storeTransaction(transaction); + profile.storeTransaction(db, transaction); matchedTransactionsCount = 0; progress.setTotal(maxTransactionId); }