Sha256: 28943c2c53333d08c2b1762ce9f0d6096e98dece1f26258c070957299d7eb29a

Contents?: true

Size: 1.16 KB

Versions: 5

Compression:

Stored size: 1.16 KB

Contents

module BrInvoicesPdf
  module Cfe
    module Renderer
      module Header
        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

5 entries across 5 versions & 1 rubygems

Version Path
br_invoices_pdf-0.2.6 lib/br_invoices_pdf/cfe/renderer/header.rb
br_invoices_pdf-0.2.6.alpha.18 lib/br_invoices_pdf/cfe/renderer/header.rb
br_invoices_pdf-0.2.5.alpha.17 lib/br_invoices_pdf/cfe/renderer/header.rb
br_invoices_pdf-0.2.5 lib/br_invoices_pdf/cfe/renderer/header.rb
br_invoices_pdf-0.2.5.alpha.16 lib/br_invoices_pdf/cfe/renderer/header.rb