Class: Pdf::Document::Declaration232

Inherits:
BaseService
  • Object
show all
Includes:
Base
Defined in:
app/services/pdf/document/declaration232.rb

Overview

Printable Section 232 steel/aluminum/copper declaration for a delivery —
the PDF twin of the broker xlsm filled by Declaration232::XlsmWriter,
rendered from the same Declaration232.rows so both artifacts always agree
with each other and with the commercial invoice. Folded into the combined
international forms packet printed for the driver.

Defined Under Namespace

Classes: Result

Constant Summary collapse

MARGINS =

Margins.

[25, 20, 25, 20].freeze

Constants included from Base

Base::FONT, Base::NIMBUS_SANS_PATH, Base::NIMBUS_SANS_PATH_BOLD, Base::WY_LOGO_PATH

Instance Method Summary collapse

Constructor Details

#initialize(delivery, _options = {}) ⇒ Declaration232

Returns a new instance of Declaration232.



19
20
21
22
# File 'app/services/pdf/document/declaration232.rb', line 19

def initialize(delivery, _options = {})
  @delivery = delivery
  @order = delivery.order
end

Instance Method Details

#callObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/services/pdf/document/declaration232.rb', line 24

def call
  composer = build_composer(page_orientation: :landscape, margin: MARGINS)

  composer.style(:d232Title, font: "#{FONT} bold", font_size: 13, text_align: :center, margin: [0, 0, 4, 0])
  composer.style(:d232Note, font: FONT, font_size: 8, text_align: :center, line_height: 10)
  composer.style(:d232Regular, font: FONT, font_size: 8, line_height: 10)
  composer.style(:d232Bold, font: "#{FONT} bold", font_size: 8, line_height: 10)

  composer.text('DECLARATION OF STEEL/ALUMINUM/COPPER AND DERIVATIVE ARTICLES', style: :d232Title)
  composer.text("Shipment Reference: #{@order.reference_number}", style: :d232Note)
  composer.text('The preparer certifies that the information provided herein is true, correct, and complete to the best of their knowledge.',
                style: :d232Note)

  insert_preparer_block(composer)
  insert_rows_table(composer)

  io = StringIO.new
  composer.write(io, optimize: true)
  io.rewind
  Result.new(pdf: io.read)
end