nfe_reader 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +10 -1
- data/lib/helpers/attribute_helper.rb +18 -0
- data/lib/helpers/creator_helper.rb +32 -0
- data/lib/nfe_reader/authorization.rb +10 -6
- data/lib/nfe_reader/carrier.rb +14 -10
- data/lib/nfe_reader/collection/duplicate.rb +10 -6
- data/lib/nfe_reader/collection.rb +28 -24
- data/lib/nfe_reader/customer.rb +56 -52
- data/lib/nfe_reader/delivery.rb +18 -14
- data/lib/nfe_reader/document.rb +65 -61
- data/lib/nfe_reader/export.rb +9 -5
- data/lib/nfe_reader/fiscal.rb +31 -27
- data/lib/nfe_reader/header.rb +120 -117
- data/lib/nfe_reader/information.rb +17 -26
- data/lib/nfe_reader/nfe.rb +130 -0
- data/lib/nfe_reader/product/armament.rb +20 -16
- data/lib/nfe_reader/product/cane.rb +22 -32
- data/lib/nfe_reader/product/exportation.rb +17 -13
- data/lib/nfe_reader/product/fuel.rb +15 -11
- data/lib/nfe_reader/product/importation.rb +44 -40
- data/lib/nfe_reader/product/medicament.rb +17 -13
- data/lib/nfe_reader/product/vehicle.rb +115 -111
- data/lib/nfe_reader/product.rb +67 -76
- data/lib/nfe_reader/provider.rb +39 -35
- data/lib/nfe_reader/purchase.rb +10 -6
- data/lib/nfe_reader/removal.rb +18 -14
- data/lib/nfe_reader/taxation/cofins.rb +41 -37
- data/lib/nfe_reader/taxation/cofins_st.rb +17 -13
- data/lib/nfe_reader/taxation/icms.rb +80 -76
- data/lib/nfe_reader/taxation/importation_tax.rb +16 -12
- data/lib/nfe_reader/taxation/ipi.rb +37 -33
- data/lib/nfe_reader/taxation/issqn.rb +19 -15
- data/lib/nfe_reader/taxation/pis.rb +41 -37
- data/lib/nfe_reader/taxation/pis_st.rb +18 -14
- data/lib/nfe_reader/total.rb +71 -67
- data/lib/nfe_reader/transport.rb +87 -83
- data/lib/nfe_reader/version.rb +1 -1
- data/lib/nfe_reader.rb +3 -130
- data/test/helpers/attributte_helper_test.rb +19 -0
- data/test/helpers/creator_helper_test.rb +28 -0
- data/test/{nokogiri_test.rb → helpers/nokogiri_test.rb} +1 -1
- data/test/nfe_reader/authorization_test.rb +2 -2
- data/test/nfe_reader/cane_test.rb +2 -2
- data/test/nfe_reader/carrier_test.rb +2 -2
- data/test/nfe_reader/collection/duplicate_test.rb +2 -2
- data/test/nfe_reader/collection_test.rb +3 -3
- data/test/nfe_reader/customer_test.rb +3 -3
- data/test/nfe_reader/delivery_test.rb +2 -2
- data/test/nfe_reader/document_test.rb +2 -2
- data/test/nfe_reader/export_test.rb +2 -2
- data/test/nfe_reader/fiscal_test.rb +2 -2
- data/test/nfe_reader/header_test.rb +2 -2
- data/test/nfe_reader/information_test.rb +2 -2
- data/test/{nfe_reader_test.rb → nfe_reader/nfe_test.rb} +15 -15
- data/test/nfe_reader/product/armament_test.rb +2 -2
- data/test/nfe_reader/product/exportation_test.rb +2 -2
- data/test/nfe_reader/product/fuel_test.rb +2 -2
- data/test/nfe_reader/product/importation_test.rb +27 -2
- data/test/nfe_reader/product/medicament_test.rb +2 -2
- data/test/nfe_reader/product/vehicle_test.rb +2 -2
- data/test/nfe_reader/product_test.rb +6 -6
- data/test/nfe_reader/provider_test.rb +3 -3
- data/test/nfe_reader/purchase_test.rb +2 -2
- data/test/nfe_reader/removal_test.rb +2 -2
- data/test/nfe_reader/taxation/cofins_st_test.rb +2 -2
- data/test/nfe_reader/taxation/cofins_test.rb +2 -2
- data/test/nfe_reader/taxation/icms_test.rb +2 -2
- data/test/nfe_reader/taxation/importation_tax_test.rb +2 -2
- data/test/nfe_reader/taxation/ipi_test.rb +2 -2
- data/test/nfe_reader/taxation/issqn_test.rb +2 -2
- data/test/nfe_reader/taxation/pis_st_test.rb +2 -2
- data/test/nfe_reader/taxation/pis_test.rb +2 -2
- data/test/nfe_reader/total_test.rb +2 -2
- data/test/nfe_reader/transport_test.rb +3 -3
- metadata +14 -7
- /data/lib/{nokogiri_hash.rb → helpers/nokogiri_hash.rb} +0 -0
data/lib/nfe_reader/header.rb
CHANGED
@@ -1,129 +1,132 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
module Nfe
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
:environment, :finality, :version, :payment, :process, :digit,
|
8
|
-
:orientation, :emission_date, :destiny_code, :final_consumer,
|
9
|
-
:consumer_presence, :contingency_date, :contingency_justification,
|
10
|
-
:documents
|
3
|
+
module Reader
|
4
|
+
# Identificação da Nota Fiscal eletrônica
|
5
|
+
class Header
|
6
|
+
include ::AttributeHelper
|
11
7
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
# 51-Mato Grosso, 52-Goiás, 53-DistritoFederal
|
19
|
-
#
|
20
|
-
# mod: 55 - NF-e, 65 - NFC-e
|
21
|
-
#
|
22
|
-
# indPag: 0 - Vista, 1 - Prazo, 2 - Outros
|
23
|
-
#
|
24
|
-
# tpNF: 0 - Entrada, 1 - Saida
|
25
|
-
#
|
26
|
-
# tpAmb: 1 - Producao, 2 - Homologacao
|
27
|
-
#
|
28
|
-
# finNFe: 1 - Normal,
|
29
|
-
# 2 - Complementar,
|
30
|
-
# 3 - Ajuste,
|
31
|
-
# 4 - Devolução/Retorno.
|
32
|
-
#
|
33
|
-
# tpEmis: 1 - Normal, 2 - Contingência FS, 3 - Contingência SCAN, 4 - Contingência FS-DA
|
34
|
-
#
|
35
|
-
# tpImp: 1 - Retrato,
|
36
|
-
# 2 - Paisagem,
|
37
|
-
# 3 - DANFE Simplificado,
|
38
|
-
# 4 - DANFE NFC-e,
|
39
|
-
# 5 - DANFE NFC-e em mensagem eletrônica (o envio de
|
40
|
-
# mensagem eletrônica pode ser feita de forma simultânea
|
41
|
-
# com a impressão do DANFE; usar o tpImp=5 quando
|
42
|
-
# esta for a única forma de disponibilização do DANFE).
|
43
|
-
#
|
44
|
-
# procEmit: 0 - emissão de NF-e com aplicativo do contribuinte,
|
45
|
-
# 1 - emissão de NF-e avulsa pelo Fisco,
|
46
|
-
# 2 - emissão de NF-e avulsa, pelo site,
|
47
|
-
# 3 - emissão NF-e pelo contribuinte com aplicativo fornecido pelo Fisco,
|
48
|
-
#
|
49
|
-
# idDest: 1 - Operação interna,
|
50
|
-
# 2 - Operação interestadual,
|
51
|
-
# 3 - Operação com exterior
|
52
|
-
#
|
53
|
-
# indFinal: 0 - Não,
|
54
|
-
# 1 - Consumidor final
|
55
|
-
#
|
56
|
-
# indPres: 0 - Não se aplica (por exemplo, Nota Fiscal complementar
|
57
|
-
# ou de ajuste);
|
58
|
-
# 1 - Operação presencial;
|
59
|
-
# 2 - Operação não presencial, pela Internet;
|
60
|
-
# 3 - Operação não presencial, Teleatendimento;
|
61
|
-
# 4 - NFC-e em operação com entrega a domicílio;
|
62
|
-
# 9 - Operação não presencial, outros.
|
8
|
+
attr_reader :state, :city, :sample_number, :operation, :number,
|
9
|
+
:model, :emission, :emission_kind, :out, :out_time, :serie, :kind,
|
10
|
+
:environment, :finality, :version, :payment, :process, :digit,
|
11
|
+
:orientation, :emission_date, :destiny_code, :final_consumer,
|
12
|
+
:consumer_presence, :contingency_date, :contingency_justification,
|
13
|
+
:documents
|
63
14
|
|
64
|
-
|
65
|
-
#
|
66
|
-
|
67
|
-
#
|
68
|
-
|
69
|
-
#
|
70
|
-
|
71
|
-
#
|
72
|
-
|
73
|
-
#
|
74
|
-
|
75
|
-
#
|
76
|
-
|
77
|
-
#
|
78
|
-
|
79
|
-
#
|
80
|
-
|
81
|
-
#
|
82
|
-
|
83
|
-
#
|
84
|
-
|
85
|
-
#
|
86
|
-
|
87
|
-
#
|
88
|
-
|
89
|
-
#
|
90
|
-
|
91
|
-
#
|
92
|
-
|
93
|
-
#
|
94
|
-
|
95
|
-
#
|
96
|
-
|
97
|
-
#
|
98
|
-
|
99
|
-
#
|
100
|
-
|
101
|
-
#
|
102
|
-
|
103
|
-
#
|
104
|
-
|
105
|
-
#
|
106
|
-
|
107
|
-
#
|
108
|
-
|
109
|
-
#
|
110
|
-
|
15
|
+
# == Fields Values
|
16
|
+
#
|
17
|
+
# cUF: 11-Rondônia, 12-Acre, 13-Amazonas, 14-Roraima, 15-Pará, 16-Amapá, 17-Tocantins,
|
18
|
+
# 21-Maranhão, 22-Piauí, 23-Ceará, 24-Rio Grande do Norte, 25-Paraíba, 26-Pernambuco,
|
19
|
+
# 27-Alagoas, 28-Sergipe, 29-Bahia, 31-Minas Gerais, 32-Espírito Santo, 33-Rio de Janeiro,
|
20
|
+
# 35-São Paulo, 41-Paraná, 42-Santa Catarina, 3-Rio Grande do Sul, 50-Mato Grosso do Sul,
|
21
|
+
# 51-Mato Grosso, 52-Goiás, 53-DistritoFederal
|
22
|
+
#
|
23
|
+
# mod: 55 - NF-e, 65 - NFC-e
|
24
|
+
#
|
25
|
+
# indPag: 0 - Vista, 1 - Prazo, 2 - Outros
|
26
|
+
#
|
27
|
+
# tpNF: 0 - Entrada, 1 - Saida
|
28
|
+
#
|
29
|
+
# tpAmb: 1 - Producao, 2 - Homologacao
|
30
|
+
#
|
31
|
+
# finNFe: 1 - Normal,
|
32
|
+
# 2 - Complementar,
|
33
|
+
# 3 - Ajuste,
|
34
|
+
# 4 - Devolução/Retorno.
|
35
|
+
#
|
36
|
+
# tpEmis: 1 - Normal, 2 - Contingência FS, 3 - Contingência SCAN, 4 - Contingência FS-DA
|
37
|
+
#
|
38
|
+
# tpImp: 1 - Retrato,
|
39
|
+
# 2 - Paisagem,
|
40
|
+
# 3 - DANFE Simplificado,
|
41
|
+
# 4 - DANFE NFC-e,
|
42
|
+
# 5 - DANFE NFC-e em mensagem eletrônica (o envio de
|
43
|
+
# mensagem eletrônica pode ser feita de forma simultânea
|
44
|
+
# com a impressão do DANFE; usar o tpImp=5 quando
|
45
|
+
# esta for a única forma de disponibilização do DANFE).
|
46
|
+
#
|
47
|
+
# procEmit: 0 - emissão de NF-e com aplicativo do contribuinte,
|
48
|
+
# 1 - emissão de NF-e avulsa pelo Fisco,
|
49
|
+
# 2 - emissão de NF-e avulsa, pelo site,
|
50
|
+
# 3 - emissão NF-e pelo contribuinte com aplicativo fornecido pelo Fisco,
|
51
|
+
#
|
52
|
+
# idDest: 1 - Operação interna,
|
53
|
+
# 2 - Operação interestadual,
|
54
|
+
# 3 - Operação com exterior
|
55
|
+
#
|
56
|
+
# indFinal: 0 - Não,
|
57
|
+
# 1 - Consumidor final
|
58
|
+
#
|
59
|
+
# indPres: 0 - Não se aplica (por exemplo, Nota Fiscal complementar
|
60
|
+
# ou de ajuste);
|
61
|
+
# 1 - Operação presencial;
|
62
|
+
# 2 - Operação não presencial, pela Internet;
|
63
|
+
# 3 - Operação não presencial, Teleatendimento;
|
64
|
+
# 4 - NFC-e em operação com entrega a domicílio;
|
65
|
+
# 9 - Operação não presencial, outros.
|
111
66
|
|
112
|
-
|
113
|
-
|
114
|
-
|
67
|
+
def initialize(attrs = {})
|
68
|
+
# Estado
|
69
|
+
@state = attrs[:cUF]
|
70
|
+
# Cidade
|
71
|
+
@city = attrs[:cMunFG]
|
72
|
+
# Numero Aleatorio
|
73
|
+
@sample_number = attrs[:cNF]
|
74
|
+
# Natureza Operacao
|
75
|
+
@operation = attrs[:natOp]
|
76
|
+
# Numero da Nota
|
77
|
+
@number = attrs[:nNF]
|
78
|
+
# Modelo
|
79
|
+
@model = attrs[:mod]
|
80
|
+
# Data Emissao
|
81
|
+
@emission = attrs[:dEmi]
|
82
|
+
# Tipo de Emissao
|
83
|
+
@emission_kind = attrs[:tpEmis]
|
84
|
+
# Data de Saida
|
85
|
+
@out = attrs[:dSaiEnt]
|
86
|
+
# Hora de Saida
|
87
|
+
@out_time = attrs[:hSaiEnt]
|
88
|
+
# Data de Emissao
|
89
|
+
@emission_date = attrs[:dhEmi]
|
90
|
+
# Serie
|
91
|
+
@serie = attrs[:serie]
|
92
|
+
# Tipo da Nota
|
93
|
+
@kind = attrs[:tpNF]
|
94
|
+
# Ambiente
|
95
|
+
@environment = attrs[:tpAmb]
|
96
|
+
# Finalidade
|
97
|
+
@finality = attrs[:finNFe]
|
98
|
+
# Versao aplicativo do emissor
|
99
|
+
@version = attrs[:verProc]
|
100
|
+
# Pagamento
|
101
|
+
@payment = attrs[:indPag]
|
102
|
+
# Processo de Emissao
|
103
|
+
@process = attrs[:procEmi]
|
104
|
+
# Digito Verificador
|
105
|
+
@digit = attrs[:cDV]
|
106
|
+
# Orientação da Pagina
|
107
|
+
@orientation = attrs[:tpImp]
|
108
|
+
# Codigo do Destino
|
109
|
+
@destiny_code = attrs[:idDest]
|
110
|
+
# Consumidor final
|
111
|
+
@final_consumer = attrs[:indFinal]
|
112
|
+
# Indicador de presença do comprador
|
113
|
+
@consumer_presence = attrs[:indPres]
|
115
114
|
|
116
|
-
|
117
|
-
|
115
|
+
# Contigencia
|
116
|
+
@contingency_date = attrs[:dhCont]
|
117
|
+
@contingency_justification = attrs[:xJust]
|
118
118
|
|
119
|
-
|
120
|
-
|
121
|
-
|
119
|
+
# Documento Fiscal Referenciado
|
120
|
+
@documents = []
|
121
|
+
|
122
|
+
if attrs[:NFref].is_a? Array
|
123
|
+
attrs[:NFref].each do |document|
|
124
|
+
@documents << Document.new(document)
|
125
|
+
end
|
126
|
+
elsif attrs[:NFref].is_a? Hash
|
127
|
+
@documents << Document.new(attrs[:NFref])
|
122
128
|
end
|
123
|
-
elsif attrs[:NFref].is_a? Hash
|
124
|
-
@documents << Nfe::Document.new(attrs[:NFref])
|
125
129
|
end
|
126
|
-
|
127
130
|
end
|
128
131
|
end
|
129
132
|
end
|
@@ -1,38 +1,29 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
module Nfe
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
module Reader
|
4
|
+
class Information
|
5
|
+
include ::AttributeHelper
|
6
|
+
include ::CreatorHelper
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
@information_taxpayer = attrs[:infCpl]
|
8
|
+
attr_reader :information, :information_taxpayer, :taxpayer_messages, :messages,
|
9
|
+
:references
|
10
10
|
|
11
|
-
|
12
|
-
@
|
13
|
-
|
14
|
-
|
15
|
-
if attrs[:obsCont]
|
16
|
-
@taxpayer_messages = to_array(attrs[:obsCont])
|
17
|
-
end
|
11
|
+
def initialize(attrs = {})
|
12
|
+
@information = attrs[:infAdFisco]
|
13
|
+
@information_taxpayer = attrs[:infCpl]
|
18
14
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end
|
15
|
+
if attrs[:procRef]
|
16
|
+
@references = to_array(attrs[:procRef])
|
17
|
+
end
|
23
18
|
|
24
|
-
|
25
|
-
|
19
|
+
if attrs[:obsCont]
|
20
|
+
@taxpayer_messages = to_array(attrs[:obsCont])
|
21
|
+
end
|
26
22
|
|
27
|
-
|
28
|
-
|
29
|
-
array << hash.map { |key, value| value }
|
23
|
+
if attrs[:obsFisco]
|
24
|
+
@messages = to_array(attrs[:obsFisco])
|
30
25
|
end
|
31
|
-
else
|
32
|
-
array << attrs.map { |key, value| value }
|
33
26
|
end
|
34
|
-
|
35
|
-
array
|
36
27
|
end
|
37
28
|
end
|
38
29
|
end
|
@@ -0,0 +1,130 @@
|
|
1
|
+
module Nfe
|
2
|
+
module Reader
|
3
|
+
class Nfe
|
4
|
+
include ::AttributeHelper
|
5
|
+
|
6
|
+
attr_reader :version, :number, :signature, :client, :information,
|
7
|
+
:header, :provider, :customer, :products, :collection, :transport,
|
8
|
+
:purchase, :cane, :export, :delivery, :removal,:enviroment,
|
9
|
+
:version_app, :key, :date, :protocol, :digest, :status, :description,
|
10
|
+
:total, :authorizations, :error, :trace, :fiscal
|
11
|
+
|
12
|
+
def initialize(file)
|
13
|
+
|
14
|
+
xml = file.is_a?(Nokogiri::XML::Document) ? file : Nokogiri::XML(file)
|
15
|
+
xml = xml.to_hash
|
16
|
+
|
17
|
+
# Versao da NFe
|
18
|
+
@version = xml[:nfeProc][:versao]
|
19
|
+
# Assinatura
|
20
|
+
@signature = xml[:nfeProc][:NFe][:Signature]
|
21
|
+
|
22
|
+
# Protocolo
|
23
|
+
if xml[:nfeProc][:protNFe]
|
24
|
+
protocol = xml[:nfeProc][:protNFe][:infProt]
|
25
|
+
|
26
|
+
@enviroment = protocol[:tpAmb]
|
27
|
+
@version_app = protocol[:verAplic]
|
28
|
+
@key = protocol[:chNFe]
|
29
|
+
@date = protocol[:dhRecbto]
|
30
|
+
@protocol = protocol[:nProt]
|
31
|
+
@digest = protocol[:digVal]
|
32
|
+
@status = protocol[:cStat]
|
33
|
+
@description = protocol[:xMotivo]
|
34
|
+
end
|
35
|
+
|
36
|
+
xml = xml[:nfeProc][:NFe][:infNFe]
|
37
|
+
|
38
|
+
# Numero da Nfe
|
39
|
+
@number = xml[:Id]
|
40
|
+
|
41
|
+
# Identificação da Nota Fiscal eletrônica
|
42
|
+
@header = Header.new(xml[:ide])
|
43
|
+
|
44
|
+
# Identificação do Emitente da Nota Fiscal eletrônica
|
45
|
+
@provider = Provider.new(xml[:emit])
|
46
|
+
|
47
|
+
# Identificação do Fisco Emitente da NF-e
|
48
|
+
if xml[:avulsa]
|
49
|
+
@fiscal = Fiscal.new(xml[:avulsa])
|
50
|
+
end
|
51
|
+
|
52
|
+
# Identificação do Destinatário da Nota Fiscal eletrônica
|
53
|
+
@customer = Customer.new(xml[:dest])
|
54
|
+
|
55
|
+
# Informacoes Adicional
|
56
|
+
if xml[:infAdic]
|
57
|
+
@information = Information.new(xml[:infAdic])
|
58
|
+
end
|
59
|
+
|
60
|
+
# Detalhamento de Produtos e Serviços da NF-e
|
61
|
+
@products = []
|
62
|
+
if xml[:det].is_a? Array
|
63
|
+
xml[:det].each do |product|
|
64
|
+
@products << Product.new(product)
|
65
|
+
end
|
66
|
+
else
|
67
|
+
@products << Product.new(xml[:det])
|
68
|
+
end
|
69
|
+
|
70
|
+
# Totalizadores
|
71
|
+
@total = Total.new(xml[:total])
|
72
|
+
|
73
|
+
# Informacao de Pagamento
|
74
|
+
if xml[:cobr]
|
75
|
+
@collection = Collection.new(xml[:cobr])
|
76
|
+
end
|
77
|
+
|
78
|
+
# Transporte
|
79
|
+
if xml[:transp]
|
80
|
+
@transport = Transport.new(xml[:transp])
|
81
|
+
end
|
82
|
+
|
83
|
+
# Identificação do Local de Entrega
|
84
|
+
if xml[:retirada]
|
85
|
+
@removal = Removal.new(xml[:retirada])
|
86
|
+
end
|
87
|
+
|
88
|
+
# Identificação do Local de Retirada
|
89
|
+
if xml[:entrega]
|
90
|
+
@delivery = Delivery.new(xml[:entrega])
|
91
|
+
end
|
92
|
+
|
93
|
+
# Autorização para obter XML
|
94
|
+
@authorizations = []
|
95
|
+
if xml[:autXML].is_a? Array
|
96
|
+
xml[:autXML].each do |product|
|
97
|
+
@authorizations << Authorization.new(product)
|
98
|
+
end
|
99
|
+
elsif xml[:autXML].is_a? Hash
|
100
|
+
@authorizations << Authorization.new(xml[:autXML])
|
101
|
+
end
|
102
|
+
|
103
|
+
# Informacoes de Comercio Exterior
|
104
|
+
if xml[:exporta]
|
105
|
+
@export = Export.new(xml[:exporta])
|
106
|
+
end
|
107
|
+
|
108
|
+
# Informacoes de Compra
|
109
|
+
if xml[:compra]
|
110
|
+
@purchase = Purchase.new(xml[:compra])
|
111
|
+
end
|
112
|
+
|
113
|
+
# Cana de Acucar
|
114
|
+
if xml[:cana]
|
115
|
+
@cane = Cane.new(xml[:cana])
|
116
|
+
end
|
117
|
+
|
118
|
+
rescue => exception
|
119
|
+
@error = exception
|
120
|
+
@trace = exception.backtrace
|
121
|
+
ensure
|
122
|
+
file.close if file.respond_to? :close
|
123
|
+
end
|
124
|
+
|
125
|
+
def error?
|
126
|
+
!error.nil?
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
@@ -1,22 +1,26 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
module Nfe
|
3
|
-
|
4
|
-
|
3
|
+
module Reader
|
4
|
+
class Armament
|
5
|
+
include ::AttributeHelper
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
#
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
7
|
+
attr_reader :kind, :serie, :barrel, :description
|
8
|
+
|
9
|
+
# Fields Values
|
10
|
+
#
|
11
|
+
# tpArma : 0 - Uso permitido;
|
12
|
+
# 1 - Uso restrito;
|
13
|
+
#
|
14
|
+
def initialize(attrs = {})
|
15
|
+
# Tipo de Arma
|
16
|
+
@kind = attrs[:tpArma]
|
17
|
+
# Serie
|
18
|
+
@serie = attrs[:nSerie]
|
19
|
+
# Cano
|
20
|
+
@barrel = attrs[:nCano]
|
21
|
+
# Descricao
|
22
|
+
@description = attrs[:descr]
|
23
|
+
end
|
20
24
|
end
|
21
25
|
end
|
22
26
|
end
|
@@ -1,42 +1,32 @@
|
|
1
1
|
module Nfe
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
module Reader
|
3
|
+
class Cane
|
4
|
+
include ::AttributeHelper
|
5
|
+
include ::CreatorHelper
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
@month = attrs[:ref]
|
9
|
-
@month_amount = attrs[:qTotMes]
|
10
|
-
@previous_amount = attrs[:qTotAnt]
|
11
|
-
@amount = attrs[:qTotGer]
|
12
|
-
@value = attrs[:vFor]
|
13
|
-
@deduction_value = attrs[:vTotDed]
|
14
|
-
@net_value = attrs[:vLiqFor]
|
7
|
+
attr_reader :harvest, :month, :month_amount, :previous_amount, :amount,
|
8
|
+
:value, :deduction_value, :net_value, :days, :deductions
|
15
9
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
@
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
@
|
24
|
-
|
25
|
-
end
|
10
|
+
def initialize(attrs = {})
|
11
|
+
@harvest = attrs[:safra]
|
12
|
+
@month = attrs[:ref]
|
13
|
+
@month_amount = attrs[:qTotMes]
|
14
|
+
@previous_amount = attrs[:qTotAnt]
|
15
|
+
@amount = attrs[:qTotGer]
|
16
|
+
@value = attrs[:vFor]
|
17
|
+
@deduction_value = attrs[:vTotDed]
|
18
|
+
@net_value = attrs[:vLiqFor]
|
26
19
|
|
27
|
-
|
28
|
-
|
20
|
+
@days = []
|
21
|
+
|
22
|
+
if attrs[:forDia]
|
23
|
+
@days = to_array(attrs[:forDia])
|
24
|
+
end
|
29
25
|
|
30
|
-
|
31
|
-
|
32
|
-
array << hash.map { |key, value| value }
|
26
|
+
if attrs[:deduc]
|
27
|
+
@deductions = to_array(attrs[:deduc])
|
33
28
|
end
|
34
|
-
else
|
35
|
-
array << attrs.map { |key, value| value }
|
36
29
|
end
|
37
|
-
|
38
|
-
array
|
39
30
|
end
|
40
|
-
|
41
31
|
end
|
42
32
|
end
|
@@ -1,19 +1,23 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
module Nfe
|
3
|
-
|
4
|
-
|
3
|
+
module Reader
|
4
|
+
class Exportation
|
5
|
+
include ::AttributeHelper
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
7
|
+
attr_reader :drawnback, :number, :key, :amount
|
8
|
+
|
9
|
+
def initialize(attrs = {})
|
10
|
+
# Número do ato concessório de Drawback
|
11
|
+
@drawnback = attrs[:nDraw]
|
12
|
+
|
13
|
+
if attrs[:exportInd]
|
14
|
+
# Número do Registro de Exportação
|
15
|
+
@number = attrs[:exportInd][:nRE]
|
16
|
+
# Chave de Acesso da NF-e recebida para exportação
|
17
|
+
@key = attrs[:exportInd][:chNFe]
|
18
|
+
# Quantidade do item realmente exportado
|
19
|
+
@amount= attrs[:exportInd][:qExport]
|
20
|
+
end
|
17
21
|
end
|
18
22
|
end
|
19
23
|
end
|
@@ -1,17 +1,21 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
module Nfe
|
3
|
-
|
4
|
-
|
3
|
+
module Reader
|
4
|
+
class Fuel
|
5
|
+
include ::AttributeHelper
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
7
|
+
attr_reader :anp, :codif, :amount, :cide_base, :cide_aliquot, :cide_value
|
8
|
+
|
9
|
+
def initialize(attrs = {})
|
10
|
+
@anp = attrs[:cProdANP]
|
11
|
+
@codif = attrs[:CODIF]
|
12
|
+
@amount = attrs[:qTemp]
|
13
|
+
|
14
|
+
if attrs[:CIDE]
|
15
|
+
@cide_base = attrs[:CIDE][:qBCprod]
|
16
|
+
@cide_aliquot = attrs[:CIDE][:vAliqProd]
|
17
|
+
@cide_value = attrs[:CIDE][:vCIDE]
|
18
|
+
end
|
15
19
|
end
|
16
20
|
end
|
17
21
|
end
|