bookyt_salary 0.7.1 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,6 @@
1
+ @import partials/base
2
+ @import partials/content/icons
3
+
4
+ // Icons
5
+ // =====
6
+ +icon-class("payslip", "pdf")
@@ -29,9 +29,10 @@ class SalariesController < InvoicesController
29
29
 
30
30
  def new
31
31
  @salary = Salary.new(params[:salary])
32
- @employee = @salary.employee
32
+ @salary.state = 'booked'
33
33
 
34
- unless @employee
34
+ unless @salary.employee
35
+ # Trigger validation to flag bad values in select form
35
36
  @salary.valid?
36
37
 
37
38
  render :action => 'select_employee' and return
@@ -52,18 +53,6 @@ class SalariesController < InvoicesController
52
53
  new!
53
54
  end
54
55
 
55
- def create
56
- @salary = Salary.new(params[:salary])
57
- @salary.state = 'booked'
58
-
59
- # Set @employee in case we redisplay the form partial
60
- @employee = @salary.employee
61
-
62
- @salary.build_booking
63
-
64
- create!
65
- end
66
-
67
56
  def payslip
68
57
  show! do |format|
69
58
  format.html { redirect_to :action => :show }
data/app/models/salary.rb CHANGED
@@ -75,12 +75,23 @@ class Salary < Invoice
75
75
  self.due_date ||= date
76
76
  end
77
77
 
78
+ # Get salary template
79
+ #
80
+ # Tries to get a personal salary template, falls back to templates with
81
+ # no assigned persons.
82
+ #
83
+ # If more than one template matches the criteria, it is unspecified which
84
+ # one will be returned.
85
+ def salary_template
86
+ template = SalaryTemplate.where(:person_id => employee.id).last
87
+ template ||= SalaryTemplate.where(:person_id => nil).last
88
+ end
89
+
78
90
  # Line Items
79
91
  def build_line_items
80
- template = SalaryTemplate.where(:person_id => employee.id).first
81
- template.salary_booking_templates.each do |booking_template|
92
+ salary_template.salary_booking_templates.each do |booking_template|
82
93
  line_item = line_items.build(:date => self.value_date)
83
- line_item.booking_template = booking_template
94
+ line_item.set_booking_template(booking_template)
84
95
  end
85
96
  end
86
97
 
@@ -97,7 +108,7 @@ class Salary < Invoice
97
108
  end
98
109
 
99
110
  def self.available_credit_accounts
100
- Account.by_type(['costs', 'current_assets'])
111
+ Account.all
101
112
  end
102
113
 
103
114
  def self.default_credit_account
@@ -105,7 +116,7 @@ class Salary < Invoice
105
116
  end
106
117
 
107
118
  def self.available_debit_accounts
108
- Account.by_type(['outside_capital'])
119
+ Account.all
109
120
  end
110
121
 
111
122
  def self.default_debit_account
@@ -3,6 +3,7 @@
3
3
  = f.inputs do
4
4
  = f.input :employee_id, :as => :hidden
5
5
  = f.input :employer_id, :as => :hidden
6
+ = f.input :state, :as => :hidden
6
7
  .row
7
8
  .span16= f.input :title, :input_html => {:class => 'span12'}
8
9
  .row
@@ -1,35 +1,21 @@
1
1
  .contextual
2
- = icon_link_to :pdf, :format => :pdf
3
2
  = icon_link_to(:payslip, {:action => :payslip, :format => :pdf}, :target => '_blank')
4
3
  = contextual_links_for
5
4
 
6
- %h1= resource.title
7
- .box
8
- %table{:style => "width: 100%"}
9
- %tr
10
- %th= t_attr(:customer)
11
- %td= link_to(full_address(resource.customer.vcard, ', '), resource.customer)
12
- %th= t_attr(:company)
13
- %td= link_to(full_address(resource.company.vcard, ', '), resource.company)
14
- %tr
15
- %th= t_attr(:amount)
16
- %td= currency_fmt(resource.amount)
17
- %tr
18
- %th= t_attr(:duration_from, Invoice)
19
- %td= l(resource.duration_from) if resource.duration_from
20
- %th= t_attr(:duration_to, Invoice)
21
- %td= l(resource.duration_to) if resource.duration_to
5
+ .page-header
6
+ %h1= resource.title
22
7
 
23
- %h3= t('title.line_items')
24
- %table.list
25
- = render resource.line_items
26
- = render 'line_items/list_footer', :total_amount => resource.amount
8
+ - bookings = Booking.by_reference(resource)
9
+ - credit_accounts = bookings.select('credit_account_id').group('credit_account_id').map{|account| account.credit_account}
10
+ - debit_accounts = bookings.select('debit_account_id').group('debit_account_id').map{|account| account.debit_account}
11
+ - accounts = (credit_accounts + debit_accounts).uniq
27
12
 
28
- .contextual
29
- = form_tag new_direct_booking_path(:direct_booking => {:reference_id => resource.id, :reference_type => resource_class.base_class}), :method => :get, :remote => true do
30
- = collection_select :direct_booking, :booking_template_id, BookingTemplate.by_type(resource_class.name.underscore), :id, :title
31
- = submit_tag t_action('new')
13
+ %ul.tabs
14
+ %li.active= link_to t_model, '#tab-main'
15
+ - accounts.each do |account|
16
+ %li= link_to account.to_s, "#tab-account-#{account.id}"
32
17
 
33
- = render 'direct_bookings/show', :reference => resource, :direct_account => Account.find_by_code("2050")
34
- = render 'direct_bookings/show', :reference => resource, :direct_account => Account.find_by_code("5000")
35
- = render 'direct_bookings/show', :reference => resource, :direct_account => Account.find_by_code("5700")
18
+ .tab-content
19
+ #tab-main.active= render "form"
20
+ - accounts.each do |account|
21
+ %div{:id => "tab-account-#{account.id}"}= render 'direct_bookings/show', :reference => resource, :direct_account => account
@@ -23,10 +23,10 @@ de:
23
23
  salary_declaration_code: Lohnausweis
24
24
  for_deduction_at_source: Quellensteuer
25
25
  salary_template:
26
- person: Person
27
- salary_booking_template: Lohnarten
28
- title: Titel
29
- remarks: Bemerkungen
26
+ person: Person
27
+ salary_booking_templates: Lohnarten
28
+ title: Titel
29
+ remarks: Bemerkungen
30
30
 
31
31
  salaries:
32
32
  select_employee:
@@ -37,12 +37,3 @@ de:
37
37
  salary_templates:
38
38
  index:
39
39
  title: Lohnvorlagen
40
-
41
- bookyt:
42
- main_navigation:
43
- days: Tagesabschlüsse
44
- new_day: Tagesabschluss
45
-
46
- tooltip:
47
- new_day: Hier können Sie einen neuen Tagesabschluss gemäss Registrierkasse buchen
48
- days: Hier finden Sie eine Liste aller Tagesabschlüsse
@@ -1,3 +1,3 @@
1
1
  module BookytSalary
2
- VERSION = '0.7.1'
2
+ VERSION = '0.8.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: 1
4
+ hash: 63
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 7
9
- - 1
10
- version: 0.7.1
8
+ - 8
9
+ - 0
10
+ version: 0.8.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-01-17 00:00:00 Z
18
+ date: 2012-01-18 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rails