nfse_prefeitura_sp 0.2.0 → 0.3.2
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/README.md +20 -2
- data/lib/nfse_prefeitura_sp/client.rb +8 -3
- data/lib/nfse_prefeitura_sp/services/sync/consulta_cnpj.rb +29 -0
- data/lib/nfse_prefeitura_sp/types/tp_cpf_cnpj.rb +1 -1
- data/lib/nfse_prefeitura_sp/types/tp_rps.rb +7 -2
- data/lib/nfse_prefeitura_sp/version.rb +1 -1
- metadata +17 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 562a810b1aaa406cdfddbf2a495dd57a4f3c311b46501843568e91412b6ee294
|
|
4
|
+
data.tar.gz: 33ce66ed3452597cc123bdcab9768cc1bb473e9aa688beeed1921cdde825fcf7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7e9abcc4a4ceb6d5b53adc1bb60e0b707581660ac276a9bf5b52b7c4608d859d4e1ea5334b46ac8274e545b349dde93d3fbae81c036c145cedbac0f8828c8b56
|
|
7
|
+
data.tar.gz: a889b9b6b1ba1eeafb39948f47d3d124cac8e804e0d4556556a6d5191b31e44b60d0b6c1012d3e7e0c836c1950544971f6c7e1fdcac8bc74c96b04e92299480d
|
data/README.md
CHANGED
|
@@ -26,7 +26,7 @@ Abaixo estão indicados os serviços já disponíveis (`[X]`) e os pendentes de
|
|
|
26
26
|
- `[ ] CONSULTA DE LOTE`
|
|
27
27
|
- `[ ] CONSULTA INFORMAÇÕES DO LOTE`
|
|
28
28
|
- `[X] CANCELAMENTO DE NF-E`
|
|
29
|
-
- `[
|
|
29
|
+
- `[X] CONSULTA DE CNPJ`
|
|
30
30
|
|
|
31
31
|
### Serviços assíncronos
|
|
32
32
|
|
|
@@ -79,6 +79,7 @@ data = {
|
|
|
79
79
|
valor_inss: 'XX.XX',
|
|
80
80
|
valor_ir: 'XX.XX',
|
|
81
81
|
valor_csll: 'XX.XX',
|
|
82
|
+
retencao_pis_cofins: '0',
|
|
82
83
|
exigibilidade_suspensa: '0',
|
|
83
84
|
pagamento_parcelado_antecipado: '0',
|
|
84
85
|
nbs: '000000000',
|
|
@@ -210,7 +211,7 @@ data = {
|
|
|
210
211
|
inscricao_prestador: '00000000',
|
|
211
212
|
numero_nfe: '000000000000',
|
|
212
213
|
# codigo_verificacao: '000000',
|
|
213
|
-
# chave_nota_nacional: '000000',
|
|
214
|
+
# chave_nota_nacional: '000000',
|
|
214
215
|
}
|
|
215
216
|
}
|
|
216
217
|
],
|
|
@@ -224,6 +225,23 @@ response.retorno[:alerta] # Alertas
|
|
|
224
225
|
response.retorno[:erro] # Erros
|
|
225
226
|
```
|
|
226
227
|
|
|
228
|
+
CONSULTA DE CNPJ:
|
|
229
|
+
|
|
230
|
+
```ruby
|
|
231
|
+
data = {
|
|
232
|
+
cnpj_remetente: '00000000000000',
|
|
233
|
+
cnpj_contribuinte: '00000000000000',
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
response = client.sync_consulta_cnpj(data)
|
|
237
|
+
|
|
238
|
+
response.success? # true / false
|
|
239
|
+
response.retorno[:detalhe][:inscricao_municipal] # Inscrição municipal
|
|
240
|
+
response.retorno[:detalhe][:emite_n_fe] # Emite NF-e (true/false)
|
|
241
|
+
response.retorno[:alerta] # Alertas
|
|
242
|
+
response.retorno[:erro] # Erros
|
|
243
|
+
```
|
|
244
|
+
|
|
227
245
|
### Exemplos de serviços assíncronos
|
|
228
246
|
|
|
229
247
|
TODO
|
|
@@ -24,12 +24,17 @@ class NfsePrefeituraSp::Client
|
|
|
24
24
|
call_service(NfsePrefeituraSp::Services::Sync::CancelamentoNfe.new(data, @signer))
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
+
# CONSULTA DE CNPJ
|
|
28
|
+
def sync_consulta_cnpj(data)
|
|
29
|
+
call_service(NfsePrefeituraSp::Services::Sync::ConsultaCnpj.new(data, @signer))
|
|
30
|
+
end
|
|
31
|
+
|
|
27
32
|
private
|
|
28
33
|
|
|
29
34
|
def call_service(service)
|
|
30
35
|
soap_client = new_soap_client(:sync)
|
|
31
36
|
message = service.request_xml
|
|
32
|
-
|
|
37
|
+
|
|
33
38
|
# request = soap_client.build_request(service.class::OPERATION_REQUEST, message: message, attributes:{ xmlns: 'http://www.prefeitura.sp.gov.br/nfe' })
|
|
34
39
|
# puts "\n\n\n\n\n=============== REQUEST ==============="
|
|
35
40
|
# puts request.body
|
|
@@ -39,7 +44,7 @@ class NfsePrefeituraSp::Client
|
|
|
39
44
|
# puts "=============== RESPONSE ==============="
|
|
40
45
|
# puts response.full_hash[:envelope][:body][service.class::OPERATION_RESPONSE][:retorno_xml]
|
|
41
46
|
# puts "=============== RESPONSE ===============\n\n\n\n\n"
|
|
42
|
-
|
|
47
|
+
|
|
43
48
|
NfsePrefeituraSp::Response.new(xml: response.full_hash[:envelope][:body][service.class::OPERATION_RESPONSE][:retorno_xml], method: service.class::OPERATION_REQUEST)
|
|
44
49
|
end
|
|
45
50
|
|
|
@@ -56,7 +61,7 @@ class NfsePrefeituraSp::Client
|
|
|
56
61
|
Savon.client(
|
|
57
62
|
env_namespace: :soap,
|
|
58
63
|
soap_version: 2,
|
|
59
|
-
ssl_verify_mode:
|
|
64
|
+
ssl_verify_mode: :peer,
|
|
60
65
|
ssl_cert: @cert.certificate,
|
|
61
66
|
ssl_cert_key: @cert.key,
|
|
62
67
|
wsdl: wsdl,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# PedidoConsultaCNPJ
|
|
2
|
+
class NfsePrefeituraSp::Services::Sync::ConsultaCnpj
|
|
3
|
+
OPERATION_REQUEST = :consulta_cnpj
|
|
4
|
+
OPERATION_RESPONSE = :consulta_cnpj_response
|
|
5
|
+
|
|
6
|
+
def initialize(data, signer)
|
|
7
|
+
@data = data
|
|
8
|
+
@signer = signer
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def request_xml
|
|
12
|
+
builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
|
|
13
|
+
xml.PedidoConsultaCNPJ("xmlns" => "http://www.prefeitura.sp.gov.br/nfe") do
|
|
14
|
+
xml.Cabecalho('Versao' => '2', 'xmlns' => '') do
|
|
15
|
+
xml.CPFCNPJRemetente do
|
|
16
|
+
xml.CNPJ @data[:cnpj_remetente]
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
xml.CNPJContribuinte('xmlns' => '') do
|
|
21
|
+
xml.CNPJ @data[:cnpj_contribuinte]
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
signed_xml = @signer.sign_xml(builder.to_xml)
|
|
27
|
+
("<VersaoSchema>#{NfsePrefeituraSp::XSD_VERSION.to_s}</VersaoSchema><MensagemXML>" + "<![CDATA[#{signed_xml}]]>" + "</MensagemXML>").gsub(/\n/,'')
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
class NfsePrefeituraSp::Types::TpCpfCnpj < NfsePrefeituraSp::Types::Complex
|
|
3
3
|
def initialize_children
|
|
4
4
|
@children[:cpf] = NfsePrefeituraSp::Types::Simple.new('CPF', @data[:cpf])
|
|
5
|
-
@children[:cnpj] = NfsePrefeituraSp::Types::Simple.new('CNPJ', @data[:
|
|
5
|
+
@children[:cnpj] = NfsePrefeituraSp::Types::Simple.new('CNPJ', @data[:cnpj])
|
|
6
6
|
end
|
|
7
7
|
|
|
8
8
|
def add_children_tags_to_xml(xml)
|
|
@@ -33,6 +33,7 @@ class NfsePrefeituraSp::Types::TpRps < NfsePrefeituraSp::Types::Complex
|
|
|
33
33
|
@children[:matricula_obra] = NfsePrefeituraSp::Types::Simple.new('MatriculaObra', @data[:matricula_obra])
|
|
34
34
|
@children[:municipio_prestacao] = NfsePrefeituraSp::Types::Simple.new('MunicipioPrestacao', @data[:municipio_prestacao])
|
|
35
35
|
@children[:valor_total_recebido] = NfsePrefeituraSp::Types::Simple.new('ValorTotalRecebido', @data[:valor_total_recebido])
|
|
36
|
+
@children[:retencao_pis_cofins] = NfsePrefeituraSp::Types::Simple.new('RetencaoPisCofins', @data[:retencao_pis_cofins])
|
|
36
37
|
@children[:numero_encapsulamento] = NfsePrefeituraSp::Types::Simple.new('NumeroEncapsulamento', @data[:numero_encapsulamento])
|
|
37
38
|
@children[:valor_inicial_cobrado] = NfsePrefeituraSp::Types::Simple.new('ValorInicialCobrado', @data[:valor_inicial_cobrado])
|
|
38
39
|
@children[:valor_final_cobrado] = NfsePrefeituraSp::Types::Simple.new('ValorFinalCobrado', @data[:valor_final_cobrado])
|
|
@@ -40,13 +41,16 @@ class NfsePrefeituraSp::Types::TpRps < NfsePrefeituraSp::Types::Complex
|
|
|
40
41
|
@children[:valor_juros] = NfsePrefeituraSp::Types::Simple.new('ValorJuros', @data[:valor_juros])
|
|
41
42
|
@children[:valor_ipi] = NfsePrefeituraSp::Types::Simple.new('ValorIPI', @data[:valor_ipi])
|
|
42
43
|
@children[:exigibilidade_suspensa] = NfsePrefeituraSp::Types::Simple.new('ExigibilidadeSuspensa', @data[:exigibilidade_suspensa])
|
|
43
|
-
@children[:pagamento_parcelado_antecipado] = NfsePrefeituraSp::Types::Simple.new('PagamentoParceladoAntecipado', @data[:pagamento_parcelado_antecipado])
|
|
44
44
|
@children[:ncm] = NfsePrefeituraSp::Types::Simple.new('NCM', @data[:ncm])
|
|
45
45
|
@children[:nbs] = NfsePrefeituraSp::Types::Simple.new('NBS', @data[:nbs])
|
|
46
46
|
@children[:c_loc_prestacao] = NfsePrefeituraSp::Types::Simple.new('cLocPrestacao', @data[:c_loc_prestacao])
|
|
47
47
|
@children[:c_pais_prestacao] = NfsePrefeituraSp::Types::Simple.new('cPaisPrestacao', @data[:c_pais_prestacao])
|
|
48
48
|
@children[:ibs_cbs] = NfsePrefeituraSp::Types::TpIbsCbs.new('IBSCBS', @data[:ibs_cbs])
|
|
49
49
|
@children[:assinatura] = NfsePrefeituraSp::Types::Simple.new('Assinatura', generate_signature)
|
|
50
|
+
|
|
51
|
+
# Versão 3.3.6 - 14/05/2026
|
|
52
|
+
# O campo PagamentoParceladoAntecipado não será mais utilizado e os valores enviados serão desconsiderados.
|
|
53
|
+
# @children[:pagamento_parcelado_antecipado] = NfsePrefeituraSp::Types::Simple.new('PagamentoParceladoAntecipado', @data[:pagamento_parcelado_antecipado])
|
|
50
54
|
end
|
|
51
55
|
|
|
52
56
|
def add_children_tags_to_xml(xml)
|
|
@@ -83,6 +87,7 @@ class NfsePrefeituraSp::Types::TpRps < NfsePrefeituraSp::Types::Complex
|
|
|
83
87
|
matricula_obra.add_tag_to_xml(xml)
|
|
84
88
|
municipio_prestacao.add_tag_to_xml(xml)
|
|
85
89
|
valor_total_recebido.add_tag_to_xml(xml)
|
|
90
|
+
retencao_pis_cofins.add_tag_to_xml(xml)
|
|
86
91
|
numero_encapsulamento.add_tag_to_xml(xml)
|
|
87
92
|
|
|
88
93
|
if !valor_inicial_cobrado.value.nil?
|
|
@@ -95,7 +100,7 @@ class NfsePrefeituraSp::Types::TpRps < NfsePrefeituraSp::Types::Complex
|
|
|
95
100
|
valor_juros.add_tag_to_xml(xml)
|
|
96
101
|
valor_ipi.add_tag_to_xml(xml)
|
|
97
102
|
exigibilidade_suspensa.add_tag_to_xml(xml)
|
|
98
|
-
pagamento_parcelado_antecipado.add_tag_to_xml(xml)
|
|
103
|
+
# pagamento_parcelado_antecipado.add_tag_to_xml(xml) # Ver nota acima (Versão 3.3.6 - 14/05/2026).
|
|
99
104
|
ncm.add_tag_to_xml(xml)
|
|
100
105
|
nbs.add_tag_to_xml(xml)
|
|
101
106
|
|
metadata
CHANGED
|
@@ -1,57 +1,63 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: nfse_prefeitura_sp
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2
|
|
4
|
+
version: 0.3.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- https://www.infosimples.com.br
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-11-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: openssl
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '3.2'
|
|
20
|
+
- - "<"
|
|
18
21
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
22
|
+
version: '5.0'
|
|
20
23
|
type: :runtime
|
|
21
24
|
prerelease: false
|
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
26
|
requirements:
|
|
24
|
-
- - "
|
|
27
|
+
- - ">="
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: '3.2'
|
|
30
|
+
- - "<"
|
|
25
31
|
- !ruby/object:Gem::Version
|
|
26
|
-
version:
|
|
32
|
+
version: '5.0'
|
|
27
33
|
- !ruby/object:Gem::Dependency
|
|
28
34
|
name: nokogiri
|
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
|
30
36
|
requirements:
|
|
31
37
|
- - "~>"
|
|
32
38
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: 1.18
|
|
39
|
+
version: '1.18'
|
|
34
40
|
type: :runtime
|
|
35
41
|
prerelease: false
|
|
36
42
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
43
|
requirements:
|
|
38
44
|
- - "~>"
|
|
39
45
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: 1.18
|
|
46
|
+
version: '1.18'
|
|
41
47
|
- !ruby/object:Gem::Dependency
|
|
42
48
|
name: savon
|
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
|
44
50
|
requirements:
|
|
45
51
|
- - "~>"
|
|
46
52
|
- !ruby/object:Gem::Version
|
|
47
|
-
version:
|
|
53
|
+
version: '2.18'
|
|
48
54
|
type: :runtime
|
|
49
55
|
prerelease: false
|
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
57
|
requirements:
|
|
52
58
|
- - "~>"
|
|
53
59
|
- !ruby/object:Gem::Version
|
|
54
|
-
version:
|
|
60
|
+
version: '2.18'
|
|
55
61
|
description:
|
|
56
62
|
email:
|
|
57
63
|
- contato@infosimples.com.br
|
|
@@ -67,6 +73,7 @@ files:
|
|
|
67
73
|
- lib/nfse_prefeitura_sp/services.rb
|
|
68
74
|
- lib/nfse_prefeitura_sp/services/async/.keep
|
|
69
75
|
- lib/nfse_prefeitura_sp/services/sync/cancelamento_nfe.rb
|
|
76
|
+
- lib/nfse_prefeitura_sp/services/sync/consulta_cnpj.rb
|
|
70
77
|
- lib/nfse_prefeitura_sp/services/sync/envio_rps.rb
|
|
71
78
|
- lib/nfse_prefeitura_sp/services/sync/teste_envio_lote_rps.rb
|
|
72
79
|
- lib/nfse_prefeitura_sp/signer.rb
|