diff --git a/app/utils/analytics/finances/project_calculator.rb b/app/utils/analytics/finances/project_calculator.rb index 96b1a7f..710042a 100644 --- a/app/utils/analytics/finances/project_calculator.rb +++ b/app/utils/analytics/finances/project_calculator.rb @@ -13,8 +13,8 @@ class ProjectCalculator expected_cost ].freeze - def initialize(statement_of_work, start_date, end_date) - @statement_of_work = statement_of_work + def initialize(project, start_date, end_date) + @project = project @start_date = start_date @end_date = end_date end @@ -58,9 +58,9 @@ def data private def statements_of_work - return StatementOfWork.where(id: @statement_of_work.id) if @statement_of_work + statements = @project ? @project.statement_of_works : StatementOfWork.all - StatementOfWork.active_in_period(@start_date, @end_date) + statements.active_in_period(@start_date, @end_date) end def calculator(statement_of_work) diff --git a/app/utils/analytics/project_finances_analytics.rb b/app/utils/analytics/project_finances_analytics.rb index b0d138e..227e9c7 100644 --- a/app/utils/analytics/project_finances_analytics.rb +++ b/app/utils/analytics/project_finances_analytics.rb @@ -2,14 +2,14 @@ module Analytics class ProjectFinancesAnalytics - def initialize(start_date, end_date, statement_of_work) + def initialize(start_date, end_date, project) @start_date = start_date.to_datetime.beginning_of_day @end_date = end_date.to_datetime.end_of_day - @statement_of_work = statement_of_work + @project = project end def data - Analytics::Finances::ProjectCalculator.new(@statement_of_work, @start_date, @end_date).data + Analytics::Finances::ProjectCalculator.new(@project, @start_date, @end_date).data end end end