Run rubocop --fix-layout and remove encoding comments
This commit is contained in:
parent
fa63e6e81d
commit
ea2862fdef
283 changed files with 1164 additions and 1969 deletions
|
|
@ -1,4 +1,3 @@
|
|||
# encoding: utf-8
|
||||
#
|
||||
# Controller for managing orders, i.e. all actions that require the "orders" role.
|
||||
# Normal ordering actions of members of order groups is handled by the OrderingController.
|
||||
|
|
@ -16,12 +15,12 @@ class OrdersController < ApplicationController
|
|||
@per_page = 15
|
||||
if params['sort']
|
||||
sort = case params['sort']
|
||||
when "supplier" then "suppliers.name, ends DESC"
|
||||
when "pickup" then "pickup DESC"
|
||||
when "ends" then "ends DESC"
|
||||
when "supplier_reverse" then "suppliers.name DESC"
|
||||
when "ends_reverse" then "ends"
|
||||
end
|
||||
when "supplier" then "suppliers.name, ends DESC"
|
||||
when "pickup" then "pickup DESC"
|
||||
when "ends" then "ends DESC"
|
||||
when "supplier_reverse" then "suppliers.name DESC"
|
||||
when "ends_reverse" then "ends"
|
||||
end
|
||||
else
|
||||
sort = "ends DESC"
|
||||
end
|
||||
|
|
@ -32,13 +31,13 @@ class OrdersController < ApplicationController
|
|||
# Gives a view for the results to a specific order
|
||||
# Renders also the pdf
|
||||
def show
|
||||
@order= Order.find(params[:id])
|
||||
@order = Order.find(params[:id])
|
||||
@view = (params[:view] || 'default').gsub(/[^-_a-zA-Z0-9]/, '')
|
||||
@partial = case @view
|
||||
when 'default' then 'articles'
|
||||
when 'groups' then 'shared/articles_by/groups'
|
||||
when 'articles' then 'shared/articles_by/articles'
|
||||
else 'articles'
|
||||
when 'default' then 'articles'
|
||||
when 'groups' then 'shared/articles_by/groups'
|
||||
when 'articles' then 'shared/articles_by/articles'
|
||||
else 'articles'
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
|
|
@ -50,10 +49,10 @@ class OrdersController < ApplicationController
|
|||
send_order_pdf @order, params[:document]
|
||||
end
|
||||
format.csv do
|
||||
send_data OrderCsv.new(@order).to_csv, filename: @order.name+'.csv', type: 'text/csv'
|
||||
send_data OrderCsv.new(@order).to_csv, filename: @order.name + '.csv', type: 'text/csv'
|
||||
end
|
||||
format.text do
|
||||
send_data OrderTxt.new(@order).to_txt, filename: @order.name+'.txt', type: 'text/plain'
|
||||
send_data OrderTxt.new(@order).to_txt, filename: @order.name + '.txt', type: 'text/plain'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -163,6 +162,7 @@ class OrdersController < ApplicationController
|
|||
|
||||
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]
|
||||
|
|
@ -186,18 +186,19 @@ class OrdersController < ApplicationController
|
|||
unless oa.units_received.blank?
|
||||
cunits[0] += oa.units_received * oa.article.unit_quantity
|
||||
oacounts = oa.redistribute oa.units_received * oa.price.unit_quantity, rest_to
|
||||
oacounts.each_with_index {|c,i| cunits[i+1]+=c; counts[i+1]+=1 if c>0 }
|
||||
oacounts.each_with_index { |c, i| cunits[i + 1] += c; counts[i + 1] += 1 if c > 0 }
|
||||
end
|
||||
end
|
||||
oa.save!
|
||||
end
|
||||
end
|
||||
return nil if counts[0] == 0
|
||||
|
||||
notice = []
|
||||
notice << I18n.t('orders.update_order_amounts.msg1', count: counts[0], units: cunits[0])
|
||||
notice << I18n.t('orders.update_order_amounts.msg2', count: counts[1], units: cunits[1]) if params[:rest_to_tolerance]
|
||||
notice << I18n.t('orders.update_order_amounts.msg3', count: counts[2], units: cunits[2]) if params[:rest_to_stock]
|
||||
if counts[3]>0 || cunits[3]>0
|
||||
if counts[3] > 0 || cunits[3] > 0
|
||||
notice << I18n.t('orders.update_order_amounts.msg4', count: counts[3], units: cunits[3])
|
||||
end
|
||||
notice.join(', ')
|
||||
|
|
@ -206,5 +207,4 @@ class OrdersController < ApplicationController
|
|||
def remove_empty_article
|
||||
params[:order][:article_ids].reject!(&:blank?) if params[:order] && params[:order][:article_ids]
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue