This commit is contained in:
wvengen 2013-10-02 17:23:49 +02:00
parent a8ace3bc79
commit 17bbb0705b
3 changed files with 18 additions and 14 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: t('finance.financial_transactions.create.notice') redirect_to finance_ordergroup_transactions_url(@ordergroup), notice: I18n.t('finance.financial_transactions.controller.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
@ -44,16 +44,16 @@ class Finance::FinancialTransactionsController < ApplicationController
end end
def create_collection def create_collection
raise "Notiz wird benötigt!" if params[:note].blank? raise I18n.t('finance.financial_transactions.controller.create_collection.error_note_required') if params[:note].blank?
params[:financial_transactions].each do |trans| params[:financial_transactions].each do |trans|
# ignore empty amount fields ... # ignore empty amount fields ...
unless trans[:amount].blank? unless trans[:amount].blank?
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: t('finance.create_collection.create.notice') redirect_to finance_ordergroups_url, notice: I18n.t('finance.financial_transactions.controller.create_collection.notice')
rescue => error rescue => error
redirect_to finance_new_transaction_collection_url, alert: t('finance.create_collection.create.alert', error: error.to_s) redirect_to finance_new_transaction_collection_url, alert: I18n.t('finance.financial_transactions.controller.create_collection.alert', error: error.to_s)
end end
protected protected

View file

@ -649,10 +649,12 @@ de:
create: create:
notice: Rechnung wurde erstellt. notice: Rechnung wurde erstellt.
financial_transactions: financial_transactions:
controller:
create: create:
notice: Die Transaktion wurde gespeichert. notice: Die Transaktion wurde gespeichert.
create_collection: create_collection:
alert: ! 'Ein Fehler ist aufgetreten: %{error}' alert: ! 'Ein Fehler ist aufgetreten: %{error}'
error_note_required: ! 'Notiz wird benötigt!'
notice: Alle Transaktionen wurden gespeichert. notice: Alle Transaktionen wurden gespeichert.
index: index:
balance: ! 'Kontostand: %{balance}' balance: ! 'Kontostand: %{balance}'

View file

@ -653,10 +653,12 @@ en:
create: create:
notice: Invoice was created notice: Invoice was created
financial_transactions: financial_transactions:
controller:
create: create:
notice: The transaction was saved. notice: The transaction was saved.
create_collection: create_collection:
alert: ! 'An error occured: %{error}' alert: ! 'An error occured: %{error}'
error_note_required: ! 'Note is required!'
notice: All transactions were saved. notice: All transactions were saved.
index: index:
balance: ! 'Balance of account: %{balance}' balance: ! 'Balance of account: %{balance}'