Module: BrInvoicesPdf::Nfce::Parser::EmissionDetails
- Extended by:
- Util::XmlLocate
- Defined in:
- lib/br_invoices_pdf/nfce/parser/emission_details.rb
Constant Summary
collapse
- EMISSION_TYPES =
{
'1': 'Emissão normal',
'2': 'Contingência FS-IA',
'3': 'Contingência SCAN',
'4': 'Contingência DPEC',
'5': 'Contingência FS-DA, com impressão do DANFE em formulário de segurança',
'6': 'Contingência SVC-AN',
'7': 'Contingência SVC-RS',
'9': 'Contingência off-line da NFC-e'
}.freeze
Class Method Summary
collapse
locate_element, node_locate, root_path
Class Method Details
.contingency_params(xml) ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/br_invoices_pdf/nfce/parser/emission_details.rb', line 40
def contingency_params(xml)
emission_path = emission_root_path(xml)
hash = {
type: EMISSION_TYPES[(locate_element(xml, "#{emission_path}/tpEmis") || '1').to_sym],
number: locate_element(xml, "#{emission_path}/nNF"),
serie: locate_element(xml, "#{emission_path}/serie"),
emission_timestamp: locate_element_to_date(xml, "#{emission_path}/dhEmi"),
check_url: check_url(xml)
}
node = xml.locate('infNFeSupl/qrCode').first
hash[:qrcode_url] = node.nodes.first.value if node
hash
end
|
.emission_root_path(xml) ⇒ Object
11
12
13
|
# File 'lib/br_invoices_pdf/nfce/parser/emission_details.rb', line 11
def emission_root_path(xml)
"#{root_path(xml)}/ide"
end
|
.execute(xml) ⇒ Object
26
27
28
|
# File 'lib/br_invoices_pdf/nfce/parser/emission_details.rb', line 26
def execute(xml)
locate_element(xml, 'protNFe/infProt/chNFe') ? normal_params(xml) : contingency_params(xml)
end
|
.normal_params(xml) ⇒ Object
30
31
32
33
34
35
36
37
38
|
# File 'lib/br_invoices_pdf/nfce/parser/emission_details.rb', line 30
def normal_params(xml)
{
**contingency_params(xml),
qrcode_url: xml.locate('NFe/infNFeSupl/qrCode').first.nodes.first.value,
receival_timestamp: locate_element_to_date(xml, 'protNFe/infProt/dhRecbto'),
access_key: locate_element(xml, 'protNFe/infProt/chNFe'),
authorization_protocol: locate_element(xml, 'protNFe/infProt/nProt')
}
end
|