bookyt_projects 0.21.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,7 @@
1
1
  class ActivitiesController < AuthorizedController
2
2
  belongs_to :project, :optional => true
3
3
  belongs_to :person, :optional => true
4
+ belongs_to :employee, :optional => true
4
5
 
5
6
  has_scope :by_date
6
7
  has_scope :by_period, :using => [:from, :to]
@@ -15,16 +16,21 @@ class ActivitiesController < AuthorizedController
15
16
  end
16
17
 
17
18
  # Educated guessing of person
19
+ @activity.person ||= Person.find(params[:employee_id]) if params[:employee_id]
20
+ @activity.person ||= Person.find(params[:person_id]) if params[:person_id]
18
21
  @activity.person ||= current_user.person if current_user
19
22
 
20
23
  # Educated guessing of project
21
24
  @activity.project_id ||= params[:project_id] if params[:project_id]
22
- @activity.project_id ||= @activity.person.latest_project.id
25
+ @activity.project_id ||= @activity.person.latest_project.try(:id)
23
26
 
24
27
  new!
25
28
  end
26
29
 
27
30
  def create
28
- create! { @activity.project }
31
+ create! {
32
+ params = {:date => @activity.date.in(1.day).to_date, :project_id => @activity.project_id}
33
+ polymorphic_url([:new, parent, :activity].compact, :activity => params)
34
+ }
29
35
  end
30
36
  end
@@ -90,6 +90,10 @@ class WorkDay < ActiveRecord::Base
90
90
 
91
91
  # Calculate accumulated overtime
92
92
  def overall_overtime
93
- person.work_days.where('date <= ?', date).sum('hours_worked - hours_due')
93
+ if employment.hourly_paid?
94
+ person.work_days.where('date BETWEEN ? AND ?', date.beginning_of_month, date).sum('hours_worked - hours_due')
95
+ else
96
+ person.work_days.where('date <= ?', date).sum('hours_worked - hours_due')
97
+ end
94
98
  end
95
99
  end
@@ -1,10 +1,10 @@
1
- = simple_form_for @activity do |f|
1
+ = simple_form_for [parent, @activity].compact do |f|
2
2
  .row-fluid
3
3
  .span6= f.association :person, :as => :combobox
4
4
  .span6= f.association :project, :as => :combobox
5
5
  .row-fluid
6
+ .span6= f.input :duration, :as => :string, :input_html => {'data-autofocus' => true}
6
7
  .span6= f.input :date, :as => :date_field
7
- .span6= f.input :duration, :as => :string
8
8
 
9
9
  .row-fluid
10
10
  .span12= f.input :remarks, :input_html => {:rows => 2}
@@ -12,7 +12,7 @@
12
12
  %tr{tr_params}
13
13
  %td
14
14
  - if day.activities.empty?
15
- = link_to l(day.date, :format => '%d.%m.%Y, %a'), new_activity_path(:activity => {:person_id => day.person_id, :date => day.date.to_s(:db)}), 'data-href-container' => 'tr'
15
+ = link_to l(day.date, :format => '%d.%m.%Y, %a'), new_person_activity_path(day.person, :activity => {:date => day.date.to_s(:db)}), 'data-href-container' => 'tr'
16
16
  - else
17
17
  = link_to l(day.date, :format => '%d.%m.%Y, %a'), person_activities_path(day.person, :by_date => day.date.to_s(:db)), 'data-href-container' => 'tr'
18
18
  %td.right
data/config/routes.rb CHANGED
@@ -8,6 +8,7 @@ Rails.application.routes.draw do
8
8
 
9
9
  resources :employees do
10
10
  resources :timesheets
11
+ resources :activities
11
12
  end
12
13
 
13
14
  resources :people do
@@ -1,3 +1,3 @@
1
1
  module BookytPos
2
- VERSION = '0.21.0'
2
+ VERSION = '1.0.0'
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: 75
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
+ - 1
7
8
  - 0
8
- - 21
9
9
  - 0
10
- version: 0.21.0
10
+ version: 1.0.0
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-04-16 00:00:00 Z
19
+ date: 2012-04-17 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: rails
@@ -182,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
182
182
  requirements: []
183
183
 
184
184
  rubyforge_project:
185
- rubygems_version: 1.8.10
185
+ rubygems_version: 1.8.15
186
186
  signing_key:
187
187
  specification_version: 3
188
188
  summary: Project management plugin for bookyt