2014-03-06 16:26:16 +01:00
|
|
|
class OrderTxt
|
2023-01-06 16:27:41 +01:00
|
|
|
def initialize(order, _options = {})
|
2014-03-06 16:26:16 +01:00
|
|
|
@order = order
|
|
|
|
end
|
|
|
|
|
|
|
|
# Renders the fax-text-file
|
|
|
|
# e.g. for easier use with online-fax-software, which don't accept pdf-files
|
|
|
|
def to_txt
|
|
|
|
supplier = @order.supplier
|
|
|
|
contact = FoodsoftConfig[:contact].symbolize_keys
|
2023-05-12 13:01:12 +02:00
|
|
|
text = I18n.t('orders.fax.heading', name: FoodsoftConfig[:name])
|
|
|
|
text += "\n#{Supplier.human_attribute_name(:customer_number)}: #{supplier.customer_number}" if supplier.customer_number.present?
|
2014-03-06 16:26:16 +01:00
|
|
|
text += "\n" + I18n.t('orders.fax.delivery_day')
|
|
|
|
text += "\n\n#{supplier.name}\n#{supplier.address}\n#{Supplier.human_attribute_name(:fax)}: #{supplier.fax}\n\n"
|
2023-05-12 13:01:12 +02:00
|
|
|
text += '****** ' + I18n.t('orders.fax.to_address') + "\n\n"
|
2014-03-06 16:26:16 +01:00
|
|
|
text += "#{FoodsoftConfig[:name]}\n#{contact[:street]}\n#{contact[:zip_code]} #{contact[:city]}\n\n"
|
2023-05-12 13:01:12 +02:00
|
|
|
text += '****** ' + I18n.t('orders.fax.articles') + "\n\n"
|
|
|
|
text += format("%8s %8s %s\n", I18n.t('orders.fax.number'), I18n.t('orders.fax.amount'),
|
|
|
|
I18n.t('orders.fax.name'))
|
2014-03-06 16:26:16 +01:00
|
|
|
# now display all ordered articles
|
2023-05-12 13:01:12 +02:00
|
|
|
@order.order_articles.ordered.includes(%i[article article_price]).each do |oa|
|
2023-01-06 16:27:41 +01:00
|
|
|
text += format("%8s %8d %s\n", oa.article.order_number, oa.units_to_order.to_i, oa.article.name)
|
2014-03-06 16:26:16 +01:00
|
|
|
end
|
|
|
|
text
|
|
|
|
end
|
|
|
|
end
|