rnfse 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +25 -0
- data/.rspec +1 -0
- data/.travis.yml +14 -0
- data/CHANGELOG.md +0 -0
- data/Gemfile +3 -0
- data/Guardfile +15 -0
- data/LICENSE.md +41 -0
- data/Procfile +1 -0
- data/README.md +59 -0
- data/Rakefile +12 -0
- data/lib/provedores.yml +11 -0
- data/lib/rnfse/api/abrasf_1_0/definitions.json +374 -0
- data/lib/rnfse/api/abrasf_1_0/recepcionar_lote_rps.json +46 -0
- data/lib/rnfse/api/abrasf_1_0.rb +55 -0
- data/lib/rnfse/api/iss_net_1_0.rb +6 -0
- data/lib/rnfse/api.rb +101 -0
- data/lib/rnfse/configuration.rb +18 -0
- data/lib/rnfse/core.rb +9 -0
- data/lib/rnfse/hash.rb +148 -0
- data/lib/rnfse/string.rb +36 -0
- data/lib/rnfse/version.rb +3 -0
- data/lib/rnfse/xml_builder/abrasf_1_0.rb +95 -0
- data/lib/rnfse/xml_builder/iss_net_1_0.rb +70 -0
- data/lib/rnfse/xml_builder.rb +10 -0
- data/lib/rnfse.rb +22 -0
- data/rnfse.gemspec +60 -0
- data/spec/api/abrasf_1_0/recepcionar_lote_rps_json_spec.rb +123 -0
- data/spec/api/abrasf_1_0_spec.rb +26 -0
- data/spec/api/iss_net_1_0_spec.rb +99 -0
- data/spec/api_spec.rb +65 -0
- data/spec/core_spec.rb +35 -0
- data/spec/fixtures/abrasf_1_0/enviar_lote_rps_envio.xml +47 -0
- data/spec/fixtures/abrasf_1_0/nfse.xsd +771 -0
- data/spec/fixtures/certificate.pem +18 -0
- data/spec/fixtures/iss_net_1_0/enviar_lote_rps_envio.xml +75 -0
- data/spec/fixtures/key.pem +15 -0
- data/spec/fixtures/vcr_cassettes/iss_net_1_0_recepcionar_lote_rps.yml +214 -0
- data/spec/hash_spec.rb +205 -0
- data/spec/spec_helper.rb +29 -0
- data/spec/string_spec.rb +38 -0
- data/spec/support/.keep +0 -0
- data/spec/version_spec.rb +5 -0
- data/spec/xml_builder/abrasf_1_0_spec.rb +63 -0
- data/spec/xml_builder/iss_net_1_0_spec.rb +86 -0
- data/spec/xml_builder_spec.rb +14 -0
- metadata +433 -0
@@ -0,0 +1,123 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe "abrasf_1_0/recepcionar_lote_rps.json" do
|
5
|
+
let(:file) do
|
6
|
+
File.join($ROOT, 'lib', 'rnfse', 'api', 'abrasf_1_0',
|
7
|
+
'recepcionar_lote_rps.json')
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#/loteRps" do
|
11
|
+
it 'deveria validar' do
|
12
|
+
expect(JSON::Validator.fully_validate(file, <<-'JSON')).to be_empty
|
13
|
+
{
|
14
|
+
"loteRps": {
|
15
|
+
"numeroLote": 2,
|
16
|
+
"cnpj": "44.141.526/0001-67",
|
17
|
+
"inscricaoMunicipal": "12345678",
|
18
|
+
"quantidadeRps": 1,
|
19
|
+
"listaRps": [
|
20
|
+
{
|
21
|
+
"identificacaoRps": { "numero": 2, "serie": "8", "tipo": 1 },
|
22
|
+
"dataEmissao": "1960-04-21T21:42:42-03:00",
|
23
|
+
"naturezaOperacao": 1,
|
24
|
+
"optanteSimplesNacional": false,
|
25
|
+
"incentivadorCultural": false,
|
26
|
+
"status": 1,
|
27
|
+
"servico": {
|
28
|
+
"valores": {
|
29
|
+
"valorServicos": 10.42,
|
30
|
+
"issRetido": false,
|
31
|
+
"baseCalculo": 10.42
|
32
|
+
},
|
33
|
+
"itemListaServico": "00001",
|
34
|
+
"discriminacao": "Borealis",
|
35
|
+
"codigoMunicipio": 5300108
|
36
|
+
},
|
37
|
+
"prestador": {
|
38
|
+
"cnpj": "44.141.526/0001-67",
|
39
|
+
"inscricaoMunicipal": "12345678"
|
40
|
+
},
|
41
|
+
"tomador": {
|
42
|
+
"identificacaoTomador": {
|
43
|
+
"cnpj": "38.421.846/0001-78",
|
44
|
+
"inscricaoMunicipal": "12345679"
|
45
|
+
}
|
46
|
+
}
|
47
|
+
},
|
48
|
+
{
|
49
|
+
"identificacaoRps": { "numero": 2, "serie": "8", "tipo": 1 },
|
50
|
+
"dataEmissao": "1960-04-21T21:42:42-03:00",
|
51
|
+
"naturezaOperacao": 1,
|
52
|
+
"regimeEspecialTributacao": 1,
|
53
|
+
"optanteSimplesNacional": false,
|
54
|
+
"incentivadorCultural": false,
|
55
|
+
"status": 1,
|
56
|
+
"rpsSubstituido": { "numero": 1, "serie": "8", "tipo": 1 },
|
57
|
+
"servico": {
|
58
|
+
"valores": {
|
59
|
+
"valorServicos": 10.42,
|
60
|
+
"valorDeducoes": 0.1,
|
61
|
+
"valorPis": 0.2,
|
62
|
+
"valorCofins": 0.3,
|
63
|
+
"valorInss": 0.4,
|
64
|
+
"valorIr": 0.5,
|
65
|
+
"valorCsll": 0.6,
|
66
|
+
"issRetido": true,
|
67
|
+
"valorIss": 0.7,
|
68
|
+
"outrasRetencoes": 0.8,
|
69
|
+
"baseCalculo": 9.32,
|
70
|
+
"aliquota": 0,
|
71
|
+
"valorLiquidoNfse": 4.62,
|
72
|
+
"valorIssRetido": 1.1,
|
73
|
+
"descontoCondicionado": 0.9,
|
74
|
+
"descontoIncondicionado": 1
|
75
|
+
},
|
76
|
+
"itemListaServico": "00001",
|
77
|
+
"codigoCnae": "0000-0/00",
|
78
|
+
"codigoTributacaoMunicipio": "00001",
|
79
|
+
"discriminacao": "Borealis",
|
80
|
+
"codigoMunicipio": 5300108
|
81
|
+
},
|
82
|
+
"prestador": {
|
83
|
+
"cnpj": "44.141.526/0001-67",
|
84
|
+
"inscricaoMunicipal": "12345678"
|
85
|
+
},
|
86
|
+
"tomador": {
|
87
|
+
"identificacaoTomador": {
|
88
|
+
"cnpj": "38.421.846/0001-78",
|
89
|
+
"inscricaoMunicipal": "12345679"
|
90
|
+
},
|
91
|
+
"razaoSocial": "Aperture Science Enrichment Center",
|
92
|
+
"endereco": {
|
93
|
+
"endereco": "Rua Vital Apparatus Vent",
|
94
|
+
"numero": "42",
|
95
|
+
"complemento": "Morality Core",
|
96
|
+
"bairro": "GLaDOS",
|
97
|
+
"codigoMunicipio": 5300108,
|
98
|
+
"uf": "DF",
|
99
|
+
"cep": "70000-000"
|
100
|
+
},
|
101
|
+
"contato": {
|
102
|
+
"telefone": "61 80000000",
|
103
|
+
"email": "glados@aperture.com"
|
104
|
+
}
|
105
|
+
},
|
106
|
+
"intermediarioServico": {
|
107
|
+
"razaoSocial": "Black Mesa Research Facility",
|
108
|
+
"cnpj": "62.894.995/0001-39",
|
109
|
+
"inscricaoMunicipal": "12345670"
|
110
|
+
},
|
111
|
+
"construcaoCivil": {
|
112
|
+
"codigoObra": "1008",
|
113
|
+
"art": "3000-D CAU/BR"
|
114
|
+
}
|
115
|
+
}
|
116
|
+
]
|
117
|
+
}
|
118
|
+
}
|
119
|
+
JSON
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Rnfse::API::Abrasf10 do
|
5
|
+
let(:certificate) { File.join($ROOT, 'spec', 'fixtures', 'certificate.pem') }
|
6
|
+
let(:key) { File.join($ROOT, 'spec', 'fixtures', 'key.pem') }
|
7
|
+
|
8
|
+
let(:client) do
|
9
|
+
Rnfse::API.new(padrao: :abrasf_1_0,
|
10
|
+
namespace: 'http://www.issnetonline.com.br/webservice/nfd',
|
11
|
+
endpoint: 'http://www.issnetonline.com.br/webserviceabrasf/homologacao/servicos.asmx',
|
12
|
+
certificate: certificate,
|
13
|
+
key: key)
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
describe '#recepcionar_lote_rps' do
|
18
|
+
it { expect(client).to respond_to(:recepcionar_lote_rps) }
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#consulta_situacao_lote_rps'
|
22
|
+
describe '#consultar_nfse_por_rps'
|
23
|
+
describe '#consultar_nfse'
|
24
|
+
describe '#consultar_lote_rps'
|
25
|
+
describe '#cancelar_nfse'
|
26
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Rnfse::API::IssNet10 do
|
5
|
+
let(:certificate) { File.join($ROOT, 'spec', 'fixtures', 'certificate.pem') }
|
6
|
+
let(:key) { File.join($ROOT, 'spec', 'fixtures', 'key.pem') }
|
7
|
+
|
8
|
+
let(:client) do
|
9
|
+
Rnfse::API.new(padrao: :iss_net_1_0,
|
10
|
+
namespace: 'http://www.issnetonline.com.br/webservice/nfd',
|
11
|
+
endpoint: 'http://www.issnetonline.com.br/webserviceabrasf/homologacao/servicos.asmx',
|
12
|
+
certificate: certificate,
|
13
|
+
key: key)
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
describe '#recepcionar_lote_rps' do
|
18
|
+
context 'quando parametros errados são passados,' do
|
19
|
+
it { expect{ client.recepcionar_lote_rps(bogus: :data) }.to raise_error(ArgumentError) }
|
20
|
+
end
|
21
|
+
|
22
|
+
it { expect(client).to respond_to(:recepcionar_lote_rps) }
|
23
|
+
|
24
|
+
subject do
|
25
|
+
VCR.use_cassette('iss_net_1_0_recepcionar_lote_rps') do
|
26
|
+
client.recepcionar_lote_rps({
|
27
|
+
lote_rps: {
|
28
|
+
numero_lote: 1,
|
29
|
+
cnpj: "14.576.582/0001-63",
|
30
|
+
inscricao_municipal: "812005",
|
31
|
+
quantidade_rps: 1,
|
32
|
+
lista_rps: [
|
33
|
+
{
|
34
|
+
identificacao_rps: { numero: 15, serie: "8", tipo: 1 },
|
35
|
+
data_emissao: "2014-06-24T10:00:00",
|
36
|
+
natureza_operacao: 1,
|
37
|
+
optante_simples_nacional: false,
|
38
|
+
incentivador_cultural: false,
|
39
|
+
status: 1,
|
40
|
+
regime_especial_tributacao: 1,
|
41
|
+
servico: {
|
42
|
+
valores: {
|
43
|
+
valor_servicos: 35,
|
44
|
+
valor_pis: 0,
|
45
|
+
valor_cofins: 0,
|
46
|
+
valor_inss: 0,
|
47
|
+
valor_ir: 0,
|
48
|
+
valor_csll: 0,
|
49
|
+
iss_retido: false,
|
50
|
+
valor_iss: 0,
|
51
|
+
base_calculo: 35,
|
52
|
+
aliquota: 0.05,
|
53
|
+
valor_liquido_nfse: 35,
|
54
|
+
desconto_incondicionado: 0,
|
55
|
+
desconto_condicionado: 0
|
56
|
+
},
|
57
|
+
item_lista_servico: "8",
|
58
|
+
codigo_cnae: "6399-2/00",
|
59
|
+
discriminacao: "Borealis",
|
60
|
+
codigo_tributacao_municipio: "50000024",
|
61
|
+
discriminacao: 'Discriminação da RPS',
|
62
|
+
codigo_municipio: 999
|
63
|
+
},
|
64
|
+
prestador: {
|
65
|
+
cnpj: "11.006.269/0001-00",
|
66
|
+
inscricao_municipal: "124762"
|
67
|
+
},
|
68
|
+
tomador: {
|
69
|
+
identificacao_tomador: {
|
70
|
+
cpf: "935.659.688-34",
|
71
|
+
},
|
72
|
+
razao_social: 'José Serra',
|
73
|
+
endereco: {
|
74
|
+
endereco: 'R dos Navegantes 123, 321',
|
75
|
+
numero: '123',
|
76
|
+
complemento: '321',
|
77
|
+
bairro: 'Boa Viagem',
|
78
|
+
codigo_municipio: 1,
|
79
|
+
uf: 'PE',
|
80
|
+
cep: '51021-010'
|
81
|
+
}
|
82
|
+
}
|
83
|
+
}
|
84
|
+
]
|
85
|
+
}
|
86
|
+
})
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
it { should_not be_nil }
|
91
|
+
it { should be_kind_of(Hash) }
|
92
|
+
end
|
93
|
+
|
94
|
+
describe '#cancelar_nfse'
|
95
|
+
describe '#consultar_nfse_por_rps'
|
96
|
+
describe '#consulta_situacao_lote_rps'
|
97
|
+
describe '#consultar_url_visualizacao_nfse'
|
98
|
+
describe '#consultar_url_visualizacao_nfse_serie'
|
99
|
+
end
|
data/spec/api_spec.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Rnfse::API do
|
5
|
+
describe '::new' do
|
6
|
+
|
7
|
+
let(:certificate) { File.join($ROOT, 'spec', 'fixtures', 'certificate.pem') }
|
8
|
+
let(:key) { File.join($ROOT, 'spec', 'fixtures', 'key.pem') }
|
9
|
+
|
10
|
+
context 'ao passar um provedor e município,' do
|
11
|
+
subject do
|
12
|
+
Rnfse::API.new(provedor: :iss_net,
|
13
|
+
municipio: :cuiaba,
|
14
|
+
certificate: certificate,
|
15
|
+
key: key)
|
16
|
+
end
|
17
|
+
|
18
|
+
it { should be_kind_of(Rnfse::API) }
|
19
|
+
its(:namespace) { should eq('http://www.issnetonline.com.br/webservice/nfd') }
|
20
|
+
its(:endpoint) { should eq('http://www.issnetonline.com.br/webserviceabrasf/cuiaba/servicos.asmx') }
|
21
|
+
its(:api) { should eq('abrasf_1_0') }
|
22
|
+
its(:xml_builder) { should be_kind_of(Rnfse::XMLBuilder) }
|
23
|
+
its(:soap_client) { should be_kind_of(Savon::Client) }
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'ao passar um provedor em homologação,' do
|
27
|
+
subject do
|
28
|
+
Rnfse::API.new(provedor: :iss_net,
|
29
|
+
homologacao: true,
|
30
|
+
certificate: certificate,
|
31
|
+
key: key)
|
32
|
+
end
|
33
|
+
|
34
|
+
it { should be_kind_of(Rnfse::API) }
|
35
|
+
its(:namespace) { should eq('http://www.issnetonline.com.br/webservice/nfd') }
|
36
|
+
its(:endpoint) { should eq('http://www.issnetonline.com.br/webserviceabrasf/homologacao/servicos.asmx') }
|
37
|
+
its(:api) { should eq('abrasf_1_0') }
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'ao passar o padrão abrasf, namespace e endpoint,' do
|
41
|
+
subject do
|
42
|
+
Rnfse::API.new(padrao: :abrasf_1_0,
|
43
|
+
namespace: 'http://www.issnetonline.com.br/webservice/nfd',
|
44
|
+
endpoint: 'http://www.issnetonline.com.br/webserviceabrasf/homologacao/servicos.asmx',
|
45
|
+
certificate: certificate,
|
46
|
+
key: key)
|
47
|
+
end
|
48
|
+
it { should be_kind_of(Rnfse::API) }
|
49
|
+
its(:namespace) { should eq('http://www.issnetonline.com.br/webservice/nfd') }
|
50
|
+
its(:endpoint) { should eq('http://www.issnetonline.com.br/webserviceabrasf/homologacao/servicos.asmx') }
|
51
|
+
its(:api) { should eq('abrasf_1_0') }
|
52
|
+
end
|
53
|
+
|
54
|
+
context 'ao não passar informações válidas,' do
|
55
|
+
it { expect { Rnfse::API.new() }.to raise_error(ArgumentError) }
|
56
|
+
it { expect { Rnfse::API.new(error: 'error') }.to raise_error(ArgumentError) }
|
57
|
+
|
58
|
+
context 'como provedor inexistente,' do
|
59
|
+
it { expect { Rnfse::API.new(provedor: :none, municipio: :cuiaba) }.to raise_error(ArgumentError) }
|
60
|
+
it { expect { Rnfse::API.new(provedor: :none, homologacao: true) }.to raise_error(ArgumentError) }
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|
data/spec/core_spec.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Rnfse do
|
5
|
+
describe '::configure' do
|
6
|
+
let(:certificate) { File.join($ROOT, 'spec', 'fixtures', 'certificate.pem') }
|
7
|
+
let(:key) { File.join($ROOT, 'spec', 'fixtures', 'key.pem') }
|
8
|
+
|
9
|
+
before do
|
10
|
+
Rnfse.configure do |config|
|
11
|
+
config.verbose = true
|
12
|
+
config.provedor = :iss_net
|
13
|
+
config.municipio = :cuiaba
|
14
|
+
config.certificate = certificate
|
15
|
+
config.key = key
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
after do
|
20
|
+
Rnfse.configure do |config|
|
21
|
+
config.verbose = nil
|
22
|
+
config.provedor = nil
|
23
|
+
config.municipio = nil
|
24
|
+
config.certificate = nil
|
25
|
+
config.key = nil
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
it { expect(Rnfse::API.new.verbose).to eq(true) }
|
30
|
+
it { expect(Rnfse::API.new.namespace).to eq('http://www.issnetonline.com.br/webservice/nfd') }
|
31
|
+
it { expect(Rnfse::API.new.endpoint).to eq('http://www.issnetonline.com.br/webserviceabrasf/cuiaba/servicos.asmx') }
|
32
|
+
it { expect(Rnfse::API.new.certificate).to eq(certificate) }
|
33
|
+
it { expect(Rnfse::API.new.key).to eq(key) }
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<EnviarLoteRpsEnvio
|
3
|
+
xmlns="http://www.abrasf.org.br/servico_enviar_lote_rps_envio.xsd"
|
4
|
+
xmlns:tc="http://www.abrasf.org.br/tipos_complexos.xsd">
|
5
|
+
<LoteRps>
|
6
|
+
<tc:NumeroLote>2</tc:NumeroLote>
|
7
|
+
<tc:Cnpj>44141526000167</tc:Cnpj>
|
8
|
+
<tc:InscricaoMunicipal>12345678</tc:InscricaoMunicipal>
|
9
|
+
<tc:QuantidadeRps>1</tc:QuantidadeRps>
|
10
|
+
<tc:ListaRps>
|
11
|
+
<tc:Rps>
|
12
|
+
<tc:InfRps>
|
13
|
+
<tc:IdentificacaoRps>
|
14
|
+
<tc:Numero>2</tc:Numero>
|
15
|
+
<tc:Serie>8</tc:Serie>
|
16
|
+
<tc:Tipo>1</tc:Tipo>
|
17
|
+
</tc:IdentificacaoRps>
|
18
|
+
<tc:DataEmissao>1960-04-22T00:42:42</tc:DataEmissao>
|
19
|
+
<tc:NaturezaOperacao>1</tc:NaturezaOperacao>
|
20
|
+
<tc:OptanteSimplesNacional>2</tc:OptanteSimplesNacional>
|
21
|
+
<tc:IncentivadorCultural>2</tc:IncentivadorCultural>
|
22
|
+
<tc:Status>1</tc:Status>
|
23
|
+
<tc:Servico>
|
24
|
+
<tc:Valores>
|
25
|
+
<tc:ValorServicos>10.42</tc:ValorServicos>
|
26
|
+
<tc:IssRetido>2</tc:IssRetido>
|
27
|
+
<tc:BaseCalculo>10.42</tc:BaseCalculo>
|
28
|
+
</tc:Valores>
|
29
|
+
<tc:ItemListaServico>00001</tc:ItemListaServico>
|
30
|
+
<tc:CodigoMunicipio>5300108</tc:CodigoMunicipio>
|
31
|
+
<tc:Discriminacao>Borealis</tc:Discriminacao>
|
32
|
+
</tc:Servico>
|
33
|
+
<tc:Prestador>
|
34
|
+
<tc:Cnpj>44141526000167</tc:Cnpj>
|
35
|
+
<tc:InscricaoMunicipal>12345678</tc:InscricaoMunicipal>
|
36
|
+
</tc:Prestador>
|
37
|
+
<tc:Tomador>
|
38
|
+
<tc:IdentificacaoTomador>
|
39
|
+
<tc:Cnpj>38421846000178</tc:Cnpj>
|
40
|
+
<tc:InscricaoMunicipal>12345679</tc:InscricaoMunicipal>
|
41
|
+
</tc:IdentificacaoTomador>
|
42
|
+
</tc:Tomador>
|
43
|
+
</tc:InfRps>
|
44
|
+
</tc:Rps>
|
45
|
+
</tc:ListaRps>
|
46
|
+
</LoteRps>
|
47
|
+
</EnviarLoteRpsEnvio>
|