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.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +10 -1
  3. data/lib/helpers/attribute_helper.rb +18 -0
  4. data/lib/helpers/creator_helper.rb +32 -0
  5. data/lib/nfe_reader/authorization.rb +10 -6
  6. data/lib/nfe_reader/carrier.rb +14 -10
  7. data/lib/nfe_reader/collection/duplicate.rb +10 -6
  8. data/lib/nfe_reader/collection.rb +28 -24
  9. data/lib/nfe_reader/customer.rb +56 -52
  10. data/lib/nfe_reader/delivery.rb +18 -14
  11. data/lib/nfe_reader/document.rb +65 -61
  12. data/lib/nfe_reader/export.rb +9 -5
  13. data/lib/nfe_reader/fiscal.rb +31 -27
  14. data/lib/nfe_reader/header.rb +120 -117
  15. data/lib/nfe_reader/information.rb +17 -26
  16. data/lib/nfe_reader/nfe.rb +130 -0
  17. data/lib/nfe_reader/product/armament.rb +20 -16
  18. data/lib/nfe_reader/product/cane.rb +22 -32
  19. data/lib/nfe_reader/product/exportation.rb +17 -13
  20. data/lib/nfe_reader/product/fuel.rb +15 -11
  21. data/lib/nfe_reader/product/importation.rb +44 -40
  22. data/lib/nfe_reader/product/medicament.rb +17 -13
  23. data/lib/nfe_reader/product/vehicle.rb +115 -111
  24. data/lib/nfe_reader/product.rb +67 -76
  25. data/lib/nfe_reader/provider.rb +39 -35
  26. data/lib/nfe_reader/purchase.rb +10 -6
  27. data/lib/nfe_reader/removal.rb +18 -14
  28. data/lib/nfe_reader/taxation/cofins.rb +41 -37
  29. data/lib/nfe_reader/taxation/cofins_st.rb +17 -13
  30. data/lib/nfe_reader/taxation/icms.rb +80 -76
  31. data/lib/nfe_reader/taxation/importation_tax.rb +16 -12
  32. data/lib/nfe_reader/taxation/ipi.rb +37 -33
  33. data/lib/nfe_reader/taxation/issqn.rb +19 -15
  34. data/lib/nfe_reader/taxation/pis.rb +41 -37
  35. data/lib/nfe_reader/taxation/pis_st.rb +18 -14
  36. data/lib/nfe_reader/total.rb +71 -67
  37. data/lib/nfe_reader/transport.rb +87 -83
  38. data/lib/nfe_reader/version.rb +1 -1
  39. data/lib/nfe_reader.rb +3 -130
  40. data/test/helpers/attributte_helper_test.rb +19 -0
  41. data/test/helpers/creator_helper_test.rb +28 -0
  42. data/test/{nokogiri_test.rb → helpers/nokogiri_test.rb} +1 -1
  43. data/test/nfe_reader/authorization_test.rb +2 -2
  44. data/test/nfe_reader/cane_test.rb +2 -2
  45. data/test/nfe_reader/carrier_test.rb +2 -2
  46. data/test/nfe_reader/collection/duplicate_test.rb +2 -2
  47. data/test/nfe_reader/collection_test.rb +3 -3
  48. data/test/nfe_reader/customer_test.rb +3 -3
  49. data/test/nfe_reader/delivery_test.rb +2 -2
  50. data/test/nfe_reader/document_test.rb +2 -2
  51. data/test/nfe_reader/export_test.rb +2 -2
  52. data/test/nfe_reader/fiscal_test.rb +2 -2
  53. data/test/nfe_reader/header_test.rb +2 -2
  54. data/test/nfe_reader/information_test.rb +2 -2
  55. data/test/{nfe_reader_test.rb → nfe_reader/nfe_test.rb} +15 -15
  56. data/test/nfe_reader/product/armament_test.rb +2 -2
  57. data/test/nfe_reader/product/exportation_test.rb +2 -2
  58. data/test/nfe_reader/product/fuel_test.rb +2 -2
  59. data/test/nfe_reader/product/importation_test.rb +27 -2
  60. data/test/nfe_reader/product/medicament_test.rb +2 -2
  61. data/test/nfe_reader/product/vehicle_test.rb +2 -2
  62. data/test/nfe_reader/product_test.rb +6 -6
  63. data/test/nfe_reader/provider_test.rb +3 -3
  64. data/test/nfe_reader/purchase_test.rb +2 -2
  65. data/test/nfe_reader/removal_test.rb +2 -2
  66. data/test/nfe_reader/taxation/cofins_st_test.rb +2 -2
  67. data/test/nfe_reader/taxation/cofins_test.rb +2 -2
  68. data/test/nfe_reader/taxation/icms_test.rb +2 -2
  69. data/test/nfe_reader/taxation/importation_tax_test.rb +2 -2
  70. data/test/nfe_reader/taxation/ipi_test.rb +2 -2
  71. data/test/nfe_reader/taxation/issqn_test.rb +2 -2
  72. data/test/nfe_reader/taxation/pis_st_test.rb +2 -2
  73. data/test/nfe_reader/taxation/pis_test.rb +2 -2
  74. data/test/nfe_reader/total_test.rb +2 -2
  75. data/test/nfe_reader/transport_test.rb +3 -3
  76. metadata +14 -7
  77. /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: 4e774c8870d885012e9766d7414e929602371814
