bookyt_salary 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,60 @@
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,15 @@
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 ADDED
@@ -0,0 +1,23 @@
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
@@ -0,0 +1,21 @@
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')
@@ -0,0 +1,3 @@
1
+ = render 'calculate'
2
+
3
+ = render 'form'
@@ -0,0 +1,13 @@
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)
@@ -0,0 +1,15 @@
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
@@ -0,0 +1 @@
1
+ $('#cash').html(<%=j @cash.to_s %>)
@@ -0,0 +1,5 @@
1
+ = contextual_links
2
+
3
+ %h2= t_title
4
+
5
+ = render 'form'
@@ -0,0 +1,19 @@
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
@@ -0,0 +1,5 @@
1
+ = contextual_links
2
+
3
+ %h1= t('crud.title.day.new', :day => @day.date)
4
+
5
+ = render 'complete_form'
@@ -0,0 +1,35 @@
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
@@ -0,0 +1,34 @@
1
+ de:
2
+ activerecord:
3
+ models:
4
+ day: Tagesabschluss
5
+
6
+ attributes:
7
+ day:
8
+ date: Datum
9
+ cash: Bargeldumsatz
10
+ card_turnover: Kreditkartenumsatz
11
+ expenses: Barausgabe
12
+ gross_turnover: Bruttoumsatz
13
+ net_turnover: Nettoumsatz
14
+ client_count: Anzahl Verkäufe
15
+ product_count: Verkaufte Produkte
16
+ credit_turnover: Kreditumsatz
17
+ discount: Rabatt
18
+ from: Abrechnung von
19
+ total: Total
20
+ calculate: Ausrechnen
21
+
22
+ crud:
23
+ title:
24
+ day:
25
+ new: Abrechnung von %{day}
26
+
27
+ bookyt:
28
+ main_navigation:
29
+ days: Tagesabschlüsse
30
+ new_day: Tagesabschluss
31
+
32
+ tooltip:
33
+ new_day: Hier können Sie einen neuen Tagesabschluss gemäss Registrierkasse buchen
34
+ days: Hier finden Sie eine Liste aller Tagesabschlüsse
data/config/routes.rb ADDED
@@ -0,0 +1,8 @@
1
+ Rails.application.routes.draw do
2
+ # Days
3
+ resources :days do
4
+ collection do
5
+ post :calculate_cash
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,15 @@
1
+ module BookytSalary
2
+ module Navigation
3
+ def setup_bookyt_salary(navigation)
4
+ navigation.item :salaries, t_title(:index, Salary), salaries_path,
5
+ :if => Proc.new { user_signed_in? } do |salaries|
6
+ salaries.item :salaries, t_title(:index, Salary), salaries_path, :highlights_on => /\/salaries($|\/[0-9]*($|\/.*))/
7
+ salaries.item :new_salary, t_title(:new, Salary), new_salary_path
8
+ salaries.item :employees, t_title(:index, Employee), employees_path
9
+ salaries.item :employments, t_title(:index, Employment), employments_path, :highlights_on => /\/employments($|\/[0-9]*($|\/.*))/
10
+ salaries.item :salary_statistics, t_title(:statistics, Salary), statistics_salaries_path, :highlights_on => /\/salaries\/statistics($|\?)/
11
+ account_item(salaries, '5000')
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,10 @@
1
+ require 'bookyt_salary'
2
+ require 'rails'
3
+
4
+ module BookytSalary
5
+ class Railtie < Rails::Engine
6
+ initializer :after_initialize do |app|
7
+ app.config.bookyt.engines << 'bookyt_salary'
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,3 @@
1
+ module BookytSalary
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,3 @@
1
+ require 'bookyt_salary/railtie' if defined?(::Rails::Railtie)
2
+
3
+ require 'bookyt_salary/navigation'
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bookyt_salary
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - "Simon H\xC3\xBCrlimann (CyT)"
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-08-03 00:00:00 +02:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: This plugin extends bookyt with Salary functionality.
23
+ email: simon.huerlimann@cyt.ch
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files: []
29
+
30
+ files:
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
43
+ - config/locales/de.yml
44
+ - config/routes.rb
45
+ - lib/bookyt_salary.rb
46
+ - lib/bookyt_salary/navigation.rb
47
+ - lib/bookyt_salary/railtie.rb
48
+ - lib/bookyt_salary/version.rb
49
+ has_rdoc: true
50
+ homepage: https://github.com/huerlisi/bookyt_salary
51
+ licenses: []
52
+
53
+ post_install_message:
54
+ rdoc_options: []
55
+
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ hash: 3
64
+ segments:
65
+ - 0
66
+ version: "0"
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ hash: 3
73
+ segments:
74
+ - 0
75
+ version: "0"
76
+ requirements: []
77
+
78
+ rubyforge_project:
79
+ rubygems_version: 1.3.7
80
+ signing_key:
81
+ specification_version: 3
82
+ summary: Salary plugin for bookyt
83
+ test_files: []
84
+