Skip to content

Commit

Permalink
codinguser#876 - Rename mTransactionsAdapter into mTransactionsDbAdapter
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanGarf committed Jun 13, 2020
1 parent 7fc3485 commit a1626c1
Showing 1 changed file with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public class AccountsDbAdapter extends DatabaseAdapter<Account> {
/**
* Transactions database adapter for manipulating transactions associated with accounts
*/
private final TransactionsDbAdapter mTransactionsAdapter;
private final TransactionsDbAdapter mTransactionsDbAdapter;

/**
* Commodities database adapter for commodity manipulation
Expand All @@ -101,7 +101,7 @@ public AccountsDbAdapter(SQLiteDatabase db, TransactionsDbAdapter transactionsDb
AccountEntry.COLUMN_PARENT_ACCOUNT_UID,
AccountEntry.COLUMN_DEFAULT_TRANSFER_ACCOUNT_UID
});
mTransactionsAdapter = transactionsDbAdapter;
mTransactionsDbAdapter = transactionsDbAdapter;
mCommoditiesDbAdapter = new CommoditiesDbAdapter(db);
}

Expand Down Expand Up @@ -129,7 +129,7 @@ public AccountsDbAdapter(SQLiteDatabase db){
AccountEntry.COLUMN_DEFAULT_TRANSFER_ACCOUNT_UID
});

mTransactionsAdapter = new TransactionsDbAdapter(db, new SplitsDbAdapter(db));
mTransactionsDbAdapter = new TransactionsDbAdapter(db, new SplitsDbAdapter(db));
mCommoditiesDbAdapter = new CommoditiesDbAdapter(db);
}

Expand All @@ -150,7 +150,7 @@ public static AccountsDbAdapter getInstance(){
public void addRecord(@NonNull Account account, UpdateMethod updateMethod){
Log.d(LOG_TAG, "Replace account to db");
//in-case the account already existed, we want to update the templates based on it as well
List<Transaction> templateTransactions = mTransactionsAdapter.getScheduledTransactionsForAccount(account.getUID());
List<Transaction> templateTransactions = mTransactionsDbAdapter.getScheduledTransactionsForAccount(account.getUID());
super.addRecord(account, updateMethod);
String accountUID = account.getUID();
//now add transactions if there are any
Expand All @@ -159,10 +159,10 @@ public void addRecord(@NonNull Account account, UpdateMethod updateMethod){
updateRecord(accountUID, AccountEntry.COLUMN_FULL_NAME, getFullyQualifiedAccountName(accountUID));
for (Transaction t : account.getTransactions()) {
t.setCommodity(account.getCommodity());
mTransactionsAdapter.addRecord(t, updateMethod);
mTransactionsDbAdapter.addRecord(t, updateMethod);
}
for (Transaction transaction : templateTransactions) {
mTransactionsAdapter.addRecord(transaction, UpdateMethod.update);
mTransactionsDbAdapter.addRecord(transaction, UpdateMethod.update);
}
}
}
Expand All @@ -187,12 +187,12 @@ public long bulkAddRecords(@NonNull List<Account> accountList, UpdateMethod upda
List<Transaction> transactionList = new ArrayList<>(accountList.size()*2);
for (Account account : accountList) {
transactionList.addAll(account.getTransactions());
transactionList.addAll(mTransactionsAdapter.getScheduledTransactionsForAccount(account.getUID()));
transactionList.addAll(mTransactionsDbAdapter.getScheduledTransactionsForAccount(account.getUID()));
}
long nRow = super.bulkAddRecords(accountList, updateMethod);

if (nRow > 0 && !transactionList.isEmpty()){
mTransactionsAdapter.bulkAddRecords(transactionList, updateMethod);
mTransactionsDbAdapter.bulkAddRecords(transactionList, updateMethod);
}
return nRow;
}
Expand Down Expand Up @@ -374,7 +374,7 @@ public boolean recursiveDeleteAccount(long accountId){
try {
descendantAccountUIDs.add(accountUID); //add account to descendants list just for convenience
for (String descendantAccountUID : descendantAccountUIDs) {
mTransactionsAdapter.deleteTransactionsForAccount(descendantAccountUID);
mTransactionsDbAdapter.deleteTransactionsForAccount(descendantAccountUID);
}

String accountUIDList = "'" + TextUtils.join("','", descendantAccountUIDs) + "'";
Expand Down Expand Up @@ -413,7 +413,7 @@ public boolean recursiveDeleteAccount(long accountId){
@Override
public Account buildModelInstance(@NonNull final Cursor c){
Account account = buildSimpleAccountInstance(c);
account.setTransactions(mTransactionsAdapter.getAllTransactionsForAccount(account.getUID()));
account.setTransactions(mTransactionsDbAdapter.getAllTransactionsForAccount(account.getUID()));

return account;
}
Expand Down Expand Up @@ -801,7 +801,7 @@ public Money getAccountBalance(AccountType accountType, long startTimestamp, lon
String currencyCode = GnuCashApplication.getDefaultCurrencyCode();

Log.d(LOG_TAG, "all account list : " + accountUidList.size());
SplitsDbAdapter splitsDbAdapter = mTransactionsAdapter.getSplitDbAdapter();
SplitsDbAdapter splitsDbAdapter = mTransactionsDbAdapter.getSplitDbAdapter();

return (startTimestamp == -1 && endTimestamp == -1)
? splitsDbAdapter.computeSplitBalance(accountUidList, currencyCode, hasDebitNormalBalance)
Expand All @@ -825,7 +825,7 @@ public Money getAccountBalance(List<AccountType> accountTypes, long start, long

private Money computeBalance(String accountUID, long startTimestamp, long endTimestamp) {
Log.d(LOG_TAG, "Computing account balance for account ID " + accountUID);
String currencyCode = mTransactionsAdapter.getAccountCurrencyCode(accountUID);
String currencyCode = mTransactionsDbAdapter.getAccountCurrencyCode(accountUID);
boolean hasDebitNormalBalance = getAccountType(accountUID).hasDebitNormalBalance();

List<String> accountsList = getDescendantAccountUIDs(accountUID,
Expand All @@ -834,7 +834,7 @@ private Money computeBalance(String accountUID, long startTimestamp, long endTim
accountsList.add(0, accountUID);

Log.d(LOG_TAG, "all account list : " + accountsList.size());
SplitsDbAdapter splitsDbAdapter = mTransactionsAdapter.getSplitDbAdapter();
SplitsDbAdapter splitsDbAdapter = mTransactionsDbAdapter.getSplitDbAdapter();
return (startTimestamp == -1 && endTimestamp == -1)
? splitsDbAdapter.computeSplitBalance(accountsList, currencyCode, hasDebitNormalBalance)
: splitsDbAdapter.computeSplitBalance(accountsList, currencyCode, hasDebitNormalBalance, startTimestamp, endTimestamp);
Expand All @@ -858,7 +858,7 @@ public Money getAccountsBalance(@NonNull List<String> accountUIDList, long star

boolean hasDebitNormalBalance = getAccountType(accountUIDList.get(0)).hasDebitNormalBalance();

SplitsDbAdapter splitsDbAdapter = mTransactionsAdapter.getSplitDbAdapter();
SplitsDbAdapter splitsDbAdapter = mTransactionsDbAdapter.getSplitDbAdapter();
Money splitSum = (startTimestamp == -1 && endTimestamp == -1)
? splitsDbAdapter.computeSplitBalance(accountUIDList, currencyCode, hasDebitNormalBalance)
: splitsDbAdapter.computeSplitBalance(accountUIDList, currencyCode, hasDebitNormalBalance, startTimestamp, endTimestamp);
Expand Down Expand Up @@ -1145,7 +1145,7 @@ public List<Transaction> getAllOpeningBalanceTransactions(){
Cursor cursor = fetchAccounts(null, null, null);
List<Transaction> openingTransactions = new ArrayList<>();
try {
SplitsDbAdapter splitsDbAdapter = mTransactionsAdapter.getSplitDbAdapter();
SplitsDbAdapter splitsDbAdapter = mTransactionsDbAdapter.getSplitDbAdapter();
while (cursor.moveToNext()) {
long id = cursor.getLong(cursor.getColumnIndexOrThrow(AccountEntry._ID));
String accountUID = getUID(id);
Expand Down

0 comments on commit a1626c1

Please sign in to comment.