has_accounts_engine 1.0.4 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,23 @@
1
+ class BookingTemplatesController < AuthorizedController
2
+ # Actions
3
+ def create
4
+ create! do |success, failure|
5
+ success.html { redirect_to collection_path }
6
+ end
7
+ end
8
+
9
+ def update
10
+ update! do |success, failure|
11
+ success.html { redirect_to collection_path }
12
+ end
13
+ end
14
+
15
+ def new_booking
16
+ booking_params = params[:booking] || {}
17
+ booking_params[:value_date] ||= Date.today
18
+ booking_params[:code] ||= (Booking.maximum(:code) || 0) + 1
19
+ booking_parameters = @booking_template.booking_parameters(booking_params)
20
+
21
+ redirect_to simple_edit_bookings_path(:booking => booking_parameters)
22
+ end
23
+ end
@@ -0,0 +1,39 @@
1
+ # encoding: UTF-8
2
+
3
+ class SimpleBookingsController < ApplicationController
4
+ # GET /bookings/new
5
+ def new
6
+ params[:booking] ||= {}
7
+
8
+ if invoice_id = params[:invoice_id]
9
+ params[:booking][:reference_id] = invoice_id
10
+ params[:booking][:reference_type] = 'Invoice'
11
+ end
12
+
13
+ if template_id = params[:booking_template_id]
14
+ template = BookingTemplate.find(template_id)
15
+ @booking = template.build_booking(params[:booking])
16
+ else
17
+ @booking = Booking.new
18
+ end
19
+ @booking.value_date = Date.today
20
+
21
+ render 'show_modal'
22
+ end
23
+
24
+ # PUT /booking
25
+ def create
26
+ if params[:invoice_id]
27
+ @invoice = Invoice.find(params[:invoice_id])
28
+ @booking = @invoice.bookings.build(params[:booking])
29
+ else
30
+ @booking = Booking.new(params[:booking])
31
+ end
32
+
33
+ if @booking.save
34
+ flash[:notice] = 'Buchung erfasst.'
35
+ end
36
+
37
+ redirect_to @invoice
38
+ end
39
+ end
@@ -0,0 +1,17 @@
1
+ module BookingTemplateHelper
2
+ def amount_relations_as_collection
3
+ relations = ['reference_amount', 'reference_balance', 'reference_amount_minus_balance']
4
+ relations.inject({}) do |result, relation|
5
+ result[t(relation, :scope => 'booking_template.relation')] = relation
6
+ result
7
+ end
8
+ end
9
+
10
+ def amount_to_s(booking_template)
11
+ if booking_template.amount_relates_to.present?
12
+ return "%.2f%%" % (booking_template.amount.to_f * 100)
13
+ else
14
+ return currency_fmt(booking_template.amount)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,12 @@
1
+ - item_action ||= lambda{|object| url_for(object)}
2
+
3
+ %tr[booking_template]
4
+ %td
5
+ = link_to "%s" % [booking_template.title, booking_template.code], item_action.call(booking_template), 'data-href-container' => 'tr'
6
+ - if booking_template.comments.present?
7
+ %hr{:style => "height: 1px; margin: 0"}/
8
+ %i= booking_template.comments
9
+ %td= link_to booking_template.credit_account.code, account_path(booking_template.credit_account), :title => booking_template.credit_account.title unless booking_template.credit_account.nil?
10
+ %td= link_to booking_template.debit_account.code, account_path(booking_template.debit_account), :title => booking_template.debit_account.title unless booking_template.debit_account.nil?
11
+ %td.currency= amount_to_s(booking_template)
12
+ %td= t(booking_template.amount_relates_to, :scope => 'booking_template.relation') if booking_template.amount_relates_to.present?
@@ -0,0 +1,26 @@
1
+ = simple_form_for @booking_template do |f|
2
+ .row-fluid
3
+ .span6
4
+ = f.input :title, :input_html => {"data-autofocus" => true}
5
+ .span6
6
+ = f.input :code
7
+ .row-fluid
8
+ .span6
9
+ = f.association :credit_account, :as => :combobox, :collection => accounts_as_collection, :input_html => {:class => 'span6'}
10
+ .span6
11
+ = f.association :debit_account, :as => :combobox, :collection => accounts_as_collection, :input_html => {:class => 'span6'}
12
+ .row-fluid
13
+ .span6
14
+ = f.input :amount
15
+ .span6
16
+ = f.input :amount_relates_to, :collection => amount_relations_as_collection
17
+ .row-fluid
18
+ .span12
19
+ = f.input :tag_list, :input_html => {:class => 'select2-tags'}
20
+
21
+ .row-fluid
22
+ .span12
23
+ = f.input :comments, :input_html => {:rows => 5, :class => 'span12'}
24
+
25
+ .form-actions
26
+ = f.button :submit
@@ -0,0 +1,11 @@
1
+ %table.table.table-striped.booking_templates.collection
2
+ %thead
3
+ %tr
4
+ %th= t_attr :title, BookingTemplate
5
+ %th= t_attr :credit_account, BookingTemplate
6
+ %th= t_attr :debit_account, BookingTemplate
7
+ %th.currency= t_attr 'amount', BookingTemplate
8
+ %th= t_attr :amount_relates_to, BookingTemplate
9
+ %th.action-links
10
+ %tbody
11
+ = render @booking_templates, :item_action => (item_action ||= nil)
@@ -6,7 +6,7 @@
6
6
  = f.input :value_date, :as => :date_field
