bookyt_salary 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -18,10 +18,7 @@ class SalariesController < InvoicesController
18
18
  def select_employee
19
19
  # Allow pre-seeding some parameters
20
20
  salary_params = {
21
- :customer_id => current_tenant.company.id,
22
- :state => 'booked',
23
- :duration_from => Date.today,
24
- :duration_to => Date.today.in(30.days).to_date
21
+ :duration_from => Date.today.beginning_of_month
25
22
  }
26
23
 
27
24
  # Set default parameters
@@ -32,12 +29,13 @@ class SalariesController < InvoicesController
32
29
 
33
30
  def new
34
31
  @salary = Salary.new(params[:salary])
32
+ @employee = @salary.employee
35
33
 
36
- employment = @salary.employee.employments.current
37
-
38
- @salary.amount = employment.salary_amount
39
-
40
- # Line Items
34
+ # Deduced defaults
35
+ @salary.employer_id = current_tenant.company.id
36
+ month_name = t('date.month_names')[@salary.duration_from.month]
37
+ @salary.title = "Lohn #{month_name} - #{@salary.employee.vcard.full_name}"
38
+ @salary.duration_to = @salary.duration_from.end_of_month
41
39
 
42
40
  # Prebuild an empty attachment instance
43
41
  @salary.attachments.build
@@ -47,6 +45,11 @@ class SalariesController < InvoicesController
47
45
 
48
46
  def create
49
47
  @salary = Salary.new(params[:salary])
48
+ @salary.state = 'booked'
49
+
50
+ # Set @employee in case we redisplay the form partial
51
+ @employee = @salary.employee
52
+
50
53
  @salary.build_booking
51
54
 
52
55
  create!
data/app/models/salary.rb CHANGED
@@ -6,19 +6,26 @@ class Salary < Invoice
6
6
  validates :employee, :employer, :presence => true
7
7
 
8
8
  def employer_id=(value)
9
- customer_id = value
9
+ self.customer_id = value
10
+ end
11
+ def employer_id
12
+ customer_id
10
13
  end
11
14
 
12
15
  def employee_id=(value)
13
- company_id = value
16
+ self.company_id = value
17
+ end
18
+ def employee_id
19
+ company_id
14
20
  end
15
21
 
22
+ def employment
23
+ employee.employments.current
24
+ end
25
+
16
26
  # States
17
27
  # ======
18
28
  STATES = ['booked', 'canceled', 'paid']
19
- scope :by_state, lambda {|value|
20
- where(:state => value) unless value == 'all'
21
- }
22
29
 
23
30
  # String
24
31
  def to_s(format = :default)
@@ -74,27 +81,30 @@ class Salary < Invoice
74
81
  Account.find_by_code("5000")
75
82
  end
76
83
 
84
+ def amount
85
+ employment.salary_amount if employment
86
+ end
87
+
77
88
  # Build booking
78
89
  #
79
90
  # We need to ensure the order of creation as we depent on current balance.
80
91
  def build_booking(params = {}, template_code = nil)
81
92
  # Build and assign booking
82
- super(params, 'salary:employee:ahv_iv_eo').save
83
- super(params, 'salary:employer:ahv_iv_eo').save
84
- super(params, 'salary:employee:alv').save
85
- super(params, 'salary:employer:alv').save
86
- super(params, 'salary:employee:nbu').save
87
- super(params, 'salary:employer:nbu').save
88
- super(params, 'salary:employer:bu').save
89
- super(params, 'salary:employer:fak').save
90
- super(params, 'salary:employer:vkb').save
91
-
92
- super(params, 'salary:employee:ktg').save
93
- super(params.merge(:person_id => employee.id), "salary:bvg").save
94
-
95
- super(params, 'salary:invoice').save
96
-
97
- super(params.merge(:person_id => employee.id), "salary:kz").save
98
- super(params.merge(:person_id => employee.id), "salary:social:kz").save
93
+ super(params, 'salary:invoice')
94
+ super(params, 'salary:employee:ahv_iv_eo')
95
+ super(params, 'salary:employer:ahv_iv_eo')
96
+ super(params, 'salary:employee:alv')
97
+ super(params, 'salary:employer:alv')
98
+ super(params, 'salary:employee:nbu')
99
+ super(params, 'salary:employer:nbu')
100
+ super(params, 'salary:employer:bu')
101
+ super(params, 'salary:employer:fak')
102
+ super(params, 'salary:employer:vkb')
103
+
104
+ super(params, 'salary:employee:ktg')
105
+ super(params.merge(:person_id => employee.id), "salary:bvg")
106
+
107
+ super(params.merge(:person_id => employee.id), "salary:kz")
108
+ super(params.merge(:person_id => employee.id), "salary:social:kz")
99
109
  end
