[#4183] Implemented Contract#profit_budget and Deliverable#profit_budget.

This commit is contained in:
Eric Davis
2010-07-13 10:28:45 -07:00
parent f89e0bf14a
commit 4d475042f0
6 changed files with 85 additions and 1 deletions
+6 -1
View File
@@ -31,7 +31,7 @@ class Contract < ActiveRecord::Base
[:status, :contract_type, :labor_spent, :overhead_spent,
:fixed_spent, :fixed_budget, :total_spent,
:markup_spent, :markup_budget, :profit_spent, :profit_budget,
:markup_spent, :markup_budget, :profit_spent,
:discount_spent, :discount_budget, :client_point_of_contact,
:estimated_hour_spent
].each do |mthd|
@@ -58,6 +58,11 @@ class Contract < ActiveRecord::Base
deliverables.inject(0) {|total, deliverable| total += deliverable.total }
end
# OPTIMIZE: N+1
def profit_budget
deliverables.inject(0) {|total, deliverable| total += deliverable.profit_budget }
end
PaymentTerms = {
:net_0 => :text_payment_terms_net_0,
:net_15 => :text_payment_terms_net_15,
+7
View File
@@ -15,6 +15,13 @@ class FixedDeliverable < Deliverable
read_attribute(:total) || 0.0
end
# The amount of profit that is budgeted for this deliverable.
# Profit = Total - ( Labor + Overhead + Fixed + Markup )
def profit_budget
budgets = labor_budget_total + overhead_budget_total
(total || 0.0) - budgets
end
# Hardcoded value used as a wrapper for the old Budget plugin API.
#
# The Overhead plugin uses this in it's calcuations.
+7
View File
@@ -31,4 +31,11 @@ class HourlyDeliverable < Deliverable
def clear_total
write_attribute(:total, nil)
end
# The amount of profit that is budgeted for this deliverable
# Profit = Total - ( Labor + Overhead + Fixed + Markup )
def profit_budget
budgets = labor_budget_total + overhead_budget_total
(total || 0.0) - budgets
end
end