bookyt_salary 0.2.4 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/salaries_controller.rb +10 -8
- data/app/models/salary.rb +8 -1
- data/app/views/salaries/_form.html.haml +0 -3
- data/app/views/salaries/_list.html.haml +2 -0
- data/app/views/salaries/_sidebar.html.haml +11 -0
- data/app/views/salaries/index.html.haml +1 -0
- data/app/views/salaries/select_employee.html.haml +10 -0
- data/config/routes.rb +1 -0
- data/lib/bookyt_salary/version.rb +1 -1
- metadata +8 -5
@@ -1,10 +1,9 @@
|
|
1
1
|
class SalariesController < InvoicesController
|
2
|
-
|
3
2
|
respond_to :html, :pdf
|
4
3
|
|
5
4
|
# Filter/Search
|
6
5
|
# =============
|
7
|
-
has_scope :by_state
|
6
|
+
has_scope :by_state, :default => nil
|
8
7
|
has_scope :by_value_period, :using => [:from, :to], :default => proc { |c| c.session[:has_scope] }
|
9
8
|
has_scope :by_employee_id
|
10
9
|
|
@@ -14,7 +13,7 @@ class SalariesController < InvoicesController
|
|
14
13
|
index!
|
15
14
|
end
|
16
15
|
|
17
|
-
def
|
16
|
+
def select_employee
|
18
17
|
# Allow pre-seeding some parameters
|
19
18
|
salary_params = {
|
20
19
|
:customer_id => current_tenant.company.id,
|
@@ -27,13 +26,16 @@ class SalariesController < InvoicesController
|
|
27
26
|
salary_params.merge!(params[:salary]) if params[:salary]
|
28
27
|
|
29
28
|
@salary = Salary.new(salary_params)
|
29
|
+
end
|
30
|
+
|
31
|
+
def new
|
32
|
+
@salary = Salary.new(params[:salary])
|
33
|
+
|
34
|
+
employment = @salary.employee.employments.current
|
35
|
+
|
36
|
+
@salary.amount = employment.salary_amount
|
30
37
|
|
31
38
|
# Line Items
|
32
|
-
line_item = @salary.line_items.build(
|
33
|
-
:times => 1,
|
34
|
-
:quantity => 'x'
|
35
|
-
)
|
36
|
-
line_item.assign_booking_template = BookingTemplate.find_by_code('salary:employee:ahv_iv_eo')
|
37
39
|
|
38
40
|
# Prebuild an empty attachment instance
|
39
41
|
@salary.attachments.build
|
data/app/models/salary.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class Salary < Invoice
|
2
2
|
# Association customizing
|
3
|
-
belongs_to :employee, :foreign_key => :company_id, :class_name => '
|
3
|
+
belongs_to :employee, :foreign_key => :company_id, :class_name => 'Employee'
|
4
4
|
belongs_to :employer, :foreign_key => :customer_id, :class_name => 'Person'
|
5
5
|
|
6
6
|
validates :employee, :employer, :presence => true
|
@@ -13,6 +13,13 @@ class Salary < Invoice
|
|
13
13
|
company_id = value
|
14
14
|
end
|
15
15
|
|
16
|
+
# States
|
17
|
+
# ======
|
18
|
+
STATES = ['booked', 'canceled', 'paid']
|
19
|
+
scope :by_state, lambda {|value|
|
20
|
+
where(:state => value) unless value == 'all'
|
21
|
+
}
|
22
|
+
|
16
23
|
# String
|
17
24
|
def to_s(format = :default)
|
18
25
|
"%s (%s / %s - %s)" % [title, company, duration_from ? I18n::localize(duration_from) : '', duration_to ? I18n::localize(duration_to) : '']
|
@@ -1,9 +1,6 @@
|
|
1
1
|
= semantic_form_for @salary do |f|
|
2
2
|
= f.semantic_errors
|
3
3
|
= f.inputs do
|
4
|
-
= f.input :state, :collection => invoice_states_as_collection
|
5
|
-
= f.input :employer, :as => :combobox
|
6
|
-
= f.input :employee, :as => :combobox
|
7
4
|
= f.input :title
|
8
5
|
= f.input :duration_from, :as => :date_field
|
9
6
|
= f.input :duration_to, :as => :date_field
|
@@ -0,0 +1,11 @@
|
|
1
|
+
- unless @salary_sidebar
|
2
|
+
- @salary_sidebar = true
|
3
|
+
|
4
|
+
- content_for :sidebar do
|
5
|
+
.sub-tabs
|
6
|
+
%h3 Filter
|
7
|
+
%ul
|
8
|
+
%li= link_to t('bookyt.all'), url_for(params.merge(:by_state => 'all', :overdue => nil))
|
9
|
+
- for state in Salary::STATES
|
10
|
+
%li= link_to t(state, :scope => 'invoice.state'), url_for(params.merge(:by_state => state, :overdue => nil))
|
11
|
+
%li= link_to t(:overdue, :scope => 'invoice.state'), url_for(params.merge(:by_state => nil, :overdue => true))
|
@@ -0,0 +1 @@
|
|
1
|
+
= render :template => 'application/index'
|
data/config/routes.rb
CHANGED
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: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 0.3.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: 2011-11-
|
18
|
+
date: 2011-11-16 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -35,7 +35,10 @@ files:
|
|
35
35
|
- app/views/salaries/_list.html.haml
|
36
36
|
- app/views/salaries/_salary.html.haml
|
37
37
|
- app/views/salaries/_salary_certificate.html.haml
|
38
|
+
- app/views/salaries/_sidebar.html.haml
|
39
|
+
- app/views/salaries/index.html.haml
|
38
40
|
- app/views/salaries/payslip.pdf.prawn
|
41
|
+
- app/views/salaries/select_employee.html.haml
|
39
42
|
- app/views/salaries/show.html.haml
|
40
43
|
- app/views/salaries/statistics.html.haml
|
41
44
|
- config/locales/de.yml
|