opennfse_osasco 0.1.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b7cbd8a440821091000f850029b85acdb9674d77
4
+ data.tar.gz: d3776aae9480e6f74fcf12b32203b1e19f573f81
5
+ SHA512:
6
+ metadata.gz: dd92b06894dc7b96bafbf989b8d4cbfac5b99e002c14320067fe858cf78730517f7f1caaafc177c7a9f8d9f36297473493bcf3dcdd94a93a634239891d5bec83
7
+ data.tar.gz: 8db0800a5f5c57641ffd2c767185ff8af623105bd43274326f077781de1cb06b82b41abfc1779546135891f77386d3917420850252192fe77707105887a27dbb
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.2.2
5
+ before_install: gem install bundler -v 1.12.5
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in opennfse_osasco.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 =
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,50 @@
1
+ # Biblioteca de integração de NFS-e via API com sistema da prefeitura de Osasco
2
+
3
+ ## Descrição
4
+
5
+ A biblioteca opennfse_osasco em Ruby possui total integração com serviço de nfse-e da prefeitura de Osasco.
6
+
7
+ ##Instalação
8
+
9
+ - Adicione a biblioteca ao seu Gemfile.
10
+
11
+ ```ruby
12
+ gem 'opennfse_osasco'
13
+ ```
14
+ - Execute o comando bundle install.
15
+
16
+ ## Emissão de NFS-e
17
+
18
+ - Para iniciar uma emissão de NFS-e, você precisa criar uma instancia da classe 'OpennfseOsasco::Nfse' e informar sua chave de acesso do para emissão de NFS-e via API
19
+
20
+ ```ruby
21
+ nfse = OpennfseOsasco::Nfse.new("CHAVE-ACESSO")
22
+
23
+ nfse.valor = 0.10
24
+ nfse.tributacao = {atividade: 1.08}
25
+ nfse.tomador = {cnpj: "00000000000000", bairro: "Jd Veloso", nome: "Empresa",
26
+ cidade: "São Paulo", complemento: "4° andar", uf: "SP",
27
+ logradouro: "Benedito Alves turibio", numero: "10", pais: "Brasil", tipo_logradouro: "Rua"}
28
+
29
+ nfse.register
30
+ ```
31
+
32
+ - Para emitir NFS-e em homologação a propriedade homologacao da classe 'OpennfseOsasco::Nfse' precisa estar true
33
+
34
+ ```ruby
35
+ nfse.homologacao = true
36
+ ```
37
+
38
+ ## Contribuições
39
+
40
+ Achou e corrigiu um bug ou tem alguma feature em mente e deseja contribuir?
41
+
42
+ * Faça um fork
43
+ * Adicione sua feature ou correção de bug (`git checkout -b my-new-feature`)
44
+ * Commit suas mudanças (`git commit -am 'Added some feature'`)
45
+ * Rode um push para o branch (`git push origin my-new-feature`)
46
+ * Envie um Pull Request
47
+
48
+ ## License
49
+
50
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "opennfse_osasco"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,40 @@
1
+ <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:rgm="http://schemas.datacontract.org/2004/07/Rgm.Eissnfe.Negocio.WebServices.Mensagem" xmlns:rgm1="http://schemas.datacontract.org/2004/07/Rgm.Eissnfe.Dominio.DataTransferObject.Prestador" xmlns:rgm2="http://schemas.datacontract.org/2004/07/Rgm.Eissnfe.Dominio.DataTransferObject.Contribuinte">
2
+ <soapenv:Header/>
3
+ <soapenv:Body>
4
+ <tem:Emitir>
5
+ <tem:request>
6
+ <rgm:NotaFiscal>
7
+ <rgm1:Aliquota><%= tributacao.aliquota %></rgm1:Aliquota>
8
+ <rgm1:Atividade><%= tributacao.atividade %></rgm1:Atividade>
9
+ <rgm1:ChaveAutenticacao><%= chave_autenticacao %></rgm1:ChaveAutenticacao>
10
+ <rgm1:Homologacao><%= homologacao %></rgm1:Homologacao>
11
+ <rgm1:NotificarTomadorPorEmail><%= notificar_tomador_Email %></rgm1:NotificarTomadorPorEmail>
12
+ <rgm1:SubstituicaoTributaria><%= tributacao.substituicao_tributaria %></rgm1:SubstituicaoTributaria>
13
+ <rgm1:Tomador>
14
+ <rgm2:CNPJ><%= tomador.cnpj %></rgm2:CNPJ>
15
+ <rgm2:Endereco>
16
+ <rgm2:Bairro><%= tomador.bairro %></rgm2:Bairro>
17
+ <rgm2:Cidade><%= tomador.cidade %></rgm2:Cidade>
18
+ <rgm2:Complemento><%= tomador.cidade %></rgm2:Complemento>
19
+ <rgm2:Estado><%= tomador.uf %></rgm2:Estado>
20
+ <rgm2:Logradouro><%= tomador.uf %></rgm2:Logradouro>
21
+ <rgm2:Numero><%= tomador.numero %></rgm2:Numero>
22
+ <rgm2:Pais><%= tomador.pais %></rgm2:Pais>
23
+ <rgm2:TipoLogradouro><%= tomador.tipo_logradouro %></rgm2:TipoLogradouro>
24
+ </rgm2:Endereco>
25
+ <rgm2:InscricaoMunicipal>?</rgm2:InscricaoMunicipal>
26
+ <rgm2:Nome><%= tomador.nome %></rgm2:Nome>
27
+ </rgm1:Tomador>
28
+ <rgm1:Valor><%= valor %></rgm1:Valor>
29
+ <rgm1:ValorCSLL><%= tributacao.valor_csll %></rgm1:ValorCSLL>
30
+ <rgm1:ValorCofins><%= tributacao.valor_cofins %></rgm1:ValorCofins>
31
+ <rgm1:ValorDeducao><%= tributacao.valor_deducao %></rgm1:ValorDeducao>
32
+ <rgm1:ValorINSS><%= tributacao.valor_inss %></rgm1:ValorINSS>
33
+ <rgm1:ValorIR><%= tributacao.valor_ir %></rgm1:ValorIR>
34
+ <rgm1:ValorOutrosImpostos><%= tributacao.valor_outros_impostos %></rgm1:ValorOutrosImpostos>
35
+ <rgm1:ValorPisPasep><%= tributacao.valor_pis_pasep %></rgm1:ValorPisPasep>
36
+ </rgm:NotaFiscal>
37
+ </tem:request>
38
+ </tem:Emitir>
39
+ </soapenv:Body>
40
+ </soapenv:Envelope>
@@ -0,0 +1,67 @@
1
+ require 'erb'
2
+ require 'savon'
3
+
4
+ require "opennfse_osasco/extensions/ensure_type"
5
+ require "opennfse_osasco/extensions/mass_assignment"
6
+ require "opennfse_osasco/tomador"
7
+ require "opennfse_osasco/tributacao"
8
+ require "opennfse_osasco/version"
9
+
10
+ module OpennfseOsasco
11
+ class Nfse
12
+ include Extensions::MassAssignment
13
+ include Extensions::EnsureType
14
+
15
+ attr_reader :tomador
16
+
17
+ attr_reader :tributacao
18
+
19
+ attr_reader :chave_autenticacao
20
+
21
+ attr_accessor :homologacao
22
+
23
+ attr_accessor :notificar_tomador_Email
24
+
25
+ attr_accessor :valor
26
+
27
+ def initialize(chave_autenticacao)
28
+ @chave_autenticacao = chave_autenticacao
29
+ end
30
+
31
+ def tributacao=(tributacao)
32
+ @tributacao = ensure_type(Tributacao, tributacao)
33
+ end
34
+
35
+ def tomador=(tomador)
36
+ @tomador = ensure_type(Tomador, tomador)
37
+ end
38
+
39
+ def register
40
+ validar_informacoes
41
+
42
+ client = Savon.client(wsdl: url)
43
+ client.call(:emitir, xml: to_xml).body
44
+ end
45
+
46
+ private
47
+ def before_initialize
48
+ @notificar_tomador_Email = false
49
+ end
50
+
51
+ def to_xml
52
+ ERB.new(File.read(template)).result(binding)
53
+ end
54
+
55
+ def template
56
+ File.join(File.dirname(__FILE__), "../etc/schemas/template_nfse_osasco.erb")
57
+ end
58
+
59
+ def url
60
+ "https://www.nfeosasco.com.br/EissnfeWebServices/NotaFiscalEletronica.svc?wsdl"
61
+ end
62
+
63
+ def validar_informacoes
64
+ raise NoMethodError if @valor < 0
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,9 @@
1
+ module OpennfseOsasco
2
+ module Extensions
3
+ module EnsureType
4
+ def ensure_type(klass, options = {})
5
+ options.kind_of?(klass) ? options : klass.new(options)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ module OpennfseOsasco
2
+ module Extensions
3
+ module MassAssignment
4
+ def initialize(options = {})
5
+ before_initialize if respond_to?(:before_initialize, true)
6
+ options.each {|name, value| public_send("#{name}=", value) }
7
+ after_initialize if respond_to?(:after_initialize, true)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,30 @@
1
+ module OpennfseOsasco
2
+ class Tomador
3
+ include Extensions::MassAssignment
4
+
5
+ attr_accessor :cnpj
6
+
7
+ attr_accessor :bairro
8
+
9
+ attr_accessor :cidade
10
+
11
+ attr_accessor :complemento
12
+
13
+ attr_accessor :uf
14
+
15
+ attr_accessor :logradouro
16
+
17
+ attr_accessor :numero
18
+
19
+ attr_accessor :pais
20
+
21
+ attr_accessor :tipo_logradouro
22
+
23
+ attr_accessor :nome
24
+
25
+ private
26
+ def before_initialize
27
+ self.pais = "Brasil"
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,38 @@
1
+ module OpennfseOsasco
2
+ class Tributacao
3
+ include Extensions::MassAssignment
4
+
5
+ attr_accessor :aliquota
6
+
7
+ attr_accessor :substituicao_tributaria
8
+
9
+ attr_accessor :valor_csll
10
+
11
+ attr_accessor :valor_cofins
12
+
13
+ attr_accessor :valor_deducao
14
+
15
+ attr_accessor :valor_inss
16
+
17
+ attr_accessor :valor_ir
18
+
19
+ attr_accessor :valor_outros_impostos
20
+
21
+ attr_accessor :valor_pis_pasep
22
+
23
+ attr_accessor :atividade
24
+
25
+ private
26
+ def before_initialize
27
+ self.aliquota = 0
28
+ self.substituicao_tributaria = false
29
+ self.valor_csll = 0
30
+ self.valor_cofins = 0
31
+ self.valor_deducao = 0
32
+ self.valor_inss = 0
33
+ self.valor_ir = 0
34
+ self.valor_outros_impostos = 0
35
+ self.valor_pis_pasep = 0
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,3 @@
1
+ module OpennfseOsasco
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'opennfse_osasco/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "opennfse_osasco"
8
+ spec.version = OpennfseOsasco::VERSION
9
+ spec.authors = ["Emerson Jose"]
10
+ spec.email = ["emersonjprogramador@gmail.com"]
11
+
12
+ spec.summary = %q{Gerador de nfse via API com sistema de NFS-e da prefeitura de Osasco}
13
+ spec.description = %q{Gem para comunicação via API com o sistema de NFS-e da prefeitura de Osasco}
14
+ spec.homepage = "https://github.com/emersonjsouza/opennfse_osasco"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_dependency "savon", "~> 2.11.0"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.12"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rspec", "~> 3.0"
27
+ end
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: opennfse_osasco
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Emerson Jose
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-07-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: savon
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 2.11.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 2.11.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.12'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.12'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ description: Gem para comunicação via API com o sistema de NFS-e da prefeitura de
70
+ Osasco
71
+ email:
72
+ - emersonjprogramador@gmail.com
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".rspec"
79
+ - ".travis.yml"
80
+ - Gemfile
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - bin/console
85
+ - bin/setup
86
+ - etc/schemas/template_nfse_osasco.erb
87
+ - lib/opennfse_osasco.rb
88
+ - lib/opennfse_osasco/extensions/ensure_type.rb
89
+ - lib/opennfse_osasco/extensions/mass_assignment.rb
90
+ - lib/opennfse_osasco/tomador.rb
91
+ - lib/opennfse_osasco/tributacao.rb
92
+ - lib/opennfse_osasco/version.rb
93
+ - opennfse_osasco.gemspec
94
+ homepage: https://github.com/emersonjsouza/opennfse_osasco
95
+ licenses:
96
+ - MIT
97
+ metadata: {}
98
+ post_install_message:
99
+ rdoc_options: []
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ requirements: []
113
+ rubyforge_project:
114
+ rubygems_version: 2.4.8
115
+ signing_key:
116
+ specification_version: 4
117
+ summary: Gerador de nfse via API com sistema de NFS-e da prefeitura de Osasco
118
+ test_files: []