Files
grecia/app/models/budget/ballot.rb
2016-05-24 13:04:12 +02:00

18 lines
353 B
Ruby

class Budget
class Ballot < ActiveRecord::Base
belongs_to :user
belongs_to :budget
has_many :lines, dependent: :destroy
has_many :investments, through: :lines
def total_amount_spent
investments.sum(:price).to_i
end
def amount_spent(heading)
investments.by_heading(heading).sum(:price).to_i
end
end
end