Filtering investments are based on the latest milestone status

This commit is contained in:
Angel Perez
2018-07-12 22:01:26 -04:00
committed by Javi Martín
parent 749954267d
commit a3ef662509
2 changed files with 11 additions and 2 deletions

View File

@@ -6,7 +6,7 @@ module BudgetExecutionsHelper
.winners
.joins(:milestones)
.distinct
.where('budget_investment_milestones.status_id = ?', params[:status])
.where(filter_investment_by_latest_milestone, params[:status])
else
heading.investments
.winners
@@ -15,4 +15,11 @@ module BudgetExecutionsHelper
end
end
def filter_investment_by_latest_milestone
<<-SQL
(SELECT status_id FROM budget_investment_milestones
WHERE investment_id = budget_investments.id ORDER BY publication_date DESC LIMIT 1) = ?
SQL
end
end