From bb7f82a72f70bf262103ed246082c455591544b2 Mon Sep 17 00:00:00 2001 From: kikito Date: Fri, 27 May 2016 15:12:54 +0200 Subject: [PATCH] Fixes hidden bug when calculating amount_available --- app/models/budget/ballot.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/budget/ballot.rb b/app/models/budget/ballot.rb index bf7851883..9b9a089d6 100644 --- a/app/models/budget/ballot.rb +++ b/app/models/budget/ballot.rb @@ -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