Skip to content

Commit

Permalink
Global date check
Browse files Browse the repository at this point in the history
  • Loading branch information
fabioelia committed Jan 25, 2013
1 parent b66f56a commit 9cefb18
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
4 changes: 3 additions & 1 deletion app/models/plutus/asset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,12 @@ def balance
# => #<BigDecimal:1030fcc98,'0.82875E5',8(20)>
#
# @return [BigDecimal] The decimal value balance
def self.balance
def self.balance( startDate = nil, endDate = nil )
accounts_balance = BigDecimal.new('0')
accounts = self.find(:all)
accounts.each do |asset|
asset.start_date = startDate if startDate
asset.end_date = endDate if endDate
unless asset.contra
accounts_balance += asset.balance
else
Expand Down
4 changes: 3 additions & 1 deletion app/models/plutus/equity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,12 @@ def balance
# => #<BigDecimal:1030fcc98,'0.82875E5',8(20)>
#
# @return [BigDecimal] The decimal value balance
def self.balance
def self.balance( startDate = nil, endDate = nil )
accounts_balance = BigDecimal.new('0')
accounts = self.find(:all)
accounts.each do |equity|
equity.start_date = startDate if startDate
equity.end_date = endDate if endDate
unless equity.contra
accounts_balance += equity.balance
else
Expand Down
4 changes: 3 additions & 1 deletion app/models/plutus/expense.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,12 @@ def balance
# => #<BigDecimal:1030fcc98,'0.82875E5',8(20)>
#
# @return [BigDecimal] The decimal value balance
def self.balance
def self.balance( startDate = nil, endDate = nil )
accounts_balance = BigDecimal.new('0')
accounts = self.find(:all)
accounts.each do |expense|
expense.start_date = startDate if startDate
expense.end_date = endDate if endDate
unless expense.contra
accounts_balance += expense.balance
else
Expand Down
4 changes: 3 additions & 1 deletion app/models/plutus/liability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,12 @@ def balance
# @example
# >> Plutus::Liability.balance
# => #<BigDecimal:1030fcc98,'0.82875E5',8(20)>
def self.balance
def self.balance( startDate = nil, endDate = nil )
accounts_balance = BigDecimal.new('0')
accounts = self.find(:all)
accounts.each do |liability|
liability.startDate = startDate if startDate
liability.endDate = endDate if endDate
unless liability.contra
accounts_balance += liability.balance
else
Expand Down
4 changes: 3 additions & 1 deletion app/models/plutus/revenue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,12 @@ def balance
# => #<BigDecimal:1030fcc98,'0.82875E5',8(20)>
#
# @return [BigDecimal] The decimal value balance
def self.balance
def self.balance( startDate = nil, endDate = nil )
accounts_balance = BigDecimal.new('0')
accounts = self.find(:all)
accounts.each do |revenue|
revenue.start_date = startDate if startDate
revenue.end_date = endDate if endDate
unless revenue.contra
accounts_balance += revenue.balance
else
Expand Down

0 comments on commit 9cefb18

Please sign in to comment.