class BrDanfe::DanfeLib::NfceLib::Recipient
Public Class Methods
new(pdf, xml)
click to toggle source
# File lib/br_danfe/danfe_lib/nfce_lib/recipient.rb, line 5 def initialize(pdf, xml) @pdf = pdf @xml = xml end
Public Instance Methods
render()
click to toggle source
# File lib/br_danfe/danfe_lib/nfce_lib/recipient.rb, line 10 def render @pdf.render_blank_line if identified_recipient? render_document @pdf.text @xml['dest/xNome'], options @pdf.text BrDanfe::DanfeLib::NfceLib::Helper.address(@xml.css('enderDest')), options else @pdf.text 'CONSUMIDOR NÃO IDENTIFICADO', options end end
Private Instance Methods
company()
click to toggle source
# File lib/br_danfe/danfe_lib/nfce_lib/recipient.rb, line 51 def company cnpj = BrDocuments::CnpjCpf::Cnpj.new @xml['dest/CNPJ'] "CONSUMIDOR CNPJ: #{cnpj.formatted}" end
company?()
click to toggle source
# File lib/br_danfe/danfe_lib/nfce_lib/recipient.rb, line 47 def company? @xml['dest/CNPJ'].present? end
document()
click to toggle source
# File lib/br_danfe/danfe_lib/nfce_lib/recipient.rb, line 39 def document return company if company? return individual if individual? return foreign if foreign? '' end
foreign()
click to toggle source
# File lib/br_danfe/danfe_lib/nfce_lib/recipient.rb, line 69 def foreign "CONSUMIDOR Id. Estrangeiro: #{@xml['dest/idEstrangeiro']}" end
foreign?()
click to toggle source
# File lib/br_danfe/danfe_lib/nfce_lib/recipient.rb, line 65 def foreign? @xml['dest/idEstrangeiro'].present? end
identified_recipient?()
click to toggle source
# File lib/br_danfe/danfe_lib/nfce_lib/recipient.rb, line 29 def identified_recipient? @xml['dest/xNome'].present? end
individual()
click to toggle source
# File lib/br_danfe/danfe_lib/nfce_lib/recipient.rb, line 60 def individual cpf = BrDocuments::CnpjCpf::Cpf.new(@xml['dest/CPF']) "CONSUMIDOR CPF: #{cpf.formatted}" end
individual?()
click to toggle source
# File lib/br_danfe/danfe_lib/nfce_lib/recipient.rb, line 56 def individual? @xml['dest/CPF'].present? end
options()
click to toggle source
# File lib/br_danfe/danfe_lib/nfce_lib/recipient.rb, line 25 def options { size: 9, align: :center } end
render_document()
click to toggle source
# File lib/br_danfe/danfe_lib/nfce_lib/recipient.rb, line 33 def render_document document_text = document @pdf.text document_text, options if document_text.present? end