bookyt_salary 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,60 +0,0 @@
1
- @import blueprint/grid
2
-
3
- // Grid
4
- $blueprint-grid-columns: 24
5
- $blueprint-grid-width: 30px
6
- $blueprint-grid-margin: 10px
7
-
8
-
9
- // Column widths
10
- $column_small_form: 10
11
-
12
- // Cash up styling
13
- #cash_register_new,
14
- #new_day
15
- +column(12)
16
-
17
- #cash_register_new
18
- ul
19
- width: 50%
20
- float: left
21
- &.second
22
- li
23
- width: 141px
24
- float: right
25
- label
26
- width: 45px
27
- float: left
28
- input
29
- width: 90px
30
- #cash
31
- float: left
32
- color: red
33
- text-decoration: underline
34
- font-weight: bold
35
- #result
36
- width: 100%
37
- margin-top: 10px
38
- padding-top: 10px
39
- border-top: 1px solid black
40
- label
41
- font-weight: bold
42
- margin-right: 15px
43
- input
44
- width: 100%
45
- li:first-child
46
- margin-bottom: 10px
47
-
48
- #new_day
49
- label
50
- width: 160px
51
- input
52
- width: 100px
53
- float: right
54
- &#day_submit
55
- width: 100%
56
-
57
- #day_edit
58
- table
59
- th
60
- padding-right: 20px
@@ -0,0 +1,44 @@
1
+ class SalariesController < AuthorizedController
2
+ # Filter/Search
3
+ # =============
4
+ has_scope :by_state
5
+ has_scope :by_value_period, :using => [:from, :to], :default => proc { |c| c.session[:has_scope] }
6
+ has_scope :by_employee_id
7
+
8
+ # Actions
9
+ # =======
10
+ def statistics
11
+ index!
12
+ end
13
+
14
+ def new
15
+ # Allow pre-seeding some parameters
16
+ salary_params = {
17
+ :customer_id => current_tenant.company.id,
18
+ :state => 'booked',
19
+ :duration_from => Date.today,
20
+ :duration_to => Date.today.in(30.days).to_date
21
+ }
22
+
23
+ # Set default parameters
24
+ salary_params.merge!(params[:salary]) if params[:salary]
25
+
26
+ @salary = Salary.new(salary_params)
27
+
28
+ # Prebuild an empty attachment instance
29
+ @salary.attachments.build
30
+
31
+ new!
32
+ end
33
+
34
+ def create
35
+ @salary = Salary.new(params[:salary])
36
+ @salary.build_booking
37
+
38
+ create!
39
+ end
40
+
41
+ def payslip
42
+ show!
43
+ end
44
+ end
@@ -0,0 +1,79 @@
1
+ class Salary < Invoice
2
+ # String
3
+ def to_s(format = :default)
4
+ "%s (%s / %s - %s)" % [title, company, duration_from ? I18n::localize(duration_from) : '', duration_to ? I18n::localize(duration_to) : '']
5
+ end
6
+
7
+ # Calculations
8
+ def net_amount
9
+ salary_invoice_booking = bookings.where(:debit_account_id => Account.find_by_code('2050').id).first
10
+ return 0.0 unless salary_invoice_booking
11
+
12
+ salary_invoice_booking.amount
13
+ end
14
+
15
+ def bvg_amount
16
+ bookings.by_text("BVG").sum(:amount)
17
+ end
18
+
19
+ def social_amount
20
+ result = bookings.by_text("AHV/IV/EO Arbeitnehmer").sum(:amount)
21
+ result += bookings.by_text("ALV Arbeitnehmer").sum(:amount)
22
+ result += bookings.by_text("NBU Arbeitnehmer").sum(:amount)
23
+
24
+ result
25
+ end
26
+
27
+ def ahv_amount
28
+ result = amount
29
+ result += bookings.where(:title => "Kinderzulage").sum(:amount)
30
+
31
+ result
32
+ end
33
+
34
+ # Assignment proxies
35
+ def duration_from=(value)
36
+ write_attribute(:duration_from, value)
37
+
38
+ value_as_date = self.duration_from
39
+ # Calculate value and due dates
40
+ date = Date.new(value_as_date.year, value_as_date.month, 1).in(1.month).ago(1.day)
41
+ self.value_date ||= date
42
+ self.due_date ||= date
43
+ end
44
+
45
+ # Filter/Search
46
+ # =============
47
+ scope :by_value_period, lambda {|from, to| where("date(value_date) BETWEEN ? AND ?", from, to) }
48
+ scope :by_employee_id, lambda {|value| where(:company_id => value)}
49
+
50
+ # Bookings
51
+ # ========
52
+ def self.direct_account
53
+ Account.find_by_code("5000")
54
+ end
55
+
56
+ # Build booking
57
+ #
58
+ # We need to ensure the order of creation as we depent on current balance.
59
+ def build_booking(params = {}, template_code = nil)
60
+ # Build and assign booking
61
+ super(params, 'salary:employee:ahv_iv_eo').save
62
+ super(params, 'salary:employer:ahv_iv_eo').save
63
+ super(params, 'salary:employee:alv').save
64
+ super(params, 'salary:employer:alv').save
65
+ super(params, 'salary:employee:nbu').save
66
+ super(params, 'salary:employer:nbu').save
67
+ super(params, 'salary:employer:bu').save
68
+ super(params, 'salary:employer:fak').save
69
+ super(params, 'salary:employer:vkb').save
70
+
71
+ super(params, 'salary:employee:ktg').save
72
+ super(params.merge(:person_id => company.id), "salary:bvg").save
73
+
74
+ super(params, 'salary:invoice').save
75
+
76
+ super(params.merge(:person_id => company.id), "salary:kz").save
77
+ super(params.merge(:person_id => company.id), "salary:social:kz").save
78
+ end
79
+ end
@@ -0,0 +1,14 @@
1
+ = semantic_form_for @salary, :remote => true do |f|
2
+ = f.semantic_errors
3
+ = f.inputs do
4
+ = f.input :state, :collection => invoice_states_as_collection
5
+ = f.input :customer_id, :as => :hidden
6
+ = f.input :company_id, :as => :hidden
7
+ = f.input :title
8
+ = f.input :duration_from, :as => :date_field
9
+ = f.input :duration_to, :as => :date_field
10
+ = f.input :amount, :input_html => {:size => 12}
11
+ = f.input :remarks, :input_html => {:rows => 4}
12
+
13
+ = f.buttons do
14
+ = f.commit_button
@@ -0,0 +1,12 @@
1
+ %table.list#salaries_list
2
+ %tr
3
+ %th= t_attr :value_date, Invoice
4
+ %th= t_attr :company, Invoice
5
+ %th= t_attr :title, Invoice
6
+ %th= t_attr :due_date, Invoice
7
+ %th.currency= t_attr :amount, Salary
8
+ %th.currency= t_attr :net_amount, Salary
9
+ %th.currency= t_attr :balance, Invoice
10
+ %th.action-links
11
+
12
+ = render @salaries
@@ -0,0 +1,10 @@
1
+ %tr[salary]
2
+ %td= salary.value_date
3
+ %td= link_to salary.company, salary.company
4
+ %td= link_to salary.title, salary, {'data-href-container' => 'tr'}
5
+ %td= salary.due_date
6
+ %td.currency= currency_fmt(salary.amount)
7
+ %td.currency= currency_fmt(salary.net_amount)
8
+ %td.currency= currency_fmt(salary.balance(Date.today, Account.find_by_code('2050')))
9
+ %td.action-links
10
+ = list_link_for(:edit, salary)
@@ -0,0 +1,25 @@
1
+ %h3= t('salary_certificate')
2
+
3
+ = paginated_section collection do
4
+ %table.list
5
+ %tr
6
+ %th= t_attr :company, Invoice
7
+ %th.currency= t_attr :amount, Salary
8
+ %th.currency= t_attr :social_amount, Salary
9
+ %th.currency= t_attr :bvg_amount, Salary
10
+ %th.currency= t_attr :net_amount, Salary
11
+
12
+ - for salary in @salaries
13
+ %tr
14
+ %td= salary.company
15
+ %td.currency= link_to currency_fmt(salary.ahv_amount), salary, "data-href-container" => 'tr'
16
+ %td.currency= currency_fmt(salary.social_amount)
17
+ %td.currency= currency_fmt(salary.bvg_amount)
18
+ %td.currency= currency_fmt(salary.net_amount)
19
+
20
+ %tr
21
+ %th= t('bookyt.total')
22
+ %th.currency= currency_fmt(@salaries.sum(&:ahv_amount))
23
+ %th.currency= currency_fmt(@salaries.sum(&:social_amount))
24
+ %th.currency= currency_fmt(@salaries.sum(&:bvg_amount))
25
+ %th.currency= currency_fmt(@salaries.sum(&:net_amount))
@@ -0,0 +1,40 @@
1
+ .contextual
2
+ = icon_link_to :pdf, :format => :pdf
3
+ = icon_link_to :show
4
+
5
+ %h1= resource.title
6
+ .box
7
+ %table{:style => "width: 100%"}
8
+ %tr
9
+ %th= t_attr(:customer, Invoice)
10
+ %td= link_to(full_address(resource.customer.vcard, ', '), resource.customer)
11
+ %th= t_attr(:company, Invoice)
12
+ %td= link_to(full_address(resource.company.vcard, ', '), resource.company)
13
+ %tr
14
+ %th= t_attr(:state, Invoice)
15
+ %td#invoice_state=t resource.state, :scope => 'invoice.state'
16
+ %tr
17
+ %th= t_attr(:duration_from, Invoice)
18
+ %td= l(resource.duration_from) if resource.duration_from
19
+ %th= t_attr(:duration_to, Invoice)
20
+ %td= l(resource.duration_to) if resource.duration_to
21
+
22
+ .contextual
23
+ = form_tag new_direct_booking_path(:direct_booking => {:reference_id => resource.id, :reference_type => resource_class.base_class}), :method => :get, :remote => true do
24
+ = collection_select :direct_booking, :booking_template_id, BookingTemplate.by_type(resource_class.name.underscore), :id, :title
25
+ = submit_tag t_action('new')
26
+
27
+ %h3= Account.find_by_code("2050").title
28
+ - @direct_account = Account.find_by_code("2050")
29
+ #salary_payment_booking_list
30
+ = render 'direct_bookings/list', :reference => resource
31
+
32
+ %h3= Account.find_by_code("5000").title
33
+ - @direct_account = Account.find_by_code("5000")
34
+ #salary_payment_booking_list
35
+ = render 'direct_bookings/list', :reference => resource
36
+
37
+ %h3= Account.find_by_code("5700").title
38
+ - @direct_account = Account.find_by_code("5700")
39
+ #salary_booking_list
40
+ = render 'direct_bookings/list', :reference => resource
@@ -0,0 +1,41 @@
1
+ .contextual
2
+ = icon_link_to :pdf, :format => :pdf
3
+ = icon_link_to :payslip
4
+ = contextual_links_for
5
+
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
22
+
23
+ .contextual
24
+ = form_tag new_direct_booking_path(:direct_booking => {:reference_id => resource.id, :reference_type => resource_class.base_class}), :method => :get, :remote => true do
25
+ = collection_select :direct_booking, :booking_template_id, BookingTemplate.by_type(resource_class.name.underscore), :id, :title
26
+ = submit_tag t_action('new')
27
+
28
+ - @direct_account = Account.find_by_code("2050")
29
+ %h3= link_to @direct_account.title, @direct_account
30
+ #salary_payment_booking_list
31
+ = render 'direct_bookings/list', :reference => resource
32
+
33
+ - @direct_account = Account.find_by_code("5000")
34
+ %h3= link_to @direct_account.title, @direct_account
35
+ #salary_payment_booking_list
36
+ = render 'direct_bookings/list', :reference => resource
37
+
38
+ - @direct_account = Account.find_by_code("5700")
39
+ %h3= link_to @direct_account.title, @direct_account
40
+ #salary_booking_list
41
+ = render 'direct_bookings/list', :reference => resource
@@ -0,0 +1,6 @@
1
+ .contextual
2
+ = icon_link_to :index
3
+
4
+ %h2= t_title
5
+
6
+ = render 'salary_certificate'
data/db/seeds.rb CHANGED
@@ -1,5 +1,8 @@
1
1
  # Salaries
