mirror of
https://github.com/internetee/registry.git
synced 2025-07-28 05:26:17 +02:00
21 lines
432 B
Ruby
21 lines
432 B
Ruby
class Invoice
|
|
class PdfGenerator
|
|
attr_reader :invoice
|
|
|
|
def initialize(invoice)
|
|
@invoice = invoice
|
|
end
|
|
|
|
def as_pdf
|
|
generator = PDFKit.new(invoice_html)
|
|
generator.to_pdf
|
|
end
|
|
|
|
private
|
|
|
|
def invoice_html
|
|
template = invoice.monthly_invoice ? 'invoice/monthly_pdf' : 'invoice/pdf'
|
|
ApplicationController.render(template: template, assigns: { invoice: invoice })
|
|
end
|
|
end
|
|
end
|