bookyt_salary 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/salaries_controller.rb +7 -1
- data/app/controllers/salary_booking_templates_controller.rb +13 -0
- data/app/models/salary.rb +28 -5
- data/app/models/salary_booking_template.rb +3 -0
- data/app/views/salaries/_form.html.haml +9 -1
- data/app/views/salaries/payslip.pdf.prawn +1 -1
- data/app/views/salaries/show.html.haml +5 -0
- data/app/views/salary_booking_templates/_form.html.haml +22 -0
- data/app/views/salary_booking_templates/_list.html.haml +17 -0
- data/app/views/salary_booking_templates/_salary_booking_template.html.haml +21 -0
- data/config/locales/{de.yml → bookyt_salary.de.yml} +10 -1
- data/config/routes.rb +6 -0
- data/db/migrate/20111223162759_add_salary_specific_flags_to_booking_templates.rb +11 -0
- data/db/migrate/20111227093619_use_string_for_salary_declaration_code.rb +9 -0
- data/db/seeds.rb +4 -4
- data/lib/bookyt_salary/navigation.rb +3 -3
- data/lib/bookyt_salary/railtie.rb +1 -0
- data/lib/bookyt_salary/version.rb +1 -1
- metadata +13 -6
@@ -31,10 +31,16 @@ class SalariesController < InvoicesController
|
|
31
31
|
@salary = Salary.new(params[:salary])
|
32
32
|
@employee = @salary.employee
|
33
33
|
|
34
|
+
unless @employee
|
35
|
+
@salary.valid?
|
36
|
+
|
37
|
+
render :action => 'select_employee' and return
|
38
|
+
end
|
39
|
+
|
34
40
|
# Deduced defaults
|
35
41
|
@salary.employer_id = current_tenant.company.id
|
36
42
|
month_name = t('date.month_names')[@salary.duration_from.month]
|
37
|
-
@salary.title = "Lohn #{month_name} - #{@salary.employee.vcard.full_name}"
|
43
|
+
@salary.title = "Lohn #{month_name} #{@salary.duration_from.year} - #{@salary.employee.vcard.full_name}"
|
38
44
|
@salary.duration_to = @salary.duration_from.end_of_month
|
39
45
|
|
40
46
|
# Prebuild an empty attachment instance
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class SalaryBookingTemplatesController < BookingTemplatesController
|
2
|
+
defaults :resource_class => SalaryBookingTemplate
|
3
|
+
|
4
|
+
def copy
|
5
|
+
# Duplicate original record
|
6
|
+
template = resource.dup
|
7
|
+
|
8
|
+
# Rebuild positions
|
9
|
+
set_resource_ivar template
|
10
|
+
|
11
|
+
render 'edit'
|
12
|
+
end
|
13
|
+
end
|
data/app/models/salary.rb
CHANGED
@@ -29,7 +29,12 @@ class Salary < Invoice
|
|
29
29
|
|
30
30
|
# String
|
31
31
|
def to_s(format = :default)
|
32
|
-
|
32
|
+
case format
|
33
|
+
when :long
|
34
|
+
"%s (%s / %s - %s)" % [title, employee, duration_from ? I18n::localize(duration_from) : '', duration_to ? I18n::localize(duration_to) : '']
|
35
|
+
else
|
36
|
+
title
|
37
|
+
end
|
33
38
|
end
|
34
39
|
|
35
40
|
# Calculations
|
@@ -75,12 +80,30 @@ class Salary < Invoice
|
|
75
80
|
scope :by_value_period, lambda {|from, to| where("date(value_date) BETWEEN ? AND ?", from, to) }
|
76
81
|
scope :by_employee_id, lambda {|value| where(:company_id => value)}
|
77
82
|
|
78
|
-
#
|
83
|
+
# Accounts
|
79
84
|
# ========
|
80
85
|
def self.direct_account
|
81
|
-
Account.find_by_code("
|
86
|
+
Account.find_by_code("2050")
|
87
|
+
end
|
88
|
+
|
89
|
+
def self.available_credit_accounts
|
90
|
+
Account.by_type(['costs', 'current_assets'])
|
82
91
|
end
|
83
92
|
|
93
|
+
def self.default_credit_account
|
94
|
+
Account.find_by_code('5000')
|
95
|
+
end
|
96
|
+
|
97
|
+
def self.available_debit_accounts
|
98
|
+
Account.by_type(['outside_capital'])
|
99
|
+
end
|
100
|
+
|
101
|
+
def self.default_debit_account
|
102
|
+
self.direct_account
|
103
|
+
end
|
104
|
+
|
105
|
+
# Bookings
|
106
|
+
# ========
|
84
107
|
def amount
|
85
108
|
employment.salary_amount if employment
|
86
109
|
end
|
@@ -102,9 +125,9 @@ class Salary < Invoice
|
|
102
125
|
super(params, 'salary:employer:vkb')
|
103
126
|
|
104
127
|
super(params, 'salary:employee:ktg')
|
105
|
-
super(params.merge(:person_id => employee.id), "salary:bvg")
|
128
|
+
super(params.merge(:person_id => employee.id), "salary:employee:bvg")
|
106
129
|
|
107
|
-
super(params.merge(:person_id => employee.id), "salary:kz")
|
130
|
+
super(params.merge(:person_id => employee.id), "salary:employee:kz")
|
108
131
|
super(params.merge(:person_id => employee.id), "salary:social:kz")
|
109
132
|
end
|
110
133
|
end
|
@@ -8,7 +8,15 @@
|
|
8
8
|
= f.input :duration_to, :as => :date_field
|
9
9
|
= f.input :remarks, :input_html => {:rows => 4}
|
10
10
|
|
11
|
-
=
|
11
|
+
= f.inputs t('title.line_items') do
|
12
|
+
%table#line_items
|
13
|
+
%thead
|
14
|
+
= render 'line_items/list_header', :invoice => resource
|
15
|
+
%tbody
|
16
|
+
= f.fields_for :line_items do |line_item|
|
17
|
+
= render 'line_items/form', :line_item => line_item
|
18
|
+
%tfoot
|
19
|
+
= render 'line_items/list_footer', :total_amount => resource.amount
|
12
20
|
|
13
21
|
= f.buttons do
|
14
22
|
= f.commit_button
|
@@ -20,6 +20,11 @@
|
|
20
20
|
%th= t_attr(:duration_to, Invoice)
|
21
21
|
%td= l(resource.duration_to) if resource.duration_to
|
22
22
|
|
23
|
+
%h3= t('title.line_items')
|
24
|
+
%table.list
|
25
|
+
= render resource.line_items
|
26
|
+
= render 'line_items/list_footer', :total_amount => resource.amount
|
27
|
+
|
23
28
|
.contextual
|
24
29
|
= form_tag new_direct_booking_path(:direct_booking => {:reference_id => resource.id, :reference_type => resource_class.base_class}), :method => :get, :remote => true do
|
25
30
|
= collection_select :direct_booking, :booking_template_id, BookingTemplate.by_type(resource_class.name.underscore), :id, :title
|
@@ -0,0 +1,22 @@
|
|
1
|
+
= semantic_form_for @salary_booking_template do |f|
|
2
|
+
= f.semantic_errors
|
3
|
+
= f.inputs do
|
4
|
+
= f.input :title, :input_html => {"data-autofocus" => true}
|
5
|
+
= f.input :code, :input_html => {:style => 'width: 6em'}
|
6
|
+
= f.input :credit_account, :as => :combobox, :collection => accounts_as_collection
|
7
|
+
= f.input :debit_account, :as => :combobox, :collection => accounts_as_collection
|
8
|
+
= f.input :amount, :input_html => {:style => 'width: 6em'}
|
9
|
+
= f.input :amount_relates_to, :collection => amount_relations_as_collection
|
10
|
+
= f.input :comments, :input_html => {:rows => 5}
|
11
|
+
|
12
|
+
= f.inputs do
|
13
|
+
= f.input :for_ahv, :wrapper_html => {:class => 'col1'}
|
14
|
+
= f.input :for_ktg, :wrapper_html => {:class => 'col2'}
|
15
|
+
= f.input :for_uvg, :wrapper_html => {:class => 'col1'}
|
16
|
+
= f.input :for_uvgz, :wrapper_html => {:class => 'col2'}
|
17
|
+
= f.input :for_gross_income, :wrapper_html => {:class => 'col1'}
|
18
|
+
= f.input :for_deduction_at_source, :wrapper_html => {:class => 'col2'}
|
19
|
+
= f.input :salary_declaration_code, :wrapper_html => {:class => 'col1'}
|
20
|
+
|
21
|
+
= f.buttons do
|
22
|
+
= f.commit_button
|
@@ -0,0 +1,17 @@
|
|
1
|
+
%table.list.salary_booking_template_list
|
2
|
+
%tr
|
3
|
+
%th= t_attr :title, SalaryBookingTemplate
|
4
|
+
%th= t_attr :credit_account, SalaryBookingTemplate
|
5
|
+
%th= t_attr :debit_account, SalaryBookingTemplate
|
6
|
+
%th.currency= t_attr 'amount', SalaryBookingTemplate
|
7
|
+
%th= t_attr :amount_relates_to, SalaryBookingTemplate
|
8
|
+
%th= t_attr :for_gross_income, SalaryBookingTemplate
|
9
|
+
%th= t_attr :for_ahv, SalaryBookingTemplate
|
10
|
+
%th= t_attr :for_ktg, SalaryBookingTemplate
|
11
|
+
%th= t_attr :for_uvg, SalaryBookingTemplate
|
12
|
+
%th= t_attr :for_uvgz, SalaryBookingTemplate
|
13
|
+
%th= t_attr :for_deduction_at_source, SalaryBookingTemplate
|
14
|
+
%th= t_attr :salary_declaration_code, SalaryBookingTemplate
|
15
|
+
%th.action-links
|
16
|
+
|
17
|
+
= render @salary_booking_templates
|
@@ -0,0 +1,21 @@
|
|
1
|
+
%tr[salary_booking_template]
|
2
|
+
%td
|
3
|
+
= link_to "%s (%s)" % [salary_booking_template.title, salary_booking_template.code], salary_booking_template
|
4
|
+
- if salary_booking_template.comments.present?
|
5
|
+
%hr{:style => "height: 1px; margin: 0"}/
|
6
|
+
%i= salary_booking_template.comments
|
7
|
+
%td= link_to salary_booking_template.credit_account.code, account_path(salary_booking_template.credit_account), :title => salary_booking_template.credit_account.title unless salary_booking_template.credit_account.nil?
|
8
|
+
%td= link_to salary_booking_template.debit_account.code, account_path(salary_booking_template.debit_account), :title => salary_booking_template.debit_account.title unless salary_booking_template.debit_account.nil?
|
9
|
+
%td.currency= amount_to_s(salary_booking_template)
|
10
|
+
%td= t(salary_booking_template.amount_relates_to, :scope => 'salary_booking_template.relation') if salary_booking_template.amount_relates_to.present?
|
11
|
+
%td= salary_booking_template.for_gross_income
|
12
|
+
%td= salary_booking_template.for_ahv
|
13
|
+
%td= salary_booking_template.for_ktg
|
14
|
+
%td= salary_booking_template.for_uvg
|
15
|
+
%td= salary_booking_template.for_uvgz
|
16
|
+
%td= salary_booking_template.for_deduction_at_source
|
17
|
+
%td= salary_booking_template.salary_declaration_code
|
18
|
+
%td.action-links
|
19
|
+
= list_link_for(:edit, salary_booking_template)
|
20
|
+
= list_link_for(:delete, salary_booking_template)
|
21
|
+
= link_to image_tag('16x16/copy.png', :title => 'Copy'), copy_salary_booking_template_path(salary_booking_template)
|
@@ -1,7 +1,8 @@
|
|
1
1
|
de:
|
2
2
|
activerecord:
|
3
3
|
models:
|
4
|
-
salary:
|
4
|
+
salary: Lohn
|
5
|
+
salary_booking_template: Lohnart
|
5
6
|
|
6
7
|
attributes:
|
7
8
|
salary:
|
@@ -11,6 +12,14 @@ de:
|
|
11
12
|
social_amount: AHV/IV/EO/ALV/NBU
|
12
13
|
employer: Arbeitgeber
|
13
14
|
employee: Arbeitnehmer
|
15
|
+
salary_booking_template:
|
16
|
+
for_ahv: AHV/ALV
|
17
|
+
for_ktg: KTG
|
18
|
+
for_gross_income: Bruttolohn
|
19
|
+
for_uvg: UVG
|
20
|
+
for_uvgz: UVGZ
|
21
|
+
salary_declaration_code: Lohnausweis
|
22
|
+
for_deduction_at_source: Quellensteuer
|
14
23
|
|
15
24
|
salaries:
|
16
25
|
select_employee:
|
data/config/routes.rb
CHANGED
@@ -0,0 +1,11 @@
|
|
1
|
+
class AddSalarySpecificFlagsToBookingTemplates < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
add_column :booking_templates, :for_gross_income, :boolean
|
4
|
+
add_column :booking_templates, :for_ahv, :boolean
|
5
|
+
add_column :booking_templates, :for_uvg, :boolean
|
6
|
+
add_column :booking_templates, :for_uvgz, :boolean
|
7
|
+
add_column :booking_templates, :for_ktg, :boolean
|
8
|
+
add_column :booking_templates, :for_deduction_at_source, :boolean
|
9
|
+
add_column :booking_templates, :salary_declaration_code, :integer
|
10
|
+
end
|
11
|
+
end
|
data/db/seeds.rb
CHANGED
@@ -13,7 +13,7 @@ Account.create!([
|
|
13
13
|
|
14
14
|
# Booking Templates
|
15
15
|
BookingTemplate.create!([
|
16
|
-
{:code => "salary:invoice", :title => "
|
16
|
+
{:code => "salary:invoice", :title => "Monatslohn", :debit_account => Account.find_by_code("2050"), :credit_account => Account.find_by_code("5000"), :amount => 1, :amount_relates_to => 'reference_amount'},
|
17
17
|
{:code => "salary:cancel", :title => "Storno", :debit_account => Account.find_by_code("5000"), :credit_account => Account.find_by_code("2050"), :amount => 1, :amount_relates_to => 'reference_amount'},
|
18
18
|
|
19
19
|
{:code => "salary:cash_payment", :title => "Barzahlung Lohn", :debit_account => Account.find_by_code("1000"), :credit_account => Account.find_by_code("2050"), :amount => 1, :amount_relates_to => 'reference_balance'},
|
@@ -43,15 +43,15 @@ ChargeRate.create!([
|
|
43
43
|
])
|
44
44
|
|
45
45
|
ChargeBookingTemplate.create!([
|
46
|
-
{:code => "salary:employee:ahv_iv_eo", :charge_rate_code => 'salary:both:ahv_iv_eo', :title => "AHV/IV/EO Arbeitnehmer", :debit_account => Account.find_by_code("2020"), :credit_account => Account.find_by_code("
|
46
|
+
{:code => "salary:employee:ahv_iv_eo", :charge_rate_code => 'salary:both:ahv_iv_eo', :title => "AHV/IV/EO Arbeitnehmer", :debit_account => Account.find_by_code("2020"), :credit_account => Account.find_by_code("2050"), :amount_relates_to => 'reference_amount'},
|
47
47
|
{:code => "salary:employer:ahv_iv_eo", :charge_rate_code => 'salary:both:ahv_iv_eo', :title => "AHV/IV/EO Arbeitgeber", :debit_account => Account.find_by_code("2020"), :credit_account => Account.find_by_code("5700"), :amount_relates_to => 'reference_amount'},
|
48
48
|
|
49
|
-
{:code => "salary:employee:alv", :charge_rate_code => 'salary:both:alv', :title => "ALV Arbeitnehmer", :debit_account => Account.find_by_code("2020"), :credit_account => Account.find_by_code("
|
49
|
+
{:code => "salary:employee:alv", :charge_rate_code => 'salary:both:alv', :title => "ALV Arbeitnehmer", :debit_account => Account.find_by_code("2020"), :credit_account => Account.find_by_code("2050"), :amount_relates_to => 'reference_amount'},
|
50
50
|
{:code => "salary:employer:alv", :charge_rate_code => 'salary:both:alv', :title => "ALV Arbeitgeber", :debit_account => Account.find_by_code("2020"), :credit_account => Account.find_by_code("5700"), :amount_relates_to => 'reference_amount'},
|
51
51
|
|
52
52
|
{:code => "salary:employer:bu", :charge_rate_code => 'salary:employer:bu', :title => "BU Arbeitgeber", :debit_account => Account.find_by_code("2020"), :credit_account => Account.find_by_code("5700"), :amount_relates_to => 'reference_amount'},
|
53
53
|
|
54
|
-
{:code => "salary:employee:nbu", :charge_rate_code => 'salary:employee:nbu', :title => "NBU Arbeitnehmer", :debit_account => Account.find_by_code("2020"), :credit_account => Account.find_by_code("
|
54
|
+
{:code => "salary:employee:nbu", :charge_rate_code => 'salary:employee:nbu', :title => "NBU Arbeitnehmer", :debit_account => Account.find_by_code("2020"), :credit_account => Account.find_by_code("2050"), :amount_relates_to => 'reference_amount'},
|
55
55
|
{:code => "salary:employer:nbu", :charge_rate_code => 'salary:employer:nbu', :title => "NBU Arbeitgeber", :debit_account => Account.find_by_code("2020"), :credit_account => Account.find_by_code("5700"), :amount_relates_to => 'reference_amount'},
|
56
56
|
|
57
57
|
{:code => "salary:employer:fak", :charge_rate_code => 'salary:employer:fak', :title => "FAK Arbeitgeber", :debit_account => Account.find_by_code("2020"), :credit_account => Account.find_by_code("5700"), :amount_relates_to => 'reference_amount'},
|
@@ -1,10 +1,10 @@
|
|
1
1
|
module BookytSalary
|
2
2
|
module Navigation
|
3
3
|
def setup_bookyt_salary(navigation)
|
4
|
-
navigation.item :salaries,
|
4
|
+
navigation.item :salaries, t('bookyt.main_navigation.salaries'), salaries_path,
|
5
5
|
:if => Proc.new { user_signed_in? } do |salaries|
|
6
|
-
salaries.item :salaries,
|
7
|
-
salaries.item :new_salary, t_title(:new, Salary),
|
6
|
+
salaries.item :salaries, t('bookyt.main_navigation.salaries'), salaries_path, :highlights_on => /\/salaries($|\/[0-9]*($|\/.*))/
|
7
|
+
salaries.item :new_salary, t_title(:new, Salary), select_employee_salaries_path
|
8
8
|
salaries.item :employees, t_title(:index, Employee), employees_path
|
9
9
|
salaries.item :employments, t_title(:index, Employment), employments_path, :highlights_on => /\/employments($|\/[0-9]*($|\/.*))/
|
10
10
|
salaries.item :salary_statistics, t_title(:statistics, Salary), statistics_salaries_path, :highlights_on => /\/salaries\/statistics($|\?)/
|
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:
|
4
|
+
hash: 9
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 0.5.
|
9
|
+
- 1
|
10
|
+
version: 0.5.1
|
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:
|
18
|
+
date: 2012-01-13 00:00:00 Z
|
19
19
|
dependencies: []
|
20
20
|
|
21
21
|
description: This plugin extends bookyt with Salary functionality.
|
@@ -29,7 +29,9 @@ extra_rdoc_files: []
|
|
29
29
|
files:
|
30
30
|
- app/assets/stylesheets/bookyt_salary.sass
|
31
31
|
- app/controllers/salaries_controller.rb
|
32
|
+
- app/controllers/salary_booking_templates_controller.rb
|
32
33
|
- app/models/salary.rb
|
34
|
+
- app/models/salary_booking_template.rb
|
33
35
|
- app/views/salaries/_form.html.haml
|
34
36
|
- app/views/salaries/_list.html.haml
|
35
37
|
- app/views/salaries/_salary.html.haml
|
@@ -40,8 +42,13 @@ files:
|
|
40
42
|
- app/views/salaries/select_employee.html.haml
|
41
43
|
- app/views/salaries/show.html.haml
|
42
44
|
- app/views/salaries/statistics.html.haml
|
43
|
-
-
|
45
|
+
- app/views/salary_booking_templates/_form.html.haml
|
46
|
+
- app/views/salary_booking_templates/_list.html.haml
|
47
|
+
- app/views/salary_booking_templates/_salary_booking_template.html.haml
|
48
|
+
- config/locales/bookyt_salary.de.yml
|
44
49
|
- config/routes.rb
|
50
|
+
- db/migrate/20111223162759_add_salary_specific_flags_to_booking_templates.rb
|
51
|
+
- db/migrate/20111227093619_use_string_for_salary_declaration_code.rb
|
45
52
|
- db/seeds.rb
|
46
53
|
- lib/bookyt_salary.rb
|
47
54
|
- lib/bookyt_salary/navigation.rb
|
@@ -76,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
83
|
requirements: []
|
77
84
|
|
78
85
|
rubyforge_project:
|
79
|
-
rubygems_version: 1.8.
|
86
|
+
rubygems_version: 1.8.12
|
80
87
|
signing_key:
|
81
88
|
specification_version: 3
|
82
89
|
summary: Salary plugin for bookyt
|