Class: Invoicing::PdfGenerator
- Inherits:
-
BaseService
- Object
- BaseService
- Invoicing::PdfGenerator
- Includes:
- Pdf::Base
- Defined in:
- app/services/invoicing/pdf_generator.rb
Defined Under Namespace
Classes: Result
Constant Summary
Constants included from Pdf::Base
Pdf::Base::FONT, Pdf::Base::NIMBUS_SANS_PATH, Pdf::Base::NIMBUS_SANS_PATH_BOLD, Pdf::Base::WY_LOGO_PATH
Instance Attribute Summary collapse
-
#renderer ⇒ Object
readonly
Returns the value of attribute renderer.
Instance Method Summary collapse
-
#initialize(_options = {}) ⇒ PdfGenerator
constructor
A new instance of PdfGenerator.
- #process(invoice, _options = {}) ⇒ Object
Constructor Details
#initialize(_options = {}) ⇒ PdfGenerator
Returns a new instance of PdfGenerator.
10 11 12 |
# File 'app/services/invoicing/pdf_generator.rb', line 10 def initialize( = {}) @renderer = PdfRenderer.new end |
Instance Attribute Details
#renderer ⇒ Object (readonly)
Returns the value of attribute renderer.
8 9 10 |
# File 'app/services/invoicing/pdf_generator.rb', line 8 def renderer @renderer end |
Instance Method Details
#process(invoice, _options = {}) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/services/invoicing/pdf_generator.rb', line 14 def process(invoice, = {}) pdf = PdfCombinator.new @invoice = invoice @eu = invoice.customer.country.eu_country? @currency = Money::Currency.new(invoice.currency) @currency_symbol = @currency.symbol @store = invoice.effective_store @currency_abbrev = "(#{invoice.currency})" @show_tax_info = invoice.show_tax_info? pdf_content = invoice.customer.country.eu_country? ? generate_eu_invoice(invoice, {}) : generate_invoice(invoice, {}) pdf_temp_path = write_temp_file(pdf_content) pdf << PdfCombinator.load(pdf_temp_path) pdf end |