Fixes hidden bug when calculating amount_available

This commit is contained in:
kikito
2016-05-27 15:12:54 +02:00
parent b6e47bc14a
commit bb7f82a72f

View File

@@ -11,12 +11,12 @@ class Budget
investments.sum(:price).to_i
end
def amount_spent(heading)
investments.by_heading(heading).sum(:price).to_i
def amount_spent(heading_id)
investments.by_heading(heading_id).sum(:price).to_i
end
def amount_available(heading)
budget.heading_price(heading) - amount_spent(heading)
budget.heading_price(heading) - amount_spent(heading.try(:id))
end
end
end