[#4477] Add FixedBudget items into the total and profit Deliverable calculations
This commit is contained in:
1 parent
d78e7b1dc3
commit
2c04ef4f45
4 files changed
+13
-8
No files matched your search
@@ -23,7 +23,7 @@ class FixedDeliverable < Deliverable
|
|||||||
# The amount of profit that is budgeted for this deliverable.
|
# The amount of profit that is budgeted for this deliverable.
|
||||||
# Profit = Total - ( Labor + Overhead + Fixed + Markup )
|
# Profit = Total - ( Labor + Overhead + Fixed + Markup )
|
||||||
def profit_budget(date=nil)
|
def profit_budget(date=nil)
|
||||||
budgets = labor_budget_total(date) + overhead_budget_total(date)
|
budgets = labor_budget_total(date) + overhead_budget_total(date) + fixed_budget_total(date) + fixed_markup_budget_total(date)
|
||||||
(total(date) || 0.0) - budgets
|
(total(date) || 0.0) - budgets
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -14,12 +14,14 @@ class HourlyDeliverable < Deliverable
|
|||||||
'H'
|
'H'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Total = ( Labor Hours * Billing Rate ) + ( Fixed + Markup )
|
||||||
def total(date=nil)
|
def total(date=nil)
|
||||||
return 0 if contract.nil?
|
return 0 if contract.nil?
|
||||||
return 0 if contract.billable_rate.blank?
|
return 0 if contract.billable_rate.blank?
|
||||||
return 0 if labor_budgets.count == 0 && overhead_budgets.count == 0
|
return 0 if labor_budgets.count == 0 && overhead_budgets.count == 0
|
||||||
|
|
||||||
return contract.billable_rate * labor_budget_hours(date)
|
fixed_budget_amount = fixed_budget_total(date) + fixed_markup_budget_total(date)
|
||||||
|
return (contract.billable_rate * labor_budget_hours(date)) + fixed_budget_amount
|
||||||
end
|
end
|
||||||
|
|
||||||
# Total amount to be billed on the deliverable, using the total time logged
|
# Total amount to be billed on the deliverable, using the total time logged
|
||||||
@@ -50,7 +52,7 @@ class HourlyDeliverable < Deliverable
|
|||||||
# The amount of profit that is budgeted for this deliverable
|
# The amount of profit that is budgeted for this deliverable
|
||||||
# Profit = Total - ( Labor + Overhead + Fixed + Markup )
|
# Profit = Total - ( Labor + Overhead + Fixed + Markup )
|
||||||
def profit_budget(date=nil)
|
def profit_budget(date=nil)
|
||||||
budgets = labor_budget_total(date) + overhead_budget_total(date)
|
budgets = labor_budget_total(date) + overhead_budget_total(date) + fixed_budget_total(date) + fixed_markup_budget_total(date)
|
||||||
(total(date) || 0.0) - budgets
|
(total(date) || 0.0) - budgets
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,9 @@ class FixedDeliverableTest < ActiveSupport::TestCase
|
|||||||
LaborBudget.generate!(:deliverable => deliverable, :budget => 200)
|
LaborBudget.generate!(:deliverable => deliverable, :budget => 200)
|
||||||
LaborBudget.generate!(:deliverable => deliverable, :budget => 200)
|
LaborBudget.generate!(:deliverable => deliverable, :budget => 200)
|
||||||
OverheadBudget.generate!(:deliverable => deliverable, :budget => 200)
|
OverheadBudget.generate!(:deliverable => deliverable, :budget => 200)
|
||||||
|
FixedBudget.generate!(:deliverable => deliverable, :budget => '$100', :markup => '50%') # $50 markup
|
||||||
|
|
||||||
assert_equal 400, deliverable.profit_budget
|
assert_equal 400 - 150, deliverable.profit_budget
|
||||||
end
|
end
|
||||||
|
|
||||||
should "be 0 if there is no total" do
|
should "be 0 if there is no total" do
|
||||||
|
|||||||
@@ -20,13 +20,14 @@ class HourlyDeliverableTest < ActiveSupport::TestCase
|
|||||||
assert_equal 0, d.total
|
assert_equal 0, d.total
|
||||||
end
|
end
|
||||||
|
|
||||||
should "multiply the total number of labor budget hours by the contract billable rate" do
|
should "multiply the total number of labor budget hours by the contract billable rate and add the fixed budget and markup" do
|
||||||
contract = Contract.generate!(:billable_rate => 100.0)
|
contract = Contract.generate!(:billable_rate => 100.0)
|
||||||
d = HourlyDeliverable.generate!(:contract => contract)
|
d = HourlyDeliverable.generate!(:contract => contract)
|
||||||
d.labor_budgets << LaborBudget.generate!(:hours => 10)
|
d.labor_budgets << LaborBudget.generate!(:hours => 10)
|
||||||
d.overhead_budgets << OverheadBudget.generate!(:hours => 20)
|
d.overhead_budgets << OverheadBudget.generate!(:hours => 20)
|
||||||
|
d.fixed_budgets << FixedBudget.generate!(:budget => '$100', :markup => '50%') # $50 markup
|
||||||
|
|
||||||
assert_equal 100.0 * 10, d.total
|
assert_equal (100.0 * 10) + (100 + 50), d.total
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -86,9 +87,10 @@ class HourlyDeliverableTest < ActiveSupport::TestCase
|
|||||||
LaborBudget.generate!(:deliverable => @deliverable, :hours => 5, :budget => 250)
|
LaborBudget.generate!(:deliverable => @deliverable, :hours => 5, :budget => 250)
|
||||||
LaborBudget.generate!(:deliverable => @deliverable, :hours => 5, :budget => 250)
|
LaborBudget.generate!(:deliverable => @deliverable, :hours => 5, :budget => 250)
|
||||||
OverheadBudget.generate!(:deliverable => @deliverable, :hours => 3, :budget => 225)
|
OverheadBudget.generate!(:deliverable => @deliverable, :hours => 3, :budget => 225)
|
||||||
|
FixedBudget.generate!(:deliverable => @deliverable, :budget => '$100', :markup => '50%') # $50 markup
|
||||||
|
|
||||||
assert_equal 1500, @deliverable.total
|
assert_equal 1650, @deliverable.total # has the FixedBudget items added to the total also
|
||||||
assert_equal 1500 - (225 + 250 + 250), @deliverable.profit_budget
|
assert_equal 1650 - (225 + 250 + 250 + 100 + 50), @deliverable.profit_budget
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user