Sha256: 16d4fd9c6e433a666017e23dddeabe6982f4d46d374aaa21a72f864e5d2b9119

Contents?: true

Size: 1.22 KB

Versions: 23

Compression:

Stored size: 1.22 KB

Contents

# frozen_string_literal: true

module BrInvoicesPdf
  module Cfe
    module Renderer
      module Header
        extend Util::BaseRenderer
        extend BaseRenderer

        module_function

        # :reek:FeatureEnvy
        def execute(pdf, data)
          pdf_setup(pdf) do
            add_header_config(pdf, data, identificator(data))
          end

          pdf.move_down(5)
        end

        def identificator(data)
          cpf = data[:cpf]
          cnpj = data[:cnpj]
          if cpf.to_s.empty?
            if cnpj.to_s.empty?
              'CONSUMIDOR NAO IDENTIFICADO'
            else
              'CONSUMIDOR: ' + format_cnpj(cnpj)
            end
          else
            'CONSUMIDOR: ' + format_cpf(cpf)
          end
        end
        private_class_method :identificator

        def add_header_config(pdf, data, identificator)
          pdf.font('Helvetica', style: :bold)
          pdf.text("Extrato: #{data[:document_number]}", align: :center)
          pdf.text(identificator, align: :center)
          pdf.text('CUPOM FISCAL ELETRONICO - SAT', align: :center)
          pdf.font('Helvetica', style: :normal, align: :center)
        end
        private_class_method :add_header_config
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
br_invoices_pdf-0.2.24 lib/br_invoices_pdf/cfe/renderer/header.rb
br_invoices_pdf-0.2.23 lib/br_invoices_pdf/cfe/renderer/header.rb
br_invoices_pdf-0.2.22 lib/br_invoices_pdf/cfe/renderer/header.rb
br_invoices_pdf-0.2.21 lib/br_invoices_pdf/cfe/renderer/header.rb
br_invoices_pdf-0.2.20 lib/br_invoices_pdf/cfe/renderer/header.rb
br_invoices_pdf-0.2.19 lib/br_invoices_pdf/cfe/renderer/header.rb
br_invoices_pdf-0.2.18 lib/br_invoices_pdf/cfe/renderer/header.rb
br_invoices_pdf-0.2.17 lib/br_invoices_pdf/cfe/renderer/header.rb
br_invoices_pdf-0.2.16 lib/br_invoices_pdf/cfe/renderer/header.rb
br_invoices_pdf-0.2.15 lib/br_invoices_pdf/cfe/renderer/header.rb
br_invoices_pdf-0.2.14 lib/br_invoices_pdf/cfe/renderer/header.rb
br_invoices_pdf-0.2.14.alpha.23 lib/br_invoices_pdf/cfe/renderer/header.rb
br_invoices_pdf-0.2.13 lib/br_invoices_pdf/cfe/renderer/header.rb
br_invoices_pdf-0.2.13.alpha.22 lib/br_invoices_pdf/cfe/renderer/header.rb
br_invoices_pdf-0.2.12.alpha.21 lib/br_invoices_pdf/cfe/renderer/header.rb
br_invoices_pdf-0.2.12.alpha.20 lib/br_invoices_pdf/cfe/renderer/header.rb
br_invoices_pdf-0.2.12 lib/br_invoices_pdf/cfe/renderer/header.rb
br_invoices_pdf-0.2.11 lib/br_invoices_pdf/cfe/renderer/header.rb
br_invoices_pdf-0.2.10 lib/br_invoices_pdf/cfe/renderer/header.rb
br_invoices_pdf-0.2.9 lib/br_invoices_pdf/cfe/renderer/header.rb