Class: Ecm::TimeTracking::SoftwareDeveloperSumsService
- Inherits:
-
SumsService
- Object
- Itsf::Services::V2::Service::Base
- SumsService
- Ecm::TimeTracking::SoftwareDeveloperSumsService
show all
- Defined in:
- app/services/ecm/time_tracking/software_developer_sums_service.rb
Instance Attribute Summary collapse
Attributes inherited from SumsService
#count_by_entry_type, #entries, #overtime
Instance Method Summary
collapse
Methods inherited from SumsService
#do_work
Instance Attribute Details
#gross_overtime_by_month ⇒ Object
Returns the value of attribute gross_overtime_by_month.
4
5
6
|
# File 'app/services/ecm/time_tracking/software_developer_sums_service.rb', line 4
def gross_overtime_by_month
@gross_overtime_by_month
end
|
#net_overtime_by_month ⇒ Object
Returns the value of attribute net_overtime_by_month.
5
6
7
|
# File 'app/services/ecm/time_tracking/software_developer_sums_service.rb', line 5
def net_overtime_by_month
@net_overtime_by_month
end
|
Instance Method Details
#calculate_overtime ⇒ Object
19
20
21
22
23
|
# File 'app/services/ecm/time_tracking/software_developer_sums_service.rb', line 19
def calculate_overtime
self.gross_overtime_by_month = self.entries_by_month.each_with_object({}) { |(month, entries), h| h[month] = entries.map(&:overtime).reduce(0, :+) }
self.net_overtime_by_month = self.gross_overtime_by_month.each_with_object({}) { |(month, gross_overtime), h| h[month] = (overtime = (gross_overtime - included_monthly_overtime)) < 0 ? 0 : overtime }
self.net_overtime_by_month.values.reduce(0, :+)
end
|
#calculate_sums ⇒ Object
7
8
9
10
11
12
13
|
# File 'app/services/ecm/time_tracking/software_developer_sums_service.rb', line 7
def calculate_sums
self.overtime = calculate_overtime
self.count_by_entry_type = self.entries.inject(Hash.new(0)) do |memo, entry|
memo[entry.entry_type] += 1
memo
end
end
|
#entries_by_month ⇒ Object
15
16
17
|
# File 'app/services/ecm/time_tracking/software_developer_sums_service.rb', line 15
def entries_by_month
entries.group_by { |e| e.begin_at.beginning_of_month }
end
|
#included_monthly_overtime ⇒ Object
25
26
27
|
# File 'app/services/ecm/time_tracking/software_developer_sums_service.rb', line 25
def included_monthly_overtime
10 * 3600
end
|