foodsoft/app/helpers/order_articles_helper.rb

20 lines
524 B
Ruby
Raw Normal View History

module OrderArticlesHelper
2014-02-15 00:17:37 +01:00
def new_order_articles_collection(&block)
if @order.stockit?
2014-02-15 00:17:37 +01:00
articles = StockArticle.undeleted.reorder('articles.name')
else
2014-02-15 00:17:37 +01:00
articles = @order.supplier.articles.undeleted.reorder('articles.name')
end
2014-02-15 00:17:37 +01:00
unless block_given?
block = Proc.new do |a|
pkg_info = pkg_helper(a, plain: true)
a.name + ' ' +
"(#{a.unit}" +
(pkg_info.blank? ? '' : " #{pkg_info}") + ")"
end
end
articles.map {|a| block.call(a)}
end
2012-06-21 17:19:00 +02:00
end