Class: BrNfe::Product::Response::Build::NfeInutilizacao

Inherits:
Base show all
Defined in:
lib/br_nfe/product/response/build/nfe_inutilizacao.rb

Instance Attribute Summary

Attributes inherited from Base

#operation, #savon_response

Attributes inherited from ActiveModelBase

#reference

Instance Method Summary collapse

Methods inherited from Base

#body_xml, #doc_original_xml, #header_xml, #nf_xmlns, #original_xml, #response, #response_xml, #url_xmlns_retorno, #xml_version, #xml_version_str

Methods inherited from ActiveModelBase

#assign_attributes, #default_values, #initialize

Constructor Details

This class inherits a constructor from BrNfe::ActiveModelBase

Instance Method Details

#info_xmlObject

Responsável por pegar a tag XML principal que contém os dados da homologação. Utilizado para facilitar a codificação e para não repetir o código ao buscar as informações da homologação.



20
21
22
# File 'lib/br_nfe/product/response/build/nfe_inutilizacao.rb', line 20

def info_xml
  @info_xml ||= parse_nokogiri_xml( body_xml.xpath('//ret:nfeInutilizacaoNF2Result/nf:retInutNFe/nf:infInut',  nf: nf_xmlns, ret: url_xmlns_retorno).to_xml )
end

#response_classObject

Responsável por definir qual classe será instânciada para setar os valores de retorno referentes a cada operação.

Type: Class



12
13
14
# File 'lib/br_nfe/product/response/build/nfe_inutilizacao.rb', line 12

def response_class
  BrNfe::Product::Response::NfeInutilizacao
end

#specific_attributesObject

Responsável por setar os atributos específicos para cada tipo de operação. Nesse caso irá setar as informações da homologação da inutilização.

Type: Hash



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/br_nfe/product/response/build/nfe_inutilizacao.rb', line 30

def specific_attributes
  {
    environment:              info_xml.xpath('//infInut/tpAmb').text,
    app_version:              info_xml.xpath('//infInut/verAplic').text,
    processed_at:             info_xml.xpath('//infInut/dhRecbto').text,
    protocol:                 info_xml.xpath('//infInut/nProt').text,
    
    processing_status_code:   info_xml.xpath('//infInut/cStat').text,
    processing_status_motive: info_xml.xpath('//infInut/xMotivo').text,
    
    uf:                   info_xml.xpath('//infInut/cUF').text,
    year:                 info_xml.xpath('//infInut/ano').text,
    cnpj:                 info_xml.xpath('//infInut/CNPJ').text,
    nf_model:             info_xml.xpath('//infInut/mod').text,
    nf_series:            info_xml.xpath('//infInut/serie').text,
    start_invoice_number: info_xml.xpath('//infInut/nNFIni').text,
    end_invoice_number:   info_xml.xpath('//infInut/nNFFin').text,
  }
end