Skip to content

Commit

Permalink
complete and improve receive i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
wvengen committed Jan 8, 2014
1 parent 8f14ab3 commit ce17bf3
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
14 changes: 9 additions & 5 deletions app/controllers/orders_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ def receive
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
Expand Down Expand Up @@ -156,6 +157,7 @@ def text_fax_template
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]
Expand Down Expand Up @@ -183,10 +185,12 @@ def update_order_amounts
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
6 changes: 3 additions & 3 deletions app/helpers/orders_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ def units_history_line(order_article)
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

Expand Down
19 changes: 16 additions & 3 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:'
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ce17bf3

Please sign in to comment.