bookyt_salary 0.19.3 → 0.19.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -55,21 +55,16 @@ class SalariesController < InvoicesController
55
55
  def payslip
56
56
  @salary = Salary.find(params[:id])
57
57
 
58
- @include_hours_table = !@salary.employment.hourly_paid
59
- @include_leave_days_table = !@salary.employment.hourly_paid && @salary.used_leave_days && @salary.leave_days_balance
58
+ @include_hours_table = @salary.track_hours?
59
+ @include_leave_days_table = @salary.track_leave_days?
60
60
 
61
61
  if @include_hours_table
62
62
  @hours_carry = @salary.hours_carry
63
- work_days = @salary.work_days
64
63
 
65
- if work_days.present?
66
- @hours_due = @salary.work_days.sum(:hours_due)
67
- @hours_worked = @salary.work_days.sum(:hours_worked)
68
- @hours_saldo = @salary.work_days.last.overall_overtime
69
- else
70
- # Don't show hours table if no work days are recorded
71
- @include_hours_table = false
72
- end
64
+ work_days = @salary.work_days
65
+ @hours_due = work_days.sum(:hours_due)
66
+ @hours_worked = work_days.sum(:hours_worked)
67
+ @hours_saldo = work_days.last.overall_overtime
73
68
  end
74
69
 
75
70
  show! do |format|
data/app/models/salary.rb CHANGED
@@ -19,10 +19,40 @@ class Salary < Invoice
19
19
  company_id
20
20
  end
21
21
 
22
+ # Emplyoment helpers
22
23
  def employment
23
24
  employee.employments.valid_at(value_date).last
24
25
  end
25
26
 
27
+ def hourly_paid?
28
+ employment.try(:hourly_paid?)
29
+ end
30
+
31
+ def track_hours?
32
+ # No tracking if we have no information how payment is done
33
+ return false if hourly_paid?.nil?
34
+
35
+ # No tracking if paid by hour
36
+ return false if hourly_paid?
37
+
38
+ # No tracking if we have no current information
39
+ return false unless work_days.present?
40
+ end
41
+
42
+ def track_leave_days?
43
+ # No tracking if we have no information how payment is done
44
+ return false if hourly_paid?.nil?
45
+
46
+ # No tracking if paid by hour
47
+ return false if hourly_paid?
48
+
49
+ # No tracking if we have no current information
50
+ return false unless used_leave_days && leave_days_balance
51
+
52
+ # Track otherwise
53
+ return true
54
+ end
55
+
26
56
  # States
27
57
  # ======
28
58
  STATES = ['booked', 'canceled', 'paid']
@@ -57,6 +87,11 @@ class Salary < Invoice
57
87
  amount_of('5000')
58
88
  end
59
89
 
90
+ def bvg_amount
91
+ # TODO: hardcoded salary_booking_template
92
+ amount_of('5050')
93
+ end
94
+
60
95
  # Assignment proxies
61
96
  def duration_from=(value)
62
97
  write_attribute(:duration_from, value)
