Remove all non-digits before sorting by order number in finance/balancing

* Since order_number is a string, there can be more than a-zA-Z + digits

Signed-off-by: bennibu <benni@dresdener27.de>
This commit is contained in:
sandoz 2009-04-07 01:54:07 +08:00 committed by bennibu
parent 36f9bffdb8
commit 1e011256e9

View file

@ -34,9 +34,9 @@ class Finance::BalancingController < ApplicationController
)
if params[:sort] == "order_number"
@articles = @articles.sort { |a,b| a.article.order_number.gsub(/[a-zA-Z]/, "").to_i <=> b.article.order_number.gsub(/[a-zA-Z]/, "").to_i }
@articles = @articles.sort { |a,b| a.article.order_number.gsub(/[^[:digit:]]/, "").to_i <=> b.article.order_number.gsub(/[^[:digit:]]/, "").to_i }
elsif params[:sort] == "order_number_reverse"
@articles = @articles.sort { |a,b| b.article.order_number.gsub(/[a-zA-Z]/, "").to_i <=> a.article.order_number.gsub(/[a-zA-Z]/, "").to_i }
@articles = @articles.sort { |a,b| b.article.order_number.gsub(/[^[:digit:]]/, "").to_i <=> a.article.order_number.gsub(/[^[:digit:]]/, "").to_i }
end
view = params[:view]