enotas_nfe 0.0.1 → 0.0.2

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: 6cfe4ea755838189bd877b35fc55c831599b25a3
4
- data.tar.gz: 755277cde82c745b9fb708b08c73c30b1f8f3574
3
+ metadata.gz: 6a0f7a6e390bf0e133b094377559574d0daaca1e
4
+ data.tar.gz: f7edeeadfaa3474a4709a32f0d86d3a671294c30
5
5
  SHA512:
6
- metadata.gz: d37764f1e8f6805999a32ee6bc33f9a349f553c9c352cd5f5706a5ebf1f5fd0195e10114366bd0b7670d768dc3d85d6a84382c9ab2448b124389563b17ffbbf3
7
- data.tar.gz: 8e486c302174e4061af50dbaa52ed03c6ddadcb66de5d753b337d22f238c754467f07ec2e8cebfddf5c83b296f0ade3858633c5d631c7f9efc8529bf19a347b4
6
+ metadata.gz: ab27c3d4164cd2fb7ecf640ca2cd03d75af24c2b4bc17fe169630f6652ec90bf70409cf99ec40ba7352eae82a7102ce095ab1fa0093f97db4cd50a51f9449e08
7
+ data.tar.gz: 3c4b0b5e7dfc58750833aeeb8b42f58422b802e00638b1e791f49472fcf3ef1a309d43839a9547c5de594bd3f8ef50dffc16d0912259bedbfec356f481625613
data/README.md CHANGED
@@ -2,18 +2,25 @@
2
2
 
3
3
  Wrapper não OFICIAL Ruby da API do eNotas Gateway, plataforma de emissâo automática de nota fiscal eletrônica de serviço (NFS-e), Produto (NF-e) e Consumidor (NFC-e).
4
4
 
