2009-01-08 14:10:51 +01:00
|
|
|
end_date = @order.ends.strftime('%d.%m.%Y')
|
2009-01-29 01:57:51 +01:00
|
|
|
title = "Gruppensortierung für #{@order.supplier.name}, beendet am #{end_date}"
|
2009-01-08 14:10:51 +01:00
|
|
|
|
|
|
|
# Define header and footer
|
|
|
|
pdf.header [pdf.margin_box.left,pdf.margin_box.top+20] do
|
|
|
|
pdf.text title, :size => 10, :align => :center
|
|
|
|
end
|
|
|
|
pdf.footer [pdf.margin_box.left, pdf.margin_box.bottom-5] do
|
|
|
|
pdf.stroke_horizontal_rule
|
|
|
|
pdf.text "Seite #{pdf.page_count}", :size => 8
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# Start rendering
|
2009-01-29 01:57:51 +01:00
|
|
|
groups = @order.group_orders.size
|
2009-01-08 14:10:51 +01:00
|
|
|
counter = 1
|
2009-01-29 01:57:51 +01:00
|
|
|
for group_order in @order.group_orders
|
|
|
|
pdf.text group_order.ordergroup.name, :style => :bold
|
2009-01-08 14:10:51 +01:00
|
|
|
pdf.move_down 5
|
|
|
|
pdf.text "Gruppe #{counter.to_s}/#{groups.to_s}", :size => 8
|
|
|
|
pdf.move_down 5
|
|
|
|
|
|
|
|
total = 0
|
|
|
|
data = []
|
2009-02-03 21:14:48 +01:00
|
|
|
group_order.group_order_articles.ordered.each do |goa|
|
2009-01-29 01:57:51 +01:00
|
|
|
price = goa.order_article.price.fc_price
|
|
|
|
quantity = goa.quantity
|
2009-01-08 14:10:51 +01:00
|
|
|
sub_total = price * quantity
|
|
|
|
total += sub_total
|
2009-01-29 01:57:51 +01:00
|
|
|
data << [goa.order_article.article.name,
|
|
|
|
quantity, number_with_precision(price),
|
|
|
|
goa.order_article.price.unit_quantity,
|
|
|
|
goa.order_article.article.unit,
|
|
|
|
number_with_precision(sub_total)]
|
2009-01-08 14:10:51 +01:00
|
|
|
end
|
2009-01-29 01:57:51 +01:00
|
|
|
data << [ {:text => "Summe", :colspan => 5}, number_with_precision(total)]
|
2009-01-08 14:10:51 +01:00
|
|
|
|
|
|
|
pdf.table data,
|
|
|
|
:font_size => 8,
|
|
|
|
:border_style => :grid,
|
|
|
|
:vertical_padding => 3,
|
|
|
|
:headers => ["Artikel", "Menge", "Preis", "GebGr", "Einheit", "Summe"],
|
|
|
|
:widths => { 0 => 250 },
|
2009-01-29 01:57:51 +01:00
|
|
|
:row_colors => ['ffffff','ececec'],
|
|
|
|
:align => { 0 => :right, 5 => :right }
|
2009-01-08 14:10:51 +01:00
|
|
|
|
|
|
|
counter += 1
|
|
|
|
pdf.move_down 10
|
|
|
|
end
|