Calc cleanup

This commit is contained in:
Eric Davis
2008-06-03 17:19:30 -07:00
parent 5180b5b218
commit 490bf73efe
8 changed files with 45 additions and 1 deletions
+1
View File
@@ -64,6 +64,7 @@ class Budget
def progress
return 100 unless self.deliverables.size > 0
return 100 if self.budget == 0.0
balance = 0.0
+1
View File
@@ -42,6 +42,7 @@ class Deliverable < ActiveRecord::Base
end
def budget_ratio
return 0.0 if self.budget.nil? || self.budget == 0.0
return ((self.spent / self.budget) * 100).round
end
+8
View File
@@ -9,4 +9,12 @@ class FixedDeliverable < Deliverable
def spent
(self.progress.to_f / 100 ) * self.budget
end
def profit
if read_attribute(:profit_percent).nil?
return super
else
return (read_attribute(:profit_percent).to_f / 100.0) * read_attribute(:fixed_cost)
end
end
end
+8
View File
@@ -22,5 +22,13 @@ class HourlyDeliverable < Deliverable
return self.issues.collect(&:time_entries).flatten.collect(&:hours).sum
end
def profit
if read_attribute(:profit_percent).nil?
return super
else
return (read_attribute(:profit_percent).to_f / 100.0) * (read_attribute(:cost_per_hour) * read_attribute(:total_hours))
end
end
end