1
0
Fork 0
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:
Zach Gollwitzer 2024-04-19 12:03:16 -04:00 committed by GitHub
parent 0277bc94f3
commit c46662c99f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 89 additions and 49 deletions

View file

@ -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