nfe-paulistana 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MmFlZmNlYTIyYjdjZWQ0OGI1ZGNhMTQ2YzFmYzExNDQ3ODdkZTA2Zg==
5
+ data.tar.gz: !binary |-
6
+ NmQzMzM2NGRhYjQyN2FhMGQ3NGNjYzc5MmNkMDM4ZDk3YTFmMWQ1Yg==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ YWY4YzE2MmQzYzA2ODViMjUwMDU2YTkxZGYwNWM0ZGFkMDRmNDgxNjgwOGE3
10
+ NDE0NmQ1ZThjNzQyY2EzMTNhYTM5NDQzMGVhYTVlYTJmMzBiZDlmZTA0Nzlh
11
+ YTY1ZDEzODZmYWMxYThkOWVjYmZiMTlmODBiNTc4MmRlMTlhMzk=
12
+ data.tar.gz: !binary |-
13
+ ZTg5OWQzZjZmYWFjZTdlODYzNjAzNTJiYTVlZWM1MzgwYTk1YzEwNWVmZWM0
14
+ YjQxYjQ5ZDJkZGJkYjUxMTI0ZDcyOWFmYWZlM2QzYzJmMTRjOWM2ODc4YzJl
15
+ ZmZlMGY3NGQ5OWNlYjdmNzdjNDI1ZjEyODVhNzNlYTg0NWQyMTU=
@@ -1,35 +1,36 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nfe-paulistana (1.0.0)
4
+ nfe-paulistana (1.0.2)
5
5
  nokogiri (= 1.5.9)
6
- savon (~> 2.3.0)
6
+ savon (= 2.3.0)
7
7
  signer
8
8
 
9
9
  GEM
10
10
  remote: http://rubygems.org/
11
11
  specs:
12
- akami (1.2.0)
12
+ akami (1.2.2)
13
13
  gyoku (>= 0.4.0)
14
- nokogiri (>= 1.4.0)
14
+ nokogiri
15
15
  builder (3.2.2)
16
- diff-lcs (1.1.3)
17
- gyoku (1.1.0)
16
+ columnize (0.8.9)
17
+ debugger (1.6.8)
18
+ columnize (>= 0.3.1)
19
+ debugger-linecache (~> 1.2.0)
20
+ debugger-ruby_core_source (~> 1.3.5)
21
+ debugger-linecache (1.2.0)
22
+ debugger-ruby_core_source (1.3.5)
23
+ gyoku (1.1.1)
18
24
  builder (>= 2.1.2)
19
25
  httpi (2.1.0)
20
26
  rack
21
27
  rubyntlm (~> 0.3.2)
28
+ mime-types (1.25.1)
29
+ minitest (5.4.0)
22
30
  nokogiri (1.5.9)
23
31
  nori (2.3.0)
24
32
  rack (1.5.2)
25
- rspec (2.10.0)
26
- rspec-core (~> 2.10.0)
27
- rspec-expectations (~> 2.10.0)
28
- rspec-mocks (~> 2.10.0)
29
- rspec-core (2.10.1)
30
- rspec-expectations (2.10.0)
31
- diff-lcs (~> 1.1.3)
32
- rspec-mocks (2.10.1)
33
+ rake (10.3.2)
33
34
  rubyntlm (0.3.4)
34
35
  savon (2.3.0)
35
36
  akami (~> 1.2.0)
@@ -39,15 +40,18 @@ GEM
39
40
  nokogiri (>= 1.4.0, < 1.6)
40
41
  nori (~> 2.3.0)
41
42
  wasabi (~> 3.2.0)
42
- signer (1.1.1)
43
+ signer (1.4.0)
43
44
  nokogiri (>= 1.5.1)
44
- wasabi (3.2.0)
45
+ wasabi (3.2.3)
45
46
  httpi (~> 2.0)
46
- nokogiri (>= 1.4.0, < 1.6)
47
+ mime-types (< 2.0.0)
48
+ nokogiri (>= 1.4.0)
47
49
 
48
50
  PLATFORMS
49
51
  ruby
50
52
 
51
53
  DEPENDENCIES
54
+ debugger
55
+ minitest
52
56
  nfe-paulistana!
53
- rspec
57
+ rake
data/Rakefile CHANGED
@@ -1 +1,11 @@
1
1
  require "bundler/gem_tasks"
