ruby-nfe 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9831937f61dc95bd11d461006e90f7f146889d65
4
+ data.tar.gz: 829c3d9d331d8ba4496ba850c213fa22ef515a3d
5
+ SHA512:
6
+ metadata.gz: 6ea4fa1f0079d4025077da17da7d659ca9a746443ca56c57435de334bc54eae70fe08fc6edad0087641885b42c95064b1a5907c0e3bc4fc279831a80eed5ff9b
7
+ data.tar.gz: 3c37d59461509a2003510f0f5f9f7c63fc13e258886c401e628e83f64a57e654eb001842584c84ab6faacaf70f0c70027b0d95956e2b49d2539ea4f34bd6a863
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/lib/nfe.rb ADDED
@@ -0,0 +1,20 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
+ require "nfe/version"
5
+ require 'nfe/entidades/entidade_nfe.rb'
6
+ require 'nfe/entidades/infNFe/nota_fiscal.rb'
7
+ require 'nfe/entidades/infNFe/ide/identificacao_nfe.rb'
8
+ require 'nfe/entidades/infNFe/emit/emitente.rb'
9
+ require 'nfe/entidades/infNFe/emit/endereco_emitente.rb'
10
+ require 'nfe/entidades/infNFe/dest/destinatario.rb'
11
+ require 'nfe/entidades/infNFe/dest/endereco_destinatario.rb'
12
+ require 'nfe/entidades/infNFe/det/produto.rb'
13
+ require 'nfe/entidades/infNFe/det/imposto.rb'
14
+ require 'nfe/entidades/infNFe/transp/transportadora.rb'
15
+ require 'nfe/entidades/infNFe/transp/veiculo.rb'
16
+ require 'nfe/entidades/infNFe/transp/volume.rb'
17
+ require 'nfe/entidades/infNFe/infAdic/info.rb'
18
+
19
+
20
+
@@ -0,0 +1,84 @@
1
+ # encoding: UTF-8
2
+ require 'nokogiri'
3
+ require 'roxml'
4
+ require 'json'
5
+
6
+ module NFe
7
+ class NFeProc
8
+ include ROXML
9
+ xml_name :NFeProc
10
+ xml_accessor :xmlns, :from => "http://www.portalfiscal.inf.br/nfe" # attribute with name 'ISBN'
11
+ #xmlns="http://www.portalfiscal.inf.br/nfe"
12
+ # xml_accessor :title
13
+ # xml_accessor :description, :cdata => true # text node with cdata protection
14
+ # xml_accessor :author
15
+ end
16
+
17
+ class EntidadeNFe
18
+ include ROXML
19
+ @@validations = []
20
+
21
+ class << self
22
+ alias :nfe_attr :xml_accessor
23
+
24
+ def xml_accessor(*attrs)
25
+ attr_accessor *attrs
26
+ # super(*attrs)
27
+ end
28
+
29
+ def nfe_attrs
30
+ roxml_attrs.map(&attr_name)
31
+ end
32
+ end
33
+
34
+ def nfe_attributes
35
+ self.class.nfe_attrs
36
+ end
37
+
38
+ def to_nfe_xml(file)
39
+ #entidade = EntidadeNFe.from_xml(File.read(File.expand_path('example-user.xml', File.dirname(__FILE__))))
40
+ #entidade = NFe::EntidadeNFe.from_xml(File.read(File.expand_path(file, File.dirname(__FILE__))))
41
+ entidade = Nokogiri::XML(File.open(file))
42
+ doc = Nokogiri::XML::Document.new
43
+ doc.root = self.to_xml
44
+ # open("entidade_nfe.xml", 'w') do |file|
45
+ # file << doc.serialize
46
+ # end
47
+ puts ">>>>>> #{doc.root.to_s}"
48
+ end
49
+
50
+ def to_nfe
51
+ #depois fazer o teste com REXML
52
+ doc = Nokogiri::XML::Document.new
53
+ doc.root = to_xml
54
+ doc.serialize
55
+ end
56
+
57
+ # def to_s
58
+ # self.respond_to? :to_nfe ? to_nfe : super
59
+ # end
60
+
61
+ def serialize(params)
62
+ params.each do |key, value|
63
+ send("#{key}=", value) if respond_to?(key)
64
+ end
65
+ end
66
+
67
+ def xml_to_hash(xml)
68
+ hash = {}
69
+ xml.children.each do |i|
70
+ hash.store(i.name, i.text)
71
+ end
72
+ hash
73
+ end
74
+
75
+ def to_xml(xml)
76
+ hash = ''
77
+ xml.children.each do |i|
78
+ hash << "<#{i.name}>#{i.text}</#{i.name}>"
79
+ end
80
+ hash
81
+ end
82
+
83
+ end
84
+ end
@@ -0,0 +1,36 @@
1
+ # encoding: UTF-8
2
+ module NFe
3
+ class Destinatario < NFe::EntidadeNFe
4
+ xml_name :emit
5
+ attr_accessor :xNome
6
+ attr_accessor :CNPJ
7
+ attr_accessor :enderDest
8
+ attr_accessor :indIEDest
9
+ attr_accessor :IE
10
+ attr_accessor :endereco_destinatario
11
+
12
+ def initializer
13
+ self.endereco_destinatario = NFe::EnderecoDestinatario.new
14
+ end
15
+
16
+ def attributes
17
+ @attributes = {
18
+ "xNome" => xNome,
19
+ "CNPJ" => CNPJ,
20
+ "enderEmit" => @enderEmit,
21
+ "indIEDest" => indIEDest,
22
+ "IE" => IE
23
+ }
24
+ end
25
+
26
+ def attributes=(params)
27
+ @attributes = {
28
+ "xNome" => params["razao_social"],
29
+ "CNPJ" => params["cnpj"],
30
+ "enderDest" => params["enderDest"],
31
+ "indIEDest" => params["indIEDest"],
32
+ "IE" => params["IE"],
33
+ }
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,78 @@
1
+ # encoding: UTF-8
2
+ module NFe
3
+ class EnderecoDestinatario < NFe::EntidadeNFe
4
+ xml_name :enderEmit
5
+ attr_accessor :xLgr
6
+ attr_accessor :nro
7
+ attr_accessor :xCpl
8
+ attr_accessor :xBairro
9
+ attr_accessor :cMun
10
+ attr_accessor :xMun
11
+ attr_accessor :UF
12
+ attr_accessor :CEP
13
+ attr_accessor :cPais
14
+ attr_accessor :xPais
15
+ attr_accessor :fone
16
+
17
+ def initialize(attrs = {})
18
+ self.xLgr = attrs[:xLgr]
19
+ self.nro = attrs[:nro]
20
+ self.xCpl = attrs[:xCpl]
21
+ self.xBairro = attrs[:xBairro]
22
+ self.cMun = attrs[:cMun]
23
+ self.xMun = attrs[:xMun]
24
+ self.UF = attrs[:UF]
25
+ self.CEP = attrs[:CEP]
26
+ self.cPais = attrs[:cPais]
27
+ self.xPais = attrs[:xPais]
28
+ self.fone = attrs[:fone]
29
+ end
30
+
31
+ def attributes
32
+ @attributes = {
33
+ "xLgr" => xLgr,
34
+ "nro" => nro,
35
+ "xCpl" => xCpl,
36
+ "xBairro" => xBairro,
37
+ "cMun" => cMun,
38
+ "xMun" => xMun,
39
+ "UF" => UF,
40
+ "CEP" => CEP,
41
+ "cPais" => cPais,
42
+ "xPais" => xPais,
43
+ "fone" => fone
44
+ }
45
+ end
46
+
47
+ def attributes=(params)
48
+ self.xLgr = params[:xLgr],
49
+ self.nro = params[:nro],
50
+ self.xCpl = params[:xCpl],
51
+ self.xBairro = params[:xBairro],
52
+ self.cMun = params[:cMun],
53
+ self.xMun = params[:xMun],
54
+ self.UF = params[:UF],
55
+ self.CEP = params[:CEP],
56
+ self.cPais = params[:cPais],
57
+ self.xPais = params[:xPais],
58
+ self.fone = params[:fone]
59
+ end
60
+
61
+ def xml_to_hash(xml) #node XML
62
+ xml.children.css('enderDest').each do |p|
63
+ self.xLgr = p.css('xLgr').text
64
+ self.nro = p.css('nro').text
65
+ self.xCpl = p.css('xCpl').text
66
+ self.xBairro = p.css('xBairro').text
67
+ self.cMun = p.css('cMun').text
68
+ self.xMun = p.css('xMun').text
69
+ self.UF = p.css('UF').text
70
+ self.CEP = p.css('CEP').text
71
+ self.cPais = p.css('cPais').text
72
+ self.xPais = p.css('xPais').text
73
+ self.fone = p.css('fone').text
74
+ end
75
+ self
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,5 @@
1
+ # encoding: UTF-8
2
+ class Imposto
3
+ attr_accessor :icms
4
+
5
+ end
@@ -0,0 +1,106 @@
1
+ # encoding: UTF-8
2
+ #module NFe
3
+ class Produto
4
+ attr_accessor :cProd
5
+ attr_accessor :cEAN
6
+ attr_accessor :xProd
7
+ attr_accessor :NCM
8
+ attr_accessor :EXTIPI
9
+ attr_accessor :CFOP
10
+ attr_accessor :uCom
11
+ attr_accessor :qCom
12
+ attr_accessor :vUnCom
13
+ attr_accessor :vProd
14
+ attr_accessor :cEANTrib
15
+ attr_accessor :uTrib
16
+ attr_accessor :qTrib
17
+ attr_accessor :vUnTrib
18
+ attr_accessor :indTot
19
+ attr_accessor :xPed
20
+ attr_accessor :xPed
21
+ attr_accessor :all_products
22
+
23
+ def initialize(attrs = {})
24
+ self.cProd = attrs[:cProd]
25
+ self.cEAN = attrs[:cEAN]
26
+ self.xProd = attrs[:xProd]
27
+ self.NCM = attrs[:NCM]
28
+ self.EXTIPI = attrs[:EXTIPI]
29
+ self.CFOP = attrs[:CFOP]
30
+ self.uCom = attrs[:uCom]
31
+ self.qCom = attrs[:qCom]
32
+ self.vUnCom = attrs[:vUnCom]
33
+ self.vProd = attrs[:vProd]
34
+ self.cEANTrib = attrs[:cEANTrib]
35
+ self.uTrib = attrs[:uTrib]
36
+ self.qTrib = attrs[:qTrib]
37
+ self.vUnTrib = attrs[:vUnTrib]
38
+ self.indTot = attrs[:indTot]
39
+ self.xPed = attrs[:xPed]
40
+ self.all_products = []
41
+ end
42
+
43
+ def attributes
44
+ { "cProd" => cProd,
45
+ "cEAN" => cEAN,
46
+ "xProd" => xProd,
47
+ "NCM" => NCM,
48
+ "EXTIPI" => EXTIPI,
49
+ "CFOP" => CFOP,
50
+ "uCom" => uCom,
51
+ "qCom" => qCom,
52
+ "vUnCom" => vUnCom,
53
+ "vProd" => vProd,
54
+ "cEANTrib" => cEANTrib,
55
+ "uTrib" => uTrib,
56
+ "qTrib" => qTrib,
57
+ "vUnTrib" => vUnTrib,
58
+ "indTot" => indTot,
59
+ "xPed" => xPed
60
+ }
61
+ end
62
+
63
+ def attributes=(params)
64
+ self.cProd = params["cProd"]
65
+ self.cEAN = params["cEAN"]
66
+ self.xProd = params["xProd"]
67
+ self.NCM = params["NCM"]
68
+ self.EXTIPI = params["EXTIPI"]
69
+ self.CFOP = params["CFOP"]
70
+ self.uCom = params["uCom"]
71
+ self.qCom = params["qCom"]
72
+ self.vUnCom = params["vUnCom"]
73
+ self.vProd = params["vProd"]
74
+ self.cEANTrib = params["cEANTrib"]
75
+ self.uTrib = params["uTrib"]
76
+ self.qTrib = params["qTrib"]
77
+ self.vUnTrib = params["vUnTrib"]
78
+ self.indTot = params["indTot"]
79
+ self.xPed = params["xPed"]
80
+ end
81
+
82
+ def xml_to_hash(xml) #file xml
83
+ doc = Nokogiri::XML(File.open(xml))
84
+ prods = doc.elements.css('prod').map do |p|
85
+ {
86
+ 'cProd' => p.css('cProd').text,
87
+ 'cEAN' => p.css('cEAN').text,
88
+ 'xProd' => p.css('xProd').text,
89
+ 'NCM' => p.css('NCM').text,
90
+ 'EXTIPI' => p.css('EXTIPI').text,
91
+ 'CFOP' => p.css('CFOP').text,
92
+ 'uCom' => p.css('uCom').text,
93
+ 'qCom' => p.css('qCom').text,
94
+ 'vUnCom' => p.css('vUnCom').text,
95
+ 'vProd' => p.css('vProd').text,
96
+ 'cEANTrib' => p.css('cEANTrib').text,
97
+ 'uTrib' => p.css('uTrib').text,
98
+ 'qTrib' => p.css('qTrib').text,
99
+ 'vUnTrib' => p.css('vUnTrib').text,
100
+ 'indTot' => p.css('indTot').text,
101
+ 'xPed' => p.css('xPed').text
102
+ }
103
+ end
104
+ prods.each {|p| self.all_products.push(p) }
105
+ end
106
+ end
@@ -0,0 +1,42 @@
1
+ # encoding: UTF-8
2
+ module NFe
3
+ class Emitente < NFe::EntidadeNFe
4
+ attr_accessor :CNPJ
5
+ attr_accessor :xNome
6
+ attr_accessor :enderEmit
7
+ attr_accessor :IE
8
+ attr_accessor :IM
9
+ attr_accessor :CNAE
10
+ attr_accessor :CRT
11
+ attr_accessor :endereco_emitente
12
+
13
+ def initializer
14
+ self.endereco_emitente = NFe::EnderecoEmitente.new
15
+ end
16
+
17
+ def attributes
18
+ @attributes = {
19
+ "CNPJ" => CNPJ,
20
+ "xNome" => xNome,
21
+ "enderEmit" => enderEmit,
22
+ "IE" => IE,
23
+ "IM" => IM,
24
+ "CNAE" => CNAE,
25
+ "CRT" => CRT,
26
+ }
27
+ #@endereco_emitente = @endereco_emitente.serealize(enderEmit)
28
+ end
29
+
30
+ def attributes=(params)
31
+ @attributes = {
32
+ "CNPJ" => params["CNPJ"],
33
+ "xNome" => params["xNome"],
34
+ "enderEmit" => params["enderEmit"],
35
+ "IE" => params["IE"],
36
+ "IM" => params["IM"],
37
+ "CNAE" => params["CNAE"],
38
+ "CRT" => params["CRT"]
39
+ }
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,78 @@
1
+ # encoding: UTF-8
2
+ module NFe
3
+ class EnderecoEmitente < NFe::EntidadeNFe
4
+ xml_name :enderEmit
5
+ attr_accessor :xLgr
6
+ attr_accessor :nro
7
+ attr_accessor :xCpl
8
+ attr_accessor :xBairro
9
+ attr_accessor :cMun
10
+ attr_accessor :xMun
11
+ attr_accessor :UF
12
+ attr_accessor :CEP
13
+ attr_accessor :cPais
14
+ attr_accessor :xPais
15
+ attr_accessor :fone
16
+
17
+ def initialize(attrs = {})
18
+ self.xLgr = attrs[:xLgr]
19
+ self.nro = attrs[:nro]
20
+ self.xCpl = attrs[:xCpl]
21
+ self.xBairro = attrs[:xBairro]
22
+ self.cMun = attrs[:cMun]
23
+ self.xMun = attrs[:xMun]
24
+ self.UF = attrs[:UF]
25
+ self.CEP = attrs[:CEP]
26
+ self.cPais = attrs[:cPais]
27
+ self.xPais = attrs[:xPais]
28
+ self.fone = attrs[:fone]
29
+ end
30
+
31
+ def attributes
32
+ @attributes = {
33
+ "xLgr" => xLgr,
34
+ "nro" => nro,
35
+ "xCpl" => xCpl,
36
+ "xBairro" => xBairro,
37
+ "cMun" => cMun,
38
+ "xMun" => xMun,
39
+ "UF" => UF,
40
+ "CEP" => CEP,
41
+ "cPais" => cPais,
42
+ "xPais" => xPais,
43
+ "fone" => fone
44
+ }
45
+ end
46
+
47
+ def attributes=(params)
48
+ self.xLgr = params[:xLgr],
49
+ self.nro = params[:nro],
50
+ self.xCpl = params[:xCpl],
51
+ self.xBairro = params[:xBairro],
52
+ self.cMun = params[:cMun],
53
+ self.xMun = params[:xMun],
54
+ self.UF = params[:UF],
55
+ self.CEP = params[:CEP],
56
+ self.cPais = params[:cPais],
57
+ self.xPais = params[:xPais],
58
+ self.fone = params[:fone]
59
+ end
60
+
61
+ def xml_to_hash(xml) #node XML
62
+ xml.children.css('enderEmit').each do |p|
63
+ self.xLgr = p.css('xLgr').text
64
+ self.nro = p.css('nro').text
65
+ self.xCpl = p.css('xCpl').text
66
+ self.xBairro = p.css('xBairro').text
67
+ self.cMun = p.css('cMun').text
68
+ self.xMun = p.css('xMun').text
69
+ self.UF = p.css('UF').text
70
+ self.CEP = p.css('CEP').text
71
+ self.cPais = p.css('cPais').text
72
+ self.xPais = p.css('xPais').text
73
+ self.fone = p.css('fone').text
74
+ end
75
+ self
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,83 @@
1
+ # encoding: UTF-8
2
+ module NFe
3
+ class IdentificacaoNFe < NFe::EntidadeNFe
4
+ xml_name :ide
5
+ attr_accessor :cUF
6
+ attr_accessor :cNF
7
+ attr_accessor :natOp
8
+ attr_accessor :indPag
9
+ attr_accessor :mod
10
+ attr_accessor :serie
11
+ attr_accessor :nNF
12
+ attr_accessor :dhEmi
13
+ attr_accessor :dSaiEnt
14
+ #attr_accessor :hSaiEnt
15
+ attr_accessor :tpNF
16
+ attr_accessor :idDest
17
+ attr_accessor :cMunFG
18
+ attr_accessor :tpImp
19
+ attr_accessor :tpEmis
20
+ attr_accessor :cDV
21
+ attr_accessor :tpAmb
22
+ attr_accessor :finNFe
23
+ attr_accessor :indFinal
24
+ attr_accessor :indPres
25
+ attr_accessor :procEmi
26
+ attr_accessor :verProc
27
+ attr_accessor :dhCont
28
+ attr_accessor :xJust
29
+
30
+ def attributes
31
+ @attributes = {
32
+ "cUF" => cUF,
33
+ "cNF" => cNF,
34
+ "natOp" => natOp,
35
+ "indPag" => indPag,
36
+ "mod" => mod,
37
+ "serie" => serie,
38
+ "nNF" => nNF,
39
+ "dhEmi" => dhEmi,
40
+ "dSaiEnt" => dSaiEnt,
41
+ "tpNF" => tpNF,
42
+ "idDest" => idDest,
43
+ "cMunFG" => cMunFG,
44
+ "tpImp" => tpImp,
45
+ "tpEmis" => tpEmis,
46
+ "cDV" => cDV,
47
+ "tpAmb" => tpAmb,
48
+ "finNFe" => finNFe,
49
+ "indFinal" => indFinal,
50
+ "indPres" => indPres,
51
+ "procEmi" => procEmi,
52
+ "verProc" => verProc
53
+ }
54
+ end
55
+
56
+ def attributes=(params)
57
+ @attributes = {
58
+ "cUF" => params["cUF"],
59
+ "cNF" => params["cNF"],
60
+ "natOp" => params["natOp"],
61
+ "indPag" => params["indPag"],
62
+ "mod" => params["mod"],
63
+ "serie" => params["serie"],
64
+ "nNF" => params["nNF"],
65
+ "dhEmi" => params["dhEmi"],
66
+ "dSaiEnt" => params["dSaiEnt"],
67
+ "tpNF" => params["tpNF"],
68
+ "idDest" => params["idDest"],
69
+ "cMunFG" => params["cMunFG"],
70
+ "tpImp" => params["tpImp"],
71
+ "tpEmis" => params["tpEmis"],
72
+ "cDV" => params["cDV"],
73
+ "tpAmb" => params["tpAmb"],
74
+ "finNFe" => params["finNFe"],
75
+ "indFinal" => params["indFinal"],
76
+ "indPres" => params["indPres"],
77
+ "procEmi" => params["procEmi"],
78
+ "verProc" => params["verProc"]
79
+ }
80
+ end
81
+
82
+ end
83
+ end
@@ -0,0 +1,20 @@
1
+ # encoding: UTF-8
2
+ module NFe
3
+ class Info < NFe::EntidadeNFe
4
+ xml_name :infAdic
5
+ attr_accessor :infCpl
6
+
7
+ def attributes
8
+ @attributes = {
9
+ "infCpl" => infCpl
10
+ }
11
+ end
12
+
13
+ def attributes=(params)
14
+ @attributes = {
15
+ "infCpl" => params["infCpl"]
16
+ }
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,58 @@
1
+ # encoding: UTF-8
2
+ module NFe
3
+ class NotaFiscal < NFe::EntidadeNFe
4
+ xml_name :infNFe
5
+
6
+ attr_accessor :ide
7
+ attr_accessor :emit
8
+ attr_accessor :dest
9
+ attr_accessor :prod
10
+ attr_accessor :transp
11
+ attr_accessor :veiculo
12
+ attr_accessor :vol
13
+ attr_accessor :info
14
+
15
+ def initializer
16
+ #@versao_processo_emissao = Nfe::Config::Params::VERSAO_PADRAO
17
+ @ide = NFe::IdentificacaoNFe.new
18
+ @emit = NFe::Emitente.new
19
+ @emit.endereco_emitente = NFe::EnderecoEmitente.new
20
+ @dest = NFe::Destinatario.new
21
+ @dest.endereco_destinatario = NFe::EnderecoDesinatario.new
22
+ @prod = []
23
+ @transp = NFe::Transportadora.new
24
+ @veiculo = NFe::Veiculo.new
25
+ @vol = NFe::Volume.new
26
+ @info = NFe::Info.new
27
+ @versao = '2.0' #criar uma constante em params da versao da NF-e
28
+ end
29
+
30
+ def load_xml_serealize(file)
31
+ doc = Nokogiri::XML(File.open(file))
32
+ self.ide = NFe::IdentificacaoNFe.new
33
+ self.emit = NFe::Emitente.new
34
+ self.dest = NFe::Destinatario.new
35
+ self.emit.endereco_emitente = NFe::EnderecoEmitente.new
36
+ self.transp = NFe::Transportadora.new
37
+ self.veiculo = NFe::Veiculo.new
38
+ self.vol = NFe::Volume.new
39
+ self.info = NFe::Info.new
40
+ produto = Produto.new
41
+ produto.xml_to_hash(file)
42
+
43
+ self.ide.serialize(@ide.xml_to_hash(doc.elements.css('ide')))
44
+ self.emit.serialize(@emit.xml_to_hash(doc.elements.css('emit')))
45
+ self.emit.endereco_emitente = NFe::EnderecoEmitente.new.xml_to_hash(doc.elements.css('emit'))
46
+ self.dest.serialize(@dest.xml_to_hash(doc.elements.css('dest')))
47
+ self.dest.endereco_destinatario = NFe::EnderecoDestinatario.new.xml_to_hash(doc.elements.css('dest'))
48
+ self.transp.serialize(@transp.xml_to_hash(doc.elements.css('transp/transporta')))
49
+ self.veiculo.serialize(@veiculo.xml_to_hash(doc.elements.css('transp/veicTransp')))
50
+ self.vol.serialize(@vol.xml_to_hash(doc.elements.css('transp/vol')))
51
+ self.info.serialize(@info.xml_to_hash(doc.elements.css('infAdic')))
52
+ self.prod = produto.all_products
53
+ self
54
+
55
+ end
56
+ end
57
+
58
+ end
@@ -0,0 +1,35 @@
1
+ # encoding: UTF-8
2
+ module NFe
3
+ class Transportadora < NFe::EntidadeNFe
4
+ xml_name :transporta
5
+ attr_accessor :CNPJ
6
+ attr_accessor :xNome
7
+ attr_accessor :IE
8
+ attr_accessor :xEnder
9
+ attr_accessor :xMun
10
+ attr_accessor :UF
11
+
12
+ def attributes
13
+ @attributes = {
14
+ "CNPJ" => CNPJ,
15
+ "xNome" => xNome,
16
+ "IE" => IE,
17
+ "xEnder" => xEnder,
18
+ "xMun" => xMun,
19
+ "UF" => UF
20
+ }
21
+ end
22
+
23
+ def attributes=(params)
24
+ @attributes = {
25
+ "CNPJ" => params["CNPJ"],
26
+ "xNome" => params["xNome"],
27
+ "IE" => params["IE"],
28
+ "xEnder" => params["xEnder"],
29
+ "xMun" => params["xMun"],
30
+ "UF" => params["UF"]
31
+ }
32
+ end
33
+
34
+ end
35
+ end
@@ -0,0 +1,28 @@
1
+ # encoding: UTF-8
2
+
3
+ module NFe
4
+ class Veiculo < NFe::EntidadeNFe
5
+ xml_name :veicTransp
6
+ attr_accessor :placa
7
+ attr_accessor :UF
8
+
9
+ # attr_accessor :RNTC
10
+ # "RNTC" => RCNT
11
+ # "RNTC" => params["RNTC"]
12
+
13
+ def attributes
14
+ @attributes = {
15
+ "placa" => placa,
16
+ "UF" => UF
17
+ }
18
+ end
19
+
20
+ def attributes=(params)
21
+ @attributes = {
22
+ "placa" => params["placa"],
23
+ "UF" => params["UF"]
24
+ }
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1,29 @@
1
+ # encoding: UTF-8
2
+ module NFe
3
+ class Volume < NFe::EntidadeNFe
4
+ xml_name :vol
5
+ attr_accessor :qVol
6
+ attr_accessor :esp
7
+ attr_accessor :pesoL
8
+ attr_accessor :pesoB
9
+
10
+ def attributes
11
+ @attributes = {
12
+ "qVol" => qVol,
13
+ "esp" => esp,
14
+ "pesoL" => pesoL,
15
+ "pesoB" => pesoB
16
+ }
17
+ end
18
+
19
+ def attributes=(params)
20
+ @attributes = {
21
+ "qVol" => params["qVol"],
22
+ "esp" => params["esp"],
23
+ "pesoL" => params["pesoL"],
24
+ "pesoB" => params["pesoB"]
25
+ }
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,3 @@
1
+ module NFe
2
+ VERSION = "0.0.1"
3
+ end
data/nfe.gemspec ADDED
@@ -0,0 +1,40 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'nfe/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ruby-nfe"
8
+ spec.version = NFe::VERSION
9
+ spec.authors = ["Igor C. Batista"]
10
+ spec.email = ["igor.batista@gmail.com"]
11
+
12
+ spec.summary = %q{Consulta arquivo XML da Sefaz.}
13
+ spec.description = %q{Consulta arquivo XML da Sefaz e serealiza em objeto.}
14
+ spec.homepage = "https://github.com/igorcb/ruby-nfe"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = "https://rubygems.org"
21
+ # else
22
+ # raise "RubyGems 2.0 or newer is required to protect against " \
23
+ # "public gem pushes."
24
+ # end
25
+
26
+ spec.files = Dir["{lib/**/*.rb,README.rdoc,test/**/*.rb,Rakefile,*.gemspec}"]
27
+ # spec.files = `git ls-files -z`.split("\x0").reject do |f|
28
+ # f.match(%r{^(test|spec|features)/})
29
+ # end
30
+ #spec.files = Dir['lib/**/*.rb']
31
+ spec.bindir = "exe"
32
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
33
+ spec.require_paths = ["lib"]
34
+ #spec.require_paths = Dir['lib/**/*.rb']
35
+
36
+ spec.add_development_dependency "bundler", "~> 1.13"
37
+ spec.add_development_dependency "rake", "~> 10.0"
38
+ spec.add_development_dependency "rspec", "~> 3.0"
39
+ spec.add_development_dependency "roxml", "~> 3.3"
40
+ end
metadata ADDED
@@ -0,0 +1,117 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby-nfe
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Igor C. Batista
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-03-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.13'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.13'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: roxml
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.3'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.3'
69
+ description: Consulta arquivo XML da Sefaz e serealiza em objeto.
70
+ email:
71
+ - igor.batista@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - Rakefile
77
+ - lib/nfe.rb
78
+ - lib/nfe/entidades/entidade_nfe.rb
79
+ - lib/nfe/entidades/infNFe/dest/destinatario.rb
80
+ - lib/nfe/entidades/infNFe/dest/endereco_destinatario.rb
81
+ - lib/nfe/entidades/infNFe/det/imposto.rb
82
+ - lib/nfe/entidades/infNFe/det/produto.rb
83
+ - lib/nfe/entidades/infNFe/emit/emitente.rb
84
+ - lib/nfe/entidades/infNFe/emit/endereco_emitente.rb
85
+ - lib/nfe/entidades/infNFe/ide/identificacao_nfe.rb
86
+ - lib/nfe/entidades/infNFe/infAdic/info.rb
87
+ - lib/nfe/entidades/infNFe/nota_fiscal.rb
88
+ - lib/nfe/entidades/infNFe/transp/transportadora.rb
89
+ - lib/nfe/entidades/infNFe/transp/veiculo.rb
90
+ - lib/nfe/entidades/infNFe/transp/volume.rb
91
+ - lib/nfe/version.rb
92
+ - nfe.gemspec
93
+ homepage: https://github.com/igorcb/ruby-nfe
94
+ licenses:
95
+ - MIT
96
+ metadata: {}
97
+ post_install_message:
98
+ rdoc_options: []
99
+ require_paths:
100
+ - lib
101
+ required_ruby_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ requirements: []
112
+ rubyforge_project:
113
+ rubygems_version: 2.6.6
114
+ signing_key:
115
+ specification_version: 4
116
+ summary: Consulta arquivo XML da Sefaz.
117
+ test_files: []