Class: Quote::LetterPdfGenerator

Inherits:
BaseService show all
Includes:
Pdf::Base
Defined in:
app/services/quote/letter_pdf_generator.rb

Overview

Service object: letter pdf generator.

Defined Under Namespace

Classes: Result

Constant Summary collapse

BRAND_COLOR =

Palette — "Modern Executive". Dark charcoal text + warm-maroon logo accent

  • slate-blue secondary accent + light cool-grey for callouts and table rows.
'4A607A'
MARKETING_RED =

slate-blue accent (was orange) — Grand Total bar, buttons, numerals

'983333'
INK =

warm maroon — section eyebrows, links, brand accents

'2B2D2F'
MUTED =

dark charcoal — primary text

'6b7280'
HAIRLINE =

secondary text

'e5e7eb'
SURFACE =

ultra-subtle dividers

'F0F2F5'
'4A607A'
SAVINGS_BG =

slate blue (matches BRAND_COLOR for links)

'F0F2F5'
SAVINGS_BR =

light cool grey for the "You Saved" callout

'd6dae0'
AM_CARD_BG =

complementary border

'F0F2F5'
TESTIMONIAL_BG =

account manager card (unused in consolidated v2)

'd1fae5'
TESTIMONIAL_FG =

legacy

'065f46'
BRAND_TINT_BG =

Tinted card surfaces (now neutral light cool grey to match Option 1).

'F0F2F5'
BRAND_TINT_BR =
'd6dae0'
TRANSPARENT_LOGO_PATH =

Transparent-background WarmlyYours logo (Image #6520 from CRM, downloaded
to public/images/pdf/). Used in the page-level header so the logo sits
cleanly on the grey shaded band without a white box around it.

Rails.public_path.join('images', 'pdf', 'wy-logo-transparent.png').to_s.freeze
STOCK_BADGE_BG =

Success green for the in-stock badge.

'ecfdf5'
STOCK_BADGE_FG =
'047857'
STOCK_BADGE_BR =
'a7f3d0'
CALLOUT_BG =

Neutral callout (for design-alternatives note).

'F0F2F5'
CALLOUT_BR =
MARKETING_RED

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

Attributes inherited from BaseService

#options

Instance Method Summary collapse

Methods inherited from BaseService

#initialize, #log_debug, #log_error, #log_info, #log_warning, #logger, #tagged_logger

Constructor Details

This class inherits a constructor from BaseService

Instance Method Details

#process(quote, options = {}) ⇒ Result

Returns the rendered PDF and quote.

Parameters:

  • quote (Quote)

    the quote to render

  • options (Hash) (defaults to: {})

    section toggles and content overrides (normalized by #normalize_options)

Options Hash (options):

  • show_line_items (Boolean)

    render the consolidated line-items section (defaults to true)

  • show_suggested_services (Boolean)

    render SmartInstall/SmartGuide sections (defaults to true)

  • show_suggested_add_ons (Boolean)

    render the optional add-ons section (defaults to true)

  • show_ordering_information (Boolean)

    render the how-to-order section (defaults to true)

  • suggested_items (Hash)

    suggested line items grouped by room (defaults to empty)

  • suggested_services (Array)

    suggested service line items (defaults to empty)

  • show_room_summary (Boolean)

    render the marketing cover page (defaults to false)

  • condensed_text (Boolean)

    use condensed letter text (defaults to false)

  • show_discount_breakdown (Boolean)

    show per-line discount columns (defaults to false)

  • proforma_invoice (Boolean)

    render as a pro forma invoice (defaults to false)

  • include_addendums (Boolean)

    include quote addendums (defaults to false)

Returns:

  • (Result)

    the rendered PDF and quote



57
58
59
60
61
62
63
64
65
# File 'app/services/quote/letter_pdf_generator.rb', line 57

def process(quote, options = {})
  opts = normalize_options(options)
  composer = build_composer
  draw_body(composer, quote, opts)
  insert_headers_and_footers(composer, quote, opts)
  io = StringIO.new
  composer.write(io, optimize: true)
  Result.new(pdf: io.string, quote: quote)
end