2012-10-02 02:50:48 +02:00
|
|
|
# encoding: utf-8
|
|
|
|
class OrderFax < OrderPdf
|
|
|
|
|
|
|
|
def filename
|
2013-04-04 02:04:31 +02:00
|
|
|
I18n.t('documents.order_fax.filename', :name => @order.name, :date => @order.ends.to_date) + '.pdf'
|
2012-10-02 02:50:48 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def title
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
|
|
|
def body
|
|
|
|
contact = FoodsoftConfig[:contact].symbolize_keys
|
|
|
|
|
|
|
|
# From paragraph
|
|
|
|
bounding_box [margin_box.right-200,margin_box.top], width: 200 do
|
2014-03-19 14:01:51 +01:00
|
|
|
text FoodsoftConfig[:name], size: fontsize(9), align: :right
|
2012-10-02 02:50:48 +02:00
|
|
|
move_down 5
|
2014-03-19 14:01:51 +01:00
|
|
|
text contact[:street], size: fontsize(9), align: :right
|
2012-10-02 02:50:48 +02:00
|
|
|
move_down 5
|
2014-03-19 14:01:51 +01:00
|
|
|
text "#{contact[:zip_code]} #{contact[:city]}", size: fontsize(9), align: :right
|
2013-01-30 19:46:18 +01:00
|
|
|
move_down 5
|
2013-06-20 17:17:15 +02:00
|
|
|
unless @order.supplier.try(:customer_number).blank?
|
2014-03-19 14:01:51 +01:00
|
|
|
text "#{Supplier.human_attribute_name :customer_number}: #{@order.supplier[:customer_number]}", size: fontsize(9), align: :right
|
2013-06-20 17:17:15 +02:00
|
|
|
move_down 5
|
|
|
|
end
|
|
|
|
unless contact[:phone].blank?
|
2014-03-19 14:01:51 +01:00
|
|
|
text "#{Supplier.human_attribute_name :phone}: #{contact[:phone]}", size: fontsize(9), align: :right
|
2013-06-20 17:17:15 +02:00
|
|
|
move_down 5
|
|
|
|
end
|
|
|
|
unless contact[:email].blank?
|
2014-03-19 14:01:51 +01:00
|
|
|
text "#{Supplier.human_attribute_name :email}: #{contact[:email]}", size: fontsize(9), align: :right
|
2013-06-20 17:17:15 +02:00
|
|
|
end
|
2012-10-02 02:50:48 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
# Recipient
|
|
|
|
bounding_box [margin_box.left,margin_box.top-60], width: 200 do
|
|
|
|
text @order.name
|
|
|
|
move_down 5
|
2013-03-17 18:10:48 +01:00
|
|
|
text @order.supplier.try(:address).to_s
|
2013-06-20 17:17:15 +02:00
|
|
|
unless @order.supplier.try(:fax).blank?
|
|
|
|
move_down 5
|
2013-10-09 23:41:15 +02:00
|
|
|
text "#{Supplier.human_attribute_name :fax}: #{@order.supplier[:fax]}"
|
2013-06-20 17:17:15 +02:00
|
|
|
end
|
2012-10-02 02:50:48 +02:00
|
|
|
end
|
|
|
|
|
2013-01-30 19:46:18 +01:00
|
|
|
move_down 5
|
2013-04-04 02:04:31 +02:00
|
|
|
text Date.today.strftime(I18n.t('date.formats.default')), align: :right
|
2012-10-02 02:50:48 +02:00
|
|
|
|
|
|
|
move_down 10
|
2013-10-09 23:41:15 +02:00
|
|
|
text "#{Delivery.human_attribute_name :delivered_on}:"
|
2012-10-02 02:50:48 +02:00
|
|
|
move_down 10
|
2013-06-20 17:17:15 +02:00
|
|
|
unless @order.supplier.try(:contact_person).blank?
|
2013-10-09 23:41:15 +02:00
|
|
|
text "#{Supplier.human_attribute_name :contact_person}: #{@order.supplier[:contact_person]}"
|
2013-06-20 17:17:15 +02:00
|
|
|
move_down 10
|
|
|
|
end
|
2012-10-02 02:50:48 +02:00
|
|
|
|
|
|
|
# Articles
|
2013-06-21 02:34:56 +02:00
|
|
|
total = 0
|
2013-04-04 02:04:31 +02:00
|
|
|
data = [I18n.t('documents.order_fax.rows')]
|
2014-08-18 10:56:03 +02:00
|
|
|
data += @order.order_articles.ordered.includes(:article).order('articles.order_number, articles.name').collect do |a|
|
2013-06-21 02:34:56 +02:00
|
|
|
subtotal = a.units_to_order * a.price.unit_quantity * a.price.price
|
|
|
|
total += subtotal
|
2012-10-02 02:50:48 +02:00
|
|
|
[a.article.order_number,
|
|
|
|
a.units_to_order,
|
|
|
|
a.article.name,
|
|
|
|
a.price.unit_quantity,
|
|
|
|
a.article.unit,
|
2013-06-21 02:34:56 +02:00
|
|
|
number_to_currency(a.price.price),
|
|
|
|
number_to_currency(subtotal)]
|
2012-10-02 02:50:48 +02:00
|
|
|
end
|
2013-06-21 02:34:56 +02:00
|
|
|
data << [I18n.t('documents.order_fax.total'), nil, nil, nil, nil, nil, number_to_currency(total)]
|
2014-03-19 14:01:51 +01:00
|
|
|
table data, cell_style: {size: fontsize(8), overflow: :shrink_to_fit} do |table|
|
2013-06-21 02:34:56 +02:00
|
|
|
table.header = true
|
2012-10-02 02:50:48 +02:00
|
|
|
table.cells.border_width = 1
|
|
|
|
table.cells.border_color = '666666'
|
|
|
|
|
2013-06-21 02:34:56 +02:00
|
|
|
table.row(0).border_bottom_width = 2
|
2012-10-02 02:50:48 +02:00
|
|
|
table.columns(1).align = :right
|
2013-06-21 02:34:56 +02:00
|
|
|
table.columns(3..6).align = :right
|
|
|
|
table.row(data.length-1).columns(0..5).borders = [:top, :bottom]
|
|
|
|
table.row(data.length-1).columns(0).borders = [:top, :bottom, :left]
|
|
|
|
table.row(data.length-1).border_top_width = 2
|
2012-10-02 02:50:48 +02:00
|
|
|
end
|
2014-03-19 14:01:51 +01:00
|
|
|
#font_size: fontsize(8),
|
2012-10-02 02:50:48 +02:00
|
|
|
#vertical_padding: 3,
|
|
|
|
#border_style: :grid,
|
|
|
|
#headers: ["BestellNr.", "Menge","Name", "Gebinde", "Einheit","Preis/Einheit"],
|
|
|
|
#align: {0 => :left}
|
|
|
|
end
|
|
|
|
|
2013-01-30 19:46:18 +01:00
|
|
|
end
|