nfse_prefeitura_sp 0.2.0 → 0.3.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/README.md +20 -2
- data/lib/nfse_prefeitura_sp/client.rb +7 -2
- 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 +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b079b03fe4fbc9e55ddc07893599e8826085ce20799435c9542e600aefa4a5ad
|
|
4
|
+
data.tar.gz: ba8d85c29ebe374b7f809ce43c040d5cc24d9430713afc32b834f9d773e04bef
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9a244834027ceabf184d12a5f2a2823f2858ede8c38d0e2a172eae0fe13156e18a6e8e63db6c7cc0389037f5610ced5fd60f93ec2bb8e3522ffdb625197ce53e
|
|
7
|
+
data.tar.gz: 5cc6958d045a2fb39b721ba555846647da2a1c5e1d39a072b37bfedfb1282a78f3a170d196e1b73bf780d9762f6be23daee4a0e36ea69656d2f3f86e29f775b9
|
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
|
|
|
@@ -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,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: nfse_prefeitura_sp
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
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-07-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: openssl
|
|
@@ -67,6 +67,7 @@ files:
|
|
|
67
67
|
- lib/nfse_prefeitura_sp/services.rb
|
|
68
68
|
- lib/nfse_prefeitura_sp/services/async/.keep
|
|
69
69
|
- lib/nfse_prefeitura_sp/services/sync/cancelamento_nfe.rb
|
|
70
|
+
- lib/nfse_prefeitura_sp/services/sync/consulta_cnpj.rb
|
|
70
71
|
- lib/nfse_prefeitura_sp/services/sync/envio_rps.rb
|
|
71
72
|
- lib/nfse_prefeitura_sp/services/sync/teste_envio_lote_rps.rb
|
|
72
73
|
- lib/nfse_prefeitura_sp/signer.rb
|