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,11 +649,13 @@ de:
create: create:
notice: Rechnung wurde erstellt. notice: Rechnung wurde erstellt.
financial_transactions: financial_transactions:
create: controller:
notice: Die Transaktion wurde gespeichert. create:
create_collection: notice: Die Transaktion wurde gespeichert.
alert: ! 'Ein Fehler ist aufgetreten: %{error}' create_collection:
notice: Alle Transaktionen wurden gespeichert. alert: ! 'Ein Fehler ist aufgetreten: %{error}'
error_note_required: ! 'Notiz wird benötigt!'
notice: Alle Transaktionen wurden gespeichert.
index: index:
balance: ! 'Kontostand: %{balance}' balance: ! 'Kontostand: %{balance}'
last_updated_at: (zuletzt aktualisiert vor %{when}) last_updated_at: (zuletzt aktualisiert vor %{when})

View File

@ -653,11 +653,13 @@ en:
create: create:
notice: Invoice was created notice: Invoice was created
financial_transactions: financial_transactions:
create: controller:
notice: The transaction was saved. create:
create_collection: notice: The transaction was saved.
alert: ! 'An error occured: %{error}' create_collection:
notice: All transactions were saved. alert: ! 'An error occured: %{error}'
error_note_required: ! 'Note is required!'
notice: All transactions were saved.
index: index:
balance: ! 'Balance of account: %{balance}' balance: ! 'Balance of account: %{balance}'
last_updated_at: (last updated %{when} ago) last_updated_at: (last updated %{when} ago)