HourlyDeliverable profit was being counted twice because HourlyDeliverable.profit would return the actual profit or the profit percent already. #1389
This commit is contained in:
@@ -103,16 +103,8 @@ class Budget
|
||||
def profit
|
||||
return 0.0 unless self.deliverables.size > 0
|
||||
|
||||
profit = 0.0
|
||||
# Fixed profit
|
||||
profit += self.deliverables.collect(&:profit).delete_if { |d| d.blank?}.inject { |sum, n| sum + n } || 0.0
|
||||
|
||||
# Percentage Rate
|
||||
self.deliverables.delete_if { |d| d.profit_percent.blank?}.each do |deliverable|
|
||||
profit += deliverable.budget * (deliverable.profit_percent.to_f / 100 )
|
||||
end
|
||||
|
||||
return profit
|
||||
# Covers fixed and percentage profit though the +profit+ method being overloaded on the Deliverable types
|
||||
return self.deliverables.collect(&:profit).delete_if { |d| d.blank?}.inject { |sum, n| sum + n } || 0.0
|
||||
end
|
||||
|
||||
# Dollar amount of time that has been logged to the project itself
|
||||
|
||||
Reference in New Issue
Block a user