[#4570] Add an alert message about orphaned time on a project
This commit is contained in:
@@ -124,6 +124,18 @@ class Contract < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
def orphaned_time
|
||||
cost_of_time_without_issue = project.time_entries.all(:conditions => {:issue_id => nil}).inject(0) do |total, time_entry|
|
||||
total += time_entry.cost
|
||||
end
|
||||
|
||||
cost_of_time_without_deliverable = project.issues.all(:include => 'time_entries', :conditions => {:deliverable_id => nil}).collect(&:time_entries).flatten.inject(0) do |total, time_entry|
|
||||
total += time_entry.cost
|
||||
end
|
||||
|
||||
cost_of_time_without_issue + cost_of_time_without_deliverable
|
||||
end
|
||||
|
||||
def to_s
|
||||
name
|
||||
end
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
<%= render :partial => 'title', :locals => {:contract => resource} %>
|
||||
|
||||
<% if resource.orphaned_time && resource.orphaned_time > 0 %>
|
||||
<div class="error_msg">
|
||||
<p>
|
||||
<%= l(:text_error_message_orphaned_time, :amount => format_value_field_for_contracts(resource.orphaned_time)) %>
|
||||
<%= link_to_issue_list_with_filter(l(:text_error_message_update_orphaned_time), :deliverable_id => '!*') %>
|
||||
</p>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% div_for(resource) do %>
|
||||
|
||||
<%= avatar(resource.account_executive, :size => 40) %>
|
||||
|
||||
Reference in New Issue
Block a user