[#2279] Threw away previous work getting the custom data values for Billable.
They should be only Billable and Overhead. * Hard coded the options for the Billable select instead of dynamically pull the values from the Custom Field * Removed TimeEntryActivity#find_with_billable_values in favor of two new methods to return a TimeEntryActivity if it is billable or overhead. `find_billable_activities` and `find_overhead_activities` * Reworked the TimesheetController hook to use the new methods for finding the TimeEntryActivities * Updated RSpec examples
This commit is contained in:
1 parent
04d0d8ad9e
commit
9a8c9371f6
5 files changed
+123
-53
No files matched your search
@@ -24,20 +24,49 @@ module OverheadTimeEntryActivityPatch
|
||||
Setting['plugin_redmine_overhead'] && Setting['plugin_redmine_overhead']['custom_field']
|
||||
end
|
||||
|
||||
def find_with_billable_values(values = [])
|
||||
def billable_value_configured?
|
||||
Setting['plugin_redmine_overhead']['billable_value']
|
||||
end
|
||||
|
||||
def overhead_value_configured?
|
||||
Setting['plugin_redmine_overhead']['overhead_value']
|
||||
end
|
||||
|
||||
def find_billable_activities
|
||||
return [] unless overhead_configured?
|
||||
return [] unless billable_value_configured?
|
||||
|
||||
billable_field = TimeEntryActivity.billable_custom_field
|
||||
if billable_field
|
||||
value = Setting['plugin_redmine_overhead']['billable_value'] == 'true' # convert "true" to true...
|
||||
finder = ARCondition.new
|
||||
finder.add "#{CustomValue.table_name}.customized_type = '#{TimeEntryActivity.class_name}'"
|
||||
finder.add ["#{CustomValue.table_name}.custom_field_id = ?", billable_field.id]
|
||||
finder.add ["#{CustomValue.table_name}.value IN (?)", values]
|
||||
finder.add ["#{CustomValue.table_name}.value IN (?)", value]
|
||||
return TimeEntryActivity.find(:all, :include => :custom_values, :conditions => finder.conditions)
|
||||
else
|
||||
return []
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def find_overhead_activities
|
||||
return [] unless overhead_configured?
|
||||
return [] unless overhead_value_configured?
|
||||
|
||||
billable_field = TimeEntryActivity.billable_custom_field
|
||||
if billable_field
|
||||
value = Setting['plugin_redmine_overhead']['overhead_value'] == 'true' # convert "true" to true...
|
||||
finder = ARCondition.new
|
||||
finder.add "#{CustomValue.table_name}.customized_type = '#{TimeEntryActivity.class_name}'"
|
||||
finder.add ["#{CustomValue.table_name}.custom_field_id = ?", billable_field.id]
|
||||
finder.add ["#{CustomValue.table_name}.value IN (?)", value]
|
||||
|
||||
return TimeEntryActivity.find(:all, :include => :custom_values, :conditions => finder.conditions)
|
||||
else
|
||||
return []
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in new issue
Block a user