Files
nairobi/app/components/valuation/budgets/row_component.rb
Javi Martín 1649b9125e Add scope to get investments visible to a valuator
Using this method makes it more obvious that we're loading the same
investments in the budgets index as in the investments index.
2023-02-17 15:27:53 +01:00

23 lines
501 B
Ruby

class Valuation::Budgets::RowComponent < ApplicationComponent
attr_reader :budget
with_collection_parameter :budget
delegate :current_user, to: :helpers
def initialize(budget:)
@budget = budget
end
def investments
return Budget::Investment.none unless budget.valuating_or_later?
budget.investments.visible_to_valuator(current_user.valuator)
end
def valuation_open_investments_count
return 0 unless budget.valuating?
investments.valuation_open.count
end
end