Skip to content

Commit

Permalink
Added date filtering to accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
fabioelia committed Jan 22, 2013
1 parent 4c22a55 commit 8fba602
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions app/models/plutus/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ module Plutus
# @author Michael Bulat
class Account < ActiveRecord::Base
attr_accessible :name, :contra

has_many :credit_amounts
has_many :debit_amounts
attr_accessor :start_date, :end_date

has_many :credit_amounts, :include => :transaction, :conditions => proc { "plutus_transactions.date >= '#{start_date || "1900-01-01"}' AND plutus_transactions.date <= #{end_date || ( Date.today + 15.days ).to_s}" }
has_many :debit_amounts, :include => :transaction, :conditions => proc { "plutus_transactions.date >= '#{start_date || "1900-01-01"}' AND plutus_transactions.date <= #{end_date || ( Date.today + 15.days ).to_s}"
has_many :credit_transactions, :through => :credit_amounts, :source => :transaction
has_many :debit_transactions, :through => :debit_amounts, :source => :transaction
belongs_to :accountable, :polymorphic => true
Expand Down

0 comments on commit 8fba602

Please sign in to comment.