100
110
  end
@@ -1,21 +1,14 @@
1
1
  = semantic_form_for @salary do |f|
2
2
  = f.semantic_errors
3
3
  = f.inputs do
4
+ = f.input :employee_id, :as => :hidden
5
+ = f.input :employer_id, :as => :hidden
4
6
  = f.input :title
5
7
  = f.input :duration_from, :as => :date_field
6
8
  = f.input :duration_to, :as => :date_field
7
- = f.input :amount, :input_html => {:size => 12}
8
9
  = f.input :remarks, :input_html => {:rows => 4}
9
10
 
10
- = f.inputs t('title.line_items') do
11
- %table#line_items
12
- %thead
13
- = render 'line_items/list_header', :invoice => resource
14
- %tbody
15
- = f.fields_for :line_items do |line_item|
16
- = render 'line_items/form', :line_item => line_item
17
- %tfoot
18
- = render 'line_items/list_footer', :total_amount => resource.amount
11
+ = render 'employees/show_charge_rates'
19
12
 
20
13
  = f.buttons do
21
14
  = f.commit_button
@@ -1 +1,8 @@
1
- = render :template => 'application/index'
1
+ .contextual
2
+ = icon_link_to :new, {:action => :select_employee}
3
+
4
+ %h2= t_title
5
+
6
+ = paginated_section collection do
7
+ - if collection.any?
8
+ = render "list"
@@ -1,10 +1,11 @@
1
- %h2 Arbeitnehmer auswählen
1
+ %h2= t_title
2
2
 
3
3
  = semantic_form_for @salary, :url => new_salary_path, :method => :get do |f|
4
4
  = f.semantic_errors
5
5
 
6
6
  = f.inputs do
7
7
  = f.input :employee, :as => :combobox
8
+ = f.input :duration_from, :discard_day => true, :start_year => Time.now.year - 2, :end_year => Time.now.year + 1, :include_blank => false
8
9
 
9
10
  = f.buttons do
10
11
  = f.commit_button
@@ -12,10 +12,9 @@ de:
12
12
  employer: Arbeitgeber
13
13
  employee: Arbeitnehmer
14
14
 
15
- crud:
16
- title:
17
- day:
18
- new: Abrechnung von %{day}
15
+ salaries:
16
+ select_employee:
17
+ title: Arbeitnehmer auswählen
19
18
 
20
19
  bookyt:
21
20
  main_navigation:
@@ -1,3 +1,3 @@
1
1
  module BookytSalary
2
- VERSION = '0.4.0'
2
+ VERSION = '0.5.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: 15
5
- prerelease: false
4
+ hash: 11
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
- - 4
8
+ - 5
9
9
  - 0
10
- version: 0.4.0
10
+ version: 0.5.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Simon H\xC3\xBCrlimann (CyT)"
@@ -15,8 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-11-21 00:00:00 +01:00
19
- default_executable:
18
+ date: 2011-12-21 00:00:00 Z
20
19
  dependencies: []
21
20
 
22
21
  description: This plugin extends bookyt with Salary functionality.
@@ -48,7 +47,6 @@ files:
48
47
  - lib/bookyt_salary/navigation.rb
49
48
  - lib/bookyt_salary/railtie.rb
50
49
  - lib/bookyt_salary/version.rb
51
- has_rdoc: true
52
50
  homepage: https://github.com/huerlisi/bookyt_salary
53
51
  licenses: []
54
52
 
@@ -78,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
78
76
  requirements: []
79
77
 
80
78
  rubyforge_project:
81
- rubygems_version: 1.3.7
79
+ rubygems_version: 1.8.10
82
80
  signing_key:
83
81
  specification_version: 3
84
82
  summary: Salary plugin for bookyt