2
+
3
+ require 'rake/testtask'
4
+
5
+ Rake::TestTask.new do |t|
6
+ t.libs << 'lib/nfe-paulistana'
7
+ t.test_files = FileList['test/lib/nfe-paulistana/*_test.rb']
8
+ t.verbose = true
9
+ end
10
+
11
+ task :default => :test
@@ -75,14 +75,23 @@ module NfePaulistana
75
75
  def request(method, data = {})
76
76
  certificado = certificate
77
77
  client = get_client
78
- response = client.call(method, message: XmlBuilder.new.xml_for(method, data, certificado))
78
+ message = XmlBuilder.new.xml_for(method, data, certificado)
79
+ response = client.call(method, message: message)
79
80
  method_response = (method.to_s + "_response").to_sym
80
81
  Response.new(xml: response.hash[:envelope][:body][method_response][:retorno_xml], method: method)
81
- rescue Savon::Error => error
82
+ rescue Savon::Error
82
83
  end
83
84
 
84
85
  def get_client
85
- Savon.client(soap_version: 2, env_namespace: :soap, ssl_verify_mode: :peer, ssl_cert_file: @options[:ssl_cert_path], ssl_cert_key_file: @options[:ssl_key_path], ssl_cert_key_password: @options[:ssl_cert_pass], wsdl: @options[:wsdl], env_namespace: :soap, namespace_identifier: nil)
86
+ Savon.client(soap_version: 2,
87
+ env_namespace: :soap,
88
+ ssl_verify_mode: :peer,
89
+ ssl_cert_file: @options[:ssl_cert_path],
90
+ ssl_cert_key_file: @options[:ssl_key_path],
91
+ ssl_cert_key_password: @options[:ssl_cert_pass],
92
+ wsdl: @options[:wsdl],
93
+ env_namespace: :soap,
94
+ namespace_identifier: nil)
86
95
  end
87
96
  end
88
97
  end
@@ -16,8 +16,12 @@ module NfePaulistana
16
16
  @options[:xml]
17
17
  end
18
18
 
19
+ def nfe_method
20
+ @options[:method]
21
+ end
22
+
19
23
  def retorno
20
- Nori.parse(xml)[("retorno_" + (RETURN_ROOT[@options[:method]] || @options[:method]).to_s).to_sym]
24
+ Nori.new(:convert_tags_to => lambda { |tag| tag.snakecase.to_sym }).parse(xml)[("retorno_" + (RETURN_ROOT[@options[:method]] || @options[:method]).to_s).to_sym]
21
25
  end
22
26
 
23
27
  def success?
@@ -1,3 +1,3 @@
1
1
  module NfePaulistana
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
@@ -36,8 +36,12 @@ module NfePaulistana
36
36
  :iss_retido => false,
37
37
  :cpf_tomador => '',
38
38
  :cnpj_tomador => '',
39
+ :iss_retido_intermediario => false,
40
+ :cpf_intermediario => '',
41
+ :cnpj_intermediario => '',
39
42
  :im_tomador => '',
40
43
  :ie_tomador => '',
44
+ :im_intermediario => '',
41
45
  :razao_tomador => '',
42
46
  :tp_logradouro => '',
43
47
  :logradouro => '',
@@ -48,6 +52,7 @@ module NfePaulistana
48
52
  :uf => '',
49
53
  :cep => '',
50
54
  :email_tomador => '',
55
+ :email_intermediario => '',
51
56
  :discriminacao => '',
52
57
  :wsdl => 'https://nfe.prefeitura.sp.gov.br/ws/lotenfe.asmx?wsdl'
53
58
  }
@@ -72,7 +77,6 @@ module NfePaulistana
72
77
  send("add_#{method}_data_to_xml", xml, data, certificado)
73
78
  }
74
79
  end
75
- puts builder.to_xml
76
80
  Nokogiri::XML( builder.to_xml( :save_with => Nokogiri::XML::Node::SaveOptions::AS_XML | Nokogiri::XML::Node::SaveOptions::NO_DECLARATION ) )
77
81
  end
78
82
 
@@ -242,6 +246,17 @@ module NfePaulistana
242
246
  }
243
247
  end
244
248
  xml.EmailTomador data[:email_tomador]
