Files
openfoodnetwork/app/services/invoice_renderer.rb
2019-02-06 14:53:05 +11:00

30 lines
520 B
Ruby

class InvoiceRenderer
def render_to_string(order)
renderer.render_to_string(args(order))
end
def args(order)
{
pdf: "invoice-#{order.number}.pdf",
template: invoice_template,
formats: [:html],
encoding: "UTF-8",
locals: { :@order => order }
}
end
private
def renderer
ApplicationController.new
end
def invoice_template
if Spree::Config.invoice_style2?
"spree/admin/orders/invoice2"
else
"spree/admin/orders/invoice"
end
end
end