@@ -10,9 +10,12 @@ prawn_document(:filename => "#{resource.to_s}.pdf", :renderer => PayslipDocument
10
10
 
11
11
  pdf.move_down 20
12
12
  rows = [
13
- [t_attr(:social_security_nr, Employee), employee.social_security_nr],
14
- [t_attr(:payment_to, Employment), resource.employment.payment_to]
13
+ [t_attr(:social_security_nr, Employee), employee.social_security_nr]
15
14
  ]
15
+ rows << [
16
+ [t_attr(:payment_to, Employment), resource.employment.payment_to]
17
+ ] if resource.employment
18
+
16
19
  pdf.table rows, :width => pdf.bounds.width do
17
20
  cells.valign = :top
18
21
  cells.borders = []
@@ -1,3 +1,3 @@
1
1
  module BookytSalary
2
- VERSION = '0.19.3'
2
+ VERSION = '0.19.4'
3
3
  end
metadata CHANGED
@@ -1,102 +1,102 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: bookyt_salary
3
- version: !ruby/object:Gem::Version
4
- hash: 85
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.19.4
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 19
9
- - 3
10
- version: 0.19.3
11
6
  platform: ruby
12
- authors:
13
- - "Simon H\xC3\xBCrlimann (CyT)"
7
+ authors:
8
+ - Simon Hürlimann (CyT)
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-06-22 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2012-09-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: rails
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
18
+ requirements:
26
19
  - - ~>
27
- - !ruby/object:Gem::Version
28
- hash: 5
29
- segments:
30
- - 3
31
- - 1
32
- version: "3.1"
20
+ - !ruby/object:Gem::Version
21
+ version: '3.1'
33
22
  type: :runtime
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- name: recurrence
37
23
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '3.1'
30
+ - !ruby/object:Gem::Dependency
31
+ name: recurrence
32
+ requirement: !ruby/object:Gem::Requirement
39
33
  none: false
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- hash: 3
44
- segments:
45
- - 0
46
- version: "0"
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
47
38
  type: :runtime
48
- version_requirements: *id002
49
- - !ruby/object:Gem::Dependency
50
- name: shoulda
51
39
  prerelease: false
52
- requirement: &id003 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: shoulda
48
+ requirement: !ruby/object:Gem::Requirement
53
49
  none: false
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- hash: 3
58
- segments:
59
- - 0
60
- version: "0"
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
61
54
  type: :development
62
- version_requirements: *id003
63
- - !ruby/object:Gem::Dependency
64
- name: rcov
65
55
  prerelease: false
66
- requirement: &id004 !ruby/object:Gem::Requirement
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rcov
64
+ requirement: !ruby/object:Gem::Requirement
67
65
  none: false
68
- requirements:
69
- - - ">="
70
- - !ruby/object:Gem::Version
71
- hash: 3
72
- segments:
73
- - 0
74
- version: "0"
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
75
70
  type: :development
76
- version_requirements: *id004
77
- - !ruby/object:Gem::Dependency
78
- name: rspec-rails
79
71
  prerelease: false
80
- requirement: &id005 !ruby/object:Gem::Requirement
72
+ version_requirements: !ruby/object:Gem::Requirement
81
73
  none: false
82
- requirements:
83
- - - ">="
84
- - !ruby/object:Gem::Version
85
- hash: 3
86
- segments:
87
- - 0
88
- version: "0"
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rspec-rails
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
89
86
  type: :development
90
- version_requirements: *id005
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
91
94
  description: This plugin extends bookyt with Salary functionality.
92
95
  email: simon.huerlimann@cyt.ch
93
96
  executables: []
94
-
95
97
  extensions: []
96
-
97
98
  extra_rdoc_files: []
98
-
99
- files:
99
+ files:
100
100
  - app/assets/stylesheets/bookyt_salary.sass
101
101
  - app/controllers/salaries_controller.rb
102
102
  - app/controllers/salary_booking_templates_controller.rb
@@ -159,38 +159,29 @@ files:
159
159
  - lib/bookyt_salary/railtie.rb
160
160
  - lib/bookyt_salary/version.rb
161
161
  homepage: https://github.com/huerlisi/bookyt_salary
162
- licenses:
162
+ licenses:
163
163
  - MIT
164
164
  post_install_message:
165
165
  rdoc_options: []
166
-
167
- require_paths:
166
+ require_paths:
168
167
  - lib
169
- required_ruby_version: !ruby/object:Gem::Requirement
168
+ required_ruby_version: !ruby/object:Gem::Requirement
170
169
  none: false
171
- requirements:
172
- - - ">="
173
- - !ruby/object:Gem::Version
174
- hash: 3
175
- segments:
176
- - 0
177
- version: "0"
178
- required_rubygems_version: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ! '>='
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ required_rubygems_version: !ruby/object:Gem::Requirement
179
175
  none: false
180
- requirements:
181
- - - ">="
182
- - !ruby/object:Gem::Version
183
- hash: 3
184
- segments:
185
- - 0
186
- version: "0"
176
+ requirements:
177
+ - - ! '>='
178
+ - !ruby/object:Gem::Version
179
+ version: '0'
187
180
  requirements: []
188
-
189
181
  rubyforge_project:
190
- rubygems_version: 1.8.15
182
+ rubygems_version: 1.8.23
191
183
  signing_key:
192
184
  specification_version: 3
193
185
  summary: Salary plugin for bookyt
194
186
  test_files: []
195
-
196
187
  has_rdoc: