2013-12-31 11:41:14 +01:00
|
|
|
module OrderArticlesHelper
|
2012-07-27 18:03:46 +02:00
|
|
|
|
2014-02-15 00:17:37 +01:00
|
|
|
def new_order_articles_collection(&block)
|
2012-07-27 18:03:46 +02:00
|
|
|
if @order.stockit?
|
2014-02-15 00:17:37 +01:00
|
|
|
articles = StockArticle.undeleted.reorder('articles.name')
|
2012-07-27 18:03:46 +02:00
|
|
|
else
|
2014-02-15 00:17:37 +01:00
|
|
|
articles = @order.supplier.articles.undeleted.reorder('articles.name')
|
2012-07-27 18:03:46 +02:00
|
|
|
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)}
|
2012-07-27 18:03:46 +02:00
|
|
|
end
|
2012-06-21 17:19:00 +02:00
|
|
|
end
|