From 9cefb18fb3a8efd76d0076f0b0372c5bc7623dd5 Mon Sep 17 00:00:00 2001 From: fabioelia Date: Fri, 25 Jan 2013 10:08:51 -0500 Subject: [PATCH] Global date check --- app/models/plutus/asset.rb | 4 +++- app/models/plutus/equity.rb | 4 +++- app/models/plutus/expense.rb | 4 +++- app/models/plutus/liability.rb | 4 +++- app/models/plutus/revenue.rb | 4 +++- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/models/plutus/asset.rb b/app/models/plutus/asset.rb index 45344db1..c6778f5f 100644 --- a/app/models/plutus/asset.rb +++ b/app/models/plutus/asset.rb @@ -67,10 +67,12 @@ def balance # => # # # @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 diff --git a/app/models/plutus/equity.rb b/app/models/plutus/equity.rb index 5fc0dbba..05e4e6f5 100644 --- a/app/models/plutus/equity.rb +++ b/app/models/plutus/equity.rb @@ -68,10 +68,12 @@ def balance # => # # # @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 diff --git a/app/models/plutus/expense.rb b/app/models/plutus/expense.rb index b709053c..1c6c18de 100644 --- a/app/models/plutus/expense.rb +++ b/app/models/plutus/expense.rb @@ -67,10 +67,12 @@ def balance # => # # # @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 diff --git a/app/models/plutus/liability.rb b/app/models/plutus/liability.rb index 9491449c..3ec43674 100644 --- a/app/models/plutus/liability.rb +++ b/app/models/plutus/liability.rb @@ -62,10 +62,12 @@ def balance # @example # >> Plutus::Liability.balance # => # - 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 diff --git a/app/models/plutus/revenue.rb b/app/models/plutus/revenue.rb index ccb0015f..f8b918f5 100644 --- a/app/models/plutus/revenue.rb +++ b/app/models/plutus/revenue.rb @@ -67,10 +67,12 @@ def balance # => # # # @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