mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-22 06:39:39 +02:00
* Isolate infinite loop bug, add timeout to actions * Increase timeout to allow for temporary failure * Set correct timeout, implement temporary fix * Trigger syncs at controller layer
43 lines
1.1 KiB
Ruby
43 lines
1.1 KiB
Ruby
class Transaction < ApplicationRecord
|
|
include Monetizable
|
|
|
|
belongs_to :account
|
|
belongs_to :category, optional: true
|
|
|
|
validates :name, :date, :amount, :account, presence: true
|
|
|
|
monetize :amount
|
|
|
|
scope :inflows, -> { where("amount > 0") }
|
|
scope :outflows, -> { where("amount < 0") }
|
|
scope :active, -> { where(excluded: false) }
|
|
|
|
def self.ransackable_attributes(auth_object = nil)
|
|
%w[name amount date]
|
|
end
|
|
|
|
def self.ransackable_associations(auth_object = nil)
|
|
%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
|
|
end
|