[#4183] Implemented Contract#total_budget.
This commit is contained in:
1 parent
91b16a2310
commit
f89e0bf14a
2 files changed
+19
-1
No files matched your search
@@ -30,7 +30,7 @@ class Contract < ActiveRecord::Base
|
|||||||
attr_accessible :details
|
attr_accessible :details
|
||||||
|
|
||||||
[:status, :contract_type, :labor_spent, :overhead_spent,
|
[:status, :contract_type, :labor_spent, :overhead_spent,
|
||||||
:fixed_spent, :fixed_budget, :total_spent, :total_budget,
|
:fixed_spent, :fixed_budget, :total_spent,
|
||||||
:markup_spent, :markup_budget, :profit_spent, :profit_budget,
|
:markup_spent, :markup_budget, :profit_spent, :profit_budget,
|
||||||
:discount_spent, :discount_budget, :client_point_of_contact,
|
:discount_spent, :discount_budget, :client_point_of_contact,
|
||||||
:estimated_hour_spent
|
:estimated_hour_spent
|
||||||
@@ -48,10 +48,16 @@ class Contract < ActiveRecord::Base
|
|||||||
deliverables.inject(0) {|total, deliverable| total += deliverable.overhead_budget_total }
|
deliverables.inject(0) {|total, deliverable| total += deliverable.overhead_budget_total }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# OPTIMIZE: N+1
|
||||||
def estimated_hour_budget
|
def estimated_hour_budget
|
||||||
deliverables.inject(0) {|total, deliverable| total += deliverable.estimated_hour_budget_total }
|
deliverables.inject(0) {|total, deliverable| total += deliverable.estimated_hour_budget_total }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# OPTIMIZE: N+1
|
||||||
|
def total_budget
|
||||||
|
deliverables.inject(0) {|total, deliverable| total += deliverable.total }
|
||||||
|
end
|
||||||
|
|
||||||
PaymentTerms = {
|
PaymentTerms = {
|
||||||
:net_0 => :text_payment_terms_net_0,
|
:net_0 => :text_payment_terms_net_0,
|
||||||
:net_15 => :text_payment_terms_net_15,
|
:net_15 => :text_payment_terms_net_15,
|
||||||
|
|||||||
@@ -68,4 +68,16 @@ class ContractTest < ActiveSupport::TestCase
|
|||||||
assert_equal 110, contract.estimated_hour_budget
|
assert_equal 110, contract.estimated_hour_budget
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "#total_budget" do
|
||||||
|
should "sum all of the totals of the Deliverables" do
|
||||||
|
contract = Contract.generate!(:billable_rate => 100.0)
|
||||||
|
contract.deliverables << @deliverable_1 = FixedDeliverable.generate!(:total => 10_000)
|
||||||
|
contract.deliverables << @deliverable_2 = HourlyDeliverable.generate!
|
||||||
|
LaborBudget.generate!(:deliverable => @deliverable_2, :hours => 10)
|
||||||
|
OverheadBudget.generate!(:deliverable => @deliverable_2, :hours => 20)
|
||||||
|
|
||||||
|
assert_equal 10_000 + (30 * 100), contract.total_budget
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
Reference in new issue
Block a user