249
+ =begin
250
+ unless (data[:cpf_intermediario].blank? and data[:cnpj_intermediario].blank?)
251
+ xml.CPFCNPJIntermediario {
252
+ xml.CPF data[:cpf_intermediario] unless data[:cpf_intermediario].blank?
253
+ xml.CNPJ data[:cnpj_intermediario] unless data[:cnpj_intermediario].blank?
254
+ }
255
+ xml.InscricaoMunicipalIntermediario data[:im_intermediario] unless data[:im_intermediario].blank?
256
+ xml.ISSRetidoIntermediario data[:iss_retido_intermediario]
257
+ xml.EmailIntermediario data[:email_intermediario]
258
+ end
259
+ =end
245
260
  xml.Discriminacao data[:discriminacao]
246
261
  }
247
262
  end
@@ -359,7 +374,13 @@ module NfePaulistana
359
374
  part_10 = data[:codigo_servico].rjust(5,'0')
360
375
  part_11 = (data[:cpf_tomador].blank? ? (data[:cnpj_tomador].blank? ? '3' : '2') : '1')
361
376
  part_12 = (data[:cpf_tomador].blank? ? (data[:cnpj_tomador].blank? ? "".rjust(14,'0') : data[:cnpj_tomador].rjust(14,'0') ) : data[:cpf_tomador].rjust(14,'0'))
377
+ =begin
378
+ part_13 = (data[:cpf_intermediario].blank? ? (data[:cnpj_intermediario].blank? ? '3' : '2') : '1')
379
+ part_14 = (data[:cpf_intermediario].blank? ? (data[:cnpj_intermediario].blank? ? "".rjust(14,'0') : data[:cnpj_intermediario].rjust(14,'0') ) : data[:cpf_intermediario].rjust(14,'0'))
380
+ part_15 = data[:iss_retido_intermediario] ? 'S' : 'N'
381
+ =end
362
382
 
383
+ #value = part_1 + part_2 + part_3 + part_4 + part_5 + part_6 + part_7 + part_8 + part_9 + part_10 + part_11 + part_12 + part_13 + part_14 + part_15
363
384
  value = part_1 + part_2 + part_3 + part_4 + part_5 + part_6 + part_7 + part_8 + part_9 + part_10 + part_11 + part_12
364
385
 
365
386
  assinatura_simples(value, certificado)
@@ -5,9 +5,9 @@ require "nfe-paulistana/version"
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "nfe-paulistana"
7
7
  s.version = NfePaulistana::VERSION
8
- s.authors = ["Marcelo Paez"]
9
- s.email = ["marcelo@iugu.com.br"]
10
- s.homepage = "https://iugu.com.br"
8
+ s.authors = ["Marcelo Paez Sequeira"]
9
+ s.email = ["marcelo@iugu.com"]
10
+ s.homepage = "https://iugu.com"
11
11
  s.summary = %q{Notafiscal Eletronica}
12
12
  s.description = %q{Gema para utilização do Webservice da Nf Paulistana}
13
13
 
@@ -20,8 +20,10 @@ Gem::Specification.new do |s|
20
20
 
21
21
  # specify any dependencies here; for example:
22
22
  s.add_dependency "nokogiri", "1.5.9"
23
- s.add_dependency "savon", "~> 2.3.0"
23
+ s.add_dependency "savon", "2.3.0"
24
24
  s.add_dependency "signer"
25
- s.add_development_dependency "rspec"
25
+ s.add_development_dependency "rake"
26
+ s.add_development_dependency "minitest"
27
+ s.add_development_dependency "debugger"
26
28
  # s.add_runtime_dependency "rest-client"
27
29
  end
