diff --git a/app/src/main/java/com/money/manager/ex/account/AccountTransactionListFragment.java b/app/src/main/java/com/money/manager/ex/account/AccountTransactionListFragment.java index 816865927..21afd59c5 100644 --- a/app/src/main/java/com/money/manager/ex/account/AccountTransactionListFragment.java +++ b/app/src/main/java/com/money/manager/ex/account/AccountTransactionListFragment.java @@ -672,7 +672,7 @@ private Bundle prepareQuery() { .toIsoDateString()); // Status - where.addStatement(QueryAllData.Status, "IN", mFilter.transactionStatus.getSqlParameters()); + where.addStatement(QueryAllData.STATUS, "IN", mFilter.transactionStatus.getSqlParameters()); // create a bundle to returns diff --git a/app/src/main/java/com/money/manager/ex/account/CalculateRunningBalanceTask2.java b/app/src/main/java/com/money/manager/ex/account/CalculateRunningBalanceTask2.java index e28658977..12ec1a2be 100644 --- a/app/src/main/java/com/money/manager/ex/account/CalculateRunningBalanceTask2.java +++ b/app/src/main/java/com/money/manager/ex/account/CalculateRunningBalanceTask2.java @@ -26,7 +26,7 @@ import com.money.manager.ex.common.AllDataListFragment; import com.money.manager.ex.core.TransactionStatuses; import com.money.manager.ex.core.TransactionTypes; -import com.money.manager.ex.datalayer.QueryAllDataRepository; +import com.money.manager.ex.database.QueryAllDataRepository; import com.money.manager.ex.utils.MmxDate; import com.money.manager.ex.viewmodels.AccountTransactionDisplay; diff --git a/app/src/main/java/com/money/manager/ex/adapter/AllDataAdapter.java b/app/src/main/java/com/money/manager/ex/adapter/AllDataAdapter.java index 46daebd4a..7bfacd310 100644 --- a/app/src/main/java/com/money/manager/ex/adapter/AllDataAdapter.java +++ b/app/src/main/java/com/money/manager/ex/adapter/AllDataAdapter.java @@ -321,10 +321,10 @@ public void setShowBalanceAmount(boolean mShowBalanceAmount) { public void setFieldFromTypeCursor() { ID = mTypeCursor == TypeCursor.ALLDATA ? QueryAllData.ID : QueryBillDeposits.BDID; DATE = mTypeCursor == TypeCursor.ALLDATA ? QueryAllData.Date : QueryBillDeposits.NEXTOCCURRENCEDATE; - ACCOUNTID = mTypeCursor == TypeCursor.ALLDATA ? QueryAllData.ACCOUNTID : QueryBillDeposits.TOACCOUNTID; - STATUS = mTypeCursor == TypeCursor.ALLDATA ? QueryAllData.Status : QueryBillDeposits.STATUS; - AMOUNT = mTypeCursor == TypeCursor.ALLDATA ? QueryAllData.Amount : QueryBillDeposits.AMOUNT; - PAYEE = mTypeCursor == TypeCursor.ALLDATA ? QueryAllData.Payee : QueryBillDeposits.PAYEENAME; + ACCOUNTID = mTypeCursor == TypeCursor.ALLDATA ? QueryAllData.ACCOUNTID : QueryBillDeposits.ACCOUNTID; + STATUS = mTypeCursor == TypeCursor.ALLDATA ? QueryAllData.STATUS : QueryBillDeposits.STATUS; + AMOUNT = mTypeCursor == TypeCursor.ALLDATA ? QueryAllData.AMOUNT : QueryBillDeposits.AMOUNT; + PAYEE = mTypeCursor == TypeCursor.ALLDATA ? QueryAllData.PAYEENAME : QueryBillDeposits.PAYEENAME; TRANSACTIONTYPE = mTypeCursor == TypeCursor.ALLDATA ? QueryAllData.TransactionType : QueryBillDeposits.TRANSCODE; CURRENCYID = mTypeCursor == TypeCursor.ALLDATA ? QueryAllData.CURRENCYID : QueryBillDeposits.CURRENCYID; TOACCOUNTID = mTypeCursor == TypeCursor.ALLDATA ? QueryAllData.TOACCOUNTID : QueryBillDeposits.TOACCOUNTID; diff --git a/app/src/main/java/com/money/manager/ex/core/ExportToCsvFile.java b/app/src/main/java/com/money/manager/ex/core/ExportToCsvFile.java index e3bfb34f3..3dff97f04 100644 --- a/app/src/main/java/com/money/manager/ex/core/ExportToCsvFile.java +++ b/app/src/main/java/com/money/manager/ex/core/ExportToCsvFile.java @@ -115,12 +115,12 @@ private boolean runTask() { String[] record = new String[7]; // compose a records record[0] = data.getString(data.getColumnIndex(QueryAllData.Date)); - if (!TextUtils.isEmpty(data.getString(data.getColumnIndex(QueryAllData.Payee)))) { - record[1] = data.getString(data.getColumnIndex(QueryAllData.Payee)); + if (!TextUtils.isEmpty(data.getString(data.getColumnIndex(QueryAllData.PAYEENAME)))) { + record[1] = data.getString(data.getColumnIndex(QueryAllData.PAYEENAME)); } else { record[1] = data.getString(data.getColumnIndex(QueryAllData.AccountName)); } - record[2] = Double.toString(data.getDouble(data.getColumnIndex(QueryAllData.Amount))); + record[2] = Double.toString(data.getDouble(data.getColumnIndex(QueryAllData.AMOUNT))); record[3] = data.getString(data.getColumnIndex(QueryAllData.Category)); record[4] = data.getString(data.getColumnIndex(QueryAllData.Subcategory)); record[5] = Integer.toString(data.getInt(data.getColumnIndex(QueryAllData.TransactionNumber))); diff --git a/app/src/main/java/com/money/manager/ex/database/QueryAllData.java b/app/src/main/java/com/money/manager/ex/database/QueryAllData.java index eeac49bb5..c0b50b828 100644 --- a/app/src/main/java/com/money/manager/ex/database/QueryAllData.java +++ b/app/src/main/java/com/money/manager/ex/database/QueryAllData.java @@ -35,21 +35,21 @@ public class QueryAllData public static final String Day = "Day"; public static final String Category = "Category"; public static final String Subcategory = "Subcategory"; - public static final String Amount = "Amount"; + public static final String AMOUNT = "Amount"; public static final String BaseConvRate = "BaseConvRate"; public static final String CURRENCYID = "CurrencyID"; public static final String AccountName = "AccountName"; public static final String ACCOUNTID = "AccountID"; public static final String SPLITTED = "SPLITTED"; public static final String CATEGID = "CategID"; - public static final String Payee = "Payee"; - public static final String PayeeID = "PayeeID"; + public static final String PAYEENAME = "PayeeName"; + public static final String PAYEEID = "PayeeID"; public static final String ToAccountName = "ToAccountName"; public static final String TOACCOUNTID = "ToAccountId"; public static final String ToAmount = "ToAmount"; public static final String ToCurrencyId = "ToCurrencyId"; public static final String TransactionNumber = "TransactionNumber"; - public static final String Status = "Status"; + public static final String STATUS = "Status"; public static final String Notes = "Notes"; public static final String currency = "currency"; @@ -63,8 +63,8 @@ public QueryAllData(Context context) { @Override public String[] getAllColumns() { return new String[]{"ID AS _id", ID, TransactionType, Date, Year, Month, Day, - Category, Subcategory, Amount, BaseConvRate, CURRENCYID, AccountName, ACCOUNTID, - SPLITTED, CATEGID, Payee, PayeeID, TransactionNumber, Status, Notes, + Category, Subcategory, AMOUNT, BaseConvRate, CURRENCYID, AccountName, ACCOUNTID, + SPLITTED, CATEGID, PAYEENAME, PAYEEID, TransactionNumber, STATUS, Notes, ToAccountName, TOACCOUNTID, ToAmount, ToCurrencyId, currency}; } diff --git a/app/src/main/java/com/money/manager/ex/datalayer/QueryAllDataRepository.java b/app/src/main/java/com/money/manager/ex/database/QueryAllDataRepository.java similarity index 84% rename from app/src/main/java/com/money/manager/ex/datalayer/QueryAllDataRepository.java rename to app/src/main/java/com/money/manager/ex/database/QueryAllDataRepository.java index 96a1ffa28..5ce1c5abb 100644 --- a/app/src/main/java/com/money/manager/ex/datalayer/QueryAllDataRepository.java +++ b/app/src/main/java/com/money/manager/ex/database/QueryAllDataRepository.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012-2018 The Android Money Manager Ex Project Team + * Copyright (C) 2012-2024 The Android Money Manager Ex Project Team * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -15,14 +15,13 @@ * along with this program. If not, see . */ -package com.money.manager.ex.datalayer; +package com.money.manager.ex.database; import android.content.Context; import android.database.Cursor; import com.money.manager.ex.R; -import com.money.manager.ex.database.DatasetType; -import com.money.manager.ex.database.QueryAllData; +import com.money.manager.ex.datalayer.RepositoryBase; import com.money.manager.ex.utils.MmxFileUtils; import com.money.manager.ex.viewmodels.AccountTransactionDisplay; @@ -41,12 +40,12 @@ public QueryAllDataRepository(Context context) { public String[] getAllColumns() { return new String[]{"ID AS _id", QueryAllData.ID, QueryAllData.TransactionType, QueryAllData.Date, QueryAllData.Year, QueryAllData.Month, QueryAllData.Day, - QueryAllData.Category, QueryAllData.Subcategory, QueryAllData.Amount, + QueryAllData.Category, QueryAllData.Subcategory, QueryAllData.AMOUNT, QueryAllData.BaseConvRate, QueryAllData.CURRENCYID, QueryAllData.AccountName, QueryAllData.ACCOUNTID, QueryAllData.SPLITTED, - QueryAllData.Payee, QueryAllData.PayeeID, QueryAllData.TransactionNumber, - QueryAllData.Status, QueryAllData.Notes, QueryAllData.ToAccountName, + QueryAllData.PAYEENAME, QueryAllData.PAYEEID, QueryAllData.TransactionNumber, + QueryAllData.STATUS, QueryAllData.Notes, QueryAllData.ToAccountName, QueryAllData.TOACCOUNTID, QueryAllData.ToAmount, QueryAllData.ToCurrencyId, QueryAllData.currency}; } diff --git a/app/src/main/java/com/money/manager/ex/reports/PayeeReportAdapter.java b/app/src/main/java/com/money/manager/ex/reports/PayeeReportAdapter.java index bb107727c..ab46a938b 100644 --- a/app/src/main/java/com/money/manager/ex/reports/PayeeReportAdapter.java +++ b/app/src/main/java/com/money/manager/ex/reports/PayeeReportAdapter.java @@ -55,8 +55,8 @@ public void bindView(View view, Context context, Cursor cursor) { TextView txtColumn1 = view.findViewById(R.id.textViewColumn1); TextView txtColumn2 = view.findViewById(R.id.textViewColumn2); double total = cursor.getDouble(cursor.getColumnIndex("TOTAL")); - if (cursor.getColumnIndex(QueryAllData.Payee) >= 0 && !TextUtils.isEmpty(cursor.getString(cursor.getColumnIndex(QueryAllData.Payee)))) { - txtColumn1.setText(cursor.getString(cursor.getColumnIndex(QueryAllData.Payee))); + if (cursor.getColumnIndex(QueryAllData.PAYEENAME) >= 0 && !TextUtils.isEmpty(cursor.getString(cursor.getColumnIndex(QueryAllData.PAYEENAME)))) { + txtColumn1.setText(cursor.getString(cursor.getColumnIndex(QueryAllData.PAYEENAME))); } else { txtColumn1.setText(context.getString(R.string.empty_payee)); } diff --git a/app/src/main/java/com/money/manager/ex/search/SearchParametersFragment.java b/app/src/main/java/com/money/manager/ex/search/SearchParametersFragment.java index 35a18dfa5..7c9e0d601 100644 --- a/app/src/main/java/com/money/manager/ex/search/SearchParametersFragment.java +++ b/app/src/main/java/com/money/manager/ex/search/SearchParametersFragment.java @@ -452,7 +452,7 @@ private String assembleWhereClause() { if (searchParameters.status != null && !searchParameters.status.equals(SearchParameters.STRING_NULL_VALUE) && !searchParameters.status.isEmpty()) { - where.addStatement(QueryAllData.Status, "=", searchParameters.status); + where.addStatement(QueryAllData.STATUS, "=", searchParameters.status); } addAmountStatements(where, searchParameters); @@ -469,7 +469,7 @@ private String assembleWhereClause() { } // payee if (searchParameters.payeeId != null) { - where.addStatement(QueryAllData.PayeeID, " = ", searchParameters.payeeId); + where.addStatement(QueryAllData.PAYEEID, " = ", searchParameters.payeeId); } // category @@ -541,11 +541,11 @@ private void addAmountStatements(WhereStatementGenerator where, SearchParameters // from amount if (searchParameters.amountFrom != null) { - where.addStatement(QueryAllData.Amount, " >= ", searchParameters.amountFrom); + where.addStatement(QueryAllData.AMOUNT, " >= ", searchParameters.amountFrom); } // to amount if (searchParameters.amountTo != null) { - where.addStatement(QueryAllData.Amount, " <= ", searchParameters.amountTo); + where.addStatement(QueryAllData.AMOUNT, " <= ", searchParameters.amountTo); } } @@ -561,11 +561,11 @@ private void addAmountStatementForBothAmounts(WhereStatementGenerator where, Sea // from amount if (searchParameters.amountFrom != null) { - where.addStatement(QueryAllData.Amount, " >= ", lowerAmount); + where.addStatement(QueryAllData.AMOUNT, " >= ", lowerAmount); } // to amount if (searchParameters.amountTo != null) { - where.addStatement(QueryAllData.Amount, " <= ", higherAmount); + where.addStatement(QueryAllData.AMOUNT, " <= ", higherAmount); } } diff --git a/app/src/main/java/com/money/manager/ex/servicelayer/AccountService.java b/app/src/main/java/com/money/manager/ex/servicelayer/AccountService.java index e351bf71d..8db1c4a0e 100644 --- a/app/src/main/java/com/money/manager/ex/servicelayer/AccountService.java +++ b/app/src/main/java/com/money/manager/ex/servicelayer/AccountService.java @@ -146,13 +146,13 @@ public Money calculateBalanceOn(long accountId, String isoDate) { switch (TransactionTypes.valueOf(transType)) { case Withdrawal: DatabaseUtils.cursorDoubleToContentValues(cursor, ITransactionEntity.TRANSAMOUNT, - tx.contentValues, QueryAllData.Amount); + tx.contentValues, QueryAllData.AMOUNT); amount = tx.getAmount(); total = total.subtract(amount); break; case Deposit: DatabaseUtils.cursorDoubleToContentValues(cursor, ITransactionEntity.TRANSAMOUNT, - tx.contentValues, QueryAllData.Amount); + tx.contentValues, QueryAllData.AMOUNT); amount = tx.getAmount(); total = total.add(amount); break; @@ -162,12 +162,12 @@ public Money calculateBalanceOn(long accountId, String isoDate) { if (tx.getAccountId().equals(accountId)) { DatabaseUtils.cursorDoubleToContentValues(cursor, ITransactionEntity.TRANSAMOUNT, - tx.contentValues, QueryAllData.Amount); + tx.contentValues, QueryAllData.AMOUNT); amount = tx.getAmount(); total = total.subtract(amount); } else { DatabaseUtils.cursorDoubleToContentValues(cursor, ITransactionEntity.TOTRANSAMOUNT, - tx.contentValues, QueryAllData.Amount); + tx.contentValues, QueryAllData.AMOUNT); amount = tx.getAmount(); total = total.add(amount); } diff --git a/app/src/main/java/com/money/manager/ex/viewmodels/AccountTransactionDisplay.java b/app/src/main/java/com/money/manager/ex/viewmodels/AccountTransactionDisplay.java index bd8c923b3..dfc37d88e 100644 --- a/app/src/main/java/com/money/manager/ex/viewmodels/AccountTransactionDisplay.java +++ b/app/src/main/java/com/money/manager/ex/viewmodels/AccountTransactionDisplay.java @@ -43,7 +43,7 @@ public void loadFromCursor(Cursor c) { super.loadFromCursor(c); // Reload all money values. - DatabaseUtils.cursorDoubleToCursorValues(c, QueryAllData.Amount, this.contentValues); + DatabaseUtils.cursorDoubleToCursorValues(c, QueryAllData.AMOUNT, this.contentValues); DatabaseUtils.cursorDoubleToCursorValues(c, QueryAllData.ToAmount, this.contentValues); } @@ -60,7 +60,7 @@ public String getAccountName() { } public Money getAmount() { - return getMoney(QueryAllData.Amount); + return getMoney(QueryAllData.AMOUNT); } public String getCategory() { @@ -89,11 +89,11 @@ public boolean getIsSplit() { } public String getPayee() { - return getString(QueryAllData.Payee); + return getString(QueryAllData.PAYEENAME); } public String getStatusCode() { - return getString(QueryAllData.Status); + return getString(QueryAllData.STATUS); } public TransactionStatuses getStatus() { diff --git a/app/src/main/res/raw/query_alldata.sql b/app/src/main/res/raw/query_alldata.sql index d2cd192e8..4ba20bbfa 100644 --- a/app/src/main/res/raw/query_alldata.sql +++ b/app/src/main/res/raw/query_alldata.sql @@ -27,7 +27,7 @@ SELECT ifnull(ToAcc.CurrencyId, FromAcc.CurrencyID) AS ToCurrencyId, ( CASE ifnull( TX.CATEGID, -1 ) WHEN -1 THEN 1 ELSE 0 END ) AS SPLITTED, TX.CATEGID AS CategID, - ifnull( PAYEE.PayeeName, '') AS Payee, + ifnull( PAYEE.PayeeName, '') AS PayeeName, ifnull( PAYEE.PayeeID, -1 ) AS PayeeID, TX.TRANSACTIONNUMBER AS TransactionNumber, diff --git a/app/src/main/res/raw/query_mobiledata.sql b/app/src/main/res/raw/query_mobiledata.sql index 7a1e3396f..a0be328b8 100644 --- a/app/src/main/res/raw/query_mobiledata.sql +++ b/app/src/main/res/raw/query_mobiledata.sql @@ -30,7 +30,7 @@ SELECT TX.TransID AS ID, ( CASE ifnull( TX.CATEGID, -1 ) WHEN -1 THEN 1 ELSE 0 END ) AS SPLITTED, coalesce( SPARENTCAT.CATEGID, PARENTCAT.CATEGID, st.CategId, TX.CategId ) AS CATEGID, -1 AS SubcategID, - ifnull( PAYEE.PayeeName, '') AS Payee, + ifnull( PAYEE.PayeeName, '') AS PayeeName, ifnull( PAYEE.PayeeID, -1 ) AS PayeeID, TX.TRANSACTIONNUMBER AS TransactionNumber, round( strftime( '%d', TX.transdate ) ) AS day,