* allow to define a labor budget for users without a rate

* fixed display bug if user has no rate for a fixed anymore
* allowe to remove all rates for a user

git-svn-id: https://dev.finn.de/svn/cockpit/trunk@111 7926756e-e54e-46e6-9721-ed318f58905e
pull/6827/head
hjust 15 years ago
parent 65ed0a36f8
commit 14f00375a2
  1. 12
      app/controllers/hourly_rates_controller.rb
  2. 6
      app/models/deliverable_cost.rb
  3. 6
      app/models/deliverable_hour.rb
  4. 2
      app/views/deliverables/_deliverable_hour.rhtml

@ -35,17 +35,23 @@ class HourlyRatesController < ApplicationController
existing_attributes = params[:user][:existing_rate_attributes]
unless existing_attributes.nil?
# this selects all rate_ids for the current user and the current project
rate_ids = HourlyRate.count(:conditions => {:user_id => @user, :project_id => @project},
:group => :id,
:select => [:id]).to_hash
existing_attributes = existing_attributes.reject{|a| rate_ids.has_key? a.id}
end
else
new_attributes = nil
existing_attributes = {}
end
if request.post?
@user.new_rate_attributes = new_attributes if new_attributes
@user.existing_rate_attributes = existing_attributes
end
if request.post? && @user.save
flash[:notice] = l(:notice_successful_update)
redirect_back_or_default(:action => 'show', :id => @user, :project_id => @project)

@ -9,6 +9,10 @@ class DeliverableCost < ActiveRecord::Base
end
def calculated_costs
units && cost_type ? cost_type.rate_at(deliverable.fixed_date).rate * units : 0.0
if units && cost_type && rate = cost_type.rate_at(deliverable.fixed_date)
rate.rate * units
else
0.0
end
end
end

@ -11,7 +11,11 @@ class DeliverableHour < ActiveRecord::Base
end
def calculated_costs
hours && user ? user.rate_at(deliverable.fixed_date, deliverable.project_id).rate * hours : 0.0
if user && hours && rate = user.rate_at(deliverable.fixed_date, deliverable.project_id)
rate.rate * hours
else
0.0
end
end
def can_view_costs?(usr, project)

@ -18,7 +18,7 @@
<%= cost_form.text_field :hours, :index => id_or_index, :size => 3 %>
</td>
<td class="user">
<%= cost_form.select :user_id, @project.assignable_users.sort.select{|u| u.rate_at(@deliverable.fixed_date, @project)}.collect{|u| [u.name, u.id]}, {:prompt => true}, {:index => id_or_index} %>
<%= cost_form.select :user_id, @project.assignable_users.sort.collect{|u| [u.name, u.id]}, {:prompt => true}, {:index => id_or_index} %>
</td>
<td class="comment">
<%= cost_form.text_field :comments, :index => id_or_index, :size => 40 %>

Loading…
Cancel
Save