Sha256: 0d7345ccdc2ca1f1ed8469203eab08f2342d5fe83725e0777eb719666cd39ab8

Contents?: true

Size: 1.42 KB

Versions: 2

Compression:

Stored size: 1.42 KB

Contents

# frozen_string_literal: true

module BrInvoicesPdf
  module Nfce
    module Renderer
      module FiscalMessage
        extend Util::BaseRenderer
        extend BaseRenderer

        module_function

        def execute(pdf, data)
          box(pdf, [0, pdf.cursor], page_content_width(pdf)) do
            emission_details(pdf, data)
            emission_date(pdf, data)
            consult_key(pdf, data[:emission_details][:access_key])
          end
        end

        def consult_key(pdf, key)
          pdf.text("CHAVE DE ACESSO:\n#{key.scan(/.{1,4}/).join(' ')}", align: :center)
        end
        private_class_method :consult_key

        # :reek:FeatureEnvy
        def emission_date(pdf, data)
          details = data[:emission_details]
          text = "Emissão: #{format_date(details[:emission_timestamp])} - Via Consumidor\n\n"
          pdf.text(text, align: :center)
          key_text = "Consulte pela chave de acesso em: #{details[:check_url]} \n\n"
          pdf.text(key_text, align: :center)
        end
        private_class_method :emission_date

        # :reek:FeatureEnvy
        def emission_details(pdf, data)
          pdf.text("Mensagem Fiscal\n\n", style: :italic)
          details = data[:emission_details]
          text = "Número: #{details[:number]} - Série: #{details[:serie]}\n\n"
          pdf.text(text, align: :center)
        end
        private_class_method :emission_details
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
br_invoices_pdf-0.2.7 lib/br_invoices_pdf/nfce/renderer/fiscal_message.rb
br_invoices_pdf-0.2.6.alpha.19 lib/br_invoices_pdf/nfce/renderer/fiscal_message.rb