bookyt_salary 0.14.4 → 0.14.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,4 +10,15 @@ class SalaryBookingTemplatesController < BookingTemplatesController
10
10
 
11
11
  render 'edit'
12
12
  end
13
+
14
+ def statistics
15
+ if params['date']
16
+ date = Date.parse(params['date'])
17
+ else
18
+ date = Date.today
19
+ end
20
+
21
+ @duration = date.beginning_of_month..date.end_of_month
22
+ @salary_booking_templates = SalaryBookingTemplate.all
23
+ end
13
24
  end
data/app/models/salary.rb CHANGED
@@ -20,7 +20,7 @@ class Salary < Invoice
20
20
  end
21
21
 
22
22
  def employment
23
- employee.employments.current
23
+ employee.employments.valid_at(value_date).last
24
24
  end
25
25
 
26
26
  # States
@@ -1,26 +1,16 @@
1
1
  class PayslipDocument < LetterDocument
2
2
  def salary_table(salary)
3
- head = [
4
- t_attr(:code, LineItem),
5
- t_attr(:title, LineItem),
6
- t_attr(:times, LineItem),
7
- t_attr(:price, LineItem),
8
- t_attr(:accounted_amount, LineItem)
9
- ]
10
-
11
3
  rows = []
12
4
  saldo_rows = []
13
5
  salary.line_items.each_with_index do |item, index|
14
6
  if item.quantity == "saldo_of"
15
- saldo_rows << index + 1
16
- rows << [item.code, item.title, nil, nil, currency_fmt(item.price)]
7
+ saldo_rows << index
8
+ rows << [item.title, nil, nil, currency_fmt(item.price)]
17
9
  else
18
- rows << [item.code, item.title, item.times_to_s, currency_fmt(item.price), currency_fmt(item.accounted_amount)]
10
+ rows << [item.title, item.times_to_s, currency_fmt(item.price), currency_fmt(item.accounted_amount)]
19
11
  end
20
12
  end
21
13
 
22
- rows = [head] + rows
23
-
24
14
  table(rows, :width => bounds.width) do
25
15
  # General cell styling
26
16
  cells.valign = :top
@@ -30,16 +20,13 @@ class PayslipDocument < LetterDocument
30
20
  columns(0).padding_left = 0
31
21
 
32
22
  # Columns
33
- columns(2..4).align = :right
23
+ columns(1..3).align = :right
34
24
 
35
25
  # Saldo styling
36
26
  saldo_rows.each do |index|
37
27
  row(index).font_style = :bold
38
28
  row(index).padding_bottom = 10
39
29
  end
40
-
41
- # Header styling
42
- row(0).font_style = :bold
43
30
  end
44
31
  end
45
32
  end
@@ -4,7 +4,7 @@
4
4
  %table.list
5
5
  %tr
6
6
  %th= t_attr :company, Invoice
7
- %th.currency= t_attr :amount, Salary
7
+ %th.currency= t_attr :gross_amount, Salary
8
8
  %th.currency= t_attr :social_amount, Salary
9
9
  %th.currency= t_attr :bvg_amount, Salary
10
10
  %th.currency= t_attr :net_amount, Salary
@@ -6,11 +6,14 @@ prawn_document(:filename => "#{resource.to_s}.pdf", :renderer => PayslipDocument
6
6
  pdf.letter_header(employer, employee, resource.to_s)
7
7
 
8
8
  # Free text with the socical security number
9
- pdf.free_text "#{t_attr(:social_security_nr, Employee)}: #{employee.social_security_nr}"
10
9
 
11
10
  # Line Items
12
11
  pdf.salary_table(resource)
13
-
12
+
13
+ pdf.move_down 20
14
+ pdf.text "#{t_attr(:social_security_nr, Employee)}: #{employee.social_security_nr}"
15
+ pdf.text "#{t_attr(:payment_to, Employment)}: #{resource.employment.payment_to}"
16
+
14
17
  # Closing
15
18
  pdf.common_closing(employer)
16
- end
19
+ end
@@ -0,0 +1,23 @@
1
+ = contextual_links
2
+
3
+ .page-header
4
+ %h1= t_title
5
+
6
+ %table.list
7
+ %tr
8
+ %th= t_attr :code
9
+ %th= t_attr :title
10
+ %th.right= t_attr :amount
11
+
12
+ - for template in @salary_booking_templates
13
+ %tr
14
+ %td= template.code
15
+ %td= template.title
16
+ %td.currency= currency_fmt(template.line_items.where(:date => @duration).sum(&:total_amount))
17
+
18
+ - content_for :sidebar do
19
+ .sub-tabs
20
+ %ul
21
+ - for month in 1..12
22
+ - date = Date.new(Date.today.year, month, 1)
23
+ %li= link_to t('date.month_names')[date.month], url_for(:date => date.to_s(:db))
data/config/routes.rb CHANGED
@@ -4,6 +4,9 @@ Rails.application.routes.draw do
4
4
  member do
5
5
  get :copy
6
6
  end
7
+ collection do
8
+ get :statistics
9
+ end
7
10
  end
8
11
 
9
12
  resources :salary_templates do
@@ -6,7 +6,7 @@ module BookytSalary
6
6
  salaries.item :salaries, t_title(:index, Salary), salaries_path, :highlights_on => /\/salaries($|\/[0-9]*($|\/.*))/
7
7
  salaries.item :new_salary, t_title(:new, Salary), select_employee_salaries_path
8
8
  salaries.item :divider, "", :class => 'divider'
9
- salaries.item :salary_statistics, t_title(:statistics, Salary), statistics_salaries_path
9
+ salaries.item :salary_booking_template_statistics, t_title(:statistics, Salary), statistics_salary_booking_templates_path
10
10
  salaries.item :divider, "", :class => 'divider'
11
11
  salaries.item :salary_booking_templates, t_title(:index, SalaryBookingTemplate), salary_booking_templates_path
12
12
  salaries.item :salary_templates, t_title(:index, SalaryTemplate), salary_templates_path
@@ -1,3 +1,3 @@
1
1
  module BookytSalary
2
- VERSION = '0.14.4'
2
+ VERSION = '0.14.5'
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: 47
4
+ hash: 45
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 14
9
- - 4
10
- version: 0.14.4
9
+ - 5
10
+ version: 0.14.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Simon H\xC3\xBCrlimann (CyT)"
@@ -122,6 +122,7 @@ files:
122
122
  - app/views/salary_booking_templates/_form.html.haml
123
123
  - app/views/salary_booking_templates/_list.html.haml
124
124
  - app/views/salary_booking_templates/_salary_booking_template.html.haml
125
+ - app/views/salary_booking_templates/statistics.html.haml
125
126
  - app/views/salary_items/_form.html.haml
126
127
  - app/views/salary_items/_line_item.html.haml
127
128
  - app/views/salary_items/_list_form.html.haml