bookyt_projects 0.19.4 → 0.19.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -28,10 +28,11 @@ class Activity < ActiveRecord::Base
28
28
 
29
29
  # Work day
30
30
  belongs_to :work_day, :autosave => true
31
- before_save :update_work_day
31
+ after_save :update_work_day
32
+ after_destroy :update_work_day
32
33
 
33
34
  private
34
35
  def update_work_day
35
- WorkDay.create_or_update_upto(self.person, date)
36
+ WorkDay.create_or_update(self.person, date)
36
37
  end
37
38
  end
@@ -3,8 +3,8 @@ module BookytProjects
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  included do
6
- has_many :activities, :foreign_key => :person_id
7
- has_many :work_days, :foreign_key => :person_id
6
+ has_many :activities, :foreign_key => :person_id, :dependent => :destroy
7
+ has_many :work_days, :foreign_key => :person_id, :dependent => :destroy
8
8
  end
9
9
 
10
10
  def latest_project
@@ -54,6 +54,8 @@ class WorkDay < ActiveRecord::Base
54
54
  work_day = WorkDay.where(:person_id => employee.id, :date => day).first
55
55
  work_day ||= WorkDay.create(:person => employee, :date => day)
56
56
  end
57
+
58
+ work_day
57
59
  end
58
60
 
59
61
  # Get employment
@@ -91,7 +93,7 @@ class WorkDay < ActiveRecord::Base
91
93
  # Calculates hours worked by summing up duration of all logged
92
94
  # activities.
93
95
  def calculate_hours_worked
94
- activities.where(:date => date).sum('duration')
96
+ person.activities.where(:date => date).sum('duration')
95
97
  end
96
98
 
97
99
  # Calculate accumulated overtime
@@ -1,3 +1,3 @@
1
1
  module BookytPos
2
- VERSION = '0.19.4'
2
+ VERSION = '0.19.5'
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bookyt_projects
3
3
  version: !ruby/object:Gem::Version
4
- hash: 91
4
+ hash: 89
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 19
9
- - 4
10
- version: 0.19.4
9
+ - 5
10
+ version: 0.19.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Roman Simecek (CyT)
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2012-01-27 00:00:00 Z
19
+ date: 2012-01-30 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: rails
@@ -181,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
181
  requirements: []
182
182
 
183
183
  rubyforge_project:
184
- rubygems_version: 1.8.15
184
+ rubygems_version: 1.8.10
185
185
  signing_key:
186
186
  specification_version: 3
187
187
  summary: Project management plugin for bookyt