diff --git a/app/models/fixed_deliverable.rb b/app/models/fixed_deliverable.rb index 644b751..090861d 100644 --- a/app/models/fixed_deliverable.rb +++ b/app/models/fixed_deliverable.rb @@ -28,9 +28,9 @@ class FixedDeliverable < Deliverable end # The amount of money remaining after expenses have been taken out - # Profit left = Total - Labor spent - Overhead spent + # Profit left = Total - Labor spent - Overhead spent - Fixed - Markup def profit_left(date=nil) - total_spent(date) - labor_budget_spent(date) - overhead_spent(date) + total_spent(date) - labor_budget_spent(date) - overhead_spent(date) - fixed_budget_total_spent(date) - fixed_markup_budget_total_spent(date) end # Hardcoded value used as a wrapper for the old Budget plugin API. diff --git a/app/models/hourly_deliverable.rb b/app/models/hourly_deliverable.rb index dfb1096..4757883 100644 --- a/app/models/hourly_deliverable.rb +++ b/app/models/hourly_deliverable.rb @@ -57,8 +57,8 @@ class HourlyDeliverable < Deliverable end # The amount of money remaining after expenses have been taken out - # Profit left = Total - Labor spent - Overhead spent + # Profit left = Total - Labor spent - Overhead spent - Fixed - Markup def profit_left(date=nil) - total_spent(date) - labor_budget_spent(date) - overhead_spent(date) + total_spent(date) - labor_budget_spent(date) - overhead_spent(date) - fixed_budget_total_spent(date) - fixed_markup_budget_total_spent(date) end end diff --git a/test/unit/contract_test.rb b/test/unit/contract_test.rb index c3daeae..5d307d5 100644 --- a/test/unit/contract_test.rb +++ b/test/unit/contract_test.rb @@ -247,10 +247,11 @@ class ContractTest < ActiveSupport::TestCase TimeEntry.generate!(:hours => 4, :issue => @issue2, :project => @project, :activity => @non_billable_activity, :user => @manager) + @deliverable_2.fixed_budgets << FixedBudget.spawn(:budget => 200, :markup => '$100', :paid => true) assert_equal 875, @deliverable_1.profit_left - assert_equal 1125, @deliverable_2.profit_left - assert_equal 2000, contract.profit_left + assert_equal 825, @deliverable_2.profit_left + assert_equal 1700, contract.profit_left end end