1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-05 13:35:21 +02:00

Implement transaction filtering UI (#578)

* Rough sketch of implementation

* Consolidate auto submit controller

* Store ransack params in session

* Improve how summary is calculated for txns

* Implement filters UI
This commit is contained in:
Zach Gollwitzer 2024-03-28 13:23:54 -04:00 committed by GitHub
parent 7ae25dd6df
commit f0c2d4ead0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 296 additions and 146 deletions

View file

@ -21,7 +21,7 @@ class Account < ApplicationRecord
delegated_type :accountable, types: Accountable::TYPES, dependent: :destroy
def self.ransackable_attributes(auth_object = nil)
%w[name]
%w[name id]
end
def balance_on(date)

View file

@ -22,6 +22,27 @@ class Transaction < ApplicationRecord
%w[category account]
end
def self.build_filter_list(params, family)
filters = []
if params
params.each do |key, value|
next if value.blank?
case key
when "account_id_in"
value.each do |account_id|
filters << { type: "account", value: family.accounts.find(account_id), original: { key: key, value: account_id } }
end
when "category_name_or_account_name_or_name_cont"
filters << { type: "search", value: value, original: { key: key, value: nil } }
end
end
end
filters
end
private
def sync_account