complete and improve receive i18n

This commit is contained in:
wvengen 2014-01-08 13:39:49 +01:00
parent 8f14ab31f3
commit ce17bf33e0
3 changed files with 28 additions and 11 deletions

View File

@ -111,7 +111,8 @@ class OrdersController < ApplicationController
unless request.post?
@order_articles = @order.order_articles.ordered.includes(:article)
else
flash[:notice] = "Order received: " + update_order_amounts
s = update_order_amounts
flash[:notice] = (s ? I18n.t('orders.receive.notice', :msg => s) : I18n.t('orders.receive.notice_none'))
redirect_to @order
end
end
@ -156,6 +157,7 @@ class OrdersController < ApplicationController
end
def update_order_amounts
return if not params[:order_articles]
# where to leave remainder during redistribution
rest_to = []
rest_to << :tolerance if params[:rest_to_tolerance]
@ -183,10 +185,12 @@ class OrdersController < ApplicationController
end
end
end
notice = " #{counts.shift} articles (#{cunits.shift} units) updated"
notice += ", #{counts.shift} (#{cunits.shift}) using tolerance" if params[:rest_to_tolerance]
notice += ", #{counts.shift} (#{cunits.shift}) go to stock if foodsoft would support that" if params[:rest_to_stock]
notice += ", #{counts.shift} (#{cunits.shift}) left over"
notice = I18n.t('orders.update_order_amounts.msg1', count: counts.shift, units: cunits.shift)
notice += ", " + I18n.t('orders.update_order_amounts.msg2', count: counts.shift, units: cunits.shift) if params[:rest_to_tolerance]
notice += ", " + I18n.t('orders.update_order_amounts.msg3', count: counts.shift, units: cunits.shift) if params[:rest_to_stock]
if counts[0]>0 or cunits[0]>0
notice += ", " + I18n.t('orders.update_order_amounts.msg4', count: counts.shift, units: cunits.shift)
end
end
end

View File

@ -20,9 +20,9 @@ module OrdersHelper
if order_article.order.open?
nil
else
units_info = "#{order_article.units_to_order} #{heading_helper OrderArticle, :units_to_order}"
units_info += ", #{order_article.units_billed} #{heading_helper OrderArticle, :units_billed}" unless order_article.units_billed.nil?
units_info += ", #{order_article.units_received} #{heading_helper OrderArticle, :units_received}" unless order_article.units_received.nil?
units_info = "#{order_article.units_to_order} #{OrderArticle.human_attribute_name :units_to_order, count: order_article.units_to_order}"
units_info += ", #{order_article.units_billed} #{OrderArticle.human_attribute_name :units_billed_short, count: order_article.units_billed}" unless order_article.units_billed.nil?
units_info += ", #{order_article.units_received} #{OrderArticle.human_attribute_name :units_received_short, count: order_article.units_received}" unless order_article.units_received.nil?
end
end

View File

@ -80,13 +80,19 @@ en:
supplier: Supplier
order_article:
article: Article
missing_units: Missing units
missing_units:
one: Missing unit
other: Missing units
missing_units_short: Missing
quantity: Desired amount
quantity_short: Desired
units_received: Received units
units_received:
one: Received unit
other: Received units
units_received_short: Received
units_to_order: Ordered units
units_to_order:
one: Ordered unit
other: Ordered units
units_to_order_short: Ordered
update_current_price: Globally update current price
order_comment:
@ -1149,6 +1155,8 @@ en:
receive:
add_article: Add article
consider_member_tolerance: consider tolerance
notice: ! 'Order received: %{msg}'
notice_none: No new articles to receive
rest_to_stock: rest to stock
submit: Receive order
surplus_options: 'Distribution options:'
@ -1184,6 +1192,11 @@ en:
open: open
update:
notice: The order was updated.
update_order_amounts:
msg1: "%{count} articles (%{units} units) updated"
msg2: "%{count} (%{units}) using tolerance"
msg3: "%{count} (%{units}) go to stock if foodsoft would support that [don't translate]"
msg4: "%{count} (%{units}) left over"
pages:
all:
new_page: Create new page