[#4477] Added the FixedBudget markup calculations.

This commit is contained in:
Eric Davis
2010-09-09 16:12:48 -07:00
parent 7f7e5b3042
commit 07da5d98d8
2 changed files with 50 additions and 0 deletions
+23
View File
@@ -7,4 +7,27 @@ class FixedBudget < ActiveRecord::Base
# Validations
# Accessors
def markup_value
return 0 if budget.blank? || markup.blank?
case
when percent_markup?
percent = markup.gsub('%','').to_f
return budget.to_f * (percent / 100)
when straight_markup?
markup.gsub('$','').gsub(',','').to_f
else
0 # Invalid markup
end
end
def percent_markup?
markup && markup.match(/%/)
end
def straight_markup?
markup && markup.match(/\$/)
end
end