[#6574] Associate LaborBudgets with TimeEntryActivities
This commit is contained in:
1 parent
38c22e2f92
commit
df61a1fe9e
10 files changed
+34
-2
No files matched your search
@@ -3,8 +3,10 @@ class LaborBudget < ActiveRecord::Base
|
|||||||
|
|
||||||
# Associations
|
# Associations
|
||||||
belongs_to :deliverable
|
belongs_to :deliverable
|
||||||
|
belongs_to :time_entry_activity
|
||||||
|
|
||||||
# Validations
|
# Validations
|
||||||
|
validates_presence_of :time_entry_activity_id
|
||||||
|
|
||||||
# Accessors
|
# Accessors
|
||||||
include DollarizedAttribute
|
include DollarizedAttribute
|
||||||
|
|||||||
@@ -13,7 +13,8 @@
|
|||||||
<%= labor_budget.hidden_field(:month) %>
|
<%= labor_budget.hidden_field(:month) %>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<%= release(3, "Select field for the Time Entry Activity in a td") %>
|
<%= labor_budget.label(:time_entry_activity_id, :class => "hidden") %>
|
||||||
|
<%= labor_budget.select(:time_entry_activity_id, options_from_collection_for_select(@project.billable_activities, :id, :name, labor_budget.object.time_entry_activity_id), {:include_blank => false}, {:class => 'financial'}) %>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<p class="inline-hints"><%= labor_budget.label(:hours, l(:text_short_hours)) %></p>
|
<p class="inline-hints"><%= labor_budget.label(:hours, l(:text_short_hours)) %></p>
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ html>body .tabular li {overflow:hidden;}
|
|||||||
.tabular li.hidden { height: 0; padding: 0; margin: 0; }
|
.tabular li.hidden { height: 0; padding: 0; margin: 0; }
|
||||||
/* End tabular */
|
/* End tabular */
|
||||||
|
|
||||||
|
.hidden { display: none; }
|
||||||
a.contract-delete {color: red; }
|
a.contract-delete {color: red; }
|
||||||
.overage { color: #A40000; }
|
.overage { color: #A40000; }
|
||||||
|
|
||||||
|
|||||||
@@ -100,3 +100,4 @@ en:
|
|||||||
text_deliverable_closed_warning: "This deliverable is closed and cannot be saved without changing it's status to Open."
|
text_deliverable_closed_warning: "This deliverable is closed and cannot be saved without changing it's status to Open."
|
||||||
text_contract_locked_warning: "This contract is locked and cannot be saved without changing it's status to Open."
|
text_contract_locked_warning: "This contract is locked and cannot be saved without changing it's status to Open."
|
||||||
text_contract_closed_warning: "This contract is closed and cannot be saved without changing it's status to Open."
|
text_contract_closed_warning: "This contract is closed and cannot be saved without changing it's status to Open."
|
||||||
|
field_time_entry_activity: "Activity"
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
class AddTimeEntryActivityIdToLaborBudgets < ActiveRecord::Migration
|
||||||
|
def self.up
|
||||||
|
add_column :labor_budgets, :time_entry_activity_id, :integer
|
||||||
|
add_index :labor_budgets, :time_entry_activity_id
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.down
|
||||||
|
remove_column :labor_budgets, :time_entry_activity_id
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -103,7 +103,8 @@ module RedmineContracts
|
|||||||
if old_deliverable['total_hours'].present? || old_deliverable['cost_per_hour'].present?
|
if old_deliverable['total_hours'].present? || old_deliverable['cost_per_hour'].present?
|
||||||
deliverable.labor_budgets << LaborBudget.new(:deliverable => deliverable,
|
deliverable.labor_budgets << LaborBudget.new(:deliverable => deliverable,
|
||||||
:budget => @total_cost,
|
:budget => @total_cost,
|
||||||
:hours => old_deliverable['total_hours'])
|
:hours => old_deliverable['total_hours'],
|
||||||
|
:time_entry_activity => first_billable_activity(project))
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@total_cost = 0
|
@total_cost = 0
|
||||||
@@ -228,5 +229,9 @@ module RedmineContracts
|
|||||||
def self.append_old_deliverable_to_notes(old_deliverable, new_deliverable)
|
def self.append_old_deliverable_to_notes(old_deliverable, new_deliverable)
|
||||||
new_deliverable.notes += "Converted data:\n<pre>" + old_deliverable.pretty_inspect + "</pre>"
|
new_deliverable.notes += "Converted data:\n<pre>" + old_deliverable.pretty_inspect + "</pre>"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.first_billable_activity(project)
|
||||||
|
project.billable_activities.first || TimeEntryActivity.first
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -16,6 +16,11 @@ module RedmineContracts
|
|||||||
end
|
end
|
||||||
|
|
||||||
module InstanceMethods
|
module InstanceMethods
|
||||||
|
def billable_activities
|
||||||
|
activities.partition do |activity|
|
||||||
|
activity.billable?
|
||||||
|
end.first
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ class DeliverablesEditTest < ActionController::IntegrationTest
|
|||||||
@hourly_deliverable = HourlyDeliverable.generate!(:contract => @contract, :manager => @manager, :title => 'An Hourly')
|
@hourly_deliverable = HourlyDeliverable.generate!(:contract => @contract, :manager => @manager, :title => 'An Hourly')
|
||||||
|
|
||||||
@user = User.generate_user_with_permission_to_manage_budget(:project => @project)
|
@user = User.generate_user_with_permission_to_manage_budget(:project => @project)
|
||||||
|
configure_overhead_plugin
|
||||||
|
|
||||||
login_as(@user.login, 'contracts')
|
login_as(@user.login, 'contracts')
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ class DeliverablesNewTest < ActionController::IntegrationTest
|
|||||||
@project = Project.generate!(:identifier => 'main')
|
@project = Project.generate!(:identifier => 'main')
|
||||||
@contract = Contract.generate!(:project => @project)
|
@contract = Contract.generate!(:project => @project)
|
||||||
@user = User.generate_user_with_permission_to_manage_budget(:project => @project)
|
@user = User.generate_user_with_permission_to_manage_budget(:project => @project)
|
||||||
|
configure_overhead_plugin
|
||||||
|
|
||||||
login_as(@user.login, 'contracts')
|
login_as(@user.login, 'contracts')
|
||||||
end
|
end
|
||||||
@@ -231,6 +232,7 @@ class DeliverablesNewTest < ActionController::IntegrationTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
within("#deliverable-labor") do
|
within("#deliverable-labor") do
|
||||||
|
select @billable_activity.name, :from => 'Activity'
|
||||||
fill_in "hrs", :with => '20'
|
fill_in "hrs", :with => '20'
|
||||||
fill_in "$", :with => '$2,000'
|
fill_in "$", :with => '$2,000'
|
||||||
end
|
end
|
||||||
@@ -258,6 +260,7 @@ class DeliverablesNewTest < ActionController::IntegrationTest
|
|||||||
@labor_budget = @deliverable.labor_budgets.first
|
@labor_budget = @deliverable.labor_budgets.first
|
||||||
assert_equal 20, @labor_budget.hours
|
assert_equal 20, @labor_budget.hours
|
||||||
assert_equal 2000.0, @labor_budget.budget
|
assert_equal 2000.0, @labor_budget.budget
|
||||||
|
assert_equal @billable_activity, @labor_budget.time_entry_activity
|
||||||
|
|
||||||
assert_equal 1, @deliverable.overhead_budgets.count
|
assert_equal 1, @deliverable.overhead_budgets.count
|
||||||
@overhead_budget = @deliverable.overhead_budgets.first
|
@overhead_budget = @deliverable.overhead_budgets.first
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ require File.dirname(__FILE__) + '/../test_helper'
|
|||||||
|
|
||||||
class LaborBudgetTest < ActiveSupport::TestCase
|
class LaborBudgetTest < ActiveSupport::TestCase
|
||||||
should_belong_to :deliverable
|
should_belong_to :deliverable
|
||||||
|
should_belong_to :time_entry_activity
|
||||||
|
|
||||||
|
should_validate_presence_of :time_entry_activity_id
|
||||||
|
|
||||||
context "#budget=" do
|
context "#budget=" do
|
||||||
should "strip dollar signs when writing" do
|
should "strip dollar signs when writing" do
|
||||||
|
|||||||
Reference in new issue
Block a user