2012-10-02 02:50:48 +02:00
|
|
|
# encoding: utf-8
|
|
|
|
class OrderByArticles < OrderPdf
|
|
|
|
|
|
|
|
def filename
|
2013-04-04 02:04:31 +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
|
2013-04-04 02:04:31 +02:00
|
|
|
I18n.t('documents.order_by_articles.title', :name => @order.name,
|
|
|
|
:date => @order.ends.strftime(I18n.t('date.formats.default')))
|
2012-10-02 02:50:48 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def body
|
|
|
|
@order.order_articles.ordered.each do |order_article|
|
2015-01-03 00:14:38 +01:00
|
|
|
down_or_page
|
|
|
|
|
2012-10-02 02:50:48 +02:00
|
|
|
rows = []
|
2013-09-16 23:52:58 +02:00
|
|
|
dimrows = []
|
2013-09-17 00:25:38 +02:00
|
|
|
for goa in order_article.group_order_articles.ordered
|
2012-10-02 02:50:48 +02:00
|
|
|
rows << [goa.group_order.ordergroup.name,
|
2013-09-16 23:52:58 +02:00
|
|
|
"#{goa.quantity} + #{goa.tolerance}",
|
2012-10-02 02:50:48 +02:00
|
|
|
goa.result,
|
2015-07-10 18:59:50 +02:00
|
|
|
number_to_currency(goa.total_price(order_article))]
|
2013-09-16 23:52:58 +02:00
|
|
|
dimrows << rows.length if goa.result == 0
|
2012-10-02 02:50:48 +02:00
|
|
|
end
|
2013-09-16 23:52:58 +02:00
|
|
|
next if rows.length == 0
|
|
|
|
rows.unshift I18n.t('documents.order_by_articles.rows') # table header
|
2012-10-02 02:50:48 +02:00
|
|
|
|
2015-07-10 18:59:50 +02:00
|
|
|
text "#{order_article.article.name} (#{order_article.article.unit} | #{order_article.price.unit_quantity.to_s} | #{number_to_currency(order_article.price.fc_price)})",
|
2014-03-19 14:01:51 +01:00
|
|
|
style: :bold, size: fontsize(10)
|
|
|
|
table rows, cell_style: {size: fontsize(8), overflow: :shrink_to_fit} do |table|
|
2013-09-16 23:52:58 +02:00
|
|
|
table.column(0).width = 200
|
|
|
|
table.columns(1..3).align = :right
|
|
|
|
table.column(2).font_style = :bold
|
2012-10-02 02:50:48 +02:00
|
|
|
table.cells.border_width = 1
|
|
|
|
table.cells.border_color = '666666'
|
2013-09-16 23:52:58 +02:00
|
|
|
table.rows(0).border_bottom_width = 2
|
|
|
|
# dim rows which were ordered but not received
|
2015-07-10 18:59:50 +02:00
|
|
|
dimrows.each do |ri|
|
|
|
|
table.row(ri).text_color = '999999'
|
|
|
|
table.row(ri).columns(0..-1).font_style = nil
|
|
|
|
end
|
2012-10-02 02:50:48 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-04-04 02:04:31 +02:00
|
|
|
end
|