nfe_reader 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- 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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0a6ea021f20cf8869fb72b69dc09f308b4459b2
|
4
|
+
data.tar.gz: 8fd34ca62a8976705aaa417b5aa01b67f006d260
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eecac3227082e880243211a0897a3517420719a76772b4b343d7c14386496c399ec6b570c5f90068f38c9b9f69ea2d5a09e47dda1a1e83ebad4d05ec698559c3
|
7
|
+
data.tar.gz: a0372bd094fd2cae68d5071b98a9875f20ae30cc1afce35043e6be1ae3a77891688ff7c4484b2a4461e4263801c60ae7268fd4ff65067f973a1e1278f957073b
|
data/README.md
CHANGED
@@ -26,9 +26,18 @@ Open the xml file and import to Nfe::Reader:
|
|
26
26
|
|
27
27
|
```ruby
|
28
28
|
file = File.open('sample-nfe.xml')
|
29
|
-
nfe = Nfe::Reader::
|
29
|
+
nfe = Nfe::Reader::Nfe.new(file)
|
30
30
|
```
|
31
31
|
|
32
|
+
You can access class attributes:
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
nfe.attributes
|
36
|
+
|
37
|
+
# {"version"=>"2.00", "signature"=> Hash, "enviroment"=>"1", "version_app"=>"SVRS20140825154650", "key"=>"42140979858221000155550010000483141000490912", "date"=>"2014-09-26T15:13:17", "protocol"=>"342140109891239", "digest"=>"v6ZkLNwbVB4lmk/PbND1kmr5tIY=", "status"=>"100", "description"=>"Autorizado o uso da NF-e.", "number"=>"NFe42140979858221000155550010000483141000490912"}
|
38
|
+
```
|
39
|
+
|
40
|
+
|
32
41
|
### Contributing
|
33
42
|
|
34
43
|
1. Fork it ( https://github.com/[my-github-username]/nfe-reader/fork )
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module AttributeHelper
|
2
|
+
def attributes
|
3
|
+
@attributes ||= attributes_to_hash
|
4
|
+
end
|
5
|
+
|
6
|
+
def attributes_to_hash
|
7
|
+
attrs = Hash.new
|
8
|
+
|
9
|
+
instance_variables.each do |var|
|
10
|
+
key = var.to_s.gsub /^@/, ''
|
11
|
+
value = instance_variable_get(var)
|
12
|
+
|
13
|
+
attrs[key] = value if [String, Hash].include? value.class
|
14
|
+
end
|
15
|
+
|
16
|
+
attrs
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module CreatorHelper
|
2
|
+
def create_resource(klass, attrs = {})
|
3
|
+
return unless attrs
|
4
|
+
klass.new(attrs)
|
5
|
+
end
|
6
|
+
|
7
|
+
def create_resources(klass, attrs = {})
|
8
|
+
resources = []
|
9
|
+
|
10
|
+
return resources unless attrs
|
11
|
+
|
12
|
+
attrs.each do |a|
|
13
|
+
resources << klass.new(a.last)
|
14
|
+
end
|
15
|
+
|
16
|
+
resources
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_array(attrs = {})
|
20
|
+
array = []
|
21
|
+
|
22
|
+
if attrs.is_a? Array
|
23
|
+
attrs.each do |hash|
|
24
|
+
array << hash.map { |key, value| value }
|
25
|
+
end
|
26
|
+
else
|
27
|
+
array << attrs.map { |key, value| value }
|
28
|
+
end
|
29
|
+
|
30
|
+
array
|
31
|
+
end
|
32
|
+
end
|
@@ -1,12 +1,16 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
module Nfe
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
module Reader
|
4
|
+
# Pessoas Autorizadas para obter XML
|
5
|
+
class Authorization
|
6
|
+
include ::AttributeHelper
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
attr_reader :cnpj, :cpf
|
9
|
+
|
10
|
+
def initialize(attrs = {})
|
11
|
+
@cnpj = attrs[:CNPJ]
|
12
|
+
@cpf = attrs[:CPF]
|
13
|
+
end
|
10
14
|
end
|
11
15
|
end
|
12
16
|
end
|
data/lib/nfe_reader/carrier.rb
CHANGED
@@ -1,16 +1,20 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
module Nfe
|
3
|
-
|
4
|
-
|
3
|
+
module Reader
|
4
|
+
class Carrier
|
5
|
+
include ::AttributeHelper
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
7
|
+
attr_reader :cnpj, :cpf, :name, :ie, :address, :city, :state
|
8
|
+
|
9
|
+
def initialize(attrs = {})
|
10
|
+
@cnpj = attrs[:CNPJ]
|
11
|
+
@cpf = attrs[:CPF]
|
12
|
+
@name = attrs[:xNome]
|
13
|
+
@ie = attrs[:IE]
|
14
|
+
@address = attrs[:xEnder]
|
15
|
+
@city = attrs[:xMun]
|
16
|
+
@state = attrs[:UF]
|
17
|
+
end
|
14
18
|
end
|
15
19
|
end
|
16
20
|
end
|
@@ -1,12 +1,16 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
module Nfe
|
3
|
-
|
4
|
-
|
3
|
+
module Reader
|
4
|
+
class Duplicate
|
5
|
+
include ::AttributeHelper
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
attr_reader :number, :expiration, :value
|
8
|
+
|
9
|
+
def initialize(attrs = {})
|
10
|
+
@number = attrs[:nDup]
|
11
|
+
@expiration = attrs[:dVenc]
|
12
|
+
@value = attrs[:vDup]
|
13
|
+
end
|
10
14
|
end
|
11
15
|
end
|
12
16
|
end
|
@@ -1,34 +1,38 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
module Nfe
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
def initialize(attrs = {})
|
8
|
-
if attrs[:fat]
|
9
|
-
@number = attrs[:fat][:nFat]
|
10
|
-
@value = attrs[:fat][:vOrig]
|
11
|
-
@descont = attrs[:fat][:vDesc]
|
12
|
-
@value_net = attrs[:fat][:vLiq]
|
13
|
-
end
|
3
|
+
module Reader
|
4
|
+
# Mapeia as Cobrancas
|
5
|
+
class Collection
|
6
|
+
include ::AttributeHelper
|
14
7
|
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
|
-
def set_duplicates(attrs = {})
|
19
|
-
duplicates = []
|
8
|
+
attr_reader :number, :value, :descont, :value_net, :duplicates
|
20
9
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
10
|
+
def initialize(attrs = {})
|
11
|
+
if attrs[:fat]
|
12
|
+
@number = attrs[:fat][:nFat]
|
13
|
+
@value = attrs[:fat][:vOrig]
|
14
|
+
@descont = attrs[:fat][:vDesc]
|
15
|
+
@value_net = attrs[:fat][:vLiq]
|
26
16
|
end
|
27
|
-
|
28
|
-
|
17
|
+
|
18
|
+
@duplicates = set_duplicates(attrs[:dup])
|
29
19
|
end
|
20
|
+
|
21
|
+
def set_duplicates(attrs = {})
|
22
|
+
duplicates = []
|
23
|
+
|
24
|
+
return duplicates unless attrs
|
25
|
+
|
26
|
+
if attrs.is_a? Array
|
27
|
+
attrs.each do |d|
|
28
|
+
duplicates << Duplicate.new(d)
|
29
|
+
end
|
30
|
+
else
|
31
|
+
duplicates << Duplicate.new(attrs)
|
32
|
+
end
|
30
33
|
|
31
|
-
|
34
|
+
duplicates
|
35
|
+
end
|
32
36
|
end
|
33
37
|
end
|
34
38
|
end
|
data/lib/nfe_reader/customer.rb
CHANGED
@@ -1,61 +1,65 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
module Nfe
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
:city, :state, :country_code, :country, :complement, :foreign_code,
|
8
|
-
:cep, :city_registration, :state_registration_code
|
3
|
+
module Reader
|
4
|
+
# Identificação do Destinatário da Nota Fiscal eletrônica
|
5
|
+
class Customer
|
6
|
+
include ::AttributeHelper
|
9
7
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
# 9 - Não Contribuinte, que pode ou não possuir Inscrição Estadual
|
8
|
+
attr_reader :cnpj, :cpf, :name, :state_registration, :email,
|
9
|
+
:suframa, :phone, :address, :number, :neighborhood, :city_code,
|
10
|
+
:city, :state, :country_code, :country, :complement, :foreign_code,
|
11
|
+
:zip_code, :city_registration, :state_registration_code
|
15
12
|
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
# == Fields Values
|
14
|
+
#
|
15
|
+
# indIEDest: 1 - Contribuinte ICMS (informar a IE do destinatário),
|
16
|
+
# 2 - Contribuinte isento de Inscrição no cadastro de Contribuintes do ICMS,
|
17
|
+
# 9 - Não Contribuinte, que pode ou não possuir Inscrição Estadual
|
19
18
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
@state_registration = attrs[:IE]
|
24
|
-
# Inscrição na SUFRAMA
|
25
|
-
@suframa = attrs[:ISUF]
|
26
|
-
# Inscrição Municipal do Tomador do Serviço
|
27
|
-
@city_registration = attrs[:IM]
|
28
|
-
# Indicador da IE do Destinatário
|
29
|
-
@state_registration_code = attrs[:indIEDest]
|
30
|
-
# Email
|
31
|
-
@email = attrs[:email]
|
32
|
-
# Identificação do destinatário no caso de comprador estrangeiro
|
33
|
-
@foreign_code = attrs[:idEstrangeiro]
|
19
|
+
def initialize(attrs = {})
|
20
|
+
@cnpj = attrs[:CNPJ]
|
21
|
+
@cpf = attrs[:CPF]
|
34
22
|
|
35
|
-
|
36
|
-
|
37
|
-
#
|
38
|
-
@
|
39
|
-
#
|
40
|
-
@
|
41
|
-
#
|
42
|
-
@
|
43
|
-
#
|
44
|
-
@
|
45
|
-
#
|
46
|
-
@
|
47
|
-
#
|
48
|
-
@
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
23
|
+
# Razão Social ou nome do destinatário
|
24
|
+
@name = attrs[:xNome]
|
25
|
+
# Inscrição Estadual do Destinatário
|
26
|
+
@state_registration = attrs[:IE]
|
27
|
+
# Inscrição na SUFRAMA
|
28
|
+
@suframa = attrs[:ISUF]
|
29
|
+
# Inscrição Municipal do Tomador do Serviço
|
30
|
+
@city_registration = attrs[:IM]
|
31
|
+
# Indicador da IE do Destinatário
|
32
|
+
@state_registration_code = attrs[:indIEDest]
|
33
|
+
# Email
|
34
|
+
@email = attrs[:email]
|
35
|
+
# Identificação do destinatário no caso de comprador estrangeiro
|
36
|
+
@foreign_code = attrs[:idEstrangeiro]
|
37
|
+
|
38
|
+
# Address
|
39
|
+
if attrs[:enderDest]
|
40
|
+
# Logradouro
|
41
|
+
@address = attrs[:enderDest][:xLgr]
|
42
|
+
# Numero
|
43
|
+
@number = attrs[:enderDest][:nro]
|
44
|
+
# Complemento
|
45
|
+
@complement = attrs[:enderDest][:xCpl]
|
46
|
+
# Bairro
|
47
|
+
@neighborhood = attrs[:enderDest][:xBairro]
|
48
|
+
# Código do município
|
49
|
+
@city_code = attrs[:enderDest][:cMun]
|
50
|
+
# Nome do município
|
51
|
+
@city = attrs[:enderDest][:xMun]
|
52
|
+
# Sigla da UF
|
53
|
+
@state = attrs[:enderDest][:UF]
|
54
|
+
# Código do CEP
|
55
|
+
@zip_code = attrs[:enderDest][:CEP]
|
56
|
+
# Codigo Pais
|
57
|
+
@country_code = attrs[:enderDest][:cPais]
|
58
|
+
# Nome do Pais
|
59
|
+
@country = attrs[:enderDest][:xPais]
|
60
|
+
# Telefone
|
61
|
+
@phone = attrs[:enderDest][:fone]
|
62
|
+
end
|
59
63
|
end
|
60
64
|
end
|
61
65
|
end
|
data/lib/nfe_reader/delivery.rb
CHANGED
@@ -1,20 +1,24 @@
|
|
1
1
|
# Local de Entrega
|
2
2
|
module Nfe
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
module Reader
|
4
|
+
# Identificação do Local de Entrega
|
5
|
+
class Delivery
|
6
|
+
include ::AttributeHelper
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
8
|
+
attr_reader :cnpj, :cpf, :address, :number, :complement,
|
9
|
+
:neighborhood, :city_code, :city, :state
|
10
|
+
|
11
|
+
def initialize(attrs = {})
|
12
|
+
@cnpj = attrs[:CNPJ]
|
13
|
+
@cpf = attrs[:CPF]
|
14
|
+
@address = attrs[:xLgr]
|
15
|
+
@number = attrs[:nro]
|
16
|
+
@complement = attrs[:xCpl]
|
17
|
+
@neighborhood = attrs[:xBairro]
|
18
|
+
@city_code = attrs[:cMun]
|
19
|
+
@city = attrs[:xMun]
|
20
|
+
@state = attrs[:UF]
|
21
|
+
end
|
18
22
|
end
|
19
23
|
end
|
20
24
|
end
|
data/lib/nfe_reader/document.rb
CHANGED
@@ -1,72 +1,76 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
module Nfe
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
:farmer_cpf, :farmer_ie, :farmer_model, :farmer_serie, :farmer_number,
|
8
|
-
:cte_key, :ecf_model, :ecf_number, :ecf_operation
|
3
|
+
module Reader
|
4
|
+
# Documento Fiscal Referenciado
|
5
|
+
class Document
|
6
|
+
include ::AttributeHelper
|
9
7
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
# 01 - NF (v2.0)
|
15
|
-
# refECF: 2B - Cupom Fiscal emitido por máquina registradora (não ECF),
|
16
|
-
# 2C - Cupom Fiscal PDV,
|
17
|
-
# 2D - Cupom Fiscal (emitido por ECF) (v2.0)
|
8
|
+
attr_reader :key, :nfe_state, :nfe_year, :nfe_cnpj, :nfe_model,
|
9
|
+
:nfe_serie, :nfe_number, :farmer_state, :farmer_year, :farmer_cnpj,
|
10
|
+
:farmer_cpf, :farmer_ie, :farmer_model, :farmer_serie, :farmer_number,
|
11
|
+
:cte_key, :ecf_model, :ecf_number, :ecf_operation
|
18
12
|
|
19
|
-
|
20
|
-
#
|
21
|
-
|
13
|
+
# == Fields Values
|
14
|
+
# mod:
|
15
|
+
# refNF: 01 - modelo 01
|
16
|
+
# refNFP: 04 - NF de Produtor,
|
17
|
+
# 01 - NF (v2.0)
|
18
|
+
# refECF: 2B - Cupom Fiscal emitido por máquina registradora (não ECF),
|
19
|
+
# 2C - Cupom Fiscal PDV,
|
20
|
+
# 2D - Cupom Fiscal (emitido por ECF) (v2.0)
|
22
21
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
@nfe_state = attrs[:refNF][:cUF]
|
27
|
-
# Ano e mes
|
28
|
-
@nfe_year = attrs[:refNF][:AAMM]
|
29
|
-
# CNPJ do emitente
|
30
|
-
@nfe_cnpj = attrs[:refNF][:CNPJ]
|
31
|
-
# Modelo do Documento Fiscal
|
32
|
-
@nfe_model = attrs[:refNF][:mod]
|
33
|
-
# Serie Documento Fiscal
|
34
|
-
@nfe_serie = attrs[:refNF][:serie]
|
35
|
-
# Numero Documento Fiscal
|
36
|
-
@nfe_number = attrs[:refNF][:nNF]
|
37
|
-
end
|
22
|
+
def initialize(attrs = {})
|
23
|
+
# Chave da NF-e
|
24
|
+
@key = attrs[:refNFe]
|
38
25
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
#
|
56
|
-
|
57
|
-
|
26
|
+
# Referencia uma NF-e
|
27
|
+
if attrs[:refNF]
|
28
|
+
# Estado
|
29
|
+
@nfe_state = attrs[:refNF][:cUF]
|
30
|
+
# Ano e mes
|
31
|
+
@nfe_year = attrs[:refNF][:AAMM]
|
32
|
+
# CNPJ do emitente
|
33
|
+
@nfe_cnpj = attrs[:refNF][:CNPJ]
|
34
|
+
# Modelo do Documento Fiscal
|
35
|
+
@nfe_model = attrs[:refNF][:mod]
|
36
|
+
# Serie Documento Fiscal
|
37
|
+
@nfe_serie = attrs[:refNF][:serie]
|
38
|
+
# Numero Documento Fiscal
|
39
|
+
@nfe_number = attrs[:refNF][:nNF]
|
40
|
+
end
|
41
|
+
|
42
|
+
# NF de Produtor Rural
|
43
|
+
if attrs[:refNFP]
|
44
|
+
# Estado
|
45
|
+
@farmer_state = attrs[:refNFP][:cUF]
|
46
|
+
# Ano e mes
|
47
|
+
@farmer_year = attrs[:refNFP][:AAMM]
|
48
|
+
# CNPJ do emitente
|
49
|
+
@farmer_cnpj = attrs[:refNFP][:CNPJ]
|
50
|
+
# CPF do emitente
|
51
|
+
@farmer_cpf = attrs[:refNFP][:CPF]
|
52
|
+
# IE do emitente
|
53
|
+
@farmer_ie = attrs[:refNFP][:IE]
|
54
|
+
# Modelo do Documento Fiscal
|
55
|
+
@farmer_model = attrs[:refNFP][:mod]
|
56
|
+
# Serie Documento Fiscal
|
57
|
+
@farmer_serie = attrs[:refNFP][:serie]
|
58
|
+
# Numero Documento Fiscal
|
59
|
+
@farmer_number = attrs[:refNFP][:nNF]
|
60
|
+
end
|
58
61
|
|
59
|
-
|
60
|
-
|
62
|
+
# CT-e
|
63
|
+
@cte_key = attrs[:refCTe]
|
61
64
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
65
|
+
# Referencia uma ECF
|
66
|
+
if attrs[:refECF]
|
67
|
+
# Modelo do Documento Fiscal
|
68
|
+
@ecf_model = attrs[:refECF][:mod]
|
69
|
+
# Número de ordem sequencial do ECF
|
70
|
+
@ecf_number = attrs[:refECF][:nECF]
|
71
|
+
# Número do Contador de Ordem de Operação
|
72
|
+
@ecf_operation = attrs[:refECF][:nCOO]
|
73
|
+
end
|
70
74
|
end
|
71
75
|
end
|
72
76
|
end
|
data/lib/nfe_reader/export.rb
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
# Informações de Comércio Exterior
|
3
3
|
module Nfe
|
4
|
-
|
5
|
-
|
4
|
+
module Reader
|
5
|
+
class Export
|
6
|
+
include ::AttributeHelper
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
attr_reader :state, :address
|
9
|
+
|
10
|
+
def initialize(attrs = {})
|
11
|
+
@state = attrs[:UFEmbarq]
|
12
|
+
@address = attrs[:xLocEmbarq]
|
13
|
+
end
|
10
14
|
end
|
11
15
|
end
|
12
16
|
end
|
data/lib/nfe_reader/fiscal.rb
CHANGED
@@ -1,33 +1,37 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
module Nfe
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
module Reader
|
4
|
+
# Identificação do Fisco Emitente da NF-e
|
5
|
+
class Fiscal
|
6
|
+
include ::AttributeHelper
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
8
|
+
attr_reader :cnpj, :agency, :code, :name, :paid_date,
|
9
|
+
:phone, :state, :number, :date, :value, :repartition
|
10
|
+
|
11
|
+
def initialize(attrs = {})
|
12
|
+
# CNPJ emitente
|
13
|
+
@cnpj = attrs[:CNPJ]
|
14
|
+
# Órgão emitente
|
15
|
+
@agency = attrs[:xOrgao]
|
16
|
+
# Matrícula do agente do Fisco
|
17
|
+
@code = attrs[:matr]
|
18
|
+
# Nome do agente do Fisco
|
19
|
+
@name = attrs[:xAgente]
|
20
|
+
# Telefone do agente do Fisco
|
21
|
+
@phone = attrs[:fone]
|
22
|
+
# Estado
|
23
|
+
@state = attrs[:UF]
|
24
|
+
# Número do DAR(Documento de Arrecadação de Receita)
|
25
|
+
@number = attrs[:nDAR]
|
26
|
+
# Data
|
27
|
+
@date = attrs[:dEmi]
|
28
|
+
# Valor do DAR
|
29
|
+
@value = attrs[:vDAR]
|
30
|
+
# Repartição Fiscal emitente
|
31
|
+
@repartition = attrs[:repEmi]
|
32
|
+
# Data do Pagamento
|
33
|
+
@paid_date = attrs[:dPag]
|
34
|
+
end
|
31
35
|
end
|
32
36
|
end
|
33
37
|
end
|