bookyt_salary 0.19.2 → 0.19.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -55,10 +55,22 @@ class SalariesController < InvoicesController
55
55
  def payslip
56
56
  @salary = Salary.find(params[:id])
57
57
 
58
- @hours_carry = @salary.hours_carry
59
- @hours_due = @salary.work_days.sum(:hours_due)
60
- @hours_worked = @salary.work_days.sum(:hours_worked)
61
- @hours_saldo = @salary.work_days.last.overall_overtime
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
60
+
61
+ if @include_hours_table
62
+ @hours_carry = @salary.hours_carry
63
+ work_days = @salary.work_days
64
+
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
73
+ end
62
74
 
63
75
  show! do |format|
64
76
  format.html { redirect_to :action => :show }
@@ -23,10 +23,11 @@ prawn_document(:filename => "#{resource.to_s}.pdf", :renderer => PayslipDocument
23
23
  columns(0).width = 5.cm
24
24
  end
25
25
 
26
- unless resource.employment.hourly_paid
26
+ top_y = pdf.y
27
+ bottom_y = pdf.y
28
+ if @include_hours_table
27
29
  pdf.move_down 20
28
30
 
29
- top_y = pdf.y
30
31
  pdf.text "Stundenabrechnung", :style => :bold
31
32
 
32
33
  month_name = t('date.month_names')[@salary.duration_from.month]
@@ -50,36 +51,39 @@ prawn_document(:filename => "#{resource.to_s}.pdf", :renderer => PayslipDocument
50
51
  rows(3).font_style = :bold
51
52
  end
52
53
  bottom_y = pdf.y
53
-
54
54
  pdf.y = top_y
55
- if resource.used_leave_days and resource.leave_days_balance
56
- pdf.indent 10.cm do
57
- pdf.text "Ferienabrechnung", :style => :bold
58
-
59
- month_name = t('date.month_names')[@salary.duration_from.month]
60
- rows = [
61
- ["#{t_attr(:used_leave_days)} #{month_name}", "%0.1f" % resource.used_leave_days],
62
- [t_attr(:leave_days_balance), "%0.1f" % resource.leave_days_balance],
63
- ]
64
-
65
- pdf.table rows, :width => 8.cm do
66
- cells.valign = :top
67
- cells.borders = []
68
- cells.padding_bottom = 2
69
- cells.padding_top = 2
70
-
71
- columns(0).padding_left = 0
72
- columns(0).width = 5.cm
73
- columns(1).align = :right
74
-
75
- rows(3).font_style = :bold
76
- end
55
+ end
56
+
57
+ if @include_leave_days_table
58
+ pdf.move_down 20
59
+
60
+ pdf.indent 10.cm do
61
+ pdf.text "Ferienabrechnung", :style => :bold
62
+
63
+ month_name = t('date.month_names')[@salary.duration_from.month]
64
+ rows = [
65
+ ["#{t_attr(:used_leave_days)} #{month_name}", "%0.1f" % resource.used_leave_days],
66
+ [t_attr(:leave_days_balance), "%0.1f" % resource.leave_days_balance],
67
+ ]
68
+
69
+ pdf.table rows, :width => 8.cm do
70
+ cells.valign = :top
71
+ cells.borders = []
72
+ cells.padding_bottom = 2
73
+ cells.padding_top = 2
74
+
75
+ columns(0).padding_left = 0
76
+ columns(0).width = 5.cm
77
+ columns(1).align = :right
78
+
79
+ rows(3).font_style = :bold
77
80
  end
78
81
  end
79
-
80
- pdf.y = bottom_y
82
+ bottom_y = pdf.y if pdf.y < bottom_y
81
83
  end
82
84
 
85
+ pdf.y = bottom_y
86
+
83
87
  # Free text with the socical security number
84
88
  pdf.free_text(resource.text)
85
89
 
@@ -1,3 +1,3 @@
1
1
  module BookytSalary
2
- VERSION = '0.19.2'
2
+ VERSION = '0.19.3'
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bookyt_salary
3
3
  version: !ruby/object:Gem::Version
4
- hash: 87
4
+ hash: 85
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 19
9
- - 2
10
- version: 0.19.2
9
+ - 3
10
+ version: 0.19.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Simon H\xC3\xBCrlimann (CyT)"
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-05-03 00:00:00 Z
18
+ date: 2012-06-22 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rails
@@ -187,7 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
187
187
  requirements: []
188
188
 
189
189
  rubyforge_project:
190
- rubygems_version: 1.8.10
190
+ rubygems_version: 1.8.15
191
191
  signing_key:
192
192
  specification_version: 3
193
193
  summary: Salary plugin for bookyt