2
2
  # ========
3
+ outside_capital = AccountType.find_by_code('outside_capital')
4
+ costs = AccountType.find_by_code('costs')
5
+
3
6
  # Accounts
4
7
  Account.create!([
5
8
  {:code => "2020", :title => "Kreditoren Sozialversicherungen", :account_type => outside_capital},
@@ -1,3 +1,3 @@
1
1
  module BookytSalary
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
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: 23
5
- prerelease: false
4
+ hash: 21
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.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: 2011-08-19 00:00:00 +02:00
18
+ date: 2011-10-19 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -29,17 +29,15 @@ extra_rdoc_files: []
29
29
 
30
30
  files:
31
31
  - app/assets/stylesheets/bookyt_salary.sass
32
- - app/controllers/days_controller.rb
33
- - app/models/day.rb
34
- - app/views/days/_calculate.html.haml
35
- - app/views/days/_complete_form.html.haml
36
- - app/views/days/_day.html.haml
37
- - app/views/days/_form.html.haml
38
- - app/views/days/calculate_cash.js.erb
39
- - app/views/days/edit.html.haml
40
- - app/views/days/index.html.haml
41
- - app/views/days/new.html.haml
42
- - app/views/days/show.html.haml
32
+ - app/controllers/salaries_controller.rb
33
+ - app/models/salary.rb
34
+ - app/views/salaries/_form.html.haml
35
+ - app/views/salaries/_list.html.haml
36
+ - app/views/salaries/_salary.html.haml
37
+ - app/views/salaries/_salary_certificate.html.haml
38
+ - app/views/salaries/payslip.html.haml
39
+ - app/views/salaries/show.html.haml
40
+ - app/views/salaries/statistics.html.haml
43
41
  - config/locales/de.yml
44
42
  - config/routes.rb
45
43
  - db/seeds.rb
@@ -77,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
75
  requirements: []
78
76
 
79
77
  rubyforge_project:
80
- rubygems_version: 1.3.7
78
+ rubygems_version: 1.5.2
81
79
  signing_key:
82
80
  specification_version: 3
83
81
  summary: Salary plugin for bookyt
@@ -1,15 +0,0 @@
1
- class DaysController < AuthorizedController
2
- def create
3
- # Create and redirect to index
4
- create! {days_path}
5
- end
6
-
7
- # AJAX methods
8
- def calculate_cash
9
- bills = params[:cash_register].select { |key, value| key.to_f > 5 }
10
- mint = params[:cash_register].select { |key, value| key.to_f <= 5 }
11
-
12
- @cash = bills.map { |a| a[0].to_f * a[1].to_f }.sum
13
- @cash += mint.map { |a| a[1].to_f }.sum
14
- end
15
- end
data/app/models/day.rb DELETED
@@ -1,23 +0,0 @@
1
- class Day < ActiveRecord::Base
2
- # Associations
3
- validates_date :date
4
-
5
- # Scopes
6
- default_scope :order => 'date DESC'
7
-
8
- # Helpers
9
- def to_s
10
- "%s: brutto %0.2f, netto %0.2f" % [date, gross_turnover, net_turnover]
11
- end
12
-
13
- # Callbacks
14
- after_create :create_bookings
15
-
16
- private
17
- def create_bookings
18
- BookingTemplate.create_booking('day:cash', :amount => cash, :value_date => date)
19
- BookingTemplate.create_booking('day:card turnover', :amount => card_turnover, :value_date => date)
20
- BookingTemplate.create_booking('day:expenses', :amount => expenses, :value_date => date)
21
- BookingTemplate.create_booking('day:credit_turnover', :amount => credit_turnover, :value_date => date)
22
- end
23
- end
@@ -1,21 +0,0 @@
1
- = form_for @register, :remote => true, :as =>:cash_register, :url => {:action => 'calculate_cash'}, :html => {:class => 'formtastic cash_register_new'} do |f|
2
- %ul.first
3
- - for i in [ 200, 100, 50, 20, 10 ]
4
- %li
5
- %label
6
- = h i
7
- x
8
- = f.text_field i, :type => 'number'
9
- %ul.second
10
- - for i in [ 5, 2, 1, 0.5, 0.2, 0.1, 0.05 ]
11
- %li
12
- %label
13
- = h i
14
- = f.text_field i, :type => 'number'
15
- %ul#result
16
- %li
17
- %label
18
- = t('activerecord.attributes.day.total') + ':'
19
- #cash
20
- %li
21
- = submit_tag t('activerecord.attributes.day.calculate')
@@ -1,3 +0,0 @@
1
- = render 'calculate'
2
-
3
- = render 'form'
@@ -1,13 +0,0 @@
1
- %tr[day]
2
- %td= day.date
3
- %td.currency= currency_fmt(day.cash)
4
- %td.currency= currency_fmt(day.card_turnover)
5
- %td.currency= currency_fmt(day.gross_turnover)
6
- %td.currency= currency_fmt(day.net_turnover)
7
- %td.currency= currency_fmt(day.client_count)
8
- %td.currency= currency_fmt(day.expenses)
9
- %td.currency= currency_fmt(day.credit_turnover)
10
- %td.currency= currency_fmt(day.discount)
11
- %td.action-links
12
- = list_link_for(:edit, day)
13
- = list_link_for(:delete, day)
@@ -1,15 +0,0 @@
1
- = semantic_form_for @day do |f|
2
- = f.semantic_errors
3
- = f.inputs do
4
- = f.input :date, :as => :date_field, :input_html => {"data-autofocus" => true, :size => 10, :style => 'text-align: right'}
5
- = f.input :cash, :input_html => {:size => 12, :style => 'text-align: right'}
6
- = f.input :card_turnover, :input_html => {:size => 12, :style => 'text-align: right'}
7
- = f.input :gross_turnover, :input_html => {:size => 12, :style => 'text-align: right'}
8
- = f.input :net_turnover, :input_html => {:size => 12, :style => 'text-align: right'}
9
- = f.input :client_count, :input_html => {:size => 12, :style => 'text-align: right'}
10
- = f.input :expenses, :input_html => {:size => 12, :style => 'text-align: right'}
11
- = f.input :credit_turnover, :input_html => {:size => 12, :style => 'text-align: right'}
12
- = f.input :discount, :input_html => {:size => 12, :style => 'text-align: right'}
13
-
14
- = f.buttons do
15
- = f.commit_button
@@ -1 +0,0 @@
1
- $('#cash').html(<%=j @cash.to_s %>)
@@ -1,5 +0,0 @@
1
- = contextual_links
2
-
3
- %h2= t_title
4
-
5
- = render 'form'
@@ -1,19 +0,0 @@
1
- = contextual_links
2
-
3
- %h2= t_title
4
-
5
- = paginated_section @accounts, :params => {:query => params[:query]} do
6
- %table.list#days_list
7
- %tr
8
- %th= t_attr :date
9
- %th.currency= t_attr :cash
10
- %th.currency= t_attr :card_turnover
11
- %th.currency= t_attr :gross_turnover
12
- %th.currency= t_attr :net_turnover
13
- %th.currency= t_attr :client_count
14
- %th.currency= t_attr :expenses
15
- %th.currency= t_attr :credit_turnover
16
- %th.currency= t_attr :discount
17
- %th.action-links
18
-
19
- = render @days
@@ -1,5 +0,0 @@
1
- = contextual_links
2
-
3
- %h1= t('crud.title.day.new', :day => @day.date)
4
-
5
- = render 'complete_form'
@@ -1,35 +0,0 @@
1
- = contextual_links
2
-
3
- %h1= @days
4
-
5
- %table
6
- %tr
7
- %th= t_attr :date
8
- %td= @day.date.to_date
9
- %tr
10
- %th= t_attr :cash
11
- %td= @day.cash
12
- %tr
13
- %th= t_attr :card_turnover
14
- %td= @day.card_turnover
15
- %tr
16
- %th= t_attr :gross_turnover
17
- %td= @day.gross_turnover
18
- %tr
19
- %th= t_attr :net_turnover
20
- %td= @day.net_turnover
21
- %tr
22
- %th= t_attr :client_count
23
- %td= @day.client_count
24
- %tr
25
- %th= t_attr :product_count
26
- %td= @day.product_count
27
- %tr
28
- %th= t_attr :expenses
29
- %td= @day.expenses
30
- %tr
31
- %th= t_attr :credit_turnover
32
- %td= @day.credit_turnover
33
- %tr
34
- %th= t_attr :discount
35
- %td= @day.discount