ecm_time_tracking 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9c4ca3fe7642510df8ccb55ee529319bac72bf9b
4
- data.tar.gz: 88e9b9dc0c6be53838570338e3bc3c1897cb224b
3
+ metadata.gz: d245c95a5abfbfa011148b82bbe34d92711796df
4
+ data.tar.gz: 4fe00072c0fcdd672e36f9c2d42dc7195f90caa2
5
5
  SHA512:
6
- metadata.gz: 688cf0d70606b3ce7aa3e5add4afc295fc29d37e80f9b986e98ee9a07e8317dd29ffc6d597202aec0fbe80acc5bc845c7f0bb023885a7094795cbc0008621bc2
7
- data.tar.gz: ec6a8f65190e5f2bab95034574b2c73750c65c3e4cdcf16bec0f752a6a6c90891867030f7932883025d1aab5ea1384ea87a1b42d5df69b0b97697cb4495c9d74
6
+ metadata.gz: 431bb84a92c210ec2e8d31ab90ef0adb8732431c84cd305f778d41ba51ca26673dfde097eaa034614325d6959d97331fdd803da25e0cb82a0b00d9e8f08cb32d
7
+ data.tar.gz: 913fe50c0a79ee1f94af9683e54a1972c8fb98bcdcb6ca2382be14a062fd4187f036d2262fdf4af2758cb157a676d120ae9dbf23334efb3b74cab4896f54e677
@@ -0,0 +1,30 @@
1
+ module Ecm
2
+ module TimeTracking
3
+ class SoftwareDeveloperSumsService < SumsService
4
+ attr_accessor :gross_overtime_by_month
5
+ attr_accessor :net_overtime_by_month
6
+
7
+ def calculate_sums
8
+ self.overtime = calculate_overtime
9
+ self.count_by_entry_type = self.entries.inject(Hash.new(0)) do |memo, entry|
10
+ memo[entry.entry_type] += 1
11
+ memo
12
+ end
13
+ end
14
+
15
+ def entries_by_month
16
+ entries.group_by { |e| e.begin_at.beginning_of_month }
17
+ end
18
+
19
+ def calculate_overtime
20
+ self.gross_overtime_by_month = self.entries_by_month.each_with_object({}) { |(month, entries), h| h[month] = entries.map(&:overtime).reduce(0, :+) }
21
+ 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 }
22
+ self.net_overtime_by_month.values.reduce(0, :+)
23
+ end
24
+
25
+ def included_monthly_overtime
26
+ 10 * 3600
27
+ end
28
+ end
29
+ end
30
+ end
@@ -1,5 +1,5 @@
1
1
  module Ecm
2
2
  module TimeTracking
3
- VERSION = '0.0.5'.freeze
3
+ VERSION = '0.0.6'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecm_time_tracking
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roberto Vasquez Angel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-07 00:00:00.000000000 Z
11
+ date: 2016-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -40,6 +40,7 @@ files:
40
40
  - app/helpers/ecm/time_tracking/application_helper.rb
41
41
  - app/models/ecm/time_tracking/entry.rb
42
42
  - app/models/ecm/time_tracking/entry_type.rb
43
+ - app/services/ecm/time_tracking/software_developer_sums_service.rb
43
44
  - app/services/ecm/time_tracking/sums_service.rb
44
45
  - app/views/layouts/ecm/time_tracking/application.html.erb
45
46
  - config/locales/de.yml