Files
nairobi/app/models/budget/voting_styles/knapsack.rb
Ziyan Junaideen 1e3e8c1304 Add approval voting to budgets
Co-Authored-By: Javi Martín <javim@elretirao.net>
2020-08-06 12:38:18 +02:00

26 lines
572 B
Ruby

class Budget::VotingStyles::Knapsack < Budget::VotingStyles::Base
def enough_resources?(investment)
investment.price.to_i <= amount_available(investment.heading)
end
def reason_for_not_being_ballotable(investment)
:not_enough_money unless enough_resources?(investment)
end
def not_enough_resources_error
"insufficient funds"
end
def amount_spent(heading)
investments_price(heading)
end
def amount_limit(heading)
ballot.budget.heading_price(heading)
end
def format(amount)
ballot.budget.formatted_amount(amount)
end
end