Class: Nfcom::Builder::XmlBuilder
- Inherits:
-
Object
- Object
- Nfcom::Builder::XmlBuilder
- Includes:
- Utils::Helpers
- Defined in:
- lib/nfcom/builder/xml_builder.rb
Overview
Construtor de XML para NFCom (Nota Fiscal de Comunicação)
Esta classe é responsável por gerar o XML completo da NFCom seguindo o layout 1.00 do schema oficial da SEFAZ.
Constant Summary collapse
- VERSAO_LAYOUT =
'1.00'- NAMESPACE =
'http://www.portalfiscal.inf.br/nfcom'- MODELO_NFCOM =
62- INDIEDEST_CONTRIBUINTE =
Indicadores de IE do destinatário
1- INDIEDEST_ISENTO =
2- INDIEDEST_NAO_CONTRIBUINTE =
9
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
#nota ⇒ Object
readonly
Returns the value of attribute nota.
Instance Method Summary collapse
-
#gerar ⇒ String
Gera o XML completo da NFCom.
-
#initialize(nota, configuration) ⇒ XmlBuilder
constructor
A new instance of XmlBuilder.
Methods included from Utils::Helpers
apenas_numeros, cnpj_valido?, cpf_valido?, formatar_cep, formatar_cnpj, formatar_cpf, formatar_data, formatar_data_hora, formatar_decimal, gerar_id, limitar_texto, remover_acentos, safe_to_date, vazio?
Constructor Details
#initialize(nota, configuration) ⇒ XmlBuilder
Returns a new instance of XmlBuilder.
25 26 27 28 |
# File 'lib/nfcom/builder/xml_builder.rb', line 25 def initialize(nota, configuration) @nota = nota @configuration = configuration end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
14 15 16 |
# File 'lib/nfcom/builder/xml_builder.rb', line 14 def configuration @configuration end |
#nota ⇒ Object (readonly)
Returns the value of attribute nota.
14 15 16 |
# File 'lib/nfcom/builder/xml_builder.rb', line 14 def nota @nota end |
Instance Method Details
#gerar ⇒ String
Gera o XML completo da NFCom
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/nfcom/builder/xml_builder.rb', line 32 def gerar builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml| xml.NFCom(xmlns: NAMESPACE) do xml.infNFCom(versao: VERSAO_LAYOUT, Id: "NFCom#{nota.chave_acesso}") do gerar_ide(xml) gerar_emit(xml) gerar_dest(xml) gerar_assinante(xml) if nota.assinante gerar_sub(xml) if nota.finalidade == :substituicao # gCofat iria aqui (cofaturamento) gerar_detalhes(xml) gerar_total(xml) # gFidelidade iria aqui (programa de fidelidade) gerar_fatura(xml) if nota.fatura # gFatCentral iria aqui (faturamento centralizado) # autXML iria aqui (autorizados para download) gerar_info_adicional(xml) if nota.informacoes_adicionais # gRespTec iria aqui (responsável técnico) end gerar_info_suplementar(xml) end end builder.to_xml(save_with: Nokogiri::XML::Node::SaveOptions::AS_XML) end |