@@ -0,0 +1,32 @@
1
+ require_relative '../../test_helper'
2
+
3
+ describe "Envio RPS" do
4
+ before do
5
+ @nfe = NfePaulistana::Gateway.new(
6
+ ssl_cert_p12_path: ENV["NFE_CERT_P12_PATH"],
7
+ ssl_cert_path: ENV["NFE_CERT_PATH"],
8
+ ssl_key_path: ENV["NFE_KEY_PATH"],
9
+ ssl_cert_pass: ENV["NFE_CERT_PASS"]
10
+ )
11
+ end
12
+
13
+ it "should create the NFs-e" do
14
+ response = @nfe.envio_rps({
15
+ cnpj_remetente: ENV["NFE_CNPJ"],
16
+ inscricao_prestador: ENV["NFE_IM"],
17
+ aliquota_servicos: ENV["NFE_ALIQUOTA"],
18
+ data_emissao: Time.now.to_date.strftime,
19
+ discriminacao: "Teste NFS-e",
20
+ codigo_servico: ENV["NFE_COD_SERVICO"],
21
+ valor_servicos: "100.00",
22
+ tributacao_rps: "T",
23
+ status_rps: "N",
24
+ tipo_rps: "RPS",
25
+ serie_rps: "AAAAA",
26
+ numero_rps: Time.now.to_i.to_s,
27
+ email_tomador: ENV["NFE_EMAIL"],
28
+ cpf_tomador: ENV["NFE_CPF"]
29
+ })
30
+ assert response.success? == true
31
+ end
32
+ end
@@ -0,0 +1,7 @@
1
+ require_relative '../../test_helper'
2
+
3
+ describe NfePaulistana do
4
+ it "must be defined" do
5
+ NfePaulistana::VERSION.wont_be_nil
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ require 'minitest'
2
+ require 'minitest/autorun'
3
+ require 'minitest/pride'
4
+ require 'debugger'
5
+ require File.expand_path('../../lib/nfe-paulistana.rb', __FILE__)
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nfe-paulistana
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
5
- prerelease:
4
+ version: 1.0.2
6
5
  platform: ruby
7
6
  authors:
8
- - Marcelo Paez
7
+ - Marcelo Paez Sequeira
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-11-08 00:00:00.000000000 Z
11
+ date: 2014-08-25 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: nokogiri
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - '='
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - '='
28
25
  - !ruby/object:Gem::Version
@@ -30,23 +27,20 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: savon
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ~>
31
+ - - '='
36
32
  - !ruby/object:Gem::Version
37
33
  version: 2.3.0
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ~>
38
+ - - '='
44
39
  - !ruby/object:Gem::Version
45
40
  version: 2.3.0
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: signer
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ! '>='
52
46
  - !ruby/object:Gem::Version
@@ -54,15 +48,41 @@ dependencies:
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ! '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
- name: rspec
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: debugger
64
85
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
86
  requirements:
67
87
  - - ! '>='
68
88
  - !ruby/object:Gem::Version
@@ -70,14 +90,13 @@ dependencies:
70
90
  type: :development
71
91
  prerelease: false
72
92
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
93
  requirements:
75
94
  - - ! '>='
76
95
  - !ruby/object:Gem::Version
77
96
  version: '0'
78
97
  description: Gema para utilização do Webservice da Nf Paulistana
79
98
  email:
80
- - marcelo@iugu.com.br
99
+ - marcelo@iugu.com
81
100
  executables: []
82
101
  extensions: []
83
102
  extra_rdoc_files: []
@@ -93,28 +112,33 @@ files:
93
112
  - lib/nfe-paulistana/version.rb
94
113
  - lib/nfe-paulistana/xml_builder.rb
95
114
  - nfe-paulistana.gemspec
96
- homepage: https://iugu.com.br
115
+ - test/lib/nfe-paulistana/envio_rps_test.rb
116
+ - test/lib/nfe-paulistana/version_test.rb
117
+ - test/test_helper.rb
118
+ homepage: https://iugu.com
97
119
  licenses: []
120
+ metadata: {}
98
121
  post_install_message:
99
122
  rdoc_options: []
100
123
  require_paths:
101
124
  - lib
102
125
  required_ruby_version: !ruby/object:Gem::Requirement
103
- none: false
104
126
  requirements:
105
127
  - - ! '>='
106
128
  - !ruby/object:Gem::Version
107
129
  version: '0'
108
130
  required_rubygems_version: !ruby/object:Gem::Requirement
109
- none: false
110
131
  requirements:
111
132
  - - ! '>='
112
133
  - !ruby/object:Gem::Version
113
134
  version: '0'
114
135
  requirements: []
115
136
  rubyforge_project: nfe-paulistana
116
- rubygems_version: 1.8.24
137
+ rubygems_version: 2.2.2
117
138
  signing_key:
118
- specification_version: 3
139
+ specification_version: 4
119
140
  summary: Notafiscal Eletronica
120
- test_files: []
141
+ test_files:
142
+ - test/lib/nfe-paulistana/envio_rps_test.rb
143
+ - test/lib/nfe-paulistana/version_test.rb
144
+ - test/test_helper.rb