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.
@@ -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 new
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 => 'Person'
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
@@ -1,3 +1,5 @@
1
+ = render 'salaries/sidebar'
2
+
1
3
  %table.list#salaries_list
2
4
  %tr
3
5
  %th= t_attr :value_date, Invoice
@@ -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'
@@ -0,0 +1,10 @@
1
+ %h2 Arbeitnehmer auswählen
2
+
3
+ = semantic_form_for @salary, :url => new_salary_path, :method => :get do |f|
4
+ = f.semantic_errors
5
+
6
+ = f.inputs do
7
+ = f.input :employee, :as => :combobox
8
+
9
+ = f.buttons do
10
+ = f.commit_button
data/config/routes.rb CHANGED
@@ -2,6 +2,7 @@ Rails.application.routes.draw do
2
2
  # Salaries
3
3
  resources :salaries do
4
4
  collection do
5
+ get :select_employee
5
6
  get :statistics
6
7
  end
7
8
 
@@ -1,3 +1,3 @@
1
1
  module BookytSalary
2
- VERSION = '0.2.4'
2
+ VERSION = '0.3.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: 31
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 2
9
- - 4
10
- version: 0.2.4
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-11 00:00:00 +01:00
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