4
- data.tar.gz: 9560d73f3be52d68614849708bc60d58d2b7ee1c
3
+ metadata.gz: b0a6ea021f20cf8869fb72b69dc09f308b4459b2
4
+ data.tar.gz: 8fd34ca62a8976705aaa417b5aa01b67f006d260
5
5
  SHA512:
6
- metadata.gz: adeda4aa09c7718a6dc5738dca02dfce761629d9f8ca45baf511c09248540b5dc8921c264595a300638d6914c79914c1d0fb332d1c5ab11629f972f80eafda07
7
- data.tar.gz: 006d0e2d8dfa36543cbb00706b7d4c7fd33b33c8e296c907a38070b610a77512c12f71dd6cd7a74bc53a1aad90f45010847ba2fcdf1ca97c229ae07dbdb8e1a8
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::Base.new(file)
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
- # Pessoas Autorizadas para obter XML
4
- class Authorization
5
- attr_reader :cnpj, :cpf
3
+ module Reader
4
+ # Pessoas Autorizadas para obter XML
5
+ class Authorization
6
+ include ::AttributeHelper
6
7
 
7
- def initialize(attrs = {})
8
- @cnpj = attrs[:CNPJ]
9
- @cpf = attrs[:CPF]
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
@@ -1,16 +1,20 @@
1
1
  # encoding: UTF-8
2
2
  module Nfe
3
- class Carrier
4
- attr_reader :cnpj, :cpf, :name, :ie, :address, :city, :state
3
+ module Reader
4
+ class Carrier
5
+ include ::AttributeHelper
5
6
 
6
- def initialize(attrs = {})
7
- @cnpj = attrs[:CNPJ]
8
- @cpf = attrs[:CPF]
9
- @name = attrs[:xNome]
10
- @ie = attrs[:IE]
11
- @address = attrs[:xEnder]
12
- @city = attrs[:xMun]
13
- @state = attrs[:UF]
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
- class Duplicate
4
- attr_reader :number, :expiration, :value
3
+ module Reader
4
+ class Duplicate
5
+ include ::AttributeHelper
5
6
 
6
- def initialize(attrs = {})
7
- @number = attrs[:nDup]
8
- @expiration = attrs[:dVenc]
9
- @value = attrs[:vDup]
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
- # Mapeia as Cobrancas
4
- class Collection
5
- attr_reader :number, :value, :descont, :value_net, :duplicates
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
- @duplicates = set_duplicates(attrs[:dup])
16
- end
17
-
18
- def set_duplicates(attrs = {})
19
- duplicates = []
8
+ attr_reader :number, :value, :descont, :value_net, :duplicates
20
9
 
21
- return duplicates unless attrs
22
-
23
- if attrs.is_a? Array
24
- attrs.each do |d|
25
- duplicates << Nfe::Duplicate.new(d)
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
- else
28
- duplicates << Nfe::Duplicate.new(attrs)
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
- duplicates
34
+ duplicates
35
+ end
32
36
  end
33
37
  end
34
38
  end
@@ -1,61 +1,65 @@
1
1
  # encoding: UTF-8
2
2
  module Nfe
3
- # Identificação do Destinatário da Nota Fiscal eletrônica
4
- class Customer
5
- attr_reader :cnpj, :cpf, :name, :state_registration, :email,
6
- :suframa, :phone, :address, :number, :neighborhood, :city_code,
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
- # == Fields Values
11
- #
12
- # indIEDest: 1 - Contribuinte ICMS (informar a IE do destinatário),
13
- # 2 - Contribuinte isento de Inscrição no cadastro de Contribuintes do ICMS,
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
- def initialize(attrs = {})
17
- @cnpj = attrs[:CNPJ]
18
- @cpf = attrs[:CPF]
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
- # Razão Social ou nome do destinatário
21
- @name = attrs[:xNome]
22
- # Inscrição Estadual do Destinatário
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
- # Address
36
- if attrs[:enderDest]
37
- # Logradouro
38
- @address = attrs[:enderDest][:xLgr]
39
- # Numero
40
- @number = attrs[:enderDest][:nro]
41
- # Complemento
42
- @complement = attrs[:enderDest][:xCpl]
43
- # Bairro
44
- @neighborhood = attrs[:enderDest][:xBairro]
45
- # Código do município
46
- @city_code = attrs[:enderDest][:cMun]
47
- # Nome do município
48
- @city = attrs[:enderDest][:xMun]
49
- # Sigla da UF
50
- @state = attrs[:enderDest][:UF]
51
- # Código do CEP
52
- @zip_code = attrs[:enderDest][:CEP]
53
- # Codigo Pais
54
- @country_code = attrs[:enderDest][:cPais]
55
- # Nome do Pais
56
- @country = attrs[:enderDest][:xPais]
57
- # Telefone
58
- @phone = attrs[:enderDest][:fone]
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
@@ -1,20 +1,24 @@
1
1
  # Local de Entrega
2
2
  module Nfe
3
- # Identificação do Local de Entrega
4
- class Delivery
5
- attr_reader :cnpj, :cpf, :address, :number, :complement,
6
- :neighborhood, :city_code, :city, :state
3
+ module Reader
4
+ # Identificação do Local de Entrega
5
+ class Delivery
6
+ include ::AttributeHelper
7
7
 
8
- def initialize(attrs = {})
9
- @cnpj = attrs[:CNPJ]
10
- @cpf = attrs[:CPF]
11
- @address = attrs[:xLgr]
12
- @number = attrs[:nro]
13
- @complement = attrs[:xCpl]
14
- @neighborhood = attrs[:xBairro]
15
- @city_code = attrs[:cMun]
16
- @city = attrs[:xMun]
17
- @state = attrs[:UF]
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
@@ -1,72 +1,76 @@
1
1
  # encoding: UTF-8
2
2
  module Nfe
3
- # Documento Fiscal Referenciado
4
- class Document
5
- attr_reader :key, :nfe_state, :nfe_year, :nfe_cnpj, :nfe_model,
6
- :nfe_serie, :nfe_number, :farmer_state, :farmer_year, :farmer_cnpj,
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
- # == Fields Values
11
- # mod:
12
- # refNF: 01 - modelo 01
13
- # refNFP: 04 - NF de Produtor,
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
- def initialize(attrs = {})
20
- # Chave da NF-e
21
- @key = attrs[:refNFe]
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
- # Referencia uma NF-e
24
- if attrs[:refNF]
25
- # Estado
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
- # NF de Produtor Rural
40
- if attrs[:refNFP]
41
- # Estado
42
- @farmer_state = attrs[:refNFP][:cUF]
43
- # Ano e mes
44
- @farmer_year = attrs[:refNFP][:AAMM]
45
- # CNPJ do emitente
46
- @farmer_cnpj = attrs[:refNFP][:CNPJ]
47
- # CPF do emitente
48
- @farmer_cpf = attrs[:refNFP][:CPF]
49
- # IE do emitente
50
- @farmer_ie = attrs[:refNFP][:IE]
51
- # Modelo do Documento Fiscal
52
- @farmer_model = attrs[:refNFP][:mod]
53
- # Serie Documento Fiscal
54
- @farmer_serie = attrs[:refNFP][:serie]
55
- # Numero Documento Fiscal
56
- @farmer_number = attrs[:refNFP][:nNF]
57
- end
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
- # CT-e
60
- @cte_key = attrs[:refCTe]
62
+ # CT-e
63
+ @cte_key = attrs[:refCTe]
61
64
 
62
- # Referencia uma ECF
63
- if attrs[:refECF]
64
- # Modelo do Documento Fiscal
65
- @ecf_model = attrs[:refECF][:mod]
66
- # Número de ordem sequencial do ECF
67
- @ecf_number = attrs[:refECF][:nECF]
68
- # Número do Contador de Ordem de Operação
69
- @ecf_operation = attrs[:refECF][:nCOO]
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
@@ -1,12 +1,16 @@
1
1
  # encoding: UTF-8
2
2
  # Informações de Comércio Exterior
3
3
  module Nfe
4
- class Export
5
- attr_reader :state, :address
4
+ module Reader
5
+ class Export
6
+ include ::AttributeHelper
6
7
 
7
- def initialize(attrs = {})
8
- @state = attrs[:UFEmbarq]
9
- @address = attrs[:xLocEmbarq]
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
@@ -1,33 +1,37 @@
1
1
  # encoding: UTF-8
2
2
  module Nfe
3
- # Identificação do Fisco Emitente da NF-e
4
- class Fiscal
5
- attr_reader :cnpj, :agency, :code, :name, :paid_date,
6
- :phone, :state, :number, :date, :value, :repartition
3
+ module Reader
4
+ # Identificação do Fisco Emitente da NF-e
5
+ class Fiscal
6
+ include ::AttributeHelper
7
7
 
8
- def initialize(attrs = {})
9
- # CNPJ emitente
10
- @cnpj = attrs[:CNPJ]
11
- # Órgão emitente
12
- @agency = attrs[:xOrgao]
13
- # Matrícula do agente do Fisco
14
- @code = attrs[:matr]
15
- # Nome do agente do Fisco
16
- @name = attrs[:xAgente]
17
- # Telefone do agente do Fisco
18
- @phone = attrs[:fone]
19
- # Estado
20
- @state = attrs[:UF]
21
- # Número do DAR(Documento de Arrecadação de Receita)
22
- @number = attrs[:nDAR]
23
- # Data
24
- @date = attrs[:dEmi]
25
- # Valor do DAR
26
- @value = attrs[:vDAR]
27
- # Repartição Fiscal emitente
28
- @repartition = attrs[:repEmi]
29
- # Data do Pagamento
30
- @paid_date = attrs[:dPag]
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