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
@@ -1,48 +1,52 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
module Nfe
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
:drawn
|
3
|
+
module Reader
|
4
|
+
# Declaração de Importação
|
5
|
+
class Importation
|
6
|
+
include ::AttributeHelper
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
# Data de Registro do documento
|
13
|
-
@date = attrs[:dDI]
|
14
|
-
# Local de desembaraço
|
15
|
-
@local = attrs[:xLocDesemb]
|
16
|
-
# Sigla da UF onde ocorreu o Desembaraço Aduaneiro
|
17
|
-
@state = attrs[:UFDesemb]
|
18
|
-
# Data do Desembaraço Aduaneiro
|
19
|
-
@customs_clearance = attrs[:dDesemb]
|
20
|
-
# Código do Exportador
|
21
|
-
@exporter = attrs[:cExportador]
|
8
|
+
attr_reader :number, :date, :local, :state, :customs_clearance, :exporter,
|
9
|
+
:addition_number, :addition_sequence, :manufacturer, :addition_descount,
|
10
|
+
:drawn, :transport, :afrmm, :intermediate_kind, :cnpj, :uf_customer
|
22
11
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
12
|
+
def initialize(attrs = {})
|
13
|
+
# Número do Documento de Importação
|
14
|
+
@number = attrs[:nDI]
|
15
|
+
# Data de Registro do documento
|
16
|
+
@date = attrs[:dDI]
|
17
|
+
# Local de desembaraço
|
18
|
+
@local = attrs[:xLocDesemb]
|
19
|
+
# Sigla da UF onde ocorreu o Desembaraço Aduaneiro
|
20
|
+
@state = attrs[:UFDesemb]
|
21
|
+
# Data do Desembaraço Aduaneiro
|
22
|
+
@customs_clearance = attrs[:dDesemb]
|
23
|
+
# Código do Exportador
|
24
|
+
@exporter = attrs[:cExportador]
|
33
25
|
|
34
|
-
|
35
|
-
|
36
|
-
#
|
37
|
-
@
|
38
|
-
#
|
39
|
-
@
|
40
|
-
#
|
41
|
-
@
|
42
|
-
#
|
43
|
-
@
|
44
|
-
|
45
|
-
|
26
|
+
# Via de transporte internacional
|
27
|
+
@transport = attrs[:tpViaTransp]
|
28
|
+
# Valor da AFRMM - Adicional ao Frete para Renovação da Marinha Mercante
|
29
|
+
@afrmm = attrs[:vAFRMM]
|
30
|
+
# Forma de importação
|
31
|
+
@intermediate_kind = attrs[:tpIntermedio]
|
32
|
+
# CNPJ do adquirente
|
33
|
+
@cnpj = attrs[:CNPJ]
|
34
|
+
# Sigla da UF
|
35
|
+
@uf_customer = attrs[:UFTerceiro]
|
36
|
+
|
37
|
+
# Adições
|
38
|
+
if attrs[:adi]
|
39
|
+
# Numero da Adição
|
40
|
+
@addition_number = attrs[:adi][:nAdicaonSeqAdic]
|
41
|
+
# Numero sequencial do item
|
42
|
+
@addition_sequence = attrs[:adi][:nSeqAdic]
|
43
|
+
# Código do fabricante estrangeiro
|
44
|
+
@manufacturer = attrs[:adi][:cFabricante]
|
45
|
+
# Valor do desconto do item
|
46
|
+
@addition_descount = attrs[:adi][:vDescDI]
|
47
|
+
# Drawback
|
48
|
+
@drawn = attrs[:adi][:nDraw]
|
49
|
+
end
|
46
50
|
end
|
47
51
|
end
|
48
52
|
end
|
@@ -1,19 +1,23 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
module Nfe
|
3
|
-
|
4
|
-
|
3
|
+
module Reader
|
4
|
+
class Medicament
|
5
|
+
include ::AttributeHelper
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
7
|
+
attr_reader :lot_number, :lot_amount, :fabrication, :validity, :ceiling_price
|
8
|
+
|
9
|
+
def initialize(attrs = {})
|
10
|
+
# Numero de Lote
|
11
|
+
@lot_number = attrs[:nLote]
|
12
|
+
# Quantidade de Lotes
|
13
|
+
@lot_amount = attrs[:qLote]
|
14
|
+
# Data de Fabricação
|
15
|
+
@fabrication = attrs[:dFab]
|
16
|
+
# Data de Validade
|
17
|
+
@validity = attrs[:dVal]
|
18
|
+
# Preço maximo venda para Consumidor Final
|
19
|
+
@ceiling_price = attrs[:vPMC]
|
20
|
+
end
|
17
21
|
end
|
18
22
|
end
|
19
23
|
end
|
@@ -1,117 +1,121 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
module Nfe
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
:engine_number, :cmt, :wheelbase, :year, :fabrication_year,
|
7
|
-
:paint_kind, :kind, :vehicle_kind, :vin, :condiction, :model,
|
8
|
-
:color_code, :capacity, :restriction
|
3
|
+
module Reader
|
4
|
+
class Vehicle
|
5
|
+
include ::AttributeHelper
|
9
6
|
|
10
|
-
|
11
|
-
|
12
|
-
|
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
|
-
|
7
|
+
attr_reader :operation, :chassi, :color, :color_name, :engine_power,
|
8
|
+
:engine_capacities, :weight_net, :weight_gross, :serie, :fuel_kind,
|
9
|
+
:engine_number, :cmt, :wheelbase, :year, :fabrication_year,
|
10
|
+
:paint_kind, :kind, :vehicle_kind, :vin, :condiction, :model,
|
11
|
+
:color_code, :capacity, :restriction
|
12
|
+
|
13
|
+
# Fields Values
|
14
|
+
#
|
15
|
+
# pOp: 1 - Venda concessionária,
|
16
|
+
# 2 - Faturamento direto para consumidor final
|
17
|
+
# 3 - Venda direta para grandes consumidores (frotista, governo, ...)
|
18
|
+
# 0 - Outros
|
19
|
+
#
|
20
|
+
# tpComb: 01-Álcool
|
21
|
+
# 02-Gasolina
|
22
|
+
# 03-Diesel
|
23
|
+
# (...) - Tabela Renavam 2.0
|
24
|
+
#
|
25
|
+
# tpVeic: Utilizar Tabela RENAVAM
|
26
|
+
# 06-AUTOMÓVEL
|
27
|
+
# 14-CAMINHÃO
|
28
|
+
# 13-CAMINHONETA
|
29
|
+
# ...
|
30
|
+
#
|
31
|
+
# espVeic: Utilizar Tabela RENAVAM
|
32
|
+
# 1 - PASSAGEIRO
|
33
|
+
# 2 - CARGA
|
34
|
+
# 3 - MISTO
|
35
|
+
# 4 - CORRIDA
|
36
|
+
# 5 - TRAÇÃO
|
37
|
+
# 6 - ESPECIAL
|
38
|
+
#
|
39
|
+
# VIN: R - Remarcado
|
40
|
+
# N - Normal
|
41
|
+
#
|
42
|
+
# condVeic: 1 - Acabado;
|
43
|
+
# 2 - Inacabado;
|
44
|
+
# 3 - Semi-acabado
|
45
|
+
#
|
46
|
+
# cCorDEN: 01 - AMARELO
|
47
|
+
# 02 - AZUL
|
48
|
+
# 03 - BEGE
|
49
|
+
# 04 - BRANCA
|
50
|
+
# 05 - CINZA
|
51
|
+
# 06 - DOURADA
|
52
|
+
# 07 - GRENA
|
53
|
+
# 08 - LARANJA
|
54
|
+
# 09 - MARROM
|
55
|
+
# 10 - PRATA
|
56
|
+
# 11 - PRETA
|
57
|
+
# 12 - ROSA
|
58
|
+
# 13 - ROXA
|
59
|
+
# 14 - VERDE
|
60
|
+
# 15 - VERMELHA
|
61
|
+
# 16 - FANTASIA
|
62
|
+
#
|
63
|
+
# tpRest: 0 - Não há;
|
64
|
+
# 1 - Alienação Fiduciária;
|
65
|
+
# 2 - Arrendamento Mercantil;
|
66
|
+
# 3 - Reserva de Domínio;
|
67
|
+
# 4 - Penhor de Veículos;
|
68
|
+
#
|
69
|
+
def initialize(attrs = {})
|
70
|
+
# Tipo da operação
|
71
|
+
@operation = attrs[:pOp]
|
72
|
+
# Numero do Chassi
|
73
|
+
@chassi = attrs[:chassi]
|
74
|
+
# Cor do Fabricante
|
75
|
+
@color = attrs[:cCor]
|
76
|
+
# Nome da Cor do Fabricante
|
77
|
+
@color_name = attrs[:xCor]
|
78
|
+
# Potencia do Motor em CV
|
79
|
+
@engine_power = attrs[:pot]
|
80
|
+
# Potencia do Motor em CC
|
81
|
+
@engine_capacities = attrs[:cilin]
|
82
|
+
# Peso Liquido
|
83
|
+
@weight_net = attrs[:pesoL]
|
84
|
+
# Peso Bruto
|
85
|
+
@weight_gross = attrs[:pesoB]
|
86
|
+
# Numero serie
|
87
|
+
@serie = attrs[:nSerie]
|
88
|
+
# Tipo de Combustivel
|
89
|
+
@fuel_kind = attrs[:tpComb]
|
90
|
+
# Numeracao do Motor
|
91
|
+
@engine_number = attrs[:nMotor]
|
92
|
+
# CMT: Capacidade Maxima de Tração
|
93
|
+
@cmt = attrs[:CMT]
|
94
|
+
# Distancia entre os Eixos
|
95
|
+
@wheelbase = attrs[:dist]
|
96
|
+
# Ano do Modelo
|
97
|
+
@year = attrs[:anoMod]
|
98
|
+
# Ano de Fabricacao
|
99
|
+
@fabrication_year = attrs[:anoFab]
|
100
|
+
# Tipo de Pintura
|
101
|
+
@paint_kind = attrs[:tpPint]
|
102
|
+
# Tipo de Veiculo
|
103
|
+
@kind = attrs[:tpVeic]
|
104
|
+
# Especie do veiculo
|
105
|
+
@vehicle_kind = attrs[:espVeic]
|
106
|
+
# Condição do VIN
|
107
|
+
@vin = attrs[:VIN]
|
108
|
+
# Condições do Veiculo
|
109
|
+
@condiction = attrs[:condVeic]
|
110
|
+
# Modelo
|
111
|
+
@model = attrs[:cMod]
|
112
|
+
# Codigo da Cor
|
113
|
+
@color_code = attrs[:cCorDEN]
|
114
|
+
# Capacidade
|
115
|
+
@capacity = attrs[:lota]
|
116
|
+
# Restrição
|
117
|
+
@restriction = attrs[:tpRest]
|
118
|
+
end
|
115
119
|
end
|
116
120
|
end
|
117
121
|
end
|
data/lib/nfe_reader/product.rb
CHANGED
@@ -1,90 +1,81 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
module Nfe
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
:discount, :other_value, :importation, :icms, :ipi, :pis,
|
9
|
-
:importation_tax, :exportation, :demand_number, :demand_item,
|
10
|
-
:armament, :fuel
|
3
|
+
module Reader
|
4
|
+
# Detalhamento de Produtos e Serviços da NF-e
|
5
|
+
class Product
|
6
|
+
include ::AttributeHelper
|
7
|
+
include ::CreatorHelper
|
11
8
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
if attrs[:prod]
|
21
|
-
@product_code = attrs[:prod][:cProd]
|
22
|
-
@product = attrs[:prod][:xProd]
|
23
|
-
@ean = attrs[:prod][:cEAN]
|
24
|
-
@ncm = attrs[:prod][:NCM]
|
25
|
-
|
26
|
-
# Sale
|
27
|
-
@cfop = attrs[:prod][:CFOP]
|
28
|
-
@unit_sale = attrs[:prod][:uCom]
|
29
|
-
@amount_sale = attrs[:prod][:qCom]
|
30
|
-
@value_sale = attrs[:prod][:vUnCom]
|
31
|
-
@total = attrs[:prod][:vProd]
|
32
|
-
|
33
|
-
# Numero do Pedido de Compra
|
34
|
-
@demand_number = attrs[:prod][:xPed]
|
35
|
-
# Item do Pedido de Compra
|
36
|
-
@demand_item = attrs[:prod][:nItemPed]
|
9
|
+
attr_reader :number, :code, :name, :ean, :ncm, :cfop,
|
10
|
+
:unit_sale, :value_sale, :amount_sale, :total, :gtin, :unit,
|
11
|
+
:amount, :value, :kind, :ipi_exception, :freight, :insurance,
|
12
|
+
:discount, :other_value, :importation, :icms, :ipi, :pis,
|
13
|
+
:importation_tax, :exportation, :demand_number, :demand_item,
|
14
|
+
:armament, :fuel, :vehicle, :medicament, :cofins, :pis_st,
|
15
|
+
:cofins_st, :issqn
|
37
16
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
@
|
45
|
-
@ipi_exception = attrs[:prod][:EXTIPI]
|
46
|
-
@freight = attrs[:prod][:vFrete]
|
47
|
-
@insurance = attrs[:prod][:vSeg]
|
48
|
-
@discount = attrs[:prod][:vDesc]
|
49
|
-
@other_value = attrs[:prod][:vOutro]
|
17
|
+
# == Fields Values
|
18
|
+
#
|
19
|
+
# indTot: 0 - o valor do item (vProd) compõe o valor total da NF-e (vProd)
|
20
|
+
# 1 - o valor do item (vProd) não compõe o valor total da NF-e (vProd) (v2.0)
|
21
|
+
#
|
22
|
+
def initialize(attrs = {})
|
23
|
+
@number = attrs[:nItem]
|
50
24
|
|
51
|
-
|
52
|
-
|
25
|
+
if attrs[:prod]
|
26
|
+
@code = attrs[:prod][:cProd]
|
27
|
+
@name = attrs[:prod][:xProd]
|
28
|
+
@ean = attrs[:prod][:cEAN]
|
29
|
+
@ncm = attrs[:prod][:NCM]
|
30
|
+
|
31
|
+
# Sale
|
32
|
+
@cfop = attrs[:prod][:CFOP]
|
33
|
+
@unit_sale = attrs[:prod][:uCom]
|
34
|
+
@amount_sale = attrs[:prod][:qCom]
|
35
|
+
@value_sale = attrs[:prod][:vUnCom]
|
36
|
+
@total = attrs[:prod][:vProd]
|
53
37
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
38
|
+
# Numero do Pedido de Compra
|
39
|
+
@demand_number = attrs[:prod][:xPed]
|
40
|
+
# Item do Pedido de Compra
|
41
|
+
@demand_item = attrs[:prod][:nItemPed]
|
58
42
|
|
59
|
-
|
43
|
+
# GTIN (Global Trade ItemNumber)
|
44
|
+
@gtin = attrs[:prod][:cEANTrib]
|
45
|
+
|
46
|
+
@unit = attrs[:prod][:uTrib]
|
47
|
+
@amount = attrs[:prod][:qTrib]
|
48
|
+
@value = attrs[:prod][:vUnTrib]
|
49
|
+
@kind = attrs[:prod][:indTot]
|
50
|
+
@ipi_exception = attrs[:prod][:EXTIPI]
|
51
|
+
@freight = attrs[:prod][:vFrete]
|
52
|
+
@insurance = attrs[:prod][:vSeg]
|
53
|
+
@discount = attrs[:prod][:vDesc]
|
54
|
+
@other_value = attrs[:prod][:vOutro]
|
55
|
+
|
56
|
+
@importation = create_resource(Importation, attrs[:prod][:DI])
|
57
|
+
end
|
60
58
|
|
61
|
-
|
62
|
-
@
|
63
|
-
|
64
|
-
@
|
65
|
-
@
|
66
|
-
@ipi = create_resource(Nfe::Ipi, attrs[:imposto][:IPI])
|
67
|
-
@pis_st = create_resource(Nfe::PisSt, attrs[:imposto][:PISST])
|
68
|
-
@cofins_st = create_resource(Nfe::CofinsSt, attrs[:imposto][:COFINSST])
|
69
|
-
@issqn = create_resource(Nfe::Issqn, attrs[:imposto][:ISSQN])
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
def create_resource(klass, attrs = {})
|
74
|
-
return unless attrs
|
75
|
-
klass.new(attrs)
|
76
|
-
end
|
77
|
-
|
78
|
-
def create_resources(klass, attrs = {})
|
79
|
-
resources = []
|
59
|
+
@fuel = Fuel.new(attrs[:comb]) if attrs[:comb]
|
60
|
+
@vehicle = Vehicle.new(attrs[:veicProd]) if attrs[:veicProd]
|
61
|
+
|
62
|
+
@armament = create_resources(Armament, attrs[:arma]) if attrs[:arma]
|
63
|
+
@medicament = create_resources(Medicament, attrs[:med]) if attrs[:med]
|
80
64
|
|
81
|
-
|
65
|
+
@exportation = create_resources(Exportation, attrs[:detExport])
|
82
66
|
|
83
|
-
|
84
|
-
|
67
|
+
if attrs[:imposto]
|
68
|
+
@icms = create_resources(Icms, attrs[:imposto][:ICMS])
|
69
|
+
@cofins = create_resources(Cofins, attrs[:imposto][:COFINS])
|
70
|
+
@pis = create_resources(Pis, attrs[:imposto][:PIS])
|
71
|
+
|
72
|
+
@importation_tax = create_resource(ImportationTax, attrs[:imposto][:II])
|
73
|
+
@ipi = create_resource(Ipi, attrs[:imposto][:IPI])
|
74
|
+
@pis_st = create_resource(PisSt, attrs[:imposto][:PISST])
|
75
|
+
@cofins_st = create_resource(CofinsSt, attrs[:imposto][:COFINSST])
|
76
|
+
@issqn = create_resource(Issqn, attrs[:imposto][:ISSQN])
|
77
|
+
end
|
85
78
|
end
|
86
|
-
|
87
|
-
resources
|
88
79
|
end
|
89
80
|
end
|
90
81
|
end
|
data/lib/nfe_reader/provider.rb
CHANGED
@@ -1,42 +1,46 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
module Nfe
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
:city_code, :city, :zip_code, :country_code, :country, :fantasy, :state
|
3
|
+
module Reader
|
4
|
+
# Identificação do Emitente da Nota Fiscal eletrônica
|
5
|
+
class Provider
|
6
|
+
include ::AttributeHelper
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
# 2 - Simples Nacional – excesso de sublimite de receita bruta,
|
13
|
-
# 3 - Regime Normal
|
14
|
-
#
|
15
|
-
def initialize(attrs = {})
|
16
|
-
# Provider Info
|
17
|
-
@cnpj = attrs[:CNPJ]
|
18
|
-
@cpf = attrs[:CPF]
|
19
|
-
@name = attrs[:xNome]
|
20
|
-
@fantasy = attrs[:xFant]
|
21
|
-
@state_registration = attrs[:IE]
|
22
|
-
@state_registration_st = attrs[:IEST]
|
23
|
-
@city_registration = attrs[:IM]
|
24
|
-
@regime = attrs[:CRT]
|
25
|
-
@cnae = attrs[:CNAE]
|
8
|
+
attr_reader :cnpj, :cpf, :name, :phone, :state_registration, :state_registration_st,
|
9
|
+
:city_registration, :regime, :cnae, :address, :number, :complement, :neighborhood,
|
10
|
+
:city_code, :city, :zip_code, :country_code, :country, :fantasy, :state
|
26
11
|
|
27
|
-
#
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
@
|
36
|
-
@
|
37
|
-
@
|
38
|
-
@
|
39
|
-
@
|
12
|
+
# == Fields Values
|
13
|
+
#
|
14
|
+
# CRT: 1 - Simples Nacional,
|
15
|
+
# 2 - Simples Nacional – excesso de sublimite de receita bruta,
|
16
|
+
# 3 - Regime Normal
|
17
|
+
#
|
18
|
+
def initialize(attrs = {})
|
19
|
+
# Provider Info
|
20
|
+
@cnpj = attrs[:CNPJ]
|
21
|
+
@cpf = attrs[:CPF]
|
22
|
+
@name = attrs[:xNome]
|
23
|
+
@fantasy = attrs[:xFant]
|
24
|
+
@state_registration = attrs[:IE]
|
25
|
+
@state_registration_st = attrs[:IEST]
|
26
|
+
@city_registration = attrs[:IM]
|
27
|
+
@regime = attrs[:CRT]
|
28
|
+
@cnae = attrs[:CNAE]
|
29
|
+
|
30
|
+
# Address
|
31
|
+
if attrs[:enderEmit]
|
32
|
+
@phone = attrs[:enderEmit][:fone]
|
33
|
+
@address = attrs[:enderEmit][:xLgr]
|
34
|
+
@number = attrs[:enderEmit][:nro]
|
35
|
+
@complement = attrs[:enderEmit][:xCpl]
|
36
|
+
@neighborhood = attrs[:enderEmit][:xBairro]
|
37
|
+
@city_code = attrs[:enderEmit][:cMun]
|
38
|
+
@city = attrs[:enderEmit][:xMun]
|
39
|
+
@zip_code = attrs[:enderEmit][:CEP]
|
40
|
+
@country_code = attrs[:enderEmit][:cPais]
|
41
|
+
@country = attrs[:enderEmit][:xPais]
|
42
|
+
@state = attrs[:enderEmit][:UF]
|
43
|
+
end
|
40
44
|
end
|
41
45
|
end
|
42
46
|
end
|
data/lib/nfe_reader/purchase.rb
CHANGED
@@ -2,13 +2,17 @@
|
|
2
2
|
|
3
3
|
# Informações de Compras
|
4
4
|
module Nfe
|
5
|
-
|
6
|
-
|
5
|
+
module Reader
|
6
|
+
class Purchase
|
7
|
+
include ::AttributeHelper
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
attr_reader :number, :demand, :contract
|
10
|
+
|
11
|
+
def initialize(attrs = {})
|
12
|
+
@number = attrs[:xNEmp]
|
13
|
+
@demand = attrs[:xPed]
|
14
|
+
@contract = attrs[:xCont]
|
15
|
+
end
|
12
16
|
end
|
13
17
|
end
|
14
18
|
end
|