5
- A documentação completa dos endpoints pode ser encontrada aqui: [API eNotas Gateway](http://app.enotasgw.com.br/docs).
5
+ Esse projeto foi um fork de -> https://github.com/12min/enotas-client
6
+
7
+ A documentação completa dos endpoints pode ser encontrada aqui: [API NFS-e eNotas Gateway](http://app.enotasgw.com.br/docs),
8
+ e aqui [API NF-e eNotas Gateway](http://app.enotasgw.com.br/docs/v2/NF-e#!/nf-e/post_empresas_empresaId_nf_e).
6
9
 
7
10
  Mais detalhes: [enotasgw.com.br](http://enotasgw.com.br)
8
11
 
9
- Exemplo em PHP pode ser [encontrado aqui.](https://github.com/eNotasGW) - na biblioteca oficial.
12
+ Exemplo em PHP para nfse pode ser [encontrado aqui.](https://github.com/eNotasGW/php-client) - na biblioteca oficial.
13
+
14
+ Exemplo em PHP para nfe e nfce pode ser [encontrado aqui.](https://github.com/eNotasGW/php-client-v2) - na biblioteca oficial.
15
+
16
+ Exemplos diversos para emissão de nfe [encontrado aqui.](http://portal.enotasgw.com.br/knowledge-base/exemplos-emissao-nfe-produto-conjugada/) - na biblioteca oficial.
10
17
 
11
18
  ## Instalação
12
19
 
13
20
  Adicione o código abaixo ao Gemfile da sua aplicação:
14
21
 
15
22
  ```ruby
16
- gem 'enotas-nfe'
23
+ gem 'enotas_nfe'
17
24
  ```
18
25
 
19
26
  E execute:
@@ -22,14 +29,37 @@ E execute:
22
29
 
23
30
  Ou instale manualmente:
24
31
 
25
- $ gem install enotas-nfe
32
+ $ gem install enotas_nfe
33
+
34
+ ## Configurando a empresa
35
+
36
+ ```ruby
37
+ client = Enotas::Client.new('sua-api-key-do-e-notas', 'nfse')
38
+ empresa = EnotasNfe::Model::Empresa.new(client.get_empresa('id-da-empresa-no-enotas'))
39
+
40
+ ## realize os ajustes da empresa, como nomeFantasia, email, etc
26
41
 
27
- ## Uso básico
42
+ ## atualize ou crie uma empresa
43
+ client.create_update_empresa(empresa)
44
+
45
+ ```
46
+
47
+ ## Adicionando/trocando logotipo
48
+
49
+ ```ruby
50
+ client = Enotas::Client.new('sua-api-key-do-e-notas', 'nfse')
51
+ empresa = EnotasNfe::Model::Empresa.new(client.get_empresa('id-da-empresa-no-enotas'))
52
+ empresa.logotipo = open('http://www.example.com/foo.png')
53
+ client.set_logo('id-da-empresa-no-enotas', empresa)
54
+
55
+ ```
56
+
57
+ ## Uso básico para NFSE
28
58
 
29
59
  * Instancie o cliente passando sua API key:
30
60
 
31
61
  ```ruby
32
- client = Enotas::Client.new('sua-api-key-do-e-notas')
62
+ client = Enotas::Client.new('sua-api-key-do-e-notas', 'nfse')
33
63
  ```
34
64
 
35
65
  Agora já podemos emitir uma nota!
@@ -37,15 +67,17 @@ Agora já podemos emitir uma nota!
37
67
  * Emitindo uma nova nota de SERVIÇO:
38
68
 
39
69
  ```ruby
40
- nfe = Enotas::Model::Nfe.new
41
- nfe.tipo = 'NFS-e'
42
- nfe.idExterno = '42'
70
+ nfe = EnotasNfe::Model::Nfe.new
71
+ nfe.tipo = 'NFS-e'
72
+ nfe.idExterno = '1'
73
+ nfe.ambienteEmissao = 'Homologacao'
74
+
43
75
  nfe.cliente = {
44
- name: 'Luis Fernando Pimenta',
76
+ nome: 'Luis Fernando Pimenta',
45
77
  email: 'email@luispimenta.me',
46
78
  cpfCnpj: '33199707807'
47
79
  }
48
- nfe.enviarPorEmail = true
80
+
49
81
  nfe.cliente.endereco = {
50
82
  uf: 'PR',
51
83
  cidade: 'Curitiba',
@@ -55,14 +87,13 @@ nfe.cliente.endereco = {
55
87
  cep: '80000000'
56
88
  }
57
89
 
90
+ nfe.enviarPorEmail = true
91
+
58
92
  nfe.servico = {
59
93
  descricao: 'Reparo em computador',
60
- aliquotaIss: 0,
94
+ aliquotaIss: 5,
61
95
  issRetidoFonte: true,
62
- cnae: "4520001",
63
- codigoServicoMunicipio: "666133",
64
96
  descricaoServicoMunicipio: "Reparo em computador",
65
- itemListaServicoLC116: "1000",
66
97
  ufPrestacaoServico: "PR",
67
98
  municipioPrestacaoServico: "Curitiba",
68
99
  valorCofins: 0,
@@ -72,18 +103,91 @@ nfe.servico = {
72
103
  valorPis: 0
73
104
  }
74
105
 
75
- nfe.nfe_create('id-da-empresa-no-enotas', nfe)
106
+ nfe.valorTotal = 1.00
107
+
108
+ #enviando a nota
109
+ nfe.nfse_create('id-da-empresa-no-enotas', nfe)
110
+
76
111
  ```
77
112
 
78
- * Emitindo uma nova nota NFe:
113
+ ## Uso básico para NFE
114
+
115
+ * Instancie o cliente passando sua API key:
116
+
117
+ ```ruby
118
+ client = Enotas::Client.new('sua-api-key-do-e-notas', 'nfe')
119
+ ```
120
+
121
+ Agora já podemos emitir uma nota!
122
+
123
+ * Emitindo uma nova de VENDA de produto - NFe:
124
+
125
+ ```ruby
126
+ nfe = EnotasNfe::Model::Nfe.new
127
+ nfe.id = '1'
128
+ nfe.ambienteEmissao = "Homologacao" # "Producao" ou "Homologacao"
129
+ nfe.naturezaOperacao = 'Venda'
130
+ nfe.finalidade = 'Normal'
131
+ nfe.consumidorFinal = true
132
+ nfe.indicadorPresencaConsumidor = true
133
+
134
+ nfe.cliente = {
135
+ tipoPessoa: 'F',
136
+ indicadorContribuinteICMS: "NaoContribuinte",
137
+ nome: 'Luis Fernando Pimenta',
138
+ email: 'email@luispimenta.me',
139
+ cpfCnpj: '33199707807',
140
+ telefone: '19981328642',
141
+ inscricaoMunicipal: '',
142
+ inscricaoEstadual: '',
143
+ }
144
+
145
+ nfe.cliente.endereco = {
146
+ uf: 'PR',
147
+ cidade: 'Curitiba',
148
+ logradouro: 'Rua 01',
149
+ numero: '112',
150
+ bairro: 'Centro',
151
+ cep: '80000000'
152
+ }
153
+
154
+ nfe.enviarPorEmail = true
155
+
156
+ produto = EnotasNfe::Model::Produto.new
157
+ produto.cfop = "5101"
158
+ produto.codigo = '1'
159
+ produto.descricao = 'pneu'
160
+ produto.ncm = '38151210'
161
+ produto.unidadeMedida = 'UN'
162
+ produto.valorUnitario = 1.00
163
+ produto.impostos = EnotasNfe::Model::Impostos.new
164
+ produto.impostos.icms = EnotasNfe::Model::Icms.new
165
+ produto.impostos.icms.situacaoTributaria = '102'
166
+ produto.impostos.icms.origem = 0
167
+ produto.impostos.pis = EnotasNfe::Model::Pis.new
168
+ produto.impostos.pis.situacaoTributaria = '07'
169
+ produto.impostos.cofins = EnotasNfe::Model::Cofins.new
170
+ produto.impostos.cofins.situacaoTributaria = '07'
171
+
172
+ nfe.itens << produto
173
+
174
+ nfe.informacoesAdicionais = "I - Documento emitido por ME ou EPP optante pelo Simples Nacional.\r\n II - Não gera direito a crédito fiscal de ICMS, de ISS e de IPI." #opcional
175
+
176
+ #enviando a nota
177
+ client.nfe_create('id-da-empresa-no-enotas', nfe)
178
+
179
+ #cancelando uma nota
180
+ client.nfe_delete('id-da-empresa-no-enotas', id-da-nota)
181
+ ```
79
182
 
80
183
  ## Testando a gem localmente
81
184
 
82
185
  ```ruby
83
186
  gem build enotas_nfe.gemspec
84
187
  gem install enotas-nfe-0.0.1.gem
85
- irb
188
+ abra o irb
86
189
  require 'enotas_nfe'
190
+ e siga os passos acima
87
191
  ```
88
192
 
89
193
  ## Contribuindo
@@ -95,7 +199,7 @@ Para contruibuir de uma forma adequada, siga os passos abaixo:
95
199
  * Envie seu branch para seu repositório remoto;
96
200
  * Solicite um PR a partir desse novo branch enviado.
97
201
 
98
- Issues e comentários são sempre bem-vindos no repoistório oficial: https://github.com/enotas/enotas-ruby.
202
+ Issues e comentários são sempre bem-vindos no repoistório oficial: https://github.com/eNotasGW/.
99
203
 
100
204
  ## ROADMAP
101
205
 
@@ -2,6 +2,25 @@ module EnotasNfe
2
2
  module Endpoints
3
3
  include Request
4
4
 
5
+ ## rotas para criaçacão/update e onfiguraçao da empresa
6
+ def get_empresas(pageNumber, pageSize)
7
+ get("empresas?pageNumber=#{pageNumber}&pageSize=#{pageNumber}")
8
+ end
9
+
10
+ def get_empresa(firm_id)
11
+ get("empresas/#{firm_id}")
12
+ end
13
+
14
+ def create_update_empresa(body)
15
+ post("empresas", body)
16
+ end
17
+
18
+ def set_logo(firm_id, body)
19
+ post("empresas/#{firm_id}/logo", body)
20
+ end
21
+
22
+
23
+ ## rotas para nota fiscal eletronica
5
24
  def nfe_create(firm_id, body)
6
25
  post("empresas/#{firm_id}/nf-e", body)
7
26
  end
@@ -14,6 +33,7 @@ module EnotasNfe
14
33
  get("empresas/#{firm_id}/nf-e/#{id}")
15
34
  end
16
35
 
36
+ ## rotas para nota fiscal de serviço
17
37
  def nfse_list(firm_id, body = {})
18
38
  get("empresas/#{firm_id}/nfes", body)
19
39
  end
@@ -0,0 +1,14 @@
1
+ module EnotasNfe
2
+ module Model
3
+ class AmbienteHomologacao
4
+
5
+ require "enotas_nfe/model/csc"
6
+
7
+ include Virtus.model
8
+
9
+ attribute :csc, Csc
10
+ attribute :serieNFe, String
11
+
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,13 @@
1
+ module EnotasNfe
2
+ module Model
3
+ class AmbienteProducao
4
+
5
+ require "enotas_nfe/model/csc"
6
+
7
+ include Virtus.model
8
+
9
+ attribute :csc, Csc
10
+ attribute :serieNFe, String
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,15 @@
1
+ module EnotasNfe
2
+ module Model
3
+ class ConfiguracoesNFSeHomologacao
4
+
5
+ include Virtus.model
6
+
7
+ attribute :sequencialNFe, Integer
8
+ attribute :serieNFe, String
9
+ attribute :sequencialLoteNFe, Integer
10
+ attribute :usuarioAcessoProvedor, String
11
+ attribute :tokenAcessoProvedor, String
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module EnotasNfe
2
+ module Model
3
+ class ConfiguracoesNFSeProducao
4
+
5
+ include Virtus.model
6
+
7
+ attribute :sequencialNFe, Integer
8
+ attribute :serieNFe, String
9
+ attribute :sequencialLoteNFe, Integer
10
+ attribute :usuarioAcessoProvedor, String
11
+ attribute :tokenAcessoProvedor, String
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,12 @@
1
+ module EnotasNfe
2
+ module Model
3
+ class Csc
4
+
5
+ include Virtus.model
6
+
7
+ attribute :id, String
8
+ attribute :codigo, String
9
+
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module EnotasNfe
2
+ module Model
3
+ class EmissaoNFeConsumidor
4
+
5
+ include Virtus.model
6
+
7
+ attribute :ambienteProducao, AmbienteProducao
8
+ attribute :ambienteHomologacao, AmbienteHomologacao
9
+
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,34 @@
1
+ module EnotasNfe
2
+ module Model
3
+ class Empresa
4
+
5
+ require "enotas_nfe/model/ambiente_homologacao"
6
+ require "enotas_nfe/model/ambiente_producao"
7
+ require "enotas_nfe/model/configuracoes_nfse_homologacao"
8
+ require "enotas_nfe/model/configuracoes_nfse_producao"
9
+ require "enotas_nfe/model/emissao_nfe_consumidor"
10
+ require 'open-uri'
11
+
12
+ include Virtus.model
13
+
14
+ attribute :id #Em casos de atualização o identificador único da empresa deve ser informado, atributo "id".
15
+ attribute :empresaId, String
16
+ attribute :logotipo, StringIO.new
17
+ attribute :cnpj, String
18
+ attribute :inscricaoMunicipal, String
19
+ attribute :razaoSocial, String
20
+ attribute :nomeFantasia, String
21
+ attribute :optanteSimplesNacional, Boolean
22
+ attribute :email, String
23
+ attribute :telefoneComercial, String
24
+ attribute :endereco, Endereco
25
+ attribute :enviarEmailCliente, Boolean
26
+ attribute :emissaoNFeConsumidor, EmissaoNFeConsumidor
27
+ attribute :ambienteProducao, AmbienteProducao
28
+ attribute :ambienteHomologacao, AmbienteHomologacao
29
+ attribute :configuracoesNFSeHomologacao, ConfiguracoesNFSeHomologacao
30
+ attribute :configuracoesNFSeProducao, ConfiguracoesNFSeProducao
31
+
32
+ end
33
+ end
34
+ end
@@ -6,6 +6,15 @@ module EnotasNfe
6
6
 
7
7
  attribute :situacaoTributaria, String
8
8
  attribute :origem, String
9
+ attribute :aliquota, Float
10
+ attribute :baseCalculo, Float
11
+ attribute :modalidadeBaseCalculo, String
12
+ attribute :percentualReducaoBaseCalculo, Float
13
+ attribute :baseCalculoST, Float
14
+ attribute :aliquotaST, Float
15
+ attribute :modalidadeBaseCalculoST, String
16
+ attribute :percentualReducaoBaseCalculoST, Float
17
+ attribute :percentualMargemValorAdicionadoST, Float
9
18
 
10
19
  end
11
20
  end
@@ -6,10 +6,12 @@ module EnotasNfe
6
6
  require "enotas_nfe/model/cofins"
7
7
  require "enotas_nfe/model/icms"
8
8
  require "enotas_nfe/model/pis"
9
+ require "enotas_nfe/model/issqn"
9
10
 
10
11
  attribute :icms, Icms
11
12
  attribute :pis, Pis
12
13
  attribute :cofins, Cofins
14
+ attribute :issqn, Issqn
13
15
 
14
16
  end
15
17
  end
@@ -5,7 +5,7 @@ module EnotasNfe
5
5
  include Virtus.model
6
6
 
7
7
  attribute :itemListaServicoLC116, String
8
- attribute :aliquotaIss, Decimal
8
+ attribute :aliquotaIss, Float
9
9
 
10
10
  end
11
11
  end
@@ -13,6 +13,7 @@ module EnotasNfe
13
13
  attribute :quantidade, Integer
14
14
  attribute :unidadeMedida, String
15
15
  attribute :valorUnitario, Float
16
+ attribute :descontos, Float
16
17
  attribute :impostos, Impostos
17
18
 
18
19
  end
@@ -1,3 +1,3 @@
1
1
  module EnotasNfe
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/enotas_nfe.rb CHANGED
@@ -20,6 +20,13 @@ require "enotas_nfe/model/issqn"
20
20
  require "enotas_nfe/model/pis"
21
21
  require "enotas_nfe/facades"
22
22
  require "enotas_nfe/client"
23
+ require "enotas_nfe/model/ambiente_homologacao"
24
+ require "enotas_nfe/model/ambiente_producao"
25
+ require "enotas_nfe/model/configuracoes_nfse_homologacao"
26
+ require "enotas_nfe/model/configuracoes_nfse_producao"
27
+ require "enotas_nfe/model/csc"
28
+ require "enotas_nfe/model/emissao_nfe_consumidor"
29
+ require "enotas_nfe/model/empresa"
23
30
 
24
31
  module EnotasNfe
25
32
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enotas_nfe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luis Fernando Pimenta
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-11-21 00:00:00.000000000 Z
11
+ date: 2017-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -130,8 +130,15 @@ files:
130
130
  - lib/enotas_nfe/endpoints.rb
131
131
  - lib/enotas_nfe/facades.rb
132
132
  - lib/enotas_nfe/middleware.rb
133
+ - lib/enotas_nfe/model/ambiente_homologacao.rb
134
+ - lib/enotas_nfe/model/ambiente_producao.rb
133
135
  - lib/enotas_nfe/model/cliente.rb
134
136
  - lib/enotas_nfe/model/cofins.rb
137
+ - lib/enotas_nfe/model/configuracoes_nfse_homologacao.rb
138
+ - lib/enotas_nfe/model/configuracoes_nfse_producao.rb
139
+ - lib/enotas_nfe/model/csc.rb
140
+ - lib/enotas_nfe/model/emissao_nfe_consumidor.rb
141
+ - lib/enotas_nfe/model/empresa.rb
135
142
  - lib/enotas_nfe/model/endereco.rb
136
143
  - lib/enotas_nfe/model/icms.rb
137
144
  - lib/enotas_nfe/model/impostos.rb
@@ -143,7 +150,7 @@ files:
143
150
  - lib/enotas_nfe/request.rb
144
151
  - lib/enotas_nfe/version.rb
145
152
  - lib/tasks/enotas_nfe_tasks.rake
146
- homepage: https://github.com/luispimenta/enotas-client
153
+ homepage: https://github.com/luispimenta/EnotasNfe
147
154
  licenses:
148
155
  - MIT
149
156
  metadata: {}