7
7
  .row-fluid
8
8
  .span6
9
- = f.input :amount, :as => :string, :input_html => {:size => 12}
9
+ = f.input :amount, :as => :string
10
10
  .span6
11
11
  = f.input :code
12
12
 
@@ -25,4 +25,5 @@
25
25
  = f.input :reference_type, :as => :hidden, :input_html => {:value => 'Invoice'}
26
26
  //= f.association :reference, :collection => suggested_invoices_for_booking(@booking, :include_all => true), :as => :combobox, :include_blank => true
27
27
 
28
- = f.button :submit
28
+ .form-actions
29
+ = f.button :submit
@@ -0,0 +1,18 @@
1
+ = simple_form_for @booking, :url => invoice_simple_bookings_path do |f|
2
+ = f.input :debit_account_id, :as => :hidden
3
+ = f.input :credit_account_id, :as => :hidden
4
+ = f.input :reference_id, :as => :hidden
5
+ = f.input :reference_type, :as => :hidden
6
+
7
+ .row-fluid
8
+ .span6
9
+ = f.input :title, :input_html => {"data-autofocus" => true}
10
+ .span6
11
+ = f.input :value_date, :as => :date_field
12
+ .row-fluid
13
+ .span6
14
+ = f.input :amount, :as => :string
15
+
16
+ .row-fluid
17
+ .span12
18
+ = f.input :comments, :input_html => {:rows => 4, :class => 'span12'}
@@ -0,0 +1,9 @@
1
+ .modal{:style => 'width: 80%; left: 10%; margin-left: 0'}
2
+ = modal_header t_title(:new, Booking)
3
+
4
+ .modal-body{:style => 'min-height: 30em'}
5
+ = render 'form'
6
+
7
+ .modal-footer
8
+ = link_to t_action(:new), '#', :class => 'btn submit-button'
9
+ = link_to t_action(:cancel), '#', :class => 'btn', 'data-dismiss' => 'modal'
@@ -7,6 +7,7 @@ de:
7
7
  bank: Bank
8
8
  account_type: Kontentyp
9
9
  booking: Buchung
10
+ booking_template: Buchungsvorlage
10
11
 
11
12
  attributes:
12
13
  account:
@@ -43,6 +44,13 @@ de:
43
44
  destroy: Löschen
44
45
  valuta: Valuta
45
46
  value: Betrag
47
+ booking_template:
48
+ amount_relates_to: "Relativ zu"
49
+ charge_rate_code: Abgabesatz
50
+ credit_account: Soll
51
+ debit_account: Haben
52
+ reference: Referenz
53
+ value_date: Valutadatum
46
54
 
47
55
  form:
48
56
  bank:
@@ -1,3 +1,3 @@
1
1
  module HasAccountsEngine
2
- VERSION = "1.0.4"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_accounts_engine
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-19 00:00:00.000000000 Z
12
+ date: 2013-07-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -136,8 +136,11 @@ files:
136
136
  - app/controllers/accounts_controller.rb
137
137
  - app/controllers/bank_accounts_controller.rb
138
138
  - app/controllers/banks_controller.rb
139
+ - app/controllers/booking_templates_controller.rb
139
140
  - app/controllers/bookings_controller.rb
141
+ - app/controllers/simple_bookings_controller.rb
140
142
  - app/helpers/account_helper.rb
143
+ - app/helpers/booking_template_helper.rb
141
144
  - app/views/accounts/_account.html.haml
142
145
  - app/views/accounts/_booking_item.html.haml
143
146
  - app/views/accounts/_booking_list_footer.html.haml
@@ -161,6 +164,9 @@ files:
161
164
  - app/views/bank_accounts/_form.html.haml
162
165
  - app/views/banks/_bank.html.haml
163
166
  - app/views/banks/_form.html.haml
167
+ - app/views/booking_templates/_booking_template.html.haml
168
+ - app/views/booking_templates/_form.html.haml
169
+ - app/views/booking_templates/_list.html.haml
164
170
  - app/views/bookings/_booking.html.haml
165
171
  - app/views/bookings/_form.html.haml
166
172
  - app/views/bookings/_list.html.haml
@@ -171,6 +177,8 @@ files:
171
177
  - app/views/bookings/select.html.haml
172
178
  - app/views/bookings/show.html.haml
173
179
  - app/views/bookings/simple_edit.html.haml
180
+ - app/views/simple_bookings/_form.html.haml
181
+ - app/views/simple_bookings/_show_modal.html.haml
174
182
  - config/locales/de.yml
175
183
  - config/locales/en.yml
176
184
  - config/routes.rb