Calc cleanup
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user