class BrDanfe::DanfeLib::NfeLib::EmitHeader

Public Class Methods

new(pdf, xml, logo, logo_dimensions) click to toggle source
# File lib/br_danfe/danfe_lib/nfe_lib/emit_header.rb, line 5
def initialize(pdf, xml, logo, logo_dimensions)
  @pdf = pdf
  @xml = xml
  @logo = logo
  @logo_dimensions = logo_dimensions
end

Public Instance Methods

render(page, y_position, total) click to toggle source
# File lib/br_danfe/danfe_lib/nfe_lib/emit_header.rb, line 12
def render(page, y_position, total)
  @y_position = y_position
  company_box
  danfe_box(page, total)
  access_key_box
  sefaz_box
  render_emit y_position
end

Private Instance Methods

access_key_box() click to toggle source
# File lib/br_danfe/danfe_lib/nfe_lib/emit_header.rb, line 89
def access_key_box
  @pdf.ibox 2.22, 10.02, 10.29, @y_position
  @pdf.ibarcode 1.50, 8.00, 10.4010, @y_position + 1.90, @xml['infProt > chNFe']
  @pdf.ibox 0.85, 10.02, 10.29, @y_position + 2.22, I18n.t('danfe.chNFe'),
            @xml['infProt > chNFe'].gsub(/(\d)(?=(\d\d\d\d)+(?!\d))/, '\\1 '), style: :bold, align: :center
end
address() click to toggle source
# File lib/br_danfe/danfe_lib/nfe_lib/emit_header.rb, line 40
def address
  "#{@xml['enderEmit/xLgr']}, #{@xml['enderEmit/nro']}\n" \
    "#{@xml['enderEmit/xBairro']} - #{cep}\n" \
    "#{@xml['enderEmit/xMun']}/#{@xml['enderEmit/UF']}\n" \
    "#{phone} #{@xml['enderEmit/email']}"
end
address_company() click to toggle source
# File lib/br_danfe/danfe_lib/nfe_lib/emit_header.rb, line 31
def address_company
  if @logo.blank?
    @pdf.ibox 3.92, 7.46, 1.25, @y_position + 1.46, '', address, align: :left, border: 0
  else
    @pdf.ibox 3.92, 4.7, 3.65, @y_position + 1.46, '', address, size: 8, align: :left, border: 0
    logo
  end
end
cep() click to toggle source
# File lib/br_danfe/danfe_lib/nfe_lib/emit_header.rb, line 51
def cep
  BrDanfe::Helper.format_cep(@xml['enderEmit/CEP'])
end
company_box() click to toggle source
# File lib/br_danfe/danfe_lib/nfe_lib/emit_header.rb, line 23
def company_box
  @pdf.ibox 3.92, 7.46, 0.75, @y_position
  @pdf.ibox 3.92, 7.46, 0.75, @y_position, '', @xml['emit/xNome'],
            size: 12, align: :center, border: 0, style: :bold

  address_company
end
danfe_box(page, total) click to toggle source
# File lib/br_danfe/danfe_lib/nfe_lib/emit_header.rb, line 66
def danfe_box(page, total)
  @pdf.ibox 3.92, 2.08, 8.21, @y_position

  @pdf.ibox 0.60, 2.08, 8.21, @y_position, '', 'DANFE',
            size: 12, align: :center, border: 0, style: :bold

  @pdf.ibox 1.20, 2.08, 8.21, @y_position + 0.60, '', I18n.t('danfe.others.danfe'),
            size: 8, align: :center, border: 0

  @pdf.ibox 0.60, 2.08, 8.21, @y_position + 1.80, '',
            "#{@xml['ide/tpNF']} - " +
            (@xml['ide/tpNF'] == '0' ? I18n.t('danfe.ide.tpNF.entry') : I18n.t('danfe.ide.tpNF.departure')),
            size: 8, align: :center, border: 0

  @pdf.ibox 1.00, 2.08, 8.21, @y_position + 2.40, '',
            I18n.t('danfe.ide.document', nNF: @xml['ide/nNF'], serie: @xml['ide/serie']),
            size: 8, align: :center, valign: :center, border: 0, style: :bold

  @pdf.ibox 1.00, 2.08, 8.21, @y_position + 3.00, '',
            I18n.t('danfe.others.page', current: page, total: total),
            size: 8, align: :center, valign: :center, border: 0, style: :bold
end
phone() click to toggle source
# File lib/br_danfe/danfe_lib/nfe_lib/emit_header.rb, line 47
def phone
  Phone.format(@xml['enderEmit/fone'])
end
render_emit(y_position) click to toggle source
# File lib/br_danfe/danfe_lib/nfe_lib/emit_header.rb, line 101
def render_emit(y_position)
  y_first_line = y_position + 3.92
  y_second_line = y_first_line + LINE_HEIGHT

  @pdf.lbox LINE_HEIGHT, 10.04, 0.75, y_first_line, @xml, 'ide/natOp'
  @pdf.ibox LINE_HEIGHT, 9.52, 10.79, y_first_line, I18n.t('danfe.infProt'),
            "#{@xml['infProt/nProt']} #{BrDanfe::Helper.format_datetime(@xml['infProt/dhRecbto'])}", align: :center

  @pdf.lie LINE_HEIGHT, 6.36, 0.75, y_second_line, @xml, 'enderEmit/UF', 'emit/IE'
  @pdf.lie LINE_HEIGHT, 6.86, 7.11, y_second_line, @xml, 'enderDest/UF', 'emit/IEST'
  @pdf.lcnpj LINE_HEIGHT, 6.34, 13.97, y_second_line, @xml, 'emit/CNPJ'
end
sefaz_box() click to toggle source
# File lib/br_danfe/danfe_lib/nfe_lib/emit_header.rb, line 96
def sefaz_box
  @pdf.ibox 0.85, 10.02, 10.29, @y_position + 3.07, '', I18n.t('danfe.others.sefaz'),
            align: :center, size: 8
end