Add billable/non_billable methods to Project (from redmine_contracts)
This commit is contained in:
41
lib/redmine_overhead/patches/project_patch.rb
Normal file
41
lib/redmine_overhead/patches/project_patch.rb
Normal file
@@ -0,0 +1,41 @@
|
||||
module RedmineOverhead
|
||||
module Patches
|
||||
module ProjectPatch
|
||||
def self.included(base)
|
||||
base.extend(ClassMethods)
|
||||
|
||||
base.send(:include, InstanceMethods)
|
||||
base.class_eval do
|
||||
unloadable
|
||||
end
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
end
|
||||
|
||||
module InstanceMethods
|
||||
def billable_activities
|
||||
activities_sorted_by_billable[:billable]
|
||||
end
|
||||
|
||||
def non_billable_activities
|
||||
activities_sorted_by_billable[:non_billable]
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def activities_sorted_by_billable
|
||||
split_activities = activities.partition do |activity|
|
||||
activity.billable?
|
||||
end
|
||||
|
||||
{
|
||||
:billable => split_activities.first,
|
||||
:non_billable => split_activities.second
|
||||
}
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user