nfe_reader 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/lib/nfe_reader.rb +4 -4
- data/lib/nfe_reader/address.rb +38 -0
- data/lib/nfe_reader/authorization.rb +8 -10
- data/lib/nfe_reader/billing.rb +21 -0
- data/lib/nfe_reader/billing/duplicate.rb +14 -0
- data/lib/nfe_reader/carrier.rb +12 -14
- data/lib/nfe_reader/customer.rb +15 -57
- data/lib/nfe_reader/delivery.rb +16 -18
- data/lib/nfe_reader/document.rb +63 -65
- data/lib/nfe_reader/export.rb +8 -10
- data/lib/nfe_reader/fiscal.rb +29 -31
- data/lib/nfe_reader/header.rb +114 -123
- data/lib/nfe_reader/helpers/attribute_helper.rb +24 -0
- data/lib/nfe_reader/helpers/creator_helper.rb +40 -0
- data/lib/{helpers → nfe_reader/helpers}/nokogiri_hash.rb +2 -0
- data/lib/nfe_reader/information.rb +17 -19
- data/lib/nfe_reader/nfe.rb +78 -87
- data/lib/nfe_reader/person.rb +53 -0
- data/lib/nfe_reader/product.rb +69 -67
- data/lib/nfe_reader/product/armament.rb +18 -20
- data/lib/nfe_reader/product/cane.rb +22 -24
- data/lib/nfe_reader/product/exportation.rb +15 -17
- data/lib/nfe_reader/product/fuel.rb +13 -15
- data/lib/nfe_reader/product/importation.rb +42 -44
- data/lib/nfe_reader/product/medicament.rb +15 -17
- data/lib/nfe_reader/product/vehicle.rb +113 -115
- data/lib/nfe_reader/provider.rb +10 -40
- data/lib/nfe_reader/purchase.rb +9 -12
- data/lib/nfe_reader/removal.rb +17 -19
- data/lib/nfe_reader/taxation/cofins.rb +41 -41
- data/lib/nfe_reader/taxation/cofins_st.rb +15 -17
- data/lib/nfe_reader/taxation/icms.rb +80 -81
- data/lib/nfe_reader/taxation/importation_tax.rb +14 -16
- data/lib/nfe_reader/taxation/ipi.rb +35 -37
- data/lib/nfe_reader/taxation/issqn.rb +17 -19
- data/lib/nfe_reader/taxation/pis.rb +41 -41
- data/lib/nfe_reader/taxation/pis_st.rb +16 -18
- data/lib/nfe_reader/total.rb +71 -71
- data/lib/nfe_reader/transport.rb +76 -89
- data/lib/nfe_reader/version.rb +2 -4
- data/nfe-reader.gemspec +2 -1
- data/test/nfe_reader/address_test.rb +75 -0
- data/test/nfe_reader/authorization_test.rb +2 -2
- data/test/nfe_reader/{collection → billing}/duplicate_test.rb +2 -2
- data/test/nfe_reader/{collection_test.rb → billing_test.rb} +13 -13
- data/test/nfe_reader/cane_test.rb +2 -2
- data/test/nfe_reader/carrier_test.rb +4 -4
- data/test/nfe_reader/customer_test.rb +6 -101
- 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/{helpers → nfe_reader/helpers}/attributte_helper_test.rb +3 -3
- data/test/{helpers → nfe_reader/helpers}/creator_helper_test.rb +3 -3
- data/test/{helpers → nfe_reader/helpers}/nokogiri_test.rb +1 -1
- data/test/nfe_reader/information_test.rb +2 -2
- data/test/nfe_reader/nfe_test.rb +13 -13
- data/test/nfe_reader/person_test.rb +60 -0
- 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 +2 -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 +2 -2
- data/test/nfe_reader/provider_test.rb +5 -118
- 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 +37 -17
- data/lib/helpers/attribute_helper.rb +0 -18
- data/lib/helpers/creator_helper.rb +0 -32
- data/lib/nfe_reader/collection.rb +0 -38
- data/lib/nfe_reader/collection/duplicate.rb +0 -16
@@ -1,31 +1,29 @@
|
|
1
|
-
module
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
include ::CreatorHelper
|
1
|
+
module NfeReader
|
2
|
+
class Cane
|
3
|
+
include AttributeHelper
|
4
|
+
include CreatorHelper
|
6
5
|
|
7
|
-
|
8
|
-
|
6
|
+
attr_reader :harvest, :month, :month_amount, :previous_amount, :amount,
|
7
|
+
:value, :deduction_value, :net_value, :days, :deductions
|
9
8
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
9
|
+
def initialize(attrs = {})
|
10
|
+
@harvest = attrs[:safra]
|
11
|
+
@month = attrs[:ref]
|
12
|
+
@month_amount = attrs[:qTotMes]
|
13
|
+
@previous_amount = attrs[:qTotAnt]
|
14
|
+
@amount = attrs[:qTotGer]
|
15
|
+
@value = attrs[:vFor]
|
16
|
+
@deduction_value = attrs[:vTotDed]
|
17
|
+
@net_value = attrs[:vLiqFor]
|
19
18
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
19
|
+
@days = []
|
20
|
+
|
21
|
+
if attrs[:forDia]
|
22
|
+
@days = to_array(attrs[:forDia])
|
23
|
+
end
|
25
24
|
|
26
|
-
|
27
|
-
|
28
|
-
end
|
25
|
+
if attrs[:deduc]
|
26
|
+
@deductions = to_array(attrs[:deduc])
|
29
27
|
end
|
30
28
|
end
|
31
29
|
end
|
@@ -1,23 +1,21 @@
|
|
1
1
|
# encoding: UTF-8
|
2
|
-
module
|
3
|
-
|
4
|
-
|
5
|
-
include ::AttributeHelper
|
2
|
+
module NfeReader
|
3
|
+
class Exportation
|
4
|
+
include AttributeHelper
|
6
5
|
|
7
|
-
|
6
|
+
attr_reader :drawnback, :number, :key, :amount
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
8
|
+
def initialize(attrs = {})
|
9
|
+
# Número do ato concessório de Drawback
|
10
|
+
@drawnback = attrs[:nDraw]
|
11
|
+
|
12
|
+
if attrs[:exportInd]
|
13
|
+
# Número do Registro de Exportação
|
14
|
+
@number = attrs[:exportInd][:nRE]
|
15
|
+
# Chave de Acesso da NF-e recebida para exportação
|
16
|
+
@key = attrs[:exportInd][:chNFe]
|
17
|
+
# Quantidade do item realmente exportado
|
18
|
+
@amount= attrs[:exportInd][:qExport]
|
21
19
|
end
|
22
20
|
end
|
23
21
|
end
|
@@ -1,21 +1,19 @@
|
|
1
1
|
# encoding: UTF-8
|
2
|
-
module
|
3
|
-
|
4
|
-
|
5
|
-
include ::AttributeHelper
|
2
|
+
module NfeReader
|
3
|
+
class Fuel
|
4
|
+
include AttributeHelper
|
6
5
|
|
7
|
-
|
6
|
+
attr_reader :anp, :codif, :amount, :cide_base, :cide_aliquot, :cide_value
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end
|
8
|
+
def initialize(attrs = {})
|
9
|
+
@anp = attrs[:cProdANP]
|
10
|
+
@codif = attrs[:CODIF]
|
11
|
+
@amount = attrs[:qTemp]
|
12
|
+
|
13
|
+
if attrs[:CIDE]
|
14
|
+
@cide_base = attrs[:CIDE][:qBCprod]
|
15
|
+
@cide_aliquot = attrs[:CIDE][:vAliqProd]
|
16
|
+
@cide_value = attrs[:CIDE][:vCIDE]
|
19
17
|
end
|
20
18
|
end
|
21
19
|
end
|
@@ -1,52 +1,50 @@
|
|
1
1
|
# encoding: UTF-8
|
2
|
-
module
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
include ::AttributeHelper
|
2
|
+
module NfeReader
|
3
|
+
# Declaração de Importação
|
4
|
+
class Importation
|
5
|
+
include AttributeHelper
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
attr_reader :number, :date, :local, :state, :customs_clearance, :exporter,
|
8
|
+
:addition_number, :addition_sequence, :manufacturer, :addition_descount,
|
9
|
+
:drawn, :transport, :afrmm, :intermediate_kind, :cnpj, :uf_customer
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
11
|
+
def initialize(attrs = {})
|
12
|
+
# Número do Documento de Importação
|
13
|
+
@number = attrs[:nDI]
|
14
|
+
# Data de Registro do documento
|
15
|
+
@date = attrs[:dDI]
|
16
|
+
# Local de desembaraço
|
17
|
+
@local = attrs[:xLocDesemb]
|
18
|
+
# Sigla da UF onde ocorreu o Desembaraço Aduaneiro
|
19
|
+
@state = attrs[:UFDesemb]
|
20
|
+
# Data do Desembaraço Aduaneiro
|
21
|
+
@customs_clearance = attrs[:dDesemb]
|
22
|
+
# Código do Exportador
|
23
|
+
@exporter = attrs[:cExportador]
|
25
24
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
25
|
+
# Via de transporte internacional
|
26
|
+
@transport = attrs[:tpViaTransp]
|
27
|
+
# Valor da AFRMM - Adicional ao Frete para Renovação da Marinha Mercante
|
28
|
+
@afrmm = attrs[:vAFRMM]
|
29
|
+
# Forma de importação
|
30
|
+
@intermediate_kind = attrs[:tpIntermedio]
|
31
|
+
# CNPJ do adquirente
|
32
|
+
@cnpj = attrs[:CNPJ]
|
33
|
+
# Sigla da UF
|
34
|
+
@uf_customer = attrs[:UFTerceiro]
|
36
35
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
end
|
36
|
+
# Adições
|
37
|
+
if attrs[:adi]
|
38
|
+
# Numero da Adição
|
39
|
+
@addition_number = attrs[:adi][:nAdicaonSeqAdic]
|
40
|
+
# Numero sequencial do item
|
41
|
+
@addition_sequence = attrs[:adi][:nSeqAdic]
|
42
|
+
# Código do fabricante estrangeiro
|
43
|
+
@manufacturer = attrs[:adi][:cFabricante]
|
44
|
+
# Valor do desconto do item
|
45
|
+
@addition_descount = attrs[:adi][:vDescDI]
|
46
|
+
# Drawback
|
47
|
+
@drawn = attrs[:adi][:nDraw]
|
50
48
|
end
|
51
49
|
end
|
52
50
|
end
|
@@ -1,23 +1,21 @@
|
|
1
1
|
# encoding: UTF-8
|
2
|
-
module
|
3
|
-
|
4
|
-
|
5
|
-
include ::AttributeHelper
|
2
|
+
module NfeReader
|
3
|
+
class Medicament
|
4
|
+
include AttributeHelper
|
6
5
|
|
7
|
-
|
6
|
+
attr_reader :lot_number, :lot_amount, :fabrication, :validity, :ceiling_price
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
8
|
+
def initialize(attrs = {})
|
9
|
+
# Numero de Lote
|
10
|
+
@lot_number = attrs[:nLote]
|
11
|
+
# Quantidade de Lotes
|
12
|
+
@lot_amount = attrs[:qLote]
|
13
|
+
# Data de Fabricação
|
14
|
+
@fabrication = attrs[:dFab]
|
15
|
+
# Data de Validade
|
16
|
+
@validity = attrs[:dVal]
|
17
|
+
# Preço maximo venda para Consumidor Final
|
18
|
+
@ceiling_price = attrs[:vPMC]
|
21
19
|
end
|
22
20
|
end
|
23
21
|
end
|
@@ -1,121 +1,119 @@
|
|
1
1
|
# encoding: UTF-8
|
2
|
-
module
|
3
|
-
|
4
|
-
|
5
|
-
include ::AttributeHelper
|
2
|
+
module NfeReader
|
3
|
+
class Vehicle
|
4
|
+
include AttributeHelper
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
attr_reader :operation, :chassi, :color, :color_name, :engine_power,
|
7
|
+
:engine_capacities, :weight_net, :weight_gross, :serie, :fuel_kind,
|
8
|
+
:engine_number, :cmt, :wheelbase, :year, :fabrication_year,
|
9
|
+
:paint_kind, :kind, :vehicle_kind, :vin, :condiction, :model,
|
10
|
+
:color_code, :capacity, :restriction
|
12
11
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
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
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
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
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
end
|
12
|
+
# Fields Values
|
13
|
+
#
|
14
|
+
# pOp: 1 - Venda concessionária,
|
15
|
+
# 2 - Faturamento direto para consumidor final
|
16
|
+
# 3 - Venda direta para grandes consumidores (frotista, governo, ...)
|
17
|
+
# 0 - Outros
|
18
|
+
#
|
19
|
+
# tpComb: 01-Álcool
|
20
|
+
# 02-Gasolina
|
21
|
+
# 03-Diesel
|
22
|
+
# (...) - Tabela Renavam 2.0
|
23
|
+
#
|
24
|
+
# tpVeic: Utilizar Tabela RENAVAM
|
25
|
+
# 06-AUTOMÓVEL
|
26
|
+
# 14-CAMINHÃO
|
27
|
+
# 13-CAMINHONETA
|
28
|
+
# ...
|
29
|
+
#
|
30
|
+
# espVeic: Utilizar Tabela RENAVAM
|
31
|
+
# 1 - PASSAGEIRO
|
32
|
+
# 2 - CARGA
|
33
|
+
# 3 - MISTO
|
34
|
+
# 4 - CORRIDA
|
35
|
+
# 5 - TRAÇÃO
|
36
|
+
# 6 - ESPECIAL
|
37
|
+
#
|
38
|
+
# VIN: R - Remarcado
|
39
|
+
# N - Normal
|
40
|
+
#
|
41
|
+
# condVeic: 1 - Acabado;
|
42
|
+
# 2 - Inacabado;
|
43
|
+
# 3 - Semi-acabado
|
44
|
+
#
|
45
|
+
# cCorDEN: 01 - AMARELO
|
46
|
+
# 02 - AZUL
|
47
|
+
# 03 - BEGE
|
48
|
+
# 04 - BRANCA
|
49
|
+
# 05 - CINZA
|
50
|
+
# 06 - DOURADA
|
51
|
+
# 07 - GRENA
|
52
|
+
# 08 - LARANJA
|
53
|
+
# 09 - MARROM
|
54
|
+
# 10 - PRATA
|
55
|
+
# 11 - PRETA
|
56
|
+
# 12 - ROSA
|
57
|
+
# 13 - ROXA
|
58
|
+
# 14 - VERDE
|
59
|
+
# 15 - VERMELHA
|
60
|
+
# 16 - FANTASIA
|
61
|
+
#
|
62
|
+
# tpRest: 0 - Não há;
|
63
|
+
# 1 - Alienação Fiduciária;
|
64
|
+
# 2 - Arrendamento Mercantil;
|
65
|
+
# 3 - Reserva de Domínio;
|
66
|
+
# 4 - Penhor de Veículos;
|
67
|
+
#
|
68
|
+
def initialize(attrs = {})
|
69
|
+
# Tipo da operação
|
70
|
+
@operation = attrs[:pOp]
|
71
|
+
# Numero do Chassi
|
72
|
+
@chassi = attrs[:chassi]
|
73
|
+
# Cor do Fabricante
|
74
|
+
@color = attrs[:cCor]
|
75
|
+
# Nome da Cor do Fabricante
|
76
|
+
@color_name = attrs[:xCor]
|
77
|
+
# Potencia do Motor em CV
|
78
|
+
@engine_power = attrs[:pot]
|
79
|
+
# Potencia do Motor em CC
|
80
|
+
@engine_capacities = attrs[:cilin]
|
81
|
+
# Peso Liquido
|
82
|
+
@weight_net = attrs[:pesoL]
|
83
|
+
# Peso Bruto
|
84
|
+
@weight_gross = attrs[:pesoB]
|
85
|
+
# Numero serie
|
86
|
+
@serie = attrs[:nSerie]
|
87
|
+
# Tipo de Combustivel
|
88
|
+
@fuel_kind = attrs[:tpComb]
|
89
|
+
# Numeracao do Motor
|
90
|
+
@engine_number = attrs[:nMotor]
|
91
|
+
# CMT: Capacidade Maxima de Tração
|
92
|
+
@cmt = attrs[:CMT]
|
93
|
+
# Distancia entre os Eixos
|
94
|
+
@wheelbase = attrs[:dist]
|
95
|
+
# Ano do Modelo
|
96
|
+
@year = attrs[:anoMod]
|
97
|
+
# Ano de Fabricacao
|
98
|
+
@fabrication_year = attrs[:anoFab]
|
99
|
+
# Tipo de Pintura
|
100
|
+
@paint_kind = attrs[:tpPint]
|
101
|
+
# Tipo de Veiculo
|
102
|
+
@kind = attrs[:tpVeic]
|
103
|
+
# Especie do veiculo
|
104
|
+
@vehicle_kind = attrs[:espVeic]
|
105
|
+
# Condição do VIN
|
106
|
+
@vin = attrs[:VIN]
|
107
|
+
# Condições do Veiculo
|
108
|
+
@condiction = attrs[:condVeic]
|
109
|
+
# Modelo
|
110
|
+
@model = attrs[:cMod]
|
111
|
+
# Codigo da Cor
|
112
|
+
@color_code = attrs[:cCorDEN]
|
113
|
+
# Capacidade
|
114
|
+
@capacity = attrs[:lota]
|
115
|
+
# Restrição
|
116
|
+
@restriction = attrs[:tpRest]
|
119
117
|
end
|
120
118
|
end
|
121
119
|
end
|