Show valuator group investments to their valuators
When accessing the valuation area, we were only displaying the investments directly assigned to the current valuator, but we weren't displaying the investments assigned to that valuator's group. Using the `assigned_investments_ids` method, which takes the valuator group into account, solves the issue. We've also found an issue on our development machines: since we don't have a unique index per `investment_id` and `valuator_id` in the `budget_valuator_assignments` table, we've found duplicate records on this table. When that happened, we were displaying the same investment several times. Since now we no longer join this table in the query returning the investment, this issue is also solved, and we're adding a test for it. We can now remove the call to the `distinct` method when calculating the number of investments per heading.
This commit is contained in:
@@ -73,7 +73,7 @@ class Valuation::BudgetInvestmentsController < Valuation::BaseController
|
||||
end
|
||||
|
||||
def heading_filters
|
||||
investments = @budget.investments.visible_to_valuator(current_user.valuator).distinct
|
||||
investments = @budget.investments.visible_to_valuator(current_user.valuator)
|
||||
investment_headings = Budget::Heading.where(id: investments.pluck(:heading_id)).sort_by(&:name)
|
||||
|
||||
all_headings_filter = [
|
||||
|
||||
Reference in New Issue
Block a user