Skip to content

Commit

Permalink
Merge pull request #1487 from moneymanagerex/v19
Browse files Browse the repository at this point in the history
search refinement: category search
  • Loading branch information
guanlisheng authored Dec 31, 2023
2 parents 2e701bb + aa350ca commit 864592c
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,9 @@ private void logTableInsert(Dataset dataset, ContentValues values) {
private Cursor query_internal(Uri uri, String[] projection, String selection,
String[] selectionArgs, String sortOrder){
Timber.v("Querying URI: %s", uri);
Timber.v("Querying projection: %s", projection);
Timber.v("Querying selection: %s", selection);
Timber.v("Querying selectionArgs: %s", selectionArgs);

// find object from uri
Object sourceObject = getObjectFromUri(uri);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ protected void setResult() {
result.putExtra(CategoryListActivity.INTENT_RESULT_CATEGID, categId);
result.putExtra(CategoryListActivity.INTENT_RESULT_CATEGNAME,
mCategories.get(groupIndex).getName());
result.putExtra(CategoryListActivity.INTENT_RESULT_SUBCATEGID, subCategId);
result.putExtra(CategoryListActivity.INTENT_RESULT_SUBCATEGID, Constants.NOT_SET);
result.putExtra(CategoryListActivity.INTENT_RESULT_SUBCATEGNAME, "");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class QueryAllData
// public static final String FromAmount = "FromAmount";
// public static final String FromCurrencyId = "FromCurrencyId";
public static final String SPLITTED = "Splitted";
public static final String ParentCategID = "ParentCategID";
public static final String CategID = "CategID";
public static final String SubcategID = "SubcategID";
public static final String Payee = "Payee";
Expand All @@ -69,7 +70,7 @@ public String[] getAllColumns() {
return new String[]{"ID AS _id", ID, TransactionType, Date, UserDate, Year, Month, Day,
Category, Subcategory, Amount, BaseConvRate, CURRENCYID, AccountName, ACCOUNTID,
// FromAccountName, FromAccountId, FromAmount, FromCurrencyId,
SPLITTED, CategID, SubcategID, Payee, PayeeID, TransactionNumber, Status, Notes,
SPLITTED, CategID, ParentCategID, SubcategID, Payee, PayeeID, TransactionNumber, Status, Notes,
ToAccountName, TOACCOUNTID, ToAmount, ToCurrencyId,
currency, finyear};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public String[] getAllColumns() {
QueryAllData.BaseConvRate, QueryAllData.CURRENCYID, QueryAllData.AccountName,
QueryAllData.ACCOUNTID,
// FromAccountName, FromAccountId, FromAmount, FromCurrencyId,
QueryAllData.SPLITTED, QueryAllData.CategID, QueryAllData.SubcategID,
QueryAllData.SPLITTED, QueryAllData.ParentCategID, QueryAllData.SubcategID,
QueryAllData.Payee, QueryAllData.PayeeID, QueryAllData.TransactionNumber,
QueryAllData.Status, QueryAllData.Notes, QueryAllData.ToAccountName,
QueryAllData.TOACCOUNTID, QueryAllData.ToAmount, QueryAllData.ToCurrencyId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
import android.widget.Spinner;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.core.view.MenuItemCompat;
import androidx.fragment.app.Fragment;

import com.codetroopers.betterpickers.calendardatepicker.CalendarDatePickerDialogFragment;
import com.mikepenz.google_material_typeface_library.GoogleMaterial;
import com.money.manager.ex.Constants;
Expand Down Expand Up @@ -66,9 +70,6 @@

import javax.inject.Inject;

import androidx.appcompat.app.AppCompatActivity;
import androidx.core.view.MenuItemCompat;
import androidx.fragment.app.Fragment;
import butterknife.ButterKnife;
import butterknife.OnClick;
import dagger.Lazy;
Expand Down Expand Up @@ -479,18 +480,6 @@ private String assembleWhereClause() {
" WHERE " + SplitCategory.TRANSID + "=" + QueryAllData.ID + ")" +
")" +
")");

// subcategory
if (categorySub.subCategId != Constants.NOT_SET) {
// Subcategory. Also check the splits.
where.addStatement("(" +
"(" + QueryAllData.SubcategID + "=" + categorySub.subCategId + ") " +
" OR (" + categorySub.subCategId + " IN (select " + QueryAllData.SubcategID +
" FROM " + SplitCategory.TABLE_NAME +
" WHERE " + SplitCategory.TRANSID + " = " + QueryAllData.ID + ")" +
")" +
")");
}
}

// transaction number
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/raw/query_alldata.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ SELECT TX.TransID AS ID,
TX.ToTransAmount as ToAmount,
ifnull(ToAcc.CurrencyId, FromAcc.CurrencyID) as ToCurrencyId,
( CASE ifnull( TX.CATEGID, -1 ) WHEN -1 THEN 1 ELSE 0 END ) AS SPLITTED,
ifnull( CAT.PARENTID, -1 ) AS CategID,
ifnull( PARENTCAT.CategID, CAT.CategID ) AS ParentCategID,
TX.CATEGID AS CategID,
ifnull( CAT.CategID, -1 ) AS SubcategID,
ifnull( PAYEE.PayeeName, '') AS Payee,
ifnull( PAYEE.PayeeID, -1 ) AS PayeeID,
Expand Down

0 comments on commit 864592c

Please sign in to comment.