From b93333e13ff42287bc5688294d2432eda2a63b7f Mon Sep 17 00:00:00 2001 From: fabioelia Date: Sat, 26 Jan 2013 12:58:42 -0500 Subject: [PATCH] Fix date nil --- app/models/plutus/account.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/models/plutus/account.rb b/app/models/plutus/account.rb index 03510e39..d7325c3f 100644 --- a/app/models/plutus/account.rb +++ b/app/models/plutus/account.rb @@ -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