mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-05 05:25:24 +02:00
Feature | Filter on uncategorized transactions (#1359)
* allow filtering uncategorized transactions * user can filter uncategorized transactions test * rubocop linting
This commit is contained in:
parent
aa3342b0dc
commit
2cc89195bf
4 changed files with 43 additions and 3 deletions
|
@ -13,7 +13,19 @@ class Account::Transaction < ApplicationRecord
|
|||
class << self
|
||||
def search(params)
|
||||
query = all
|
||||
query = query.joins(:category).where(categories: { name: params[:categories] }) if params[:categories].present?
|
||||
if params[:categories].present?
|
||||
if params[:categories].exclude?("Uncategorized")
|
||||
query = query
|
||||
.joins(:category)
|
||||
.where(categories: { name: params[:categories] })
|
||||
else
|
||||
query = query
|
||||
.left_joins(:category)
|
||||
.where(categories: { name: params[:categories] })
|
||||
.or(query.where(category_id: nil))
|
||||
end
|
||||
end
|
||||
|
||||
query = query.joins(:merchant).where(merchants: { name: params[:merchants] }) if params[:merchants].present?
|
||||
|
||||
if params[:tags].present?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue