[#4555] Include the spent FixedBudget in Hourly and Retainers total_spent
This commit is contained in:
@@ -37,7 +37,8 @@ class HourlyDeliverable < Deliverable
|
||||
total
|
||||
}
|
||||
|
||||
return hours * contract.billable_rate
|
||||
fixed_budget_amount = fixed_budget_total_spent(date) + fixed_markup_budget_total_spent(date)
|
||||
return (hours * contract.billable_rate) + fixed_budget_amount
|
||||
end
|
||||
|
||||
# Block setting the total on HourlyDeliverables
|
||||
|
||||
@@ -198,7 +198,9 @@ class RetainerDeliverable < HourlyDeliverable
|
||||
total
|
||||
}
|
||||
|
||||
return hours * contract.billable_rate
|
||||
fixed_budget_amount = fixed_budget_total_spent(date) + fixed_markup_budget_total_spent(date)
|
||||
|
||||
return (hours * contract.billable_rate) + fixed_budget_amount
|
||||
when :out
|
||||
0
|
||||
else
|
||||
|
||||
@@ -250,8 +250,8 @@ class ContractTest < ActiveSupport::TestCase
|
||||
@deliverable_2.fixed_budgets << FixedBudget.spawn(:budget => 200, :markup => '$100', :paid => true)
|
||||
|
||||
assert_equal 875, @deliverable_1.profit_left
|
||||
assert_equal 825, @deliverable_2.profit_left
|
||||
assert_equal 1700, contract.profit_left
|
||||
assert_equal 1125, @deliverable_2.profit_left
|
||||
assert_equal 2000, contract.profit_left
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -32,7 +32,7 @@ class HourlyDeliverableTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
context "#total_spent" do
|
||||
should "be equal to the number of hours used multipled by the contract rate" do
|
||||
should "be equal to the number of hours used multipled by the contract rate and adding the fixed budget and markup spent" do
|
||||
configure_overhead_plugin
|
||||
|
||||
contract = Contract.generate!(:billable_rate => 150.0)
|
||||
@@ -46,8 +46,11 @@ class HourlyDeliverableTest < ActiveSupport::TestCase
|
||||
TimeEntry.generate!(:hours => 15, :issue => @issue1, :project => @project,
|
||||
:activity => @billable_activity,
|
||||
:user => @developer)
|
||||
# Only paid fixed budgets counted
|
||||
d.fixed_budgets << FixedBudget.generate!(:budget => '$100', :markup => '50%') # $50 markup
|
||||
d.fixed_budgets << FixedBudget.generate!(:budget => '$100', :markup => '50%', :paid => true) # $50 markup
|
||||
|
||||
assert_equal 2250, d.total_spent
|
||||
assert_equal 2250 + 150, d.total_spent
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -382,6 +382,10 @@ class RetainerDeliverableTest < ActiveSupport::TestCase
|
||||
@deliverable = RetainerDeliverable.generate!(:start_date => '2010-01-01', :end_date => '2010-03-31', :contract => @contract)
|
||||
@deliverable.labor_budgets << LaborBudget.spawn(:budget => 100, :hours => 10)
|
||||
@deliverable.overhead_budgets << OverheadBudget.spawn(:budget => 100, :hours => 10)
|
||||
# Only paid fixed budgets counted
|
||||
@deliverable.fixed_budgets << FixedBudget.generate!(:budget => '$100', :markup => '50%') # $50 markup
|
||||
@deliverable.fixed_budgets << FixedBudget.generate!(:budget => '$100', :markup => '50%', :paid => true) # $50 markup
|
||||
|
||||
@deliverable.save!
|
||||
|
||||
@manager = User.generate!
|
||||
@@ -410,14 +414,12 @@ class RetainerDeliverableTest < ActiveSupport::TestCase
|
||||
:amount => 100)
|
||||
|
||||
@deliverable.issues << @issue1
|
||||
|
||||
|
||||
end
|
||||
|
||||
context "with a empty period" do
|
||||
should "use all periods" do
|
||||
# Labor used * contract rate
|
||||
assert_equal (10+20) * 200, @deliverable.total_spent(nil)
|
||||
# (Labor used * contract rate) + fixed
|
||||
assert_equal ((10+20) * 200) + (150 * 3), @deliverable.total_spent(nil)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -435,7 +437,7 @@ class RetainerDeliverableTest < ActiveSupport::TestCase
|
||||
|
||||
context "with a period in the retainer range" do
|
||||
should "filter the records" do
|
||||
assert_equal 20 * 200, @deliverable.total_spent(Date.new(2010,2,1))
|
||||
assert_equal (20 * 200) + 150, @deliverable.total_spent(Date.new(2010,2,1))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user