Files
openfoodnetwork/app/services/invoice_renderer.rb
Luis Ramos e52937c113 Use rubocop auto correct to add frozen string literal to all files
This is an unsafe auto corection, we will need to trust our build here
2021-06-17 23:07:26 +01:00

34 lines
642 B
Ruby

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