bookyt_projects 0.19.7 → 0.19.8

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.
@@ -8,6 +8,9 @@ class Activity < ActiveRecord::Base
8
8
  # Scopes
9
9
  scope :by_date, lambda {|value| where(:date => value)}
10
10
 
11
+ # Sorting
12
+ default_scope order("date DESC")
13
+
11
14
  # Duration
12
15
  validates :duration, :presence => true, :format => {:with => /[0-9]{1,2}([:.][0-9]{1,2})/}
13
16
 
@@ -10,6 +10,11 @@ class WorkDay < ActiveRecord::Base
10
10
  # Order
11
11
  default_scope order(:date)
12
12
 
13
+ # String
14
+ def to_s
15
+ "%s %s: %s/%s" % [date, person, hours_worked, hours_due]
16
+ end
17
+
13
18
  # Calculations
14
19
  default_scope select('work_days.*, hours_worked - hours_due AS overtime')
15
20
 
@@ -42,24 +47,6 @@ class WorkDay < ActiveRecord::Base
42
47
  end
43
48
  end
44
49
 
45
- # Get WorkDay instances for a range
46
- #
47
- # Returns an array of WorkDay instances. You probably want
48
- # to feed it a first day of month kind of starting_date.
49
- #
50
- # params:
51
- # :employee: Employee to build WorkDay instances for
52
- # :range: Date range giving first and last day
53
- def self.build_or_update(employee, date)
54
- self.create_for_current_employment(employee)
55
- range.collect do |day|
56
- work_day = WorkDay.where(:person_id => employee.id, :date => day).first
57
- work_day ||= WorkDay.create(:person => employee, :date => day)
58
- end
59
-
60
- work_day
61
- end
62
-
63
50
  # Get employment
64
51
  #
65
52
  # Lookup the employment for this day.
@@ -100,6 +87,6 @@ class WorkDay < ActiveRecord::Base
100
87
 
101
88
  # Calculate accumulated overtime
102
89
  def overall_overtime
103
- WorkDay.where('date <= ?', date).sum('hours_worked - hours_due')
90
+ person.work_days.where('date <= ?', date).sum('hours_worked - hours_due')
104
91
  end
105
92
  end
@@ -1,3 +1,3 @@
1
1
  module BookytPos
2
- VERSION = '0.19.7'
2
+ VERSION = '0.19.8'
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: 93
4
+ hash: 67
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 19
9
- - 7
10
- version: 0.19.7
9
+ - 8
10
+ version: 0.19.8
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-30 00:00:00 Z
19
+ date: 2012-02-01 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: rails