sigiss 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 48a96254ee5e6eca14b499a2aa8d728bc9d32901
4
- data.tar.gz: 0e827e646c9267d922bfbe5e9be3fd0d4c660bc4
3
+ metadata.gz: acd989e2d61471742743e41de43c18c778bb4987
4
+ data.tar.gz: f3115a0132707911b1ca26bef9aadef5832a6499
5
5
  SHA512:
6
- metadata.gz: 6dd97b61dfc52a7a666fed9f8419e5b3001591755a9485e342196125a8dcbe2f98c6d0a1f16afafffcf12d5e810e7fc4de79e30c458a8aa9cdae0fbcc101d63f
7
- data.tar.gz: ae0b9461011b57a11905db183d3b2423959f36614c958a191440b45b940977aa19bc3fb44a76795ad3cdc55a98faee014f6515984c85fce52225d77411227833
6
+ metadata.gz: 884512b737b5a73bdd069a9ec0b6fd193a99cc9d2e9d25304ea9551ad82649de96b5687dbad6597a872c8ea2d6f5a2c6b6b4a13eb22c76f5ff4b6a456cd83432
7
+ data.tar.gz: 8a8fdcd7ce38190e4eb29e863adca1d32e8025eda1b0a1c724299217c476162aa987b00935c69360a6aa2ac70b0b39b4f228ea2001c5b431c3fd572acb5e66a5
data/.travis.yml CHANGED
@@ -1,4 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.2
4
- before_install: gem install bundler -v 1.10.3
3
+ - 2.2.3
4
+ before_install: gem install bundler
5
+ addons:
6
+ code_climate:
7
+ repo_token: 0aa5f7b2088821aaa5fe58bc4064b1cbfaa359362d7b4b5b30233accd0c166af
data/README.md CHANGED
@@ -1,41 +1,138 @@
1
1
  # Sigiss
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/sigiss`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ [![Build Status](https://travis-ci.org/gabrielpedepera/sigiss.svg?branch=master)](https://travis-ci.org/gabrielpedepera/sigiss) [![Code Climate](https://codeclimate.com/github/gabrielpedepera/sigiss/badges/gpa.svg)](https://codeclimate.com/github/gabrielpedepera/sigiss) [![Test Coverage](https://codeclimate.com/github/gabrielpedepera/sigiss/badges/coverage.svg)](https://codeclimate.com/github/gabrielpedepera/sigiss/coverage)
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ Ruby gem para integração com o WebService para NFS-e do SIGISS.
6
6
 
7
- ## Installation
7
+ Atualmente suportando as seguintes cidades:
8
8
 
9
- Add this line to your application's Gemfile:
9
+ - Bauru - SP
10
+ - Botucatu - SP
11
+ - Marília - SP
12
+ - Londrina - SP
13
+ - Rio Grande - RS
14
+
15
+ Obs.: A gem foi desenvolvida baseada no WebService de [Marília-SP](https://marilia.sigiss.com.br/marilia/ws/sigiss_ws.php) e [Manual]( http://www.bauru.sp.gov.br/arquivos/arquivos_site/sec_financas/nfse_manual_webservice.pdf).
16
+ Caso exista divergências na integrações com outras cidades ou a gem contemple outras para integração,
17
+ seu PR ou sua informação será muito bem vinda para atualização.
18
+
19
+ ## Instalação
20
+
21
+ Adicionar ao Gemfile:
10
22
 
11
23
  ```ruby
12
24
  gem 'sigiss'
13
25
  ```
14
26
 
15
- And then execute:
27
+ Executar:
16
28
 
17
29
  $ bundle
18
30
 
19
- Or install it yourself as:
31
+ Ou instalar como:
20
32
 
21
33
  $ gem install sigiss
22
34
 
23
- ## Usage
35
+ ## Uso
36
+
37
+ #### Definir a cidade (gateway) para emissão da Nota Fiscal:
38
+
39
+ ```ruby
40
+ gateway = Sigiss::Gateway.new(:marilia, :test) # Ambiente de teste
41
+ gateway = Sigiss::Gateway.new(:marilia, :production) # Ambiente de Produção
42
+ ```
43
+
44
+ #### Definir os dados referente ao prestador:
45
+
46
+ ```ruby
47
+ params = {
48
+ ccm: '31000',
49
+ cnpj: '90082563000169',
50
+ senha: '12345',
51
+ crc: '',
52
+ crc_estado: ''
53
+ }
54
+ ```
55
+
56
+ ```ruby
57
+ provider = Sigiss::Provider.new(params)
58
+ ```
59
+
60
+ #### Definir os dados referente ao tomador:
24
61
 
25
- TODO: Write usage instructions here
62
+ ```ruby
63
+ params = {
64
+ tomador_tipo: '2',
65
+ tomador_cnpj: '08600061822',
66
+ tomador_email: 'email@tomador.com',
67
+ tomador_im: '',
68
+ tomador_ie: '',
69
+ tomador_razao: 'Pagador de Impostos',
70
+ tomador_fantasia: '',
71
+ tomador_endereco: 'Rua de Asfalto',
72
+ tomador_numero: '100',
73
+ tomador_complemento: 'Fundos',
74
+ tomador_bairro: 'Bairro Feliz',
75
+ tomador_CEP: '17512752',
76
+ tomador_cod_cidade: '3127107',
77
+ tomador_fone: '1499998888',
78
+ tomador_ramal: '',
79
+ tomador_fax: '',
80
+ tomador_ramal_fax: ''
81
+ }
82
+ ```
26
83
 
27
- ## Development
84
+ ```ruby
85
+ taker = Sigiss::Taker.new(params)
86
+ ```
28
87
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
88
+ ### APIs
30
89
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
90
+ #### Emissão
91
+ ```ruby
92
+ invoice = Sigiss::Invoice.new(gateway: gateway, provider: provider, taker: taker)
93
+ params = {
94
+ aliquota_simples: '',
95
+ id_sis_legado: '',
96
+ servico: '105',
97
+ situacao: 'tp',
98
+ valor: '10,00',
99
+ base: '10,00',
100
+ descricaoNF: 'Teste NF'
101
+ }
102
+ invoice.build(issue: params)
103
+ invoice.issue!
104
+ ```
105
+
106
+ #### Consulta
107
+ ```ruby
108
+ invoice = Sigiss::Invoice.new(gateway: gateway, provider: provider)
109
+ params = {
110
+ nota: '13114',
111
+ serie: '1',
112
+ autenticidade: '2ZZGUTL0',
113
+ valor: '10,00'
114
+ }
115
+ invoice.build(fetch: params)
116
+ invoice.fetch!
117
+ ```
32
118
 
33
- ## Contributing
119
+ #### Cancelamento
120
+ ```ruby
121
+ invoice = Sigiss::Invoice.new(gateway: gateway, provider: provider)
122
+ params = {
123
+ nota: '13114',
124
+ motivo: 'Falha no Engano',
125
+ email: 'email@tomador.com'
126
+ }
127
+ invoice.build(cancel: params)
128
+ invoice.cancel!
129
+ ```
34
130
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/sigiss.
131
+ ## Contribuição
36
132
 
133
+ Reportar bugs e Pull Requests são bem vindos no Github em https://github.com/gabrielpedepera/sigiss.
37
134
 
38
- ## License
39
135
 
40
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
136
+ ## Licença
41
137
 
138
+ A gem está disponível como open source sobre os termos de [MIT License](http://opensource.org/licenses/MIT).
data/bin/console CHANGED
@@ -7,8 +7,8 @@ require "sigiss"
7
7
  # with your gem easier. You can also use a different console, if you like.
8
8
 
9
9
  # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
10
+ require "pry"
11
+ Pry.start
12
12
 
13
- require "irb"
14
- IRB.start
13
+ # require "irb"
14
+ # IRB.start
@@ -1,17 +1,30 @@
1
1
  require 'yaml'
2
+ require 'active_model'
2
3
  module Sigiss
3
4
  class Gateway
4
- attr_accessor :name, :url, :environment
5
+ include ActiveModel::Validations
6
+ include ActiveModel::Validations::Callbacks
5
7
 
6
- def initialize(name, environment)
8
+ attr_accessor :environment
9
+ attr_reader :name, :url
10
+
11
+ validates_presence_of :name, :url, :environment
12
+
13
+ before_validation :validate_if_gateway_exists
14
+
15
+ def initialize(name = nil, environment = :test)
7
16
  @name = name
8
- @url = get_url(name, environment)
17
+ @url = url_webservice(name, environment)
9
18
  @environment = environment
10
19
  end
11
20
 
12
- def get_url(name, environment)
21
+ def url_webservice(name, environment)
13
22
  YAML.load_file(File.join(Sigiss.root, 'configs.yml'))[environment.to_s][name.to_s]
14
23
  end
15
24
 
25
+ def validate_if_gateway_exists
26
+ errors.add(:name, :invalid) if @url.nil?
27
+ end
28
+
16
29
  end
17
30
  end
data/lib/sigiss/ibge.rb CHANGED
@@ -4,6 +4,7 @@ module Sigiss
4
4
  class << self
5
5
 
6
6
  def get_code(name)
7
+ return if name.nil?
7
8
  cities.each do |city, code|
8
9
  return code if city == name.downcase
9
10
  end
@@ -1,20 +1,13 @@
1
- require 'lotus/validations'
2
1
  require 'sigiss/integration'
3
-
2
+ require 'active_model'
4
3
  module Sigiss
5
4
  class Invoice
6
- include Lotus::Validations
5
+ include ActiveModel::Validations
7
6
  include Sigiss::Integration
8
7
 
9
- attr_accessor :gateway,
10
- :provider,
11
- :taker,
12
- :data
8
+ attr_accessor :gateway, :provider, :taker, :data
13
9
 
14
- validates :gateway, type: Gateway, presence: true
15
- validates :provider, type: Provider, presence: true
16
- validates :taker, type: Taker
17
- validates :data, presence: true
10
+ validates_presence_of :gateway, :provider, :taker, :data
18
11
 
19
12
  def initialize(attributes = {})
20
13
  @gateway = attributes[:gateway]
@@ -1,12 +1,9 @@
1
1
  module Sigiss
2
2
  class CancelData < InvoiceData
3
3
 
4
- attr_accessor :nota,
5
- :motivo,
6
- :email
4
+ attr_accessor :nota, :motivo, :email
7
5
 
8
- validates :nota, presence: true
9
- validates :motivo, presence: true
6
+ validates_presence_of :nota, :motivo
10
7
 
11
8
  def initialize(attributes = {})
12
9
  @nota = attributes[:nota]
@@ -1,15 +1,8 @@
1
1
  module Sigiss
2
2
  class FetchData < InvoiceData
3
3
 
4
- attr_accessor :nota,
5
- :serie,
6
- :autenticidade,
7
- :valor
8
-
9
- validates :nota, presence: true
10
- validates :serie, presence: true
11
- validates :autenticidade, presence: true
12
- validates :valor, presence: true
4
+ attr_accessor :nota, :serie, :autenticidade, :valor
5
+ validates_presence_of :nota, :serie, :autenticidade, :valor
13
6
 
14
7
  def initialize(attributes = {})
15
8
  @nota = attributes[:nota]
@@ -1,8 +1,8 @@
1
- require 'lotus/validations'
1
+ require 'active_model'
2
2
  require 'sigiss/extension'
3
3
  module Sigiss
4
4
  class InvoiceData
5
- include Lotus::Validations
5
+ include ActiveModel::Validations
6
6
  include Sigiss::Extension
7
7
 
8
8
  end
@@ -9,10 +9,7 @@ module Sigiss
9
9
  :base,
10
10
  :descricaoNF
11
11
 
12
- validates :servico, presence: true
13
- validates :situacao, presence: true
14
- validates :valor, presence: true
15
- validates :base, presence: true
12
+ validates_presence_of :servico, :situacao, :valor, :base
16
13
 
17
14
  def initialize(attributes = {})
18
15
  @aliquota_simples = attributes[:aliquota_simples]
@@ -1,15 +1,12 @@
1
- require 'lotus/validations'
2
1
  require 'sigiss/extension'
3
2
  module Sigiss
4
3
  class Provider
5
- include Lotus::Validations
4
+ include ActiveModel::Validations
6
5
  include Sigiss::Extension
7
6
 
8
7
  attr_accessor :ccm, :cnpj, :senha, :crc, :crc_estado
9
8
 
10
- validates :ccm, presence: true
11
- validates :cnpj, presence: true
12
- validates :senha, presence: true
9
+ validates_presence_of :ccm, :cnpj, :senha
13
10
 
14
11
  def initialize(attributes = {})
15
12
  @ccm = attributes[:ccm]
data/lib/sigiss/taker.rb CHANGED
@@ -1,8 +1,8 @@
1
- require 'lotus/validations'
2
1
  require 'sigiss/extension'
2
+ require 'active_model'
3
3
  module Sigiss
4
4
  class Taker
5
- include Lotus::Validations
5
+ include ActiveModel::Validations
6
6
  include Sigiss::Extension
7
7
 
8
8
  attr_accessor :tomador_tipo,
@@ -23,14 +23,14 @@ module Sigiss
23
23
  :tomador_fax,
24
24
  :tomador_ramal_fax
25
25
 
26
- validates :tomador_tipo, presence: true
27
- validates :tomador_cnpj, presence: true
28
- validates :tomador_razao, presence: true
29
- validates :tomador_endereco, presence: true
30
- validates :tomador_numero, presence: true
31
- validates :tomador_bairro, presence: true
32
- validates :tomador_CEP, presence: true
33
- validates :tomador_cod_cidade, presence: true
26
+ validates_presence_of :tomador_tipo,
27
+ :tomador_cnpj,
28
+ :tomador_razao,
29
+ :tomador_endereco,
30
+ :tomador_numero,
31
+ :tomador_bairro,
32
+ :tomador_CEP,
33
+ :tomador_cod_cidade,
34
34
 
35
35
  def initialize(attributes = {})
36
36
  @tomador_tipo = attributes[:tomador_tipo]
@@ -1,3 +1,3 @@
1
1
  module Sigiss
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/sigiss.gemspec CHANGED
@@ -21,9 +21,11 @@ Gem::Specification.new do |spec|
21
21
 
22
22
  spec.add_development_dependency "bundler", "~> 1.10"
23
23
  spec.add_development_dependency "rake", "~> 10.0"
24
- spec.add_development_dependency "lotus-validations"
24
+ spec.add_development_dependency "activemodel", "~> 4.2.5"
25
25
  spec.add_development_dependency "savon"
26
26
  spec.add_development_dependency "rspec"
27
+ spec.add_development_dependency "vcr"
28
+ spec.add_development_dependency "webmock"
27
29
  spec.add_development_dependency "pry"
28
30
  spec.add_development_dependency "codeclimate-test-reporter"
29
31
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sigiss
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriel Pereira
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-11-06 00:00:00.000000000 Z
11
+ date: 2015-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -39,7 +39,21 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: lotus-validations
42
+ name: activemodel
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 4.2.5
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 4.2.5
55
+ - !ruby/object:Gem::Dependency
56
+ name: savon
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - ">="
@@ -53,7 +67,7 @@ dependencies:
53
67
  - !ruby/object:Gem::Version
54
68
  version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
- name: savon
70
+ name: rspec
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
73
  - - ">="
@@ -67,7 +81,21 @@ dependencies:
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
- name: rspec
84
+ name: vcr
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: webmock
71
99
  requirement: !ruby/object:Gem::Requirement
72
100
  requirements:
73
101
  - - ">="
@@ -140,7 +168,6 @@ files:
140
168
  - lib/sigiss/taker.rb
141
169
  - lib/sigiss/version.rb
142
170
  - sigiss.gemspec
143
- - sigiss.txt
144
171
  homepage: https://github.com/gabrielpedepera/sigiss
145
172
  licenses:
146
173
  - MIT
data/sigiss.txt DELETED
@@ -1,24 +0,0 @@
1
- SIGISS
2
-
3
- Ruby gem para integração com o sistema SIGISS para emissão de Notas Fiscais Eletrônicas.
4
-
5
- gateway = Sigiss::Gateway.new(:marilia, :test|:production)
6
-
7
- provider = Sigiss::Provider.new(params) # Prestador
8
-
9
- taker = Sigiss::Taker.new(params) # Tomador
10
-
11
- # Criar
12
- invoice = Sigiss::Invoice.new(gateway: gateway, provider: provider, taker: taker)
13
- invoice.build(issue: params)
14
- invoice.issue!
15
-
16
- # Consultar
17
- invoice = Sigiss::Invoice.new(gateway: gateway, provider: provider)
18
- invoice.build(fetch: params)
19
- invoice.fetch!
20
-
21
- # Cancelar
22
- invoice = Sigiss::Invoice.new(gateway: gateway, provider: provider)
23
- invoice.build(cancel: params)
24
- invoice.cancel!