From e6930aed0cf2eb319789422932b237ae27a748b6 Mon Sep 17 00:00:00 2001 From: fabioelia Date: Fri, 25 Jan 2013 23:43:54 -0500 Subject: [PATCH] Trialbalance by date --- app/models/plutus/account.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/plutus/account.rb b/app/models/plutus/account.rb index 415f8955..5d7300b4 100644 --- a/app/models/plutus/account.rb +++ b/app/models/plutus/account.rb @@ -50,9 +50,11 @@ class Account < ActiveRecord::Base # => 0 # # @return [BigDecimal] The decimal value balance of all accounts - def self.trial_balance + def self.trial_balance(startDate = nil, endDate = nil) unless self.new.class == Account raise(NoMethodError, "undefined method 'trial_balance'") + elsif startDate || endDate + Asset.balance( startDate, endDate ) - (Liability.balance( startDate, endDate ) + Equity.balance( startDate, endDate ) + Revenue.balance( startDate, endDate ) - Expense.balance( startDate, endDate )) else Asset.balance - (Liability.balance + Equity.balance + Revenue.balance - Expense.balance) end