rnfse 0.3.0 → 0.5.0
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/CHANGELOG.md +4 -0
- data/README.md +7 -6
- data/lib/provedores.yml +8 -0
- data/lib/rnfse.rb +5 -1
- data/lib/rnfse/api.rb +44 -22
- data/lib/rnfse/api/abrasf_1_0.rb +100 -17
- data/lib/rnfse/api/abrasf_1_0/#definitions.json# +413 -0
- data/lib/rnfse/api/abrasf_1_0/cancelar_nfse.json +13 -0
- data/lib/rnfse/api/abrasf_1_0/consultar_nfse.json +17 -0
- data/lib/rnfse/api/abrasf_1_0/consultar_nfse_por_rps.json +13 -0
- data/lib/rnfse/api/abrasf_1_0/definitions.json +27 -3
- data/lib/rnfse/api/abrasf_1_0/recepcionar_lote_rps.json +1 -1
- data/lib/rnfse/api/iss_net_1_0.rb +46 -2
- data/lib/rnfse/api/speed_gov_1_0.rb +115 -0
- data/lib/rnfse/call_chain.rb +4 -4
- data/lib/rnfse/error.rb +15 -0
- data/lib/rnfse/hash.rb +24 -11
- data/lib/rnfse/string.rb +16 -2
- data/lib/rnfse/version.rb +1 -1
- data/lib/rnfse/xml_builder/abrasf_1_0.rb +103 -13
- data/lib/rnfse/xml_builder/iss_net_1_0.rb +34 -4
- data/lib/rnfse/xml_builder/speed_gov_1_0.rb +158 -0
- data/spec/api/abrasf_1_0/cancelar_nfse_json_spec.rb +25 -0
- data/spec/api/abrasf_1_0/consultar_lote_rps_json_spec.rb +23 -0
- data/spec/api/abrasf_1_0/consultar_nfse_json_spec.rb +45 -0
- data/spec/api/abrasf_1_0/consultar_nfse_por_rps_json_spec.rb +23 -0
- data/spec/api/abrasf_1_0/consultar_situacao_lote_rps_json_spec.rb +23 -0
- data/spec/api/abrasf_1_0_spec.rb +185 -6
- data/spec/api/iss_net_1_0_spec.rb +89 -9
- data/spec/api/speed_gov_1_0_spec.rb +243 -0
- data/spec/api_spec.rb +43 -28
- data/spec/error_spec.rb +10 -0
- data/spec/fixtures/abrasf_1_0/cancelar_nfse_envio.xml +16 -0
- data/spec/fixtures/abrasf_1_0/consultar_nfse.xml +23 -0
- data/spec/fixtures/abrasf_1_0/consultar_nfse_por_rps.xml +14 -0
- data/spec/fixtures/iss_net_1_0/cancelar_nfse_envio.xml +17 -0
- data/spec/fixtures/iss_net_1_0/consultar_nfse.xml +29 -0
- data/spec/fixtures/iss_net_1_0/consultar_nfse_por_rps.xml +17 -0
- data/spec/fixtures/speed_gov_1_0/consultar_nfse_envio.xml +29 -0
- data/spec/fixtures/speed_gov_1_0/consultar_nfse_rps_envio.xml +16 -0
- data/spec/fixtures/speed_gov_1_0/consultar_situacao_lote_rps_envio.xml +12 -0
- data/spec/fixtures/speed_gov_1_0/enviar_lote_rps_envio.xml +82 -0
- data/spec/fixtures/speed_gov_1_0/header.xml +9 -0
- data/spec/fixtures/vcr_cassettes/iss_net_1_0_cancelar_nfse.yml +107 -0
- data/spec/fixtures/vcr_cassettes/iss_net_1_0_consultar_nfse.yml +7937 -0
- data/spec/fixtures/vcr_cassettes/iss_net_1_0_consultar_nfse_por_rps.yml +242 -0
- data/spec/fixtures/vcr_cassettes/speed_gov_1_0_consultar_nfse.yml +60 -0
- data/spec/fixtures/vcr_cassettes/speed_gov_1_0_consultar_nfse_por_rps.yml +80 -0
- data/spec/fixtures/vcr_cassettes/speed_gov_1_0_consultar_situacao_lote_rps.yml +77 -0
- data/spec/fixtures/vcr_cassettes/speed_gov_1_0_recepcionar_lote_rps.yml +171 -0
- data/spec/fixtures/vcr_cassettes/speed_gov_1_0_recepcionar_lote_rps_ascii.yml +171 -0
- data/spec/hash_spec.rb +21 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/string_spec.rb +31 -5
- data/spec/xml_builder/abrasf_1_0_spec.rb +110 -43
- data/spec/xml_builder/iss_net_1_0_spec.rb +111 -44
- data/spec/xml_builder/speed_gov_1_0_spec.rb +173 -0
- metadata +86 -37
- data/.gitignore +0 -25
- data/.rspec +0 -1
- data/.travis.yml +0 -14
- data/Gemfile +0 -3
- data/Guardfile +0 -15
- data/Procfile +0 -1
- data/Rakefile +0 -12
- data/rnfse.gemspec +0 -61
- data/spec/fixtures/abrasf_1_0/teste.xml +0 -8
- data/spec/support/.keep +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4a798eb55d0f7e2c930c5140085200a1653e3d2
|
4
|
+
data.tar.gz: 3f7057a92a3a5675c1df0b9c6b10f25ac97cf29e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e101457c59da02568f66d3a8b697f2ce2fc4b4550dbde9fd4ab004c6a90ea6b0965c39fa22ef2ddf37bf6a1c96a40c98a5bdefb37f5139bf4043a61150088a98
|
7
|
+
data.tar.gz: dce4fd87fc0458f7a937e24af4959d07d37f8d6550a8286a5c2366e0941f661ba021f5c7f26d44533074e26ef203567eca2893ab28f7670166d4f0a73086e64d
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# rnfse
|
2
|
-
[](http://rubygems.org/gems/rnfse)
|
3
|
-
[](http://rubygems.org/gems/rnfse)
|
3
|
+
[](https://gemnasium.com/aitherios/rnfse)
|
4
|
+
[](https://travis-ci.org/aitherios/rnfse)
|
5
|
+
[](https://codeclimate.com/github/aitherios/rnfse)
|
6
6
|
|
7
7
|
Biblioteca para integração com as várias implementações
|
8
8
|
municipais de Nota Fiscal de Serviços eletrônica (NFS-e) que utilizam uma
|
@@ -15,11 +15,11 @@ das versões ou variações dos padrões
|
|
15
15
|
## Instalação
|
16
16
|
|
17
17
|
Usando o rubygems.org rode:
|
18
|
-
```
|
18
|
+
```shell
|
19
19
|
$ gem install rnfse
|
20
20
|
```
|
21
21
|
**Ou** usando o repositório git rode:
|
22
|
-
```
|
22
|
+
```shell
|
23
23
|
$ gem build rnfse.gemspec
|
24
24
|
$ gem install rnfse-X.X.X.gem
|
25
25
|
```
|
@@ -39,6 +39,7 @@ Esta é uma lista de limitações e problemas conhecidos. São questões que nã
|
|
39
39
|
plano imediato de resolução. Talvez porque a funcionalidade nunca foi
|
40
40
|
necessária ou nenhum pull request tenha sido enviado. (dica!)
|
41
41
|
|
42
|
+
- Sem documentação =/
|
42
43
|
- Suporte para o JRuby e Rubinius (problema com a dependência nokogiri-xmlsec1).
|
43
44
|
- Só foi testada com municípios inscritos no [ISS.net](http://www.issnetonline.com.br/portaliss/) que utilizam o padrão [ABRASF v1](http://www.abrasf.org.br/paginas_multiplas_detalhes.php?cod_pagina=1).
|
44
45
|
|
data/lib/provedores.yml
CHANGED
@@ -3,9 +3,17 @@ producao:
|
|
3
3
|
namespace: http://www.issnetonline.com.br/webservice/nfd
|
4
4
|
endpoint: http://www.issnetonline.com.br/webserviceabrasf/%{municipio}/servicos.asmx
|
5
5
|
api: iss_net_1_0
|
6
|
+
speed_gov:
|
7
|
+
namespace: http://ws.speedgov.com.br/
|
8
|
+
endpoint: http://www.speedgov.com.br/ws%{municipio}/Nfes
|
9
|
+
api: speed_gov_1_0
|
6
10
|
|
7
11
|
homologacao:
|
8
12
|
iss_net:
|
9
13
|
namespace: http://www.issnetonline.com.br/webservice/nfd
|
10
14
|
endpoint: http://www.issnetonline.com.br/webserviceabrasf/homologacao/servicos.asmx
|
11
15
|
api: iss_net_1_0
|
16
|
+
speed_gov:
|
17
|
+
namespace: http://ws.speedgov.com.br/
|
18
|
+
endpoint: http://speedgov.com.br/wsmod/Nfes
|
19
|
+
api: speed_gov_1_0
|
data/lib/rnfse.rb
CHANGED
@@ -6,9 +6,11 @@ require 'json-schema'
|
|
6
6
|
require 'gyoku'
|
7
7
|
require 'nokogiri-xmlsec1'
|
8
8
|
require 'savon'
|
9
|
+
require 'cgi'
|
9
10
|
|
10
|
-
require 'rnfse/core'
|
11
11
|
require 'rnfse/version'
|
12
|
+
require 'rnfse/error'
|
13
|
+
require 'rnfse/core'
|
12
14
|
require 'rnfse/configuration'
|
13
15
|
require 'rnfse/hash'
|
14
16
|
require 'rnfse/string'
|
@@ -17,7 +19,9 @@ require 'rnfse/call_chain'
|
|
17
19
|
require 'rnfse/api'
|
18
20
|
require 'rnfse/api/abrasf_1_0'
|
19
21
|
require 'rnfse/api/iss_net_1_0'
|
22
|
+
require 'rnfse/api/speed_gov_1_0'
|
20
23
|
|
21
24
|
require 'rnfse/xml_builder'
|
22
25
|
require 'rnfse/xml_builder/abrasf_1_0'
|
23
26
|
require 'rnfse/xml_builder/iss_net_1_0'
|
27
|
+
require 'rnfse/xml_builder/speed_gov_1_0'
|
data/lib/rnfse/api.rb
CHANGED
@@ -14,52 +14,70 @@ module Rnfse
|
|
14
14
|
|
15
15
|
def initialize(options = {})
|
16
16
|
options = load_options(options)
|
17
|
-
|
18
|
-
file = Pathname.new(File.expand_path('../..', __FILE__))
|
19
|
-
provedores = YAML.load_file(file.join('provedores.yml'))
|
20
|
-
|
17
|
+
|
21
18
|
case
|
22
19
|
when has_options(options, 'provedor', 'homologacao')
|
23
20
|
provedor = provedores['homologacao'][options['provedor'].to_s]
|
24
21
|
raise ArgumentError, 'provedor de homologação inexistente', caller if provedor.nil?
|
25
|
-
self.namespace = provedor['namespace']
|
26
|
-
self.endpoint = provedor['endpoint']
|
27
22
|
self.api = provedor['api']
|
23
|
+
load_options_method = :load_options_for_staging
|
28
24
|
|
29
25
|
when has_options(options, 'provedor', 'municipio')
|
30
26
|
provedor = provedores['producao'][options['provedor'].to_s]
|
31
27
|
raise ArgumentError, 'provedor inexistente', caller if provedor.nil?
|
32
|
-
self.namespace = provedor['namespace']
|
33
|
-
self.endpoint = provedor['endpoint'] % { municipio: options['municipio'] }
|
34
28
|
self.api = provedor['api']
|
29
|
+
load_options_method = :load_options_for_production
|
35
30
|
|
36
31
|
when has_options(options, 'padrao', 'namespace', 'endpoint')
|
37
|
-
self.namespace = options['namespace'].to_s
|
38
|
-
self.endpoint = options['endpoint'].to_s
|
39
32
|
self.api = options['padrao'].to_s
|
33
|
+
load_options_method = :load_options_for_custom
|
40
34
|
|
41
35
|
else
|
42
36
|
raise ArgumentError, 'opções inválidas', caller
|
43
37
|
end
|
44
38
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
39
|
+
extend self.class.const_get(String.camelize(self.api))
|
40
|
+
|
41
|
+
self.send(load_options_method, options)
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def load_options_for_custom(options)
|
47
|
+
self.namespace = options['namespace'].to_s
|
48
|
+
self.endpoint = options['endpoint'].to_s
|
49
|
+
load_default_options(options)
|
50
|
+
end
|
51
|
+
|
52
|
+
def load_options_for_production(options)
|
53
|
+
provedor = provedores['producao'][options['provedor'].to_s]
|
54
|
+
self.namespace = provedor['namespace']
|
55
|
+
self.endpoint = provedor['endpoint'] % { municipio: options['municipio'] }
|
56
|
+
load_default_options(options)
|
57
|
+
end
|
51
58
|
|
59
|
+
def load_options_for_staging(options)
|
60
|
+
provedor = provedores['homologacao'][options['provedor'].to_s]
|
61
|
+
self.namespace = provedor['namespace']
|
62
|
+
self.endpoint = provedor['endpoint']
|
63
|
+
load_default_options(options)
|
64
|
+
end
|
65
|
+
|
66
|
+
def load_default_options(options)
|
67
|
+
self.certificate = options['certificate']
|
68
|
+
self.key = options['key']
|
52
69
|
self.verbose = options['verbose'] || false
|
53
70
|
self.xml_builder = options['xml_builder'] || XMLBuilder.new(padrao: self.api)
|
54
71
|
self.soap_client = options['soap_client'] || savon_client
|
55
|
-
|
56
|
-
extend self.class.const_get(String.camelize(self.api))
|
57
72
|
end
|
58
73
|
|
59
|
-
|
74
|
+
def provedores
|
75
|
+
file = Pathname.new(File.expand_path('../..', __FILE__))
|
76
|
+
YAML.load_file(file.join('provedores.yml'))
|
77
|
+
end
|
60
78
|
|
61
|
-
def
|
62
|
-
|
79
|
+
def savon_client_options
|
80
|
+
{
|
63
81
|
soap_version: 2,
|
64
82
|
env_namespace: :soap,
|
65
83
|
namespace_identifier: nil,
|
@@ -69,11 +87,15 @@ module Rnfse
|
|
69
87
|
endpoint: self.endpoint,
|
70
88
|
namespace: self.namespace
|
71
89
|
}
|
90
|
+
end
|
91
|
+
|
92
|
+
def savon_client
|
93
|
+
savon_hash = savon_client_options
|
72
94
|
|
73
95
|
savon_hash = savon_hash.merge(
|
74
96
|
log: true,
|
75
97
|
log_level: :debug,
|
76
|
-
pretty_print_xml:
|
98
|
+
pretty_print_xml: false
|
77
99
|
) if self.verbose
|
78
100
|
|
79
101
|
Savon.client(savon_hash)
|
data/lib/rnfse/api/abrasf_1_0.rb
CHANGED
@@ -5,10 +5,29 @@ module Rnfse::API::Abrasf10
|
|
5
5
|
|
6
6
|
module ClassMethods
|
7
7
|
|
8
|
+
def operations()
|
9
|
+
[ :recepcionar_lote_rps, :consultar_situacao_lote_rps,
|
10
|
+
:consultar_nfse_por_rps, :consultar_nfse, :consultar_lote_rps,
|
11
|
+
:cancelar_nfse ]
|
12
|
+
end
|
13
|
+
|
8
14
|
def recepcionar_lote_rps(hash = {})
|
9
|
-
|
10
|
-
|
11
|
-
xml
|
15
|
+
validate_sign_options
|
16
|
+
validate_options(hash)
|
17
|
+
xml = xml_builder.build_recepcionar_lote_rps_xml(hash) do |inner_xml|
|
18
|
+
regex = /<tc:Rps>.*<\/tc:Rps>/
|
19
|
+
plain_xml = inner_xml.to_xml(
|
20
|
+
save_with: Nokogiri::XML::Node::SaveOptions::NO_DECLARATION).strip
|
21
|
+
signed_rps = Nokogiri::XML(
|
22
|
+
plain_xml.match(regex)[0]).
|
23
|
+
sign!(
|
24
|
+
certificate: File.read(self.certificate),
|
25
|
+
key: File.read(self.key)).
|
26
|
+
to_xml(
|
27
|
+
save_with: Nokogiri::XML::Node::SaveOptions::NO_DECLARATION).
|
28
|
+
strip
|
29
|
+
plain_xml.gsub(regex, signed_rps)
|
30
|
+
end
|
12
31
|
response = self.soap_client.call(
|
13
32
|
:recepcionar_lote_rps,
|
14
33
|
soap_action: 'RecepcionarLoteRps',
|
@@ -17,8 +36,41 @@ module Rnfse::API::Abrasf10
|
|
17
36
|
parse_response(response)
|
18
37
|
end
|
19
38
|
|
39
|
+
def consultar_situacao_lote_rps(hash = {})
|
40
|
+
validate_options(hash)
|
41
|
+
xml = xml_builder.build_consultar_situacao_lote_rps_xml(hash)
|
42
|
+
response = self.soap_client.call(
|
43
|
+
:consultar_situacao_lote_rps,
|
44
|
+
soap_action: 'ConsultarSituacaoLoteRps',
|
45
|
+
message_tag: 'ConsultarSituacaoLoteRps',
|
46
|
+
message: { :'xml!' => "<![CDATA[#{xml}]]>" })
|
47
|
+
parse_response(response)
|
48
|
+
end
|
49
|
+
|
50
|
+
def consultar_nfse_por_rps(hash = {})
|
51
|
+
validate_options(hash)
|
52
|
+
xml = xml_builder.build_consultar_nfse_por_rps_xml(hash)
|
53
|
+
response = self.soap_client.call(
|
54
|
+
:consultar_nfse_por_rps,
|
55
|
+
soap_action: 'ConsultarNfsePorRps',
|
56
|
+
message_tag: 'ConsultarNfsePorRps',
|
57
|
+
message: { :'xml!' => "<![CDATA[#{xml}]]>" })
|
58
|
+
parse_response(response)
|
59
|
+
end
|
60
|
+
|
61
|
+
def consultar_nfse(hash = {})
|
62
|
+
validate_options(hash)
|
63
|
+
xml = xml_builder.build_consultar_nfse_xml(hash)
|
64
|
+
response = self.soap_client.call(
|
65
|
+
:consultar_nfse,
|
66
|
+
soap_action: 'ConsultarNfse',
|
67
|
+
message_tag: 'ConsultarNfse',
|
68
|
+
message: { :'xml!' => "<![CDATA[#{xml}]]>" })
|
69
|
+
parse_response(response)
|
70
|
+
end
|
71
|
+
|
20
72
|
def consultar_lote_rps(hash = {})
|
21
|
-
|
73
|
+
validate_options(hash)
|
22
74
|
xml = xml_builder.build_consultar_lote_rps_xml(hash)
|
23
75
|
response = self.soap_client.call(
|
24
76
|
:consultar_lote_rps,
|
@@ -28,21 +80,32 @@ module Rnfse::API::Abrasf10
|
|
28
80
|
parse_response(response)
|
29
81
|
end
|
30
82
|
|
31
|
-
def
|
32
|
-
|
33
|
-
xml = xml_builder.
|
83
|
+
def cancelar_nfse(hash = {})
|
84
|
+
validate_options(hash)
|
85
|
+
xml = xml_builder.build_cancelar_nfse_xml(hash) do |inner_xml|
|
86
|
+
inner_xml.sign!(certificate: File.read(self.certificate), key: File.read(self.key))
|
87
|
+
inner_xml.to_xml(save_with: Nokogiri::XML::Node::SaveOptions::NO_DECLARATION).strip
|
88
|
+
end
|
34
89
|
response = self.soap_client.call(
|
35
|
-
:
|
36
|
-
soap_action: '
|
37
|
-
message_tag: '
|
90
|
+
:cancelar_nfse,
|
91
|
+
soap_action: 'CancelarNfse',
|
92
|
+
message_tag: 'CancelarNfse',
|
38
93
|
message: { :'xml!' => "<![CDATA[#{xml}]]>" })
|
39
94
|
parse_response(response)
|
40
95
|
end
|
41
96
|
|
42
97
|
private
|
43
98
|
|
44
|
-
def
|
45
|
-
|
99
|
+
def validate_sign_options
|
100
|
+
if self.certificate.nil? or self.key.nil?
|
101
|
+
raise ArgumentError, 'opções de assinatura digital ' <<
|
102
|
+
'(certificate e key) ao criar ' <<
|
103
|
+
'o Rnfse::API faltando', caller
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def validate_options(hash)
|
108
|
+
file = json_filepath("#{Rnfse::CallChain.caller_method}.json")
|
46
109
|
json = Rnfse::Hash.camelize_and_symbolize_keys(hash, false).to_json
|
47
110
|
errors = JSON::Validator.fully_validate(file, json)
|
48
111
|
raise ArgumentError, errors, caller unless errors.empty?
|
@@ -50,17 +113,37 @@ module Rnfse::API::Abrasf10
|
|
50
113
|
|
51
114
|
def parse_response(response)
|
52
115
|
hash = Rnfse::Hash.new(response.body)
|
53
|
-
|
54
|
-
|
55
|
-
|
116
|
+
|
117
|
+
response_key = hash.keys.select { |k| k =~ /response$/ }
|
118
|
+
response_key = response_key.first unless response_key.nil?
|
119
|
+
|
120
|
+
if hash[response_key]
|
121
|
+
result_key = hash[response_key].keys.select { |k| k =~ /result$/ }
|
122
|
+
result_key = result_key.first unless result_key.nil?
|
123
|
+
else
|
124
|
+
result_key = nil
|
125
|
+
end
|
126
|
+
|
127
|
+
if response_key and result_key
|
56
128
|
xml = hash[response_key][result_key]
|
57
129
|
hash[response_key][result_key] = Nori.new.parse(xml)
|
58
130
|
end
|
59
131
|
hash.underscore_and_symbolize_keys
|
60
132
|
end
|
61
133
|
|
62
|
-
def
|
63
|
-
|
134
|
+
def json_folder
|
135
|
+
'abrasf_1_0'
|
136
|
+
end
|
137
|
+
|
138
|
+
def json_filepath(filename)
|
139
|
+
result = nil
|
140
|
+
folders = ['abrasf_1_0']
|
141
|
+
folders = folders.unshift(json_folder) unless folders.include?(json_folder)
|
142
|
+
folders.each do |folder|
|
143
|
+
path = File.join(File.expand_path(File.dirname(__FILE__)), folder, filename)
|
144
|
+
result = path if File.exists?(path)
|
145
|
+
end
|
146
|
+
result
|
64
147
|
end
|
65
148
|
|
66
149
|
end
|
@@ -0,0 +1,413 @@
|
|
1
|
+
{
|
2
|
+
"numeroNfse": {
|
3
|
+
"description": "Número da Nota Fiscal de Serviço Eletrônica, formado pelo ano com 04 (quatro) dígitos e um número seqüencial com 11 posições – Formato AAAANNNNNNNNNNN.",
|
4
|
+
"type": "integer",
|
5
|
+
"minimum": 190000000000000,
|
6
|
+
"maximum": 220099999999999
|
7
|
+
},
|
8
|
+
"codigoVerificacao": {
|
9
|
+
"description": "Código de verificação do número da nota",
|
10
|
+
"type": "string",
|
11
|
+
"maxLength": 9
|
12
|
+
},
|
13
|
+
"statusRps": {
|
14
|
+
"description": "Código de status do RPS 1 – Normal ; 2 – Cancelado",
|
15
|
+
"type": "integer",
|
16
|
+
"minimum": 1,
|
17
|
+
"maximum": 2
|
18
|
+
},
|
19
|
+
"statusNfse": {
|
20
|
+
"description": "Código de status da NFS-e 1 – Normal ; 2 – Cancelado",
|
21
|
+
"type": "integer",
|
22
|
+
"minimum": 1,
|
23
|
+
"maximum": 2
|
24
|
+
},
|
25
|
+
"naturezaOperacao": {
|
26
|
+
"description": "Código de natureza da operação 1 – Tributação no município ; 2 - Tributação fora do município ; 3 - Isenção ; 4 - Imune ; 5 – Exigibilidade suspensa por decisão judicial ; 6 – Exigibilidade suspensa por procedimento administrativo ",
|
27
|
+
"type": "integer",
|
28
|
+
"minimum": 1,
|
29
|
+
"maximum": 6
|
30
|
+
},
|
31
|
+
"regimeEspecialTributacao": {
|
32
|
+
"description": "Código de natureza da operação 1 – Tributação no município ; 2 - Tributação fora do município ; 3 - Isenção ; 4 - Imune ; 5 – Exigibilidade suspensa por decisão judicial ; 6 – Exigibilidade suspensa por procedimento administrativo ",
|
33
|
+
"type": "integer",
|
34
|
+
"minimum": 1,
|
35
|
+
"maximum": 6
|
36
|
+
},
|
37
|
+
"simNao": {
|
38
|
+
"type": "boolean"
|
39
|
+
},
|
40
|
+
"quantidadeRps": {
|
41
|
+
"description": "Quantidade de RPS do Lote",
|
42
|
+
"type": "integer",
|
43
|
+
"minimum": 1,
|
44
|
+
"maximum": 9999
|
45
|
+
},
|
46
|
+
"numeroRps": {
|
47
|
+
"description": "Número do RPS",
|
48
|
+
"type": "integer",
|
49
|
+
"minimum": 0,
|
50
|
+
"maximum": 999999999999999
|
51
|
+
},
|
52
|
+
"serieRps": {
|
53
|
+
"description": "Número de série do RPS",
|
54
|
+
"type": "string",
|
55
|
+
"maxLength": 5
|
56
|
+
},
|
57
|
+
"tipoRps": {
|
58
|
+
"description": "Código de tipo de RPS 1 - RPS ; 2 – Nota Fiscal Conjugada (Mista) ; 3 – Cupom",
|
59
|
+
"type": "integer",
|
60
|
+
"minimum": 1,
|
61
|
+
"maximum": 3
|
62
|
+
},
|
63
|
+
"outrasInformacoes": {
|
64
|
+
"description": "Informações adicionais ao documento",
|
65
|
+
"type": "string",
|
66
|
+
"maxLength": 255
|
67
|
+
},
|
68
|
+
"valor": {
|
69
|
+
"description": "Valor monetário. Formato: 0.00 (ponto separando casa decimal) Ex: 1.234,56 = 1234.56 ; 1.000,00 = 1000.00 ; 1.000,00 = 1000",
|
70
|
+
"type": "number",
|
71
|
+
"minimum": 0,
|
72
|
+
"maximum": 9999999999999.99
|
73
|
+
},
|
74
|
+
"itemListaServico": {
|
75
|
+
"description": "Código de item da lista de serviço",
|
76
|
+
"type": "string",
|
77
|
+
"maxLength": 5
|
78
|
+
},
|
79
|
+
"codigoCnae": {
|
80
|
+
"description": "Código CNAE. Formato: 0000-0/00",
|
81
|
+
"type": "string",
|
82
|
+
"pattern": "^[0-9]{4}-[0-9]{1}/[0-9]{2}$"
|
83
|
+
},
|
84
|
+
"codigoTributacao": {
|
85
|
+
"description": "Código de Tributação",
|
86
|
+
"type": "string",
|
87
|
+
"maxLength": 20
|
88
|
+
},
|
89
|
+
"aliquota": {
|
90
|
+
"description": "Alíquota. Valor percentual. Formato: 0.0000 Ex: 1% = 0.01 ; 25,5% = 0.255 ; 100% = 1.0000 ou 1",
|
91
|
+
"type": "numeric",
|
92
|
+
"minimum": 0,
|
93
|
+
"maximum": 1
|
94
|
+
},
|
95
|
+
"discriminacao": {
|
96
|
+
"description": "Discriminação do conteúdo da NFS-e",
|
97
|
+
"type": "string",
|
98
|
+
"maxLength": 2000
|
99
|
+
},
|
100
|
+
"codigoMunicipioIbge": {
|
101
|
+
"description": "Código de identificação do município conforme tabela do IBGE",
|
102
|
+
"type": "integer",
|
103
|
+
"minimum": 1,
|
104
|
+
"maximum": 9999999
|
105
|
+
},
|
106
|
+
"inscricaoMunicipal": {
|
107
|
+
"description": "Número de inscrição municipal",
|
108
|
+
"type": "string",
|
109
|
+
"maxLength": 15
|
110
|
+
},
|
111
|
+
"razaoSocial": {
|
112
|
+
"description": "Razão Social do contribuinte",
|
113
|
+
"type": "string",
|
114
|
+
"maxLength": 115
|
115
|
+
},
|
116
|
+
"nomeFantasia": {
|
117
|
+
"description": "Nome fantasia",
|
118
|
+
"type": "string",
|
119
|
+
"maxLength": 60
|
120
|
+
},
|
121
|
+
"cnpj": {
|
122
|
+
"description": "Número CNPJ. Formato: 00.000.000/0000-00",
|
123
|
+
"type": "string",
|
124
|
+
"pattern": "^[0-9]{2}\.[0-9]{3}\.[0-9]{3}/[0-9]{4}-[0-9]{2}$"
|
125
|
+
},
|
126
|
+
"endereco": {
|
127
|
+
"description": "Endereço",
|
128
|
+
"type": "string",
|
129
|
+
"maxLength": 125
|
130
|
+
},
|
131
|
+
"numeroEndereco": {
|
132
|
+
"description": "Número do endereço",
|
133
|
+
"type": "string",
|
134
|
+
"maxLength": 10
|
135
|
+
},
|
136
|
+
"complementoEndereco": {
|
137
|
+
"description": "Número do endereço",
|
138
|
+
"type": "string",
|
139
|
+
"maxLength": 60
|
140
|
+
},
|
141
|
+
"bairro": {
|
142
|
+
"description": "Bairro",
|
143
|
+
"type": "string",
|
144
|
+
"maxLength": 60
|
145
|
+
},
|
146
|
+
"uf": {
|
147
|
+
"description": "Sigla da unidade federativa",
|
148
|
+
"type": "string",
|
149
|
+
"enum": ["AC", "AL", "AP", "AM", "BA", "CE", "DF", "ES", "GO", "MA", "MT", "MS", "MG", "PA", "PB", "PR", "PE", "PI", "RJ", "RN", "RS", "RO", "RR", "SC", "SP", "SE", "TO"]
|
150
|
+
},
|
151
|
+
"cep": {
|
152
|
+
"description": "Número do CEP. Formato: 00000-000",
|
153
|
+
"type": "string",
|
154
|
+
"pattern": "^[0-9]{5}-[0-9]{3}$"
|
155
|
+
},
|
156
|
+
"email": {
|
157
|
+
"description": "E-mail",
|
158
|
+
"type": "string",
|
159
|
+
"format": "email"
|
160
|
+
},
|
161
|
+
"telefone": {
|
162
|
+
"description": "Telefone",
|
163
|
+
"type": "string",
|
164
|
+
"maxLength": 11
|
165
|
+
},
|
166
|
+
"cpf": {
|
167
|
+
"description": "Número de CPF. Formato: 000.000.000-00",
|
168
|
+
"type": "string",
|
169
|
+
"pattern": "^[0-9]{3}\.[0-9]{3}\.[0-9]{3}-[0-9]{2}$"
|
170
|
+
},
|
171
|
+
"indicacaoCpfCnpj": {
|
172
|
+
"description": "Indicador de uso de CPF ou CNPJ 1 – CPF ; 2 – CNPJ ; 3 – Não Informado",
|
173
|
+
"type": "integer",
|
174
|
+
"minimum": 1,
|
175
|
+
"maximum": 3
|
176
|
+
},
|
177
|
+
"codigoObra": {
|
178
|
+
"description": "Código de Obra",
|
179
|
+
"type": "string",
|
180
|
+
"maxLength": 15
|
181
|
+
},
|
182
|
+
"art": {
|
183
|
+
"description": "Código ART",
|
184
|
+
"type": "string",
|
185
|
+
"maxLength": 15
|
186
|
+
},
|
187
|
+
"numeroLote": {
|
188
|
+
"description": "Número do Lote de RPS",
|
189
|
+
"type": "integer",
|
190
|
+
"minimum": 1,
|
191
|
+
"maximum": 999999999999999
|
192
|
+
},
|
193
|
+
"numeroProtocolo": {
|
194
|
+
"description": "Número do protocolo de recebimento do RPS",
|
195
|
+
"type": "string",
|
196
|
+
"maxLength": 50
|
197
|
+
},
|
198
|
+
"situacaoLoteRps": {
|
199
|
+
"description": "Código de situação de lote de RPS 1 – Não Recebido ; 2 – Não Processado ; 3 – Processado com Erro ; 4 – Processado com Sucesso",
|
200
|
+
"type": "integer",
|
201
|
+
"minimum": 1,
|
202
|
+
"maximum": 4
|
203
|
+
},
|
204
|
+
"codigoMensagemAlerta": {
|
205
|
+
"description": "Código de mensagem de retorno de serviço",
|
206
|
+
"type": "string",
|
207
|
+
"maxLength": 4
|
208
|
+
},
|
209
|
+
"descricaoMensagemAlerta": {
|
210
|
+
"description": "Descrição da mensagem de retorno de serviço",
|
211
|
+
"type": "string",
|
212
|
+
"maxLength": 200
|
213
|
+
},
|
214
|
+
"codigoCancelamentoNfse": {
|
215
|
+
"description": "Código de cancelamento com base na tabela de Erros e alertas",
|
216
|
+
"type": "string",
|
217
|
+
"maxLength": 4
|
218
|
+
},
|
219
|
+
"idTag": {
|
220
|
+
"description": "Atributo de identificação da tag a ser assinada no documento XML",
|
221
|
+
"type": "string",
|
222
|
+
"maxLength": 255
|
223
|
+
},
|
224
|
+
"identificacaoRps": {
|
225
|
+
"description": "Dados de identificação do RPS",
|
226
|
+
"type": "object",
|
227
|
+
"properties": {
|
228
|
+
"numero": { "$ref": "#/numeroRps" },
|
229
|
+
"serie": { "$ref": "#/serieRps" },
|
230
|
+
"tipo": { "$ref": "#/tipoRps" }
|
231
|
+
},
|
232
|
+
"required": ["numero", "serie", "tipo"],
|
233
|
+
"additionalProperties": false
|
234
|
+
},
|
235
|
+
"dadosServico": {
|
236
|
+
"description": "Representa dados que compõe o serviço prestado",
|
237
|
+
"type": "object",
|
238
|
+
"properties": {
|
239
|
+
"valores": {
|
240
|
+
"type": "object",
|
241
|
+
"properties": {
|
242
|
+
"valorServicos": { "$ref": "#/valor" },
|
243
|
+
"valorDeducoes": { "$ref": "#/valor" },
|
244
|
+
"valorPis": { "$ref": "#/valor" },
|
245
|
+
"valorCofins": { "$ref": "#/valor" },
|
246
|
+
"valorInss": { "$ref": "#/valor" },
|
247
|
+
"valorIr": { "$ref": "#/valor" },
|
248
|
+
"valorCsll": { "$ref": "#/valor" },
|
249
|
+
"issRetido": { "type": "boolean" },
|
250
|
+
"valorIss": { "$ref": "#/valor" },
|
251
|
+
"outrasRetencoes": { "$ref": "#/valor" },
|
252
|
+
"baseCalculo": {
|
253
|
+
"description": "(Valor dos serviços - Valor das deduções - descontos incondicionados)",
|
254
|
+
"$ref": "#/valor"
|
255
|
+
},
|
256
|
+
"aliquota": { "$ref": "#/aliquota" },
|
257
|
+
"valorLiquidoNfse": {
|
258
|
+
"description": "(ValorServicos - ValorPIS - ValorCOFINS - ValorINSS - ValorIR - ValorCSLL - OutrasRetençoes - ValorISSRetido - DescontoIncondicionado - DescontoCondicionado)",
|
259
|
+
"$ref": "#/valor"
|
260
|
+
},
|
261
|
+
"valorIssRetido": { "$ref": "#/valor" },
|
262
|
+
"descontoCondicionado": { "$ref": "#/valor" },
|
263
|
+
"descontoIncondicionado": { "$ref": "#/valor" }
|
264
|
+
},
|
265
|
+
"required": ["valorServicos", "issRetido", "baseCalculo"],
|
266
|
+
"additionalProperties": false
|
267
|
+
},
|
268
|
+
"itemListaServico": { "$ref": "#/itemListaServico" },
|
269
|
+
"codigoCnae": { "$ref": "#/codigoCnae" },
|
270
|
+
"codigoTributacaoMunicipio": { "$ref": "#/codigoTributacao" },
|
271
|
+
"discriminacao": { "$ref": "#/discriminacao" },
|
272
|
+
"codigoMunicipio": { "$ref": "#/codigoMunicipioIbge" }
|
273
|
+
},
|
274
|
+
"required": ["valores", "itemListaServico", "discriminacao", "codigoMunicipio"],
|
275
|
+
"additionalProperties": false
|
276
|
+
},
|
277
|
+
"identificacaoPrestador": {
|
278
|
+
"description": "Representa dados para identificação do prestador de serviço",
|
279
|
+
"oneOf": [
|
280
|
+
{
|
281
|
+
"type": "object",
|
282
|
+
"properties": {
|
283
|
+
"inscricaoMunicipal": { "$ref": "#/inscricaoMunicipal" },
|
284
|
+
"cnpj": { "$ref": "#/cnpj" }
|
285
|
+
},
|
286
|
+
"required": ["cnpj"],
|
287
|
+
"additionalProperties": false
|
288
|
+
},
|
289
|
+
{
|
290
|
+
"type": "object",
|
291
|
+
"properties": {
|
292
|
+
"inscricaoMunicipal": { "$ref": "#/inscricaoMunicipal" },
|
293
|
+
"cpf": { "$ref": "#/cpf" }
|
294
|
+
},
|
295
|
+
"required": ["cpf"],
|
296
|
+
"additionalProperties": false
|
297
|
+
}
|
298
|
+
]
|
299
|
+
},
|
300
|
+
"dadosTomador": {
|
301
|
+
"description": "Representa dados do tomador de serviço",
|
302
|
+
"type": "object",
|
303
|
+
"properties": {
|
304
|
+
"identificacaoTomador": { "$ref": "#/identificacaoTomador" },
|
305
|
+
"razaoSocial": { "$ref": "#/razaoSocial" },
|
306
|
+
"endereco": { "$ref": "#/enderecoCompleto" },
|
307
|
+
"contato": { "$ref": "#/contato" }
|
308
|
+
},
|
309
|
+
"additionalProperties": false
|
310
|
+
},
|
311
|
+
"identificacaoTomador": {
|
312
|
+
"description": "Representa dados para identificação do tomador de serviço",
|
313
|
+
"oneOf": [
|
314
|
+
{
|
315
|
+
"type": "object",
|
316
|
+
"properties": {
|
317
|
+
"inscricaoMunicipal": { "$ref": "#/inscricaoMunicipal" },
|
318
|
+
"cnpj": { "$ref": "#/cnpj" }
|
319
|
+
},
|
320
|
+
"additionalProperties": false
|
321
|
+
},
|
322
|
+
{
|
323
|
+
"type": "object",
|
324
|
+
"properties": {
|
325
|
+
"cpf": { "$ref": "#/cpf" }
|
326
|
+
},
|
327
|
+
"additionalProperties": false
|
328
|
+
}
|
329
|
+
]
|
330
|
+
},
|
331
|
+
"enderecoCompleto": {
|
332
|
+
"description": "Representação completa do endereço.",
|
333
|
+
"type": "object",
|
334
|
+
"properties": {
|
335
|
+
"endereco": { "$ref": "#/endereco" },
|
336
|
+
"numero": { "$ref": "#/numeroEndereco" },
|
337
|
+
"complemento": { "$ref": "#/complementoEndereco" },
|
338
|
+
"bairro": { "$ref": "#/bairro" },
|
339
|
+
"codigoMunicipio": { "$ref": "#/codigoMunicipioIbge" },
|
340
|
+
"uf": { "$ref": "#/uf" },
|
341
|
+
"cep": { "$ref": "#/cep" }
|
342
|
+
},
|
343
|
+
"required": [],
|
344
|
+
"additionalProperties": false
|
345
|
+
},
|
346
|
+
"contato": {
|
347
|
+
"description": "Representa forma de contato com a pessoa (física/jurídica)",
|
348
|
+
"type": "object",
|
349
|
+
"properties": {
|
350
|
+
"telefone": { "$ref": "#/telefone" },
|
351
|
+
"email": { "$ref": "#/email" }
|
352
|
+
},
|
353
|
+
"required": [],
|
354
|
+
"additionalProperties": false
|
355
|
+
},
|
356
|
+
"identificacaoIntermediarioServico": {
|
357
|
+
"description": "Representa dados para identificação de intermediário do serviço",
|
358
|
+
"oneOf": [
|
359
|
+
{
|
360
|
+
"type": "object",
|
361
|
+
"properties": {
|
362
|
+
"razaoSocial": { "$ref": "#/razaoSocial" },
|
363
|
+
"cnpj": { "$ref": "#/cnpj" },
|
364
|
+
"inscricaoMunicipal": { "$ref": "#/inscricaoMunicipal" }
|
365
|
+
},
|
366
|
+
"required": ["razaoSocial", "cnpj"],
|
367
|
+
"additionalProperties": false
|
368
|
+
},
|
369
|
+
{
|
370
|
+
"type": "object",
|
371
|
+
"properties": {
|
372
|
+
"razaoSocial": { "$ref": "#/razaoSocial" },
|
373
|
+
"cpf": { "$ref": "#/cpf" },
|
374
|
+
"inscricaoMunicipal": { "$ref": "#/inscricaoMunicipal" }
|
375
|
+
},
|
376
|
+
"required": ["cpf"],
|
377
|
+
"additionalProperties": false
|
378
|
+
}
|
379
|
+
]
|
380
|
+
},
|
381
|
+
"dadosConstrucaoCivil": {
|
382
|
+
"description": "Representa dados para identificação de intermediário do serviço",
|
383
|
+
"type": "object",
|
384
|
+
"properties": {
|
385
|
+
"codigoObra": { "$ref": "#/codigoObra" },
|
386
|
+
"art": { "$ref": "#/art" }
|
387
|
+
},
|
388
|
+
"required": [],
|
389
|
+
"additionalProperties": false
|
390
|
+
},
|
391
|
+
"data": {
|
392
|
+
"description": "Data como representada no padrão RFC 3339 section 5.6",
|
393
|
+
"type": "string",
|
394
|
+
"format": "date-time"
|
395
|
+
},
|
396
|
+
"codigoCancelamentoNfse": {
|
397
|
+
"description": "Código de cancelamento com base na tabela de erros e alertas",
|
398
|
+
"type": "string",
|
399
|
+
"maxLength": 4
|
400
|
+
},
|
401
|
+
"identificacaoNfse": {
|
402
|
+
"description": "Representa dados que identificam uma Nota Fiscal de Serviços Eletrônica",
|
403
|
+
"type": "object",
|
404
|
+
"properties": {
|
405
|
+
"numero": { "$ref": "#/numeroNfse" },
|
406
|
+
"cnpj": { "$ref": "#/cnpj" },
|
407
|
+
"inscricaoMunicipal": { "$ref": "#/inscricaoMunicipal" },
|
408
|
+
"codigoMunicipio": { "$ref": "#/codigoMunicipioIbge" },
|
409
|
+
},
|
410
|
+
"required": ["numero", "cnpj"],
|
411
|
+
"additionalProperties": false
|
412
|
+
}
|
413
|
+
}
|