i18n financial_transactions + controller

This commit is contained in:
Manuel Wiedenmann 2013-02-11 09:57:33 +07:00
parent 8722a5ed36
commit 640e9799aa
7 changed files with 59 additions and 27 deletions

View file

@ -34,7 +34,7 @@ class Finance::FinancialTransactionsController < ApplicationController
@financial_transaction = FinancialTransaction.new(params[:financial_transaction]) @financial_transaction = FinancialTransaction.new(params[:financial_transaction])
@financial_transaction.user = current_user @financial_transaction.user = current_user
@financial_transaction.add_transaction! @financial_transaction.add_transaction!
redirect_to finance_ordergroup_transactions_url(@ordergroup), :notice => "Die Transaktion wurde gespeichert." redirect_to finance_ordergroup_transactions_url(@ordergroup), notice: t('finance.financial_transactions.create.notice')
rescue ActiveRecord::RecordInvalid => error rescue ActiveRecord::RecordInvalid => error
flash.now[:alert] = error.message flash.now[:alert] = error.message
render :action => :new render :action => :new
@ -51,9 +51,9 @@ class Finance::FinancialTransactionsController < ApplicationController
Ordergroup.find(trans[:ordergroup_id]).add_financial_transaction!(trans[:amount], params[:note], @current_user) Ordergroup.find(trans[:ordergroup_id]).add_financial_transaction!(trans[:amount], params[:note], @current_user)
end end
end end
redirect_to finance_ordergroups_url, notice: "Alle Transaktionen wurden gespeichert." redirect_to finance_ordergroups_url, notice: t('finance.create_collection.create.notice')
rescue => error rescue => error
redirect_to finance_new_transaction_collection_url, alert: "Ein Fehler ist aufgetreten: " + error.to_s redirect_to finance_new_transaction_collection_url, alert: t('finance.create_collection.create.alert', error: error.to_s)
end end
protected protected

View file

@ -3,5 +3,5 @@
= select_tag 'financial_transactions[][ordergroup_id]', = select_tag 'financial_transactions[][ordergroup_id]',
options_for_select(Ordergroup.order(:name).all.map { |g| [ g.name, g.id ] }) options_for_select(Ordergroup.order(:name).all.map { |g| [ g.name, g.id ] })
%td= text_field_tag 'financial_transactions[][amount]', nil, class: 'input-small' %td= text_field_tag 'financial_transactions[][amount]', nil, class: 'input-small'
%td= link_to "Entfernen", "#", :title => "Gruppe enfernen", 'data-remove-transaction' => true, %td= link_to t('.remove'), "#", :title => t('.remove_group'), 'data-remove-transaction' => true,
class: 'btn btn-small' class: 'btn btn-small'

View file

@ -4,10 +4,10 @@
%table.table.table-striped %table.table.table-striped
%thead %thead
%tr %tr
%td= sort_link_helper "Datum", "date" %td= sort_link_helper t('.date'), "date"
%td Wer %td= t('.who')
%td= sort_link_helper "Notiz", "note" %td= sort_link_helper t('.note'), "note"
%td= sort_link_helper "Betrag", "amount" %td= sort_link_helper t('amount'), "amount"
%tbody %tbody
- @financial_transactions.each do |t| - @financial_transactions.each do |t|
%tr %tr

View file

@ -1,18 +1,18 @@
- title "Kontoauszug für #{@ordergroup.name}" - title t('.title', name: @ordergroup.name)
- content_for :actionbar do - content_for :actionbar do
= link_to 'Neue Transaktion anlegen', new_finance_ordergroup_transaction_path(@ordergroup), class: 'btn btn-primary' = link_to t('.new_transaction'), new_finance_ordergroup_transaction_path(@ordergroup), class: 'btn btn-primary'
- content_for :sidebar do - content_for :sidebar do
.well.well-small .well.well-small
%strong Kontostand: #{number_to_currency(@ordergroup.account_balance)} %strong= t('.balance', balance: number_to_currency(@ordergroup.account_balance))
%br/ %br/
%small (zuletzt aktualisiert vor #{distance_of_time_in_words(Time.now, @ordergroup.account_updated)}) %small= t('.last_updated_at', when: distance_of_time_in_words(Time.now, @ordergroup.account_updated))
.well.well-small .well.well-small
= form_tag finance_ordergroup_transactions_path(@ordergroup), :method => :get, :remote => true, = form_tag finance_ordergroup_transactions_path(@ordergroup), :method => :get, :remote => true,
'data-submit-onchange' => true, class: 'form-search' do 'data-submit-onchange' => true, class: 'form-search' do
= text_field_tag :query, params[:query], class: 'input-medium search-query', = text_field_tag :query, params[:query], class: 'input-medium search-query',
placeholder: 'Suchen ...' placeholder: t('.search_placeholder')
#transactions= render 'transactions' #transactions= render 'transactions'

View file

@ -1,6 +1,6 @@
- title "Neue Transaktion" - title t('.title')
%p Hier kannst du der Bestellgruppe <b>#{@ordergroup.name}</b> Geld gutschreiben/abziehen. %p!= t('.paragraph', name: @ordergroup.name)
= simple_form_for @financial_transaction, :url => finance_ordergroup_transactions_path(@ordergroup), = simple_form_for @financial_transaction, :url => finance_ordergroup_transactions_path(@ordergroup),
:validate => true do |f| :validate => true do |f|
@ -9,4 +9,4 @@
= f.input :note, :as => :text = f.input :note, :as => :text
.form-actions .form-actions
= f.submit class: 'btn btn-primary' = f.submit class: 'btn btn-primary'
= link_to "oder abbrechen", finance_ordergroup_transactions_path(@ordergroup) = link_to t('.or_cancel'), finance_ordergroup_transactions_path(@ordergroup)

View file

@ -1,4 +1,4 @@
- title "Mehrere Konten aktualisieren" - title t('.title')
- content_for :javascript do - content_for :javascript do
:javascript :javascript
@ -17,22 +17,20 @@
}); });
- content_for :sidebar do - content_for :sidebar do
.well.well-small .well.well-small= t('.sidebar')
Hier kannst Du mehrere Konten gleichzeitig aktualsieren.
Z.B. alle Überweisungen der Bestellgruppen aus einem Kontoauszug.
= form_tag finance_create_transaction_collection_path do = form_tag finance_create_transaction_collection_path do
%p %p
%b Notiz %b= t('.note')
= text_field_tag :note, params[:note], class: 'input-xlarge', required: 'required' = text_field_tag :note, params[:note], class: 'input-xlarge', required: 'required'
%p %p
%table#ordergroups{:style => "width:20em"} %table#ordergroups{:style => "width:20em"}
%tr %tr
%th Bestellgruppe %th= t('.ordergroup')
%th Betrag %th= t('.amount')
= render :partial => 'ordergroup', :collection => [1, 2, 3] = render :partial => 'ordergroup', :collection => [1, 2, 3]
%p %p
= link_to "Weitere Bestellgruppe hinzufügen", '#', 'data-add-transaction' => true, class: 'btn' = link_to t('.new_ordergroup'), '#', 'data-add-transaction' => true, class: 'btn'
.form-actions .form-actions
= submit_tag "Transaktionen speichern", class: 'btn btn-primary' = submit_tag t('.save'), class: 'btn btn-primary'
= link_to "oder abbrechen", finance_ordergroups_path = link_to t('.or_cancel'), finance_ordergroups_path

View file

@ -96,3 +96,37 @@ de:
tax: 'MwSt' tax: 'MwSt'
refund: 'Pfand' refund: 'Pfand'
add_article: 'Artikel hinzufügen' add_article: 'Artikel hinzufügen'
financial_transactions:
create:
notice: "Die Transaktion wurde gespeichert."
create_collection:
notice: "Alle Transaktionen wurden gespeichert."
alert: "Ein Fehler ist aufgetreten: %{error}"
ordergroup:
remove: "Entfernen"
remove_group: "Gruppe enfernen"
transactions:
date: "Datum"
who: "Wer"
note: "Notiz"
amount: "Betrag"
index:
title: "Kontoauszug für %{name}"
new_transaction: 'Neue Transaktion anlegen'
balance: 'Kontostand: %{balance}'
last_updated_at: '(zuletzt aktualisiert vor %{when})'
search_placeholder: 'Suchen ...'
new_collection:
title: "Mehrere Konten aktualisieren"
sidebar: 'Hier kannst Du mehrere Konten gleichzeitig aktualsieren. Z.B. alle Überweisungen der Bestellgruppen aus einem Kontoauszug.'
new_ordergroup: 'Weitere Bestellgruppe hinzufügen'
ordergroup: 'Bestellgruppe'
note: 'Notiz'
amount: 'Betrag'
save: "Transaktionen speichern"
or_cancel: 'oder abbrechen'
new:
title: "Neue Transaktion"
paragraph: 'Hier kannst du der Bestellgruppe <b>%{name}</b> Geld gutschreiben/abziehen.'
or_cancel: "oder abbrechen"