[#6636] Add overhead table to the deliverable finance report
This commit is contained in:
1 parent
1f9cd9e86f
commit
acc825a4fe
4 files changed
+107
-4
No files matched your search
@@ -274,6 +274,10 @@ class Deliverable < ActiveRecord::Base
|
|||||||
project.activities.select {|activity| activity.billable? }
|
project.activities.select {|activity| activity.billable? }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def non_billable_time_entry_activities
|
||||||
|
project.activities.reject {|activity| activity.billable? }
|
||||||
|
end
|
||||||
|
|
||||||
# Total amount spent ($) for a given activity
|
# Total amount spent ($) for a given activity
|
||||||
def spent_for_activity(activity)
|
def spent_for_activity(activity)
|
||||||
issues.all.inject(0.0) do |all_issues_total, issue|
|
issues.all.inject(0.0) do |all_issues_total, issue|
|
||||||
|
|||||||
@@ -59,3 +59,53 @@
|
|||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
<table id="deliverable-overhead-activities">
|
||||||
|
<thead>
|
||||||
|
<th><%= l(:field_overhead) %></th>
|
||||||
|
<th colspan="2"><%= l(:field_cost) %></th>
|
||||||
|
<th colspan="2"><%= l(:field_hours) %></th>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
<% deliverable.non_billable_time_entry_activities.each do |activity| %>
|
||||||
|
|
||||||
|
<% content_tag_for(:tr, activity, :class => 'overhead ' + cycle('even','')) do %>
|
||||||
|
<td class="overhead">
|
||||||
|
<%= h(activity.name) %>
|
||||||
|
</td>
|
||||||
|
<td class="spent-amount overhead">
|
||||||
|
<%= number_to_currency(deliverable.spent_for_activity(activity), :precision => 0) %>
|
||||||
|
</td>
|
||||||
|
<td class="total-amount overhead">
|
||||||
|
<%= number_to_currency(deliverable.budget_for_activity(activity), :precision => 0) %>
|
||||||
|
</td>
|
||||||
|
<td class="spent-hours overhead">
|
||||||
|
<%= number_with_precision(deliverable.hours_spent_for_activity(activity), :precision => 0) %>
|
||||||
|
</td>
|
||||||
|
<td class="total-hours overhead">
|
||||||
|
<%= number_with_precision(deliverable.hours_budget_for_activity(activity), :precision => 0) %>
|
||||||
|
</td>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% end %>
|
||||||
|
<tr class="total overhead">
|
||||||
|
<td class="overhead">
|
||||||
|
Totals
|
||||||
|
</td>
|
||||||
|
<td class="spent-amount overhead">
|
||||||
|
<%= number_to_currency(deliverable.overhead_spent, :precision => 0) %>
|
||||||
|
</td>
|
||||||
|
<td class="total-amount overhead">
|
||||||
|
<%= number_to_currency(deliverable.overhead_budget_total, :precision => 0) %>
|
||||||
|
</td>
|
||||||
|
<td class="spent-hours overhead">
|
||||||
|
<%= number_with_precision(deliverable.overhead_hours_spent_total, :precision => 0) %>
|
||||||
|
</td>
|
||||||
|
<td class="total-hours overhead">
|
||||||
|
<%= number_with_precision(deliverable.overhead_budget_hours, :precision => 0) %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
@@ -22,6 +22,14 @@ class DeliverableFinancesShowTest < ActionController::IntegrationTest
|
|||||||
:amount => 100
|
:amount => 100
|
||||||
})
|
})
|
||||||
|
|
||||||
|
# 5 hours of $100 nonbillable work
|
||||||
|
create_issue_with_time_for_deliverable(@deliverable1, {
|
||||||
|
:activity => @non_billable_activity,
|
||||||
|
:user => @manager,
|
||||||
|
:hours => 5,
|
||||||
|
:amount => 100
|
||||||
|
})
|
||||||
|
|
||||||
@user.reload
|
@user.reload
|
||||||
login_as(@user.login, 'contracts')
|
login_as(@user.login, 'contracts')
|
||||||
end
|
end
|
||||||
@@ -70,9 +78,7 @@ class DeliverableFinancesShowTest < ActionController::IntegrationTest
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
should "render the activities table for the deliverable" do
|
should "render the labor activities table for the deliverable" do
|
||||||
assert_select "h3", :text => /Activities/
|
|
||||||
|
|
||||||
assert_select "table#deliverable-labor-activities" do
|
assert_select "table#deliverable-labor-activities" do
|
||||||
assert_select "tr" do
|
assert_select "tr" do
|
||||||
assert_select "td.labor", :text => /#{@billable_activity.name}/
|
assert_select "td.labor", :text => /#{@billable_activity.name}/
|
||||||
@@ -93,5 +99,26 @@ class DeliverableFinancesShowTest < ActionController::IntegrationTest
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "render the overhead activities table for the deliverable" do
|
||||||
|
assert_select "table#deliverable-overhead-activities" do
|
||||||
|
assert_select "tr" do
|
||||||
|
assert_select "td.overhead", :text => /#{@non_billable_activity.name}/
|
||||||
|
assert_select "td.spent-amount.overhead", :text => /\$500/
|
||||||
|
assert_select "td.total-amount.overhead", :text => /\$600/
|
||||||
|
assert_select "td.spent-hours.overhead", :text => /5/
|
||||||
|
assert_select "td.total-hours.overhead", :text => /30/ # 3 month retainer * 10
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_select "tr.total" do
|
||||||
|
assert_select "td.overhead", :text => /Totals/
|
||||||
|
assert_select "td.spent-amount.overhead", :text => /\$500/
|
||||||
|
assert_select "td.total-amount.overhead", :text => /\$600/
|
||||||
|
assert_select "td.spent-hours.overhead", :text => /5/
|
||||||
|
assert_select "td.total-hours.overhead", :text => /30/
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -101,7 +101,29 @@ class DeliverableTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "not include nonbillable activities" do
|
should "not include nonbillable activities" do
|
||||||
assert !@deliverable.billable_time_entry_activities.include?(@non_billable_activity3), "Non billable Activity included"
|
assert !@deliverable.billable_time_entry_activities.include?(@non_billable_activity), "Non billable Activity included"
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
context "#non_billable_time_entry_activities" do
|
||||||
|
setup do
|
||||||
|
configure_overhead_plugin
|
||||||
|
create_contract_and_deliverable
|
||||||
|
end
|
||||||
|
|
||||||
|
should "include all billable activities" do
|
||||||
|
@non_billable_activity2 = TimeEntryActivity.generate!.reload
|
||||||
|
@non_billable_activity2.custom_field_values = { @custom_field.id => 'false' }
|
||||||
|
assert @non_billable_activity2.save
|
||||||
|
|
||||||
|
assert @deliverable.non_billable_time_entry_activities.include?(@non_billable_activity), "Activity not included"
|
||||||
|
assert @deliverable.non_billable_time_entry_activities.include?(@non_billable_activity2), "Activity not included"
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
should "not include billable activities" do
|
||||||
|
assert !@deliverable.non_billable_time_entry_activities.include?(@billable_activity), "Billable Activity included"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in new issue
Block a user