Added labor_budget virtual field and made that the Budget column. #1190
This commit is contained in:
@@ -125,7 +125,7 @@ class DeliverablesController < ApplicationController
|
||||
|
||||
# Sorting orders
|
||||
def sort_order
|
||||
if %w(score spent progress).include?(session[@sort_name][:key])
|
||||
if %w(score spent progress labor_budget).include?(session[@sort_name][:key])
|
||||
return { }
|
||||
else
|
||||
return { :order => sort_clause }
|
||||
@@ -134,7 +134,7 @@ class DeliverablesController < ApplicationController
|
||||
|
||||
# Sort +deliverables+ manually using the virtual fields
|
||||
def sort_if_needed(deliverables)
|
||||
if %w(score spent progress).include?(session[@sort_name][:key])
|
||||
if %w(score spent progress labor_budget).include?(session[@sort_name][:key])
|
||||
case session[@sort_name][:key]
|
||||
when "score":
|
||||
sorted = deliverables.sort {|a,b| a.score <=> b.score}
|
||||
@@ -142,6 +142,8 @@ class DeliverablesController < ApplicationController
|
||||
sorted = deliverables.sort {|a,b| a.spent <=> b.spent}
|
||||
when "progress":
|
||||
sorted = deliverables.sort {|a,b| a.progress <=> b.progress}
|
||||
when "labor_budget":
|
||||
sorted = deliverables.sort {|a,b| a.labor_budget <=> b.labor_budget}
|
||||
end
|
||||
|
||||
return sorted if session[@sort_name][:order] == 'asc'
|
||||
|
||||
@@ -117,6 +117,9 @@ class Deliverable < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
def labor_budget
|
||||
0
|
||||
end
|
||||
|
||||
# Returns true if the deliverable can be edited by user, otherwise false
|
||||
def editable_by?(user)
|
||||
|
||||
@@ -17,4 +17,9 @@ class FixedDeliverable < Deliverable
|
||||
return (read_attribute(:profit_percent).to_f / 100.0) * read_attribute(:fixed_cost)
|
||||
end
|
||||
end
|
||||
|
||||
def labor_budget
|
||||
return read_attribute(:fixed_cost)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -30,5 +30,10 @@ class HourlyDeliverable < Deliverable
|
||||
return (read_attribute(:profit_percent).to_f / 100.0) * (read_attribute(:cost_per_hour) * read_attribute(:total_hours))
|
||||
end
|
||||
end
|
||||
|
||||
def labor_budget
|
||||
return read_attribute(:cost_per_hour).to_f * read_attribute(:total_hours).to_f
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user