Changed profit to take into account the overhead along with the total labor cost
when profit is a % * Fixed Models * Fixed JS Calculator * Cleaned up specs to access attributes directly #1349
This commit is contained in:
@@ -68,8 +68,16 @@ class Deliverable < ActiveRecord::Base
|
||||
return ((self.spent / self.budget) * 100).round
|
||||
end
|
||||
|
||||
def overhead
|
||||
return read_attribute(:overhead) unless read_attribute(:overhead).nil?
|
||||
return ((read_attribute(:overhead_percent).to_f / 100.0) * self.labor_budget) unless read_attribute(:overhead_percent).nil?
|
||||
return 0
|
||||
end
|
||||
|
||||
# Setter for the overhead to take an Dollar amount or a %.
|
||||
def overhead=(v)
|
||||
return if v.nil?
|
||||
|
||||
if v.match(/%/)
|
||||
# Clear amount since this is a %
|
||||
write_attribute(:overhead, nil)
|
||||
@@ -84,6 +92,8 @@ class Deliverable < ActiveRecord::Base
|
||||
|
||||
# Setter for the materials to take an Dollar amount or a %.
|
||||
def materials=(v)
|
||||
return if v.nil?
|
||||
|
||||
if v.match(/%/)
|
||||
# Clear amount since this is a %
|
||||
write_attribute(:materials, nil)
|
||||
|
||||
@@ -16,7 +16,7 @@ class FixedDeliverable < Deliverable
|
||||
if read_attribute(:profit_percent).nil?
|
||||
return super
|
||||
else
|
||||
return (read_attribute(:profit_percent).to_f / 100.0) * read_attribute(:fixed_cost)
|
||||
return (read_attribute(:profit_percent).to_f / 100.0) * (read_attribute(:fixed_cost) + self.overhead)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -35,7 +35,9 @@ class HourlyDeliverable < Deliverable
|
||||
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))
|
||||
labor = (read_attribute(:cost_per_hour) * read_attribute(:total_hours))
|
||||
|
||||
return (read_attribute(:profit_percent).to_f / 100.0) * (labor + self.overhead)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -150,8 +150,9 @@ Object.extend(BudgetModule.prototype, {
|
||||
var materials_subtotal = Budget.toAmount($('deliverable_materials').value);
|
||||
}
|
||||
|
||||
// Profit uses labor cost and overhead
|
||||
if ($('deliverable_profit').value.match('%')) {
|
||||
var profit_subtotal = (Budget.toAmount($('deliverable_profit').value) / 100) * cost;
|
||||
var profit_subtotal = (Budget.toAmount($('deliverable_profit').value) / 100) * (cost + overhead_subtotal);
|
||||
} else {
|
||||
var profit_subtotal = Budget.toAmount($('deliverable_profit').value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user