nfse-carioca 0.2.8 → 0.2.9
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/lib/nfse_carioca.rb +1 -0
- data/lib/nfse_carioca/gerar_nfse_xml.rb +8 -4
- data/lib/nfse_carioca/sanitizer.rb +16 -0
- data/lib/nfse_carioca/version.rb +1 -1
- data/spec/lib/nfse_carioca/sanitizer_spec.rb +15 -0
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bb1e8b24538a361b90b79e5eede02041581e806d
|
|
4
|
+
data.tar.gz: 37267c3f1c0818afeadc26680df63926d099f3d4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5cec76899bae06a36f9abd216e3fad22f7260100bfc848e2a000624eac7d93a3368772f5f2953518e1b92ed019cc6e334f1b0e048f527e729c447e5cbdbdfd69
|
|
7
|
+
data.tar.gz: ff3e7bb008985b83e4a6d3b9e3b7bacbe5b48a7b7f59e4b6b1afe64d7660bef3c85ebefeef60471af8ad1c8f83d3b92a64b9f4d3343d8a9d9feef3f5c717f361
|
data/lib/nfse_carioca.rb
CHANGED
|
@@ -56,6 +56,10 @@ module NfseCarioca
|
|
|
56
56
|
)
|
|
57
57
|
end
|
|
58
58
|
|
|
59
|
+
def clear(value)
|
|
60
|
+
NfseCarioca::Sanitizer.new(value).clean
|
|
61
|
+
end
|
|
62
|
+
|
|
59
63
|
def tributacao
|
|
60
64
|
tributacao = NfseCarioca.configuration.codigo_tributacao_municipio
|
|
61
65
|
|
|
@@ -104,15 +108,15 @@ module NfseCarioca
|
|
|
104
108
|
|
|
105
109
|
if @invoice[:customer][:address].present?
|
|
106
110
|
xml["Endereco"] = {
|
|
107
|
-
"Endereco" => @invoice[:customer][:address][:street],
|
|
108
|
-
"Numero" => @invoice[:customer][:address][:number]
|
|
111
|
+
"Endereco" => clear(@invoice[:customer][:address][:street]),
|
|
112
|
+
"Numero" => clear(@invoice[:customer][:address][:number])
|
|
109
113
|
}
|
|
110
114
|
|
|
111
115
|
if @invoice[:customer][:address][:complement].present?
|
|
112
|
-
xml["Endereco"]["Complemento"] = @invoice[:customer][:address][:complement]
|
|
116
|
+
xml["Endereco"]["Complemento"] = clear(@invoice[:customer][:address][:complement])
|
|
113
117
|
end
|
|
114
118
|
|
|
115
|
-
xml["Endereco"]["Bairro"] = @invoice[:customer][:address][:neighborhood]
|
|
119
|
+
xml["Endereco"]["Bairro"] = clear(@invoice[:customer][:address][:neighborhood])
|
|
116
120
|
xml["Endereco"]["CodigoMunicipio"] = @invoice[:customer][:address][:city_ibge_code]
|
|
117
121
|
xml["Endereco"]["Uf"] = @invoice[:customer][:address][:state_code]
|
|
118
122
|
xml["Endereco"]["Cep"] = @invoice[:customer][:address][:zipcode].scan(/\d/).join
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module NfseCarioca
|
|
2
|
+
class Sanitizer
|
|
3
|
+
attr_reader :value
|
|
4
|
+
|
|
5
|
+
def initialize(value)
|
|
6
|
+
@value = value
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def clear
|
|
10
|
+
temp = I18n.transliterate(value)
|
|
11
|
+
temp.gsub!(/\-/, " ")
|
|
12
|
+
temp.gsub!(/,|\./, "")
|
|
13
|
+
temp.scan(/\w+|\s+/i).join
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
data/lib/nfse_carioca/version.rb
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
RSpec.describe NfseCarioca::Sanitizer do
|
|
4
|
+
describe "#clear" do
|
|
5
|
+
{
|
|
6
|
+
"Gestimbra-Contabilidade e Gestão, Lda. PT501615725 Rua Padre Estevão Cabral,79 / Sala 313, 3000-317 Co" =>
|
|
7
|
+
"Gestimbra Contabilidade e Gestao Lda PT501615725 Rua Padre Estevao Cabral79 Sala 313 3000 317 Co"
|
|
8
|
+
}.each do |dirty, clean|
|
|
9
|
+
context "when #{dirty}" do
|
|
10
|
+
subject { described_class.new(dirty).clear }
|
|
11
|
+
it { is_expected.to eq clean }
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: nfse-carioca
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- LUZ Planilhas
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-
|
|
11
|
+
date: 2015-05-14 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: savon
|
|
@@ -159,6 +159,7 @@ files:
|
|
|
159
159
|
- lib/nfse_carioca/gerar_nfse.rb
|
|
160
160
|
- lib/nfse_carioca/gerar_nfse_xml.rb
|
|
161
161
|
- lib/nfse_carioca/response.rb
|
|
162
|
+
- lib/nfse_carioca/sanitizer.rb
|
|
162
163
|
- lib/nfse_carioca/version.rb
|
|
163
164
|
- nfse_carioca.gemspec
|
|
164
165
|
- spec/fixtures/nota_carioca/CancelarNfseResposta.xml
|
|
@@ -177,6 +178,7 @@ files:
|
|
|
177
178
|
- spec/lib/nfse_carioca/cancelar_nfse_spec.rb
|
|
178
179
|
- spec/lib/nfse_carioca/configuration_spec.rb
|
|
179
180
|
- spec/lib/nfse_carioca/gerar_nfse_spec.rb
|
|
181
|
+
- spec/lib/nfse_carioca/sanitizer_spec.rb
|
|
180
182
|
- spec/spec_helper.rb
|
|
181
183
|
homepage:
|
|
182
184
|
licenses:
|