Added rdoc comments
This commit is contained in:
1 parent
cb7d4a41a0
commit
8150cfcabc
6 files changed
+61
-11
No files matched your search
+13
-2
@@ -10,7 +10,8 @@ class Budget
|
||||
def initialize(project_id)
|
||||
@project = Project.find(project_id)
|
||||
end
|
||||
|
||||
|
||||
# Gets the next due date from the deliverables
|
||||
def next_due_date
|
||||
del = self.deliverables
|
||||
return nil unless del.size > 0
|
||||
@@ -20,6 +21,7 @@ class Budget
|
||||
return dates.sort[0]
|
||||
end
|
||||
|
||||
# Gets the last due date of the deliverables
|
||||
def final_due_date
|
||||
del = self.deliverables
|
||||
return nil unless del.size > 0
|
||||
@@ -29,14 +31,17 @@ class Budget
|
||||
return dates.sort[-1]
|
||||
end
|
||||
|
||||
# Deliverables assigned to this +Budget+
|
||||
def deliverables
|
||||
return Deliverable.find_all_by_project_id(@project.id)
|
||||
end
|
||||
|
||||
# Total budget all of the deliverables
|
||||
def budget
|
||||
return self.deliverables.collect(&:budget).inject { |sum, n| sum + n} || 0.0
|
||||
end
|
||||
|
||||
|
||||
# Amount of the budget spent. Expressed as as a percentage whole number
|
||||
def budget_ratio
|
||||
budget = self.budget # cache result
|
||||
if budget > 0.0
|
||||
@@ -46,14 +51,17 @@ class Budget
|
||||
end
|
||||
end
|
||||
|
||||
# Total amount spent for all the deliverables
|
||||
def spent
|
||||
self.deliverables.collect(&:spent).inject { |sum, n| sum + n } || 0.0
|
||||
end
|
||||
|
||||
# Amount of budget left on the deliverables
|
||||
def left
|
||||
return self.budget - self.spent
|
||||
end
|
||||
|
||||
# Amount spent over the budget
|
||||
def overruns
|
||||
if self.left >= 0
|
||||
return 0
|
||||
@@ -62,6 +70,7 @@ class Budget
|
||||
end
|
||||
end
|
||||
|
||||
# Completation progress, expressed as a percentage whole number
|
||||
def progress
|
||||
return 100 unless self.deliverables.size > 0
|
||||
return 100 if self.budget == 0.0
|
||||
@@ -75,10 +84,12 @@ class Budget
|
||||
return (balance / self.budget).round
|
||||
end
|
||||
|
||||
# Budget score. Will range from 100 (everything done with no money spent) to -100 (nothing done, all the money spent)
|
||||
def score
|
||||
return self.progress - self.budget_ratio
|
||||
end
|
||||
|
||||
# Total profit of the deliverables. This is *not* calculated based on the amount spent and total budget but is the total of the profit amount for the deliverables.
|
||||
def profit
|
||||
return 0.0 unless self.deliverables.size > 0
|
||||
|
||||
|
||||
Reference in new issue
Block a user