Skip to content

Commit

Permalink
Fix date nil
Browse files Browse the repository at this point in the history
  • Loading branch information
fabioelia committed Jan 26, 2013
1 parent 1da65de commit b93333e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/models/plutus/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,14 @@ class Account < ActiveRecord::Base
validates_uniqueness_of :name

def credits_by_date(start_date = "1900-01-01", end_date = Date.today + 15.days)
end_date = Date.today + 15.days if end_date.nil?
start_date = "1900-01-01" if start_date.nil?
credit_amounts.includes(:transaction).where("plutus_transactions.date >= '#{start_date}' AND DATE( plutus_transactions.date) <= '#{end_date.to_s}'")
end

def debits_by_date(start_date = "1900-01-01", end_date = Date.today + 15.days)
end_date = Date.today + 15.days if end_date.nil?
start_date = "1900-01-01" if start_date.nil?
debit_amounts.includes(:transaction).where("plutus_transactions.date >= '#{start_date}' AND DATE( plutus_transactions.date ) <= '#{end_date.to_s}'")
end

Expand Down

0 comments on commit b93333e

Please sign in to comment.