Sha256: 5f22cc18f9334113208d25c460d8fa6eb4f58ed29b04906c67366dc5a4233cc3

Contents?: true

Size: 1.41 KB

Versions: 23

Compression:

Stored size: 1.41 KB

Contents

# frozen_string_literal: true

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

        module_function

        def execute(pdf, data)
          box(pdf, [0, pdf.cursor], page_content_width(pdf)) do
            customer = data[:customer]
            add_customer_identification(pdf, data, identificator(customer[:identification_type],
                                                                 customer[:identification]))
          end
        end

        def identificator(identification, number)
          id = identification

          case id
          when 'CPF'
            "CPF DO CONSUMIDOR: #{format_cpf(number)}"
          when 'CNPJ'
            "CNPJ DO CONSUMIDOR: #{format_cnpj(number)}"
          when 'idEstrangeiro'
            "ID. ESTRANGEIRO: #{number}"
          else
            'CONSUMIDOR NÃO IDENTIFICADO'
          end
        end
        private_class_method :identificator

        # :reek:FeatureEnvy
        def add_customer_identification(pdf, data, identificator)
          address = data[:customer][:address]
          pdf.text("Consumidor\n\n", style: :italic)
          pdf.text(identificator, align: :center)
          pdf.text(format_address(address), align: :center) if address[:streetname]
        end
        private_class_method :add_customer_identification
      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/nfce/renderer/customer_identification.rb
br_invoices_pdf-0.2.23 lib/br_invoices_pdf/nfce/renderer/customer_identification.rb
br_invoices_pdf-0.2.22 lib/br_invoices_pdf/nfce/renderer/customer_identification.rb
br_invoices_pdf-0.2.21 lib/br_invoices_pdf/nfce/renderer/customer_identification.rb
br_invoices_pdf-0.2.20 lib/br_invoices_pdf/nfce/renderer/customer_identification.rb
br_invoices_pdf-0.2.19 lib/br_invoices_pdf/nfce/renderer/customer_identification.rb
br_invoices_pdf-0.2.18 lib/br_invoices_pdf/nfce/renderer/customer_identification.rb
br_invoices_pdf-0.2.17 lib/br_invoices_pdf/nfce/renderer/customer_identification.rb
br_invoices_pdf-0.2.16 lib/br_invoices_pdf/nfce/renderer/customer_identification.rb
br_invoices_pdf-0.2.15 lib/br_invoices_pdf/nfce/renderer/customer_identification.rb
br_invoices_pdf-0.2.14 lib/br_invoices_pdf/nfce/renderer/customer_identification.rb
br_invoices_pdf-0.2.14.alpha.23 lib/br_invoices_pdf/nfce/renderer/customer_identification.rb
br_invoices_pdf-0.2.13 lib/br_invoices_pdf/nfce/renderer/customer_identification.rb
br_invoices_pdf-0.2.13.alpha.22 lib/br_invoices_pdf/nfce/renderer/customer_identification.rb
br_invoices_pdf-0.2.12.alpha.21 lib/br_invoices_pdf/nfce/renderer/customer_identification.rb
br_invoices_pdf-0.2.12.alpha.20 lib/br_invoices_pdf/nfce/renderer/customer_identification.rb
br_invoices_pdf-0.2.12 lib/br_invoices_pdf/nfce/renderer/customer_identification.rb
br_invoices_pdf-0.2.11 lib/br_invoices_pdf/nfce/renderer/customer_identification.rb
br_invoices_pdf-0.2.10 lib/br_invoices_pdf/nfce/renderer/customer_identification.rb
br_invoices_pdf-0.2.9 lib/br_invoices_pdf/nfce/renderer/customer_identification.rb