2012-10-02 02:50:48 +02:00
|
|
|
class OrderByArticles < OrderPdf
|
|
|
|
def filename
|
2016-06-04 21:45:24 +02:00
|
|
|
I18n.t('documents.order_by_articles.filename', :name => order.name, :date => order.ends.to_date) + '.pdf'
|
2012-10-02 02:50:48 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def title
|
2016-06-04 21:45:24 +02:00
|
|
|
I18n.t('documents.order_by_articles.title', :name => order.name,
|
2021-03-01 15:27:26 +01:00
|
|
|
:date => order.ends.strftime(I18n.t('date.formats.default')))
|
2012-10-02 02:50:48 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def body
|
2016-06-04 21:45:24 +02:00
|
|
|
each_order_article do |order_article|
|
2013-09-16 23:52:58 +02:00
|
|
|
dimrows = []
|
2017-11-15 19:22:55 +01:00
|
|
|
rows = [[
|
|
|
|
GroupOrder.human_attribute_name(:ordergroup),
|
|
|
|
GroupOrderArticle.human_attribute_name(:ordered),
|
|
|
|
GroupOrderArticle.human_attribute_name(:received),
|
|
|
|
GroupOrderArticle.human_attribute_name(:total_price)
|
|
|
|
]]
|
|
|
|
|
|
|
|
each_group_order_article_for_order_article(order_article) do |goa|
|
|
|
|
dimrows << rows.length if goa.result == 0
|
2016-02-25 02:08:04 +01:00
|
|
|
rows << [goa.group_order.ordergroup_name,
|
2017-11-15 19:22:55 +01:00
|
|
|
group_order_article_quantity_with_tolerance(goa),
|
2012-10-02 02:50:48 +02:00
|
|
|
goa.result,
|
2017-11-15 19:22:55 +01:00
|
|
|
number_to_currency(goa.total_price)]
|
2012-10-02 02:50:48 +02:00
|
|
|
end
|
2017-11-15 19:22:55 +01:00
|
|
|
next unless rows.length > 1
|
2012-10-02 02:50:48 +02:00
|
|
|
|
2017-11-15 19:22:55 +01:00
|
|
|
name = "#{order_article.article.name} (#{order_article.article.unit} | #{order_article.price.unit_quantity} | #{number_to_currency(order_article.price.fc_price)})"
|
2021-02-08 01:05:29 +01:00
|
|
|
name += " #{order_article.order.name}" if @options[:show_supplier]
|
2017-11-15 19:22:55 +01:00
|
|
|
nice_table name, rows, dimrows do |table|
|
|
|
|
table.column(0).width = bounds.width / 2
|
|
|
|
table.columns(1..-1).align = :right
|
2013-09-16 23:52:58 +02:00
|
|
|
table.column(2).font_style = :bold
|
2012-10-02 02:50:48 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2013-04-04 02:04:31 +02:00
|
|
|
end
|