bookyt_salary 0.15.1 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -11,10 +11,6 @@ class SalariesController < InvoicesController
11
11
 
12
12
  # Actions
13
13
  # =======
14
- def statistics
15
- index!
16
- end
17
-
18
14
  def select_employee
19
15
  # Allow pre-seeding some parameters
20
16
  salary_params = {
@@ -0,0 +1,12 @@
1
+ class SalaryReportsController < ApplicationController
2
+ respond_to :html, :pdf
3
+
4
+ # Actions
5
+ # =======
6
+ def yearly_ahv_statement
7
+ @value_period = Date.parse(params[:by_value_period][:from] || Date.today.beginning_of_year)..Date.parse(params[:by_value_period][:to] || Date.today.end_of_year) if params[:by_value_period]
8
+ @value_period ||= Date.today.beginning_of_year..Date.today.end_of_year
9
+
10
+ @employments = Employment.valid_during(@value_period).all
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ module SalaryReportHelper
2
+ def duration_from(employment, value_period)
3
+ return value_period.first if employment.duration_from.nil?
4
+
5
+ [value_period.first, employment.duration_from].max
6
+ end
7
+
8
+ def duration_to(employment, value_period)
9
+ return value_period.last if employment.duration_to.nil?
10
+
11
+ [value_period.last, employment.duration_to].min
12
+ end
13
+ end
data/app/models/salary.rb CHANGED
@@ -38,22 +38,18 @@ class Salary < Invoice
38
38
  end
39
39
 
40
40
  # Calculations
41
+ def ahv_amount
42
+ amount_of('AHV')
43
+ end
44
+
41
45
  def net_amount
42
46
  # TODO: hardcoded salary_booking_template
43
- line_item = line_items.where(:code => '6500').first
44
-
45
- return 0.0 unless line_item
46
-
47
- line_item.accounted_amount
47
+ amount_of('6500')
48
48
  end
49
49
 
50
50
  def gross_amount
51
51
  # TODO: hardcoded salary_booking_template
52
- line_item = line_items.where(:code => '5000').first
53
-
54
- return 0.0 unless line_item
55
-
56
- line_item.accounted_amount
52
+ amount_of('5000')
57
53
  end
58
54
 
59
55
  # Assignment proxies
@@ -10,10 +10,12 @@
10
10
  %th.right= t_attr :amount
11
11
 
12
12
  - for template in @salary_booking_templates
13
+ - amount = template.line_items.where(:date => @duration).sum(&:accounted_amount)
14
+ - next if amount == 0
13
15
  %tr
14
16
  %td= template.code
15
17
  %td= template.title
16
- %td.currency= currency_fmt(template.line_items.where(:date => @duration).sum(&:total_amount))
18
+ %td.currency= currency_fmt(amount)
17
19
 
18
20
  - content_for :sidebar do
19
21
  .sub-tabs
@@ -0,0 +1,44 @@
1
+ %h3= t('salary_certificate')
2
+
3
+ %table.list
4
+ %tr
5
+ %th= t_attr :ssn, Employee
6
+ %th= t_attr :date_of_birth, Employee
7
+ %th= t_attr :full_name, Employee
8
+ %th= t_attr :duration_from, Employment
9
+ %th= t_attr :duration_to, Employment
10
+ %th.currency AHV-Lohn
11
+ %th.currency ALV-Lohn
12
+ %th.currency ALVZ-Lohn
13
+ %th M/F
14
+
15
+ - ahv_total = 0
16
+ - for employment in @employments
17
+ - ahv_amount = employment.employee.salaries.where(:value_date => @value_period).sum(&:ahv_amount)
18
+ - ahv_total += ahv_amount
19
+ %tr
20
+ %td= employment.employee.ssn
21
+ %td= employment.employee.date_of_birth
22
+ %td= employment.employee.vcard.full_name
23
+ %td= duration_from(employment, @value_period)
24
+ %td= duration_to(employment, @value_period)
25
+ %td.currency= currency_fmt(ahv_amount)
26
+ %td.currency= currency_fmt(ahv_amount)
27
+ %td.currency= currency_fmt(0)
28
+ %td= employment.employee.sex_to_s
29
+
30
+ %tr
31
+ %th= t('bookyt.total')
32
+ %th{:colspan => 4}
33
+ %th.currency= currency_fmt(ahv_total)
34
+ %th.currency= currency_fmt(ahv_total)
35
+ %th.currency= currency_fmt(0)
36
+ %th
37
+
38
+ - content_for :sidebar do
39
+ .sub-tabs
40
+ %h3 Filter
41
+ %ul
42
+ - years = current_tenant.incorporated_on.year..Date.today.year
43
+ - for year in years
44
+ %li= link_to year, url_for(params.merge({:by_value_period => {:from => Date.new(year, 1, 1).to_s(:db), :to => Date.new(year, 12, 31).to_s(:db)}}))
@@ -33,7 +33,8 @@ de:
33
33
  title: Löhne
34
34
  salary_booking_templates:
35
35
  index:
36
- title: Lohnarten
36
+ title: Lohnarten
37
+ statistics: Rekapitulation
37
38
  salary_templates:
38
39
  index:
39
40
  title: Lohnvorlagen
data/config/routes.rb CHANGED
@@ -22,7 +22,6 @@ Rails.application.routes.draw do
22
22
  resources :salaries do
23
23
  collection do
24
24
  get :select_employee
25
- get :statistics
26
25
  end
27
26
 
28
27
  member do
@@ -37,4 +36,6 @@ Rails.application.routes.draw do
37
36
  get :new_line_item
38
37
  end
39
38
  end
39
+
40
+ get 'salary_reports/:action', :controller => :salary_reports
40
41
  end
@@ -6,7 +6,8 @@ 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_booking_template_statistics, t_title(:statistics, Salary), statistics_salary_booking_templates_path
9
+ salaries.item :salary_booking_template_statistics, t_title(:statistics, SalaryBookingTemplate), statistics_salary_booking_templates_path
10
+ salaries.item :yearly_ahv_statement, "AHV Lohnbescheinigung", url_for("/salary_reports/yearly_ahv_statement")
10
11
  salaries.item :divider, "", :class => 'divider'
11
12
  salaries.item :salary_booking_templates, t_title(:index, SalaryBookingTemplate), salary_booking_templates_path
12
13
  salaries.item :salary_templates, t_title(:index, SalaryTemplate), salary_templates_path
@@ -1,3 +1,3 @@
1
1
  module BookytSalary
2
- VERSION = '0.15.1'
2
+ VERSION = '0.16.0'
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: 33
4
+ hash: 95
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 15
9
- - 1
10
- version: 0.15.1
8
+ - 16
9
+ - 0
10
+ version: 0.16.0
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-02-01 00:00:00 Z
18
+ date: 2012-02-09 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rails
@@ -100,8 +100,10 @@ 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
103
+ - app/controllers/salary_reports_controller.rb
103
104
  - app/controllers/salary_templates_controller.rb
104
105
  - app/helpers/salary_booking_template_helper.rb
106
+ - app/helpers/salary_report_helper.rb
105
107
  - app/models/bookyt_salary/employee.rb
106
108
  - app/models/salary.rb
107
109
  - app/models/salary_booking_template.rb
@@ -112,13 +114,11 @@ files:
112
114
  - app/views/salaries/_form.html.haml
113
115
  - app/views/salaries/_list.html.haml
114
116
  - app/views/salaries/_salary.html.haml
115
- - app/views/salaries/_salary_certificate.html.haml
116
117
  - app/views/salaries/_sidebar.html.haml
117
118
  - app/views/salaries/index.html.haml
118
119
  - app/views/salaries/payslip.pdf.prawn
119
120
  - app/views/salaries/select_employee.html.haml
120
121
  - app/views/salaries/show.html.haml
121
- - app/views/salaries/statistics.html.haml
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
@@ -127,6 +127,7 @@ files:
127
127
  - app/views/salary_items/_line_item.html.haml
128
128
  - app/views/salary_items/_list_form.html.haml
129
129
  - app/views/salary_items/_list_header.html.haml
130
+ - app/views/salary_reports/yearly_ahv_statement.html.haml
130
131
  - app/views/salary_templates/_form.html.haml
131
132
  - app/views/salary_templates/_list.html.haml
132
133
  - app/views/salary_templates/_salary_item_form.html.haml
@@ -1,25 +0,0 @@
1
- %h3= t('salary_certificate')
2
-
3
- = paginated_section collection do
4
- %table.list
5
- %tr
6
- %th= t_attr :company, Invoice
7
- %th.currency= t_attr :gross_amount, Salary
8
- %th.currency= t_attr :social_amount, Salary
9
- %th.currency= t_attr :bvg_amount, Salary
10
- %th.currency= t_attr :net_amount, Salary
11
-
12
- - for salary in @salaries
13
- %tr
14
- %td= salary.company
15
- %td.currency= link_to currency_fmt(salary.ahv_amount), salary, "data-href-container" => 'tr'
16
- %td.currency= currency_fmt(salary.social_amount)
17
- %td.currency= currency_fmt(salary.bvg_amount)
18
- %td.currency= currency_fmt(salary.net_amount)
19
-
20
- %tr
21
- %th= t('bookyt.total')
22
- %th.currency= currency_fmt(@salaries.sum(&:ahv_amount))
23
- %th.currency= currency_fmt(@salaries.sum(&:social_amount))
24
- %th.currency= currency_fmt(@salaries.sum(&:bvg_amount))
25
- %th.currency= currency_fmt(@salaries.sum(&:net_amount))
@@ -1,6 +0,0 @@
1
- .contextual
2
- = icon_link_to :index
3
-
4
- %h2= t_title
5
-
6
- = render 'salary_certificate'