mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-24 15:49:39 +02:00
Add apply button, improve transaction filters (#655)
* Add apply button, improve transaction filters * Remove temp log * Fix lint errors
This commit is contained in:
parent
0277bc94f3
commit
c46662c99f
8 changed files with 89 additions and 49 deletions
|
@ -23,6 +23,8 @@ class Transaction < ApplicationRecord
|
|||
def self.build_filter_list(params, family)
|
||||
filters = []
|
||||
|
||||
date_filters = { gteq: nil, lteq: nil }
|
||||
|
||||
if params
|
||||
params.each do |key, value|
|
||||
next if value.blank?
|
||||
|
@ -38,8 +40,16 @@ class Transaction < ApplicationRecord
|
|||
end
|
||||
when "category_name_or_account_name_or_name_cont"
|
||||
filters << { type: "search", value: value, original: { key: key, value: nil } }
|
||||
when "date_gteq"
|
||||
date_filters[:gteq] = value
|
||||
when "date_lteq"
|
||||
date_filters[:lteq] = value
|
||||
end
|
||||
end
|
||||
|
||||
unless date_filters.values.compact.empty?
|
||||
filters << { type: "date_range", value: date_filters, original: { key: "date_range", value: nil } }
|
||||
end
|
||||
end
|
||||
|
||||
filters
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue