transmitenota 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Rakefile +6 -0
- data/lib/transmitenota.rb +69 -0
- data/lib/transmitenota/config.rb +19 -0
- data/lib/transmitenota/dado.rb +26 -0
- data/lib/transmitenota/item.rb +18 -0
- data/lib/transmitenota/nota.rb +17 -0
- data/lib/transmitenota/version.rb +3 -0
- data/transmitenota.gemspec +25 -0
- metadata +94 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ba0ed59b70fe237d7f46e01c1828914540f85e6f
|
4
|
+
data.tar.gz: 310068291aa4dda3ba03fd53f025277872bea9fb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b1cb865c796f679630f7d2baf8b9bfc1635fa8a9a1f5c575944a0ee08db8fdb77ca568023dc0daf14b00bbe50c66f973ab2ecbb7836e6888df00c8523acb414e
|
7
|
+
data.tar.gz: 63b385184cd1edb780ebe5c376b6b32a0ff303e884f204d270390a54d0b56cce2ee4371e597ad28f04506130beed882183290fceceaeaa4b6d0e4b33f3f11f43
|
data/Rakefile
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
require "transmitenota/version"
|
2
|
+
require "transmitenota/item"
|
3
|
+
require "transmitenota/nota"
|
4
|
+
require "transmitenota/config"
|
5
|
+
require "transmitenota/dado"
|
6
|
+
require 'json'
|
7
|
+
require "net/http"
|
8
|
+
require "uri"
|
9
|
+
require 'httpclient'
|
10
|
+
|
11
|
+
module Transmitenota
|
12
|
+
class Nfe
|
13
|
+
|
14
|
+
def url
|
15
|
+
if @configuration.environment == :production
|
16
|
+
'prod'
|
17
|
+
elsif @configuration.environment == :sandbox
|
18
|
+
"http://api1.transmitenota.com.br/api/homologacao/"
|
19
|
+
#"http://localhost:8080/"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# The configuration instance
|
24
|
+
def configuration
|
25
|
+
@configuration ||= Transmitenota::Config.new
|
26
|
+
end
|
27
|
+
|
28
|
+
def enviar_nfe(nota)
|
29
|
+
puts json = nota.to_json
|
30
|
+
puts '### enviando nota ###'
|
31
|
+
http = HTTPClient.new
|
32
|
+
http.receive_timeout = 30000
|
33
|
+
puts url + "EnviarNfe/"
|
34
|
+
response = http.post(url + "EnviarNfe/", json.encode(@configuration.encoding), set_header)
|
35
|
+
#response.body
|
36
|
+
puts obj = JSON.parse(response.body)
|
37
|
+
searchkey = obj['searchkey']
|
38
|
+
end
|
39
|
+
|
40
|
+
def consultar_nfe(nota)
|
41
|
+
puts json = nota.to_json
|
42
|
+
puts '### consultando nota ###'
|
43
|
+
http = HTTPClient.new
|
44
|
+
http.receive_timeout = 30000
|
45
|
+
response = http.post(url + "ConsultarEmissaoNotaNfe/", json.encode("utf-8"), set_header)
|
46
|
+
puts response.body
|
47
|
+
end
|
48
|
+
|
49
|
+
def enviar_email_nfe(nota)
|
50
|
+
puts json = nota.to_json
|
51
|
+
puts '### enviando nota por email ###'
|
52
|
+
http = HTTPClient.new
|
53
|
+
http.receive_timeout = 30000
|
54
|
+
response = http.post(url + "EnviarEmailNfe/", json.encode("utf-8"), set_header)
|
55
|
+
puts response.body
|
56
|
+
end
|
57
|
+
|
58
|
+
def cancelar_nfe
|
59
|
+
puts 'teste'
|
60
|
+
end
|
61
|
+
|
62
|
+
def set_header
|
63
|
+
headers = {
|
64
|
+
'Content-Type' => 'application/json',
|
65
|
+
}
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Transmitenota
|
2
|
+
class Config
|
3
|
+
# The api key
|
4
|
+
attr_accessor :ApiKey
|
5
|
+
|
6
|
+
# The cnpj
|
7
|
+
attr_accessor :Cnpj
|
8
|
+
|
9
|
+
# The encoding that will be used.
|
10
|
+
attr_accessor :encoding
|
11
|
+
|
12
|
+
attr_accessor :environment
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
@environment = :sandbox
|
16
|
+
@encoding = "UTF-8"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Transmitenota
|
2
|
+
class Dado
|
3
|
+
attr_accessor :natureza_operacao, :data_emissao, :data_saida_entrada, :hora_saida_entrada, :tipo_operacao, :codigo_cfop, :forma_pagamento,
|
4
|
+
:finalidade_emissao, :nome_destinatario, :cnpj_destinatario, :inscricao_estadual_destinatario, :telefone_destinatario, :logradouro_destinatario,
|
5
|
+
:numero_destinatario, :complemento_destinatario, :bairro_destinatario, :municipio_destinatario, :uf_destinatario, :pais_destinatario,
|
6
|
+
:cep_destinatario, :icms_base_calculo, :icms_valor_total, :icms_base_calculo_st, :icms_valor_total_st, :icms_modalidade_base_calculo,
|
7
|
+
:icms_valor, :valor_frete, :valor_seguro, :valor_total, :valor_total_sem_desconto, :valor_ipi, :modalidade_frete, :informacoes_adicionais_contribuinte,
|
8
|
+
:nome_transportadora, :cnpj_transportadora, :endereco_transportadora, :municipio_transportadora, :uf_transportadora, :inscricao_estadual_transportadora
|
9
|
+
|
10
|
+
attr_accessor :Itens
|
11
|
+
|
12
|
+
attr_accessor :searchkey
|
13
|
+
|
14
|
+
attr_accessor :de, :para, :assunto, :mensagem
|
15
|
+
|
16
|
+
def initialize
|
17
|
+
@Itens = []
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_hash
|
21
|
+
hash = {}
|
22
|
+
instance_variables.each {|var| hash[var.to_s.delete("@")] = instance_variable_get(var) }
|
23
|
+
hash
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Transmitenota
|
2
|
+
class Item
|
3
|
+
attr_accessor :numero_item, :codigo_produto, :descricao, :cfop, :unidade_comercial, :quantidade_comercial, :valor_unitario_comercial, :codigo_ncm, :valor_desconto,
|
4
|
+
:valor_frete, :valor_seguro, :valor_outras_despesas, :valor_total, :valor_total_sem_desconto, :icms_aliquota_calc_credito, :icms_valor_credito, :icms_origem_cstb,
|
5
|
+
:icms_mod_base_calculo, :icms_base_calculo, :icms_reducao_base_calculo, :icms_aliquota, :icms_valor, :icms_valor_st, :icms_valor_bc_st_ret, :icms_valor_st_ret,
|
6
|
+
:icms_mod_bc_st, :icms_mva_st, :icms_bc_st, :icms_red_bc_st, :icms_aliquota_st, :valor_bc_icms_uf_destino, :aliquota_icms_uf_destino, :valor_icms_int_uf_destino,
|
7
|
+
:aliquota_int_uf_envolvidas, :valor_icms_int_uf_remetente, :aliquota_perc_prov_part_icms_int, :aliquota_icms_fundo_combate_pobreza_uf_dest,
|
8
|
+
:valor_icms_fundo_combate_pobreza_uf_dest, :pis_situacao_tributaria, :aliquota_pis, :valor_pis, :base_calculo_pis, :cofins_situacao_tributaria, :aliquota_cofins,
|
9
|
+
:valor_cofins, :base_calculo_cofins, :ipi_situacao_tributaria, :ipi_situacao_tributaria, :valor_ipi, :base_calculo_ipi, :aliquota_ipi, :cst_ipi,
|
10
|
+
:ipi_codigo_enquadramento_legal, :aliquota_iof, :valor_ii, :valor_iof, :base_calculo_ii, :aliquota_ii, :valor_despesas_aduaneiras
|
11
|
+
|
12
|
+
def to_hash
|
13
|
+
hash = {}
|
14
|
+
instance_variables.each {|var| hash[var.to_s.delete("@")] = instance_variable_get(var) }
|
15
|
+
hash
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Transmitenota
|
2
|
+
class Nota
|
3
|
+
attr_accessor :Dados
|
4
|
+
|
5
|
+
def initialize(apiKey, cnpj)
|
6
|
+
@ApiKey = apiKey
|
7
|
+
@Cnpj = cnpj
|
8
|
+
@Dados = {}
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_hash
|
12
|
+
hash = {}
|
13
|
+
instance_variables.each {|var| hash[var.to_s.delete("@")] = instance_variable_get(var) }
|
14
|
+
hash
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'transmitenota/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "transmitenota"
|
8
|
+
spec.version = Transmitenota::VERSION
|
9
|
+
spec.authors = ["Luis Fernando Pimenta"]
|
10
|
+
spec.email = ["pimenta@red4sis.com"]
|
11
|
+
|
12
|
+
spec.description = "Gem for emission and transmission of nfe"
|
13
|
+
spec.summary = "Gem for emission and transmission of nfe to transmitenota"
|
14
|
+
spec.homepage = "https://transmitenota.com.br"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = Dir["{lib/**/*.rb,README.rdoc,test/**/*.rb,Rakefile,*.gemspec}"]
|
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_development_dependency "bundler", "~> 1.14"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: transmitenota
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Luis Fernando Pimenta
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-08-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.14'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.14'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: Gem for emission and transmission of nfe
|
56
|
+
email:
|
57
|
+
- pimenta@red4sis.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- Rakefile
|
63
|
+
- lib/transmitenota.rb
|
64
|
+
- lib/transmitenota/config.rb
|
65
|
+
- lib/transmitenota/dado.rb
|
66
|
+
- lib/transmitenota/item.rb
|
67
|
+
- lib/transmitenota/nota.rb
|
68
|
+
- lib/transmitenota/version.rb
|
69
|
+
- transmitenota.gemspec
|
70
|
+
homepage: https://transmitenota.com.br
|
71
|
+
licenses:
|
72
|
+
- MIT
|
73
|
+
metadata: {}
|
74
|
+
post_install_message:
|
75
|
+
rdoc_options: []
|
76
|
+
require_paths:
|
77
|
+
- lib
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
requirements: []
|
89
|
+
rubyforge_project:
|
90
|
+
rubygems_version: 2.5.1
|
91
|
+
signing_key:
|
92
|
+
specification_version: 4
|
93
|
+
summary: Gem for emission and transmission of nfe to transmitenota
|
94
|
+
test_files: []
|