br-invoice-download 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +6 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +108 -0
- data/LICENSE +20 -0
- data/README.md +52 -0
- data/Rakefile +32 -0
- data/br_invoice_download.gemspec +29 -0
- data/lib/br_invoice_download.rb +22 -0
- data/lib/br_invoice_download/nfe_distribuicao_dfe.rb +192 -0
- data/lib/br_invoice_download/version.rb +11 -0
- data/lib/br_invoice_download/xml/root/NfeDistribuicaoDfe.xml.slim +6 -0
- data/lib/br_invoice_download/xml/soap_env.xml.slim +9 -0
- metadata +143 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: '087765e8459a45578d7bf60c20e598e5ed67536dfbf749e8159faab5ef23fb3a'
|
4
|
+
data.tar.gz: e6dfc19691a832a69516570607f39c1f8f364589b27a56546ae1cd9ea8b21d05
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cbfb13a73e0f3dcb1df0d418f46438557fcd1e448c0b818a99bc29ba16c6cf9a38aebc0afb352ee9aa878480f27bf3dffc34a8755a87e89869091732eff9c754
|
7
|
+
data.tar.gz: 779d9a175fbd20c8b24cf26076e523ac07e5d66144e0e6ccaa77f615e490efc70d609a361d5b5efa14e29b42804bcd19b33f46742de4a9ca40c44eee28eb6253
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
br-invoice-download (1.0.0)
|
5
|
+
activesupport (>= 3)
|
6
|
+
savon (>= 2.11)
|
7
|
+
slim (>= 3.0)
|
8
|
+
slim-rails (>= 3.1)
|
9
|
+
stringio (>= 0.0.2)
|
10
|
+
zlib (>= 1.0)
|
11
|
+
|
12
|
+
GEM
|
13
|
+
remote: http://rubygems.org/
|
14
|
+
specs:
|
15
|
+
actionpack (6.0.2.2)
|
16
|
+
actionview (= 6.0.2.2)
|
17
|
+
activesupport (= 6.0.2.2)
|
18
|
+
rack (~> 2.0, >= 2.0.8)
|
19
|
+
rack-test (>= 0.6.3)
|
20
|
+
rails-dom-testing (~> 2.0)
|
21
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
22
|
+
actionview (6.0.2.2)
|
23
|
+
activesupport (= 6.0.2.2)
|
24
|
+
builder (~> 3.1)
|
25
|
+
erubi (~> 1.4)
|
26
|
+
rails-dom-testing (~> 2.0)
|
27
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
28
|
+
activesupport (6.0.2.2)
|
29
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
30
|
+
i18n (>= 0.7, < 2)
|
31
|
+
minitest (~> 5.1)
|
32
|
+
tzinfo (~> 1.1)
|
33
|
+
zeitwerk (~> 2.2)
|
34
|
+
akami (1.3.1)
|
35
|
+
gyoku (>= 0.4.0)
|
36
|
+
nokogiri
|
37
|
+
builder (3.2.4)
|
38
|
+
concurrent-ruby (1.1.6)
|
39
|
+
crass (1.0.6)
|
40
|
+
erubi (1.9.0)
|
41
|
+
gyoku (1.3.1)
|
42
|
+
builder (>= 2.1.2)
|
43
|
+
httpi (2.4.4)
|
44
|
+
rack
|
45
|
+
socksify
|
46
|
+
i18n (1.8.2)
|
47
|
+
concurrent-ruby (~> 1.0)
|
48
|
+
loofah (2.4.0)
|
49
|
+
crass (~> 1.0.2)
|
50
|
+
nokogiri (>= 1.5.9)
|
51
|
+
method_source (1.0.0)
|
52
|
+
mini_portile2 (2.4.0)
|
53
|
+
minitest (5.14.0)
|
54
|
+
nokogiri (1.10.9)
|
55
|
+
mini_portile2 (~> 2.4.0)
|
56
|
+
nori (2.6.0)
|
57
|
+
rack (2.2.2)
|
58
|
+
rack-test (1.1.0)
|
59
|
+
rack (>= 1.0, < 3)
|
60
|
+
rails-dom-testing (2.0.3)
|
61
|
+
activesupport (>= 4.2.0)
|
62
|
+
nokogiri (>= 1.6)
|
63
|
+
rails-html-sanitizer (1.3.0)
|
64
|
+
loofah (~> 2.3)
|
65
|
+
railties (6.0.2.2)
|
66
|
+
actionpack (= 6.0.2.2)
|
67
|
+
activesupport (= 6.0.2.2)
|
68
|
+
method_source
|
69
|
+
rake (>= 0.8.7)
|
70
|
+
thor (>= 0.20.3, < 2.0)
|
71
|
+
rake (13.0.1)
|
72
|
+
savon (2.12.0)
|
73
|
+
akami (~> 1.2)
|
74
|
+
builder (>= 2.1.2)
|
75
|
+
gyoku (~> 1.2)
|
76
|
+
httpi (~> 2.3)
|
77
|
+
nokogiri (>= 1.8.1)
|
78
|
+
nori (~> 2.4)
|
79
|
+
wasabi (~> 3.4)
|
80
|
+
slim (4.0.1)
|
81
|
+
temple (>= 0.7.6, < 0.9)
|
82
|
+
tilt (>= 2.0.6, < 2.1)
|
83
|
+
slim-rails (3.2.0)
|
84
|
+
actionpack (>= 3.1)
|
85
|
+
railties (>= 3.1)
|
86
|
+
slim (>= 3.0, < 5.0)
|
87
|
+
socksify (1.7.1)
|
88
|
+
stringio (0.1.0)
|
89
|
+
temple (0.8.2)
|
90
|
+
thor (1.0.1)
|
91
|
+
thread_safe (0.3.6)
|
92
|
+
tilt (2.0.10)
|
93
|
+
tzinfo (1.2.6)
|
94
|
+
thread_safe (~> 0.1)
|
95
|
+
wasabi (3.5.0)
|
96
|
+
httpi (~> 2.0)
|
97
|
+
nokogiri (>= 1.4.2)
|
98
|
+
zeitwerk (2.3.0)
|
99
|
+
zlib (1.1.0)
|
100
|
+
|
101
|
+
PLATFORMS
|
102
|
+
ruby
|
103
|
+
|
104
|
+
DEPENDENCIES
|
105
|
+
br-invoice-download!
|
106
|
+
|
107
|
+
BUNDLED WITH
|
108
|
+
1.17.2
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2016 Bruno M. Mergen
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
|
2
|
+
# **br-invoice-download**
|
3
|
+
Gem para fazer o download de notas fiscais através da chave de acesso
|
4
|
+
|
5
|
+
**Introdução**
|
6
|
+
|
7
|
+
Através do serviço **NFeDistribuicaoDFe** é possível obter o XML da nota fiscal com suas informações.
|
8
|
+
Com base na documentação da [NT 2014.002 v1.02](/Brunomm/doc/NT2014.002_v1.02_WsNFeDistribuicaoDFe.pdf) foi criado apenas o serviço para a disponibilização do xml da nota fiscal, onde somente o destinatário, transportador e terceiros (identificados na tag `autXML`) podem usar este serviço.
|
9
|
+
|
10
|
+
## Instalação
|
11
|
+
**Manualmente**
|
12
|
+
|
13
|
+
gem install br-invoice-download
|
14
|
+
|
15
|
+
**Gemfile**
|
16
|
+
|
17
|
+
gem 'br-invoice-download'
|
18
|
+
|
19
|
+
## Utilização
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
@engine = BrInvoiceDownload::NfeDistribuicaoDfe.new({
|
23
|
+
certificate_pkcs12_password: 'CERTIFITACE_PASSWORD',
|
24
|
+
certificate_pkcs12_path: '/path/for/certificate-A1.pfx',
|
25
|
+
cnpj: '12345678901234',
|
26
|
+
invoice_key: '42200231775690400191560010004277701695237709',
|
27
|
+
ibge_uf: 42 # vide https://www.ibge.gov.br/explica/codigos-dos-municipios.php
|
28
|
+
})
|
29
|
+
|
30
|
+
@engine.request
|
31
|
+
|
32
|
+
@engine.invoice_xml
|
33
|
+
# => "<nfeProc versao=\"4.00\" xmlns=\"http://www.portalfiscal.inf.br" ...."
|
34
|
+
|
35
|
+
@engine.invoice_hash
|
36
|
+
# => {"nfeProc"=>{"versao"=>"4.00", "xmlns"=>"http://www.portalfiscal.inf.br/nfe", ...}
|
37
|
+
|
38
|
+
```
|
39
|
+
|
40
|
+
## Contribuições
|
41
|
+
|
42
|
+
Seja um contribuidor. Você pode contribuir de várias formas:
|
43
|
+
|
44
|
+
* Desenvolver as outras funcionalidades disponibilizadas pelo serviço **NFeDistribuicaoDFe**.
|
45
|
+
* Refatorando código.
|
46
|
+
* Fornecendo Feedback construtivo (*Sempre bem vindo!*).
|
47
|
+
|
48
|
+
|
49
|
+
## Licença
|
50
|
+
|
51
|
+
- MIT
|
52
|
+
- Copyleft 2020 Bruno Mucelini Mergen
|
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'rake/testtask'
|
2
|
+
|
3
|
+
Rake::TestTask.new do |task|
|
4
|
+
task.libs << %w(test lib)
|
5
|
+
task.pattern = 'test/**/*_test.rb'
|
6
|
+
end
|
7
|
+
|
8
|
+
desc "Open an irb session preloaded with this library"
|
9
|
+
task :console do
|
10
|
+
sh "irb -rubygems -I lib -r br_nfe.rb"
|
11
|
+
end
|
12
|
+
|
13
|
+
task :default => :test
|
14
|
+
|
15
|
+
namespace :test do
|
16
|
+
desc "Test lib source"
|
17
|
+
Rake::TestTask.new(:product) do |t|
|
18
|
+
t.libs << "test"
|
19
|
+
t.pattern = 'test/br_nfe/product/**/*_test.rb'
|
20
|
+
t.verbose = true
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
namespace :test do
|
26
|
+
desc "Test lib source"
|
27
|
+
Rake::TestTask.new(:service) do |t|
|
28
|
+
t.libs << "test"
|
29
|
+
t.pattern = 'test/br_nfe/service/**/*_test.rb'
|
30
|
+
t.verbose = true
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/br_invoice_download/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.name = 'br-invoice-download'
|
6
|
+
gem.version = BrInvoiceDownload::Version::CURRENT
|
7
|
+
gem.license = 'MIT'
|
8
|
+
gem.description = %q{BrInvoiceDownload é uma gem para projetos Ruby on Rails que tem como objetivo fazer o download do xml das notas fiscais de produto emitidas no Brasil.}
|
9
|
+
gem.summary = %q{Download de Notas Fiscais Eletrônicas em Ruby}
|
10
|
+
gem.authors = ['Bruno M. Mergen']
|
11
|
+
gem.email = ['brunomergen@gmail.com']
|
12
|
+
gem.homepage = 'https://github.com/Brunomm/br-invoice-download'
|
13
|
+
|
14
|
+
gem.files = `git ls-files`.split("\n").reject{|fil|
|
15
|
+
fil.include?('dev/') ||
|
16
|
+
fil.include?('doc/')
|
17
|
+
}
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
gem.required_ruby_version = ['>= 2.1.0', '< 3.0.0']
|
20
|
+
|
21
|
+
# gem.add_dependency "rake", '>= 10'
|
22
|
+
gem.add_dependency 'activesupport', '>= 3'
|
23
|
+
gem.add_dependency 'savon', '>= 2.11'
|
24
|
+
# gem.add_dependency 'signer', '>= 1.4'
|
25
|
+
gem.add_dependency 'slim', '>= 3.0'
|
26
|
+
gem.add_dependency 'slim-rails', '>= 3.1'
|
27
|
+
gem.add_dependency 'zlib', '>= 1.0'
|
28
|
+
gem.add_dependency 'stringio', '>= 0.0.2'
|
29
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
require 'active_support/core_ext/string'
|
5
|
+
require 'active_support/core_ext/hash'
|
6
|
+
require 'savon'
|
7
|
+
require 'slim'
|
8
|
+
|
9
|
+
require 'br_invoice_download/version'
|
10
|
+
require 'br_invoice_download/nfe_distribuicao_dfe'
|
11
|
+
|
12
|
+
|
13
|
+
# Copyright (C) 2020 Bruno M. Mergen
|
14
|
+
#
|
15
|
+
# @author Bruno Mucelini Mergen <brunomergen@gmail.com>
|
16
|
+
#
|
17
|
+
#
|
18
|
+
module BrInvoiceDownload
|
19
|
+
def self.root
|
20
|
+
File.expand_path '../..', __FILE__
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,192 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
require "zlib"
|
5
|
+
require "stringio"
|
6
|
+
require "base64"
|
7
|
+
|
8
|
+
module BrInvoiceDownload
|
9
|
+
class NfeDistribuicaoDfe
|
10
|
+
|
11
|
+
def initialize(opts={})
|
12
|
+
opts.each do |key, value|
|
13
|
+
instance_variable_set("@#{key}", value)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
attr_accessor :certificate_pkcs12_password
|
18
|
+
attr_accessor :certificate_pkcs12_path
|
19
|
+
attr_accessor :certificate_pkcs12_value
|
20
|
+
attr_accessor :ibge_uf
|
21
|
+
attr_accessor :cnpj
|
22
|
+
attr_accessor :invoice_key
|
23
|
+
|
24
|
+
def response
|
25
|
+
@response
|
26
|
+
end
|
27
|
+
|
28
|
+
def request
|
29
|
+
@response = client_wsdl.call(:nfe_dist_d_fe_interesse, xml: soap_xml)
|
30
|
+
rescue Savon::SOAPFault => error
|
31
|
+
return @response = {request_status: :soap_error, request_message_error: error.message}
|
32
|
+
rescue Savon::HTTPError => error
|
33
|
+
return @response = {request_status: :http_error, request_message_error: error.message}
|
34
|
+
rescue Exception => error
|
35
|
+
return @response = {request_status: :unknown_error, request_message_error: error.message}
|
36
|
+
end
|
37
|
+
|
38
|
+
def invoice_hash
|
39
|
+
@invoice ||= handle_invoice
|
40
|
+
end
|
41
|
+
|
42
|
+
def invoice_xml
|
43
|
+
@invoice_xml ||= handle_invoice_xml
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def handle_invoice_xml
|
49
|
+
ret = response.try(:body).dig(:nfe_dist_d_fe_interesse_response, :nfe_dist_d_fe_interesse_result, :ret_dist_d_fe_int, :lote_dist_d_fe_int, :doc_zip)
|
50
|
+
return unless ret
|
51
|
+
|
52
|
+
Zlib::GzipReader.new(
|
53
|
+
StringIO.new(
|
54
|
+
Base64.decode64( ret )
|
55
|
+
)
|
56
|
+
).read
|
57
|
+
end
|
58
|
+
|
59
|
+
def handle_invoice
|
60
|
+
Hash.from_xml invoice_xml
|
61
|
+
end
|
62
|
+
|
63
|
+
# Esse método serve para ser utilizado no Base de cada orgão emissor
|
64
|
+
# onde em alguns casos é necessário colocar o xml em um CDATA
|
65
|
+
# É esse método que é passado dentro do Body da equisição SOAP
|
66
|
+
#
|
67
|
+
def content_xml
|
68
|
+
@content_xml ||= render_xml 'root/NfeDistribuicaoDfe'
|
69
|
+
end
|
70
|
+
|
71
|
+
# Tag XML que vai na requisição SOAP
|
72
|
+
#
|
73
|
+
# <b>Tipo de retorno: </b> _String_
|
74
|
+
#
|
75
|
+
def tag_xml
|
76
|
+
'<?xml version="1.0" encoding="UTF-8"?>'
|
77
|
+
end
|
78
|
+
|
79
|
+
# XML que irá na requisição SOAP
|
80
|
+
#
|
81
|
+
# <b>Tipo de retorno: </b> _String XML_
|
82
|
+
#
|
83
|
+
def soap_xml
|
84
|
+
@soap_xml ||= "#{tag_xml}#{render_xml('soap_env')}".html_safe
|
85
|
+
end
|
86
|
+
|
87
|
+
def client_wsdl_params
|
88
|
+
{
|
89
|
+
log: true,
|
90
|
+
pretty_print_xml: true,
|
91
|
+
ssl_verify_mode: :none,
|
92
|
+
ssl_cert: certificate,
|
93
|
+
ssl_cert_key: certificate_key,
|
94
|
+
ssl_cert_key_password: certificate_pkcs12_password,
|
95
|
+
wsdl: 'https://www1.nfe.fazenda.gov.br/NFeDistribuicaoDFe/NFeDistribuicaoDFe.asmx?wsdl',
|
96
|
+
ssl_version: :TLSv1
|
97
|
+
}
|
98
|
+
end
|
99
|
+
|
100
|
+
def url_xmlns
|
101
|
+
'http://www.portalfiscal.inf.br/nfe/wsdl/NFeDistribuicaoDFe'
|
102
|
+
end
|
103
|
+
|
104
|
+
# Cliente WSDL utilizado para fazer a requisição.
|
105
|
+
# Utilizando a gem savon.
|
106
|
+
# Veja mais detalhes em http://savonrb.com/version2/client.html
|
107
|
+
def client_wsdl
|
108
|
+
@client_wsdl ||= Savon.client( client_wsdl_params )
|
109
|
+
end
|
110
|
+
|
111
|
+
# Caso não tenha o certificate_pkcs12 salvo em arquivo, pode setar a string do certificate_pkcs12 direto pelo atributo certificate_pkcs12_value
|
112
|
+
# Caso tenha o certificate_pkcs12 em arquivo, basta setar o atributo certificate_pkcs12_path e deixar o atributo certificate_pkcs12_value em branco
|
113
|
+
def certificate_pkcs12_value
|
114
|
+
@certificate_pkcs12_value ||= File.read(certificate_pkcs12_path)
|
115
|
+
end
|
116
|
+
|
117
|
+
def certificate_pkcs12
|
118
|
+
return @certificate_pkcs12 if @certificate_pkcs12
|
119
|
+
@certificate_pkcs12 = nil
|
120
|
+
|
121
|
+
# É utilizado uma Thread e limpado os errors do OpenSSL para evitar perda de
|
122
|
+
# conexão com o banco de dados PostgreSQL.
|
123
|
+
# Veja: http://stackoverflow.com/questions/33112155/pgconnectionbad-pqconsumeinput-ssl-error-key-values-mismatch/36283315#36283315
|
124
|
+
# Veja: https://github.com/tedconf/front_end_builds/pull/66
|
125
|
+
Thread.new do
|
126
|
+
@certificate_pkcs12 = OpenSSL::PKCS12.new(certificate_pkcs12_value, certificate_pkcs12_password)
|
127
|
+
OpenSSL.errors.clear
|
128
|
+
end.join
|
129
|
+
OpenSSL.errors.clear
|
130
|
+
|
131
|
+
@certificate_pkcs12
|
132
|
+
rescue
|
133
|
+
end
|
134
|
+
|
135
|
+
def certificate_pkcs12=(value)
|
136
|
+
@certificate_pkcs12 = value
|
137
|
+
end
|
138
|
+
|
139
|
+
def certificate=(value)
|
140
|
+
@certificate = value
|
141
|
+
end
|
142
|
+
|
143
|
+
def certificate
|
144
|
+
@certificate ||= (certificate_pkcs12 && certificate_pkcs12.certificate)
|
145
|
+
end
|
146
|
+
|
147
|
+
def certificate_key
|
148
|
+
@certificate_key ||= (certificate_pkcs12 && certificate_pkcs12.key)
|
149
|
+
end
|
150
|
+
|
151
|
+
def certificate_key=(value)
|
152
|
+
@certificate_key = value
|
153
|
+
end
|
154
|
+
|
155
|
+
# Utilização
|
156
|
+
# `render_xml('file_name', {dir_path: '/my/custom/dir', context: Object}`
|
157
|
+
#
|
158
|
+
# <b>Tipo de retorno: <b> _String_ (XML)
|
159
|
+
#
|
160
|
+
def render_xml file_name, opts={}
|
161
|
+
opts = {
|
162
|
+
dir_path: nil,
|
163
|
+
context: self,
|
164
|
+
}.merge(opts)
|
165
|
+
|
166
|
+
# Inicializa a variavel xml com nil para comparar se oa rquivo foi de fato encontrado.
|
167
|
+
xml = nil
|
168
|
+
get_xml_dirs(opts[:dir_path]).each do |dir|
|
169
|
+
if xml = find_xml(file_name, dir, opts[:context], opts)
|
170
|
+
break # Stop loop
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
# Lança uma excessão se não for encontrado o xml
|
175
|
+
# Deve verificar se é nil pois o arquivo xml pode estar vazio
|
176
|
+
if xml.nil?
|
177
|
+
raise "Arquivo #{file_name}.xml.slim não encontrado nos diretórios #{get_xml_dirs(default_options[:dir_path])}"
|
178
|
+
end
|
179
|
+
xml
|
180
|
+
end
|
181
|
+
|
182
|
+
def find_xml(file_name, dir, context=nil, options={})
|
183
|
+
if File.exists?("#{dir}/#{file_name}.xml.slim")
|
184
|
+
Slim::Template.new("#{dir}/#{file_name}.xml.slim").render(context, options).html_safe
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
def get_xml_dirs(custom_dir_path=nil)
|
189
|
+
[custom_dir_path, "#{BrInvoiceDownload.root}/lib/br_invoice_download/xml"].flatten.select(&:present?)
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
module BrInvoiceDownload
|
5
|
+
module Version
|
6
|
+
MAJOR = 1 #inclui alterações de API e pode quebrar compatibilidade com versões anteriores
|
7
|
+
MINOR = 0 #inclui novas funcionalidades, sem quebrar APIs existentes
|
8
|
+
PATCH = 0 #corrige bugs ou traz melhorias em implementações já existentes
|
9
|
+
CURRENT = "#{MAJOR}.#{MINOR}.#{PATCH}"
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
2
|
+
soap:Header
|
3
|
+
nfeCabecMsg xmlns="#{url_xmlns}"
|
4
|
+
cUF = ibge_uf
|
5
|
+
versaoDados = '1.00'
|
6
|
+
soap:Body
|
7
|
+
nfeDistDFeInteresse xmlns="#{url_xmlns}"
|
8
|
+
nfeDadosMsg
|
9
|
+
= content_xml.html_safe
|
metadata
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: br-invoice-download
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bruno M. Mergen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-03-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: savon
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.11'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.11'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: slim
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :runtime
|
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: slim-rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.1'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.1'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: zlib
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: stringio
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.0.2
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.0.2
|
97
|
+
description: BrInvoiceDownload é uma gem para projetos Ruby on Rails que tem como
|
98
|
+
objetivo fazer o download do xml das notas fiscais de produto emitidas no Brasil.
|
99
|
+
email:
|
100
|
+
- brunomergen@gmail.com
|
101
|
+
executables: []
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- ".gitignore"
|
106
|
+
- Gemfile
|
107
|
+
- Gemfile.lock
|
108
|
+
- LICENSE
|
109
|
+
- README.md
|
110
|
+
- Rakefile
|
111
|
+
- br_invoice_download.gemspec
|
112
|
+
- lib/br_invoice_download.rb
|
113
|
+
- lib/br_invoice_download/nfe_distribuicao_dfe.rb
|
114
|
+
- lib/br_invoice_download/version.rb
|
115
|
+
- lib/br_invoice_download/xml/root/NfeDistribuicaoDfe.xml.slim
|
116
|
+
- lib/br_invoice_download/xml/soap_env.xml.slim
|
117
|
+
homepage: https://github.com/Brunomm/br-invoice-download
|
118
|
+
licenses:
|
119
|
+
- MIT
|
120
|
+
metadata: {}
|
121
|
+
post_install_message:
|
122
|
+
rdoc_options: []
|
123
|
+
require_paths:
|
124
|
+
- lib
|
125
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: 2.1.0
|
130
|
+
- - "<"
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: 3.0.0
|
133
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
requirements: []
|
139
|
+
rubygems_version: 3.0.3
|
140
|
+
signing_key:
|
141
|
+
specification_version: 4
|
142
|
+
summary: Download de Notas Fiscais Eletrônicas em Ruby
|
143
|
+
test_files: []
|