fix articles_for_select2 helper

This commit is contained in:
wvengen 2013-12-18 17:34:45 +01:00
parent 2b511ee559
commit 1ab09b41bd
4 changed files with 14 additions and 17 deletions

View file

@ -10,12 +10,17 @@ module DeliveriesHelper
end
end
def articles_for_select2(supplier)
supplier.articles.undeleted.reorder('articles.name ASC').map {|a| {:id => a.id, :text => "#{a.name} (#{number_to_currency a.price}/#{a.unit})"} }
def articles_for_select2(articles, except = [], &block)
articles = articles.reorder('articles.name ASC')
articles.reject! {|a| not except.index(a.id).nil? } if except
block_given? or block = Proc.new {|a| "#{a.name} (#{number_to_currency a.price}/#{a.unit})" }
articles.map do |a|
{:id => a.id, :text => block.call(a)}
end
end
def stock_articles_for_table(supplier)
supplier.stock_articles.undeleted.reorder('articles.name ASC')
def articles_for_table(articles)
articles.undeleted.reorder('articles.name ASC')
end
def stock_change_remove_link(stock_change_form)