kinabo 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.
- checksums.yaml +7 -0
- data/.DS_Store +0 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +9 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/config/kinabo.yml +15 -0
- data/kinabo.gemspec +31 -0
- data/lib/kinabo/bradesco/remessa/boleto.rb +17 -0
- data/lib/kinabo/bradesco/remessa/builder.rb +19 -0
- data/lib/kinabo/bradesco/remessa/header.rb +29 -0
- data/lib/kinabo/bradesco/remessa/mensagem.rb +57 -0
- data/lib/kinabo/bradesco/remessa/pagador.rb +57 -0
- data/lib/kinabo/bradesco/remessa/trailler.rb +15 -0
- data/lib/kinabo/bradesco/remessa/transacao.rb +125 -0
- data/lib/kinabo/bradesco/retorno.rb +107 -0
- data/lib/kinabo/configuration.rb +26 -0
- data/lib/kinabo/utils.rb +19 -0
- data/lib/kinabo/version.rb +3 -0
- data/lib/kinabo.rb +26 -0
- metadata +155 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 270adf1f209a76b7bc474e7b06b8267b02e08c36
|
4
|
+
data.tar.gz: 46e379f2082fd83d20bfb33e2de411846650da4e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 76adb5193161a12ca484c2e40938ed3dbc63ee302eab210a893f9514808bdc5d9b9f8c9cac5551909bd70a4923f05c0986ae9ee47cb24d02728076f20a4b6605
|
7
|
+
data.tar.gz: 3047c53418995a06004116051f5be04a3a1276d1ff5103b5ba4dcc11c445c01c56e28989366dd632801b0b4d8ddcc69711e81c71c6d9694c28ca8eabbda7490b
|
data/.DS_Store
ADDED
Binary file
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Noverde
|
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.
|
data/README.md
ADDED
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "kinabo"
|
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
|
data/bin/setup
ADDED
data/config/kinabo.yml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
test:
|
2
|
+
bradesco:
|
3
|
+
carteira: 09
|
4
|
+
nome_empresa: FIDC TESTE
|
5
|
+
numero_empresa: 4359923
|
6
|
+
conta_corrente: 0147792-2
|
7
|
+
agencia: 00289
|
8
|
+
|
9
|
+
development:
|
10
|
+
bradesco:
|
11
|
+
carteira: 09
|
12
|
+
nome_empresa: FIDC TESTE
|
13
|
+
numero_empresa: 4359923
|
14
|
+
conta_corrente: 0147792-2
|
15
|
+
agencia: 00289
|
data/kinabo.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'kinabo/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "kinabo"
|
8
|
+
spec.version = Kinabo::VERSION
|
9
|
+
spec.authors = ["Noverde Team", "Rafael Izidoro"]
|
10
|
+
spec.email = ["dev@noverde.com.br", "izidoro.rafa@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Generate CNAB (Centro Nacional Automação Bancária) files}
|
13
|
+
spec.description = %q{This gem is responsible for generates cnabs files for main Brazilian banks}
|
14
|
+
spec.homepage = "https://github.com/noverde/kinabo"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_dependency "hashie", "~> 3.5"
|
25
|
+
spec.add_dependency "activesupport", "~> 5.0"
|
26
|
+
|
27
|
+
spec.add_development_dependency "bundler", "~> 1.13"
|
28
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
29
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
30
|
+
spec.add_development_dependency "pry-byebug", "~> 3.4.2"
|
31
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Kinabo
|
2
|
+
module Bradesco
|
3
|
+
module Remessa
|
4
|
+
class Boleto < Hashie::Dash
|
5
|
+
include Hashie::Extensions::Dash::Coercion
|
6
|
+
|
7
|
+
property :transacao, coerce: Transacao, required: true
|
8
|
+
property :mensagem, coerce: Mensagem
|
9
|
+
property :pagador, coerce: Pagador
|
10
|
+
|
11
|
+
def build
|
12
|
+
[transacao, mensagem, pagador].map(&:build)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Kinabo
|
2
|
+
module Bradesco
|
3
|
+
module Remessa
|
4
|
+
class Builder < Hashie::Dash
|
5
|
+
include Hashie::Extensions::Dash::Coercion
|
6
|
+
include Kinabo::Utils
|
7
|
+
|
8
|
+
property :header, coerce: Header, required: true
|
9
|
+
property :boletos, coerce: Array[Boleto], required: true
|
10
|
+
|
11
|
+
def build
|
12
|
+
lines = [header, boletos, Trailler.new].flatten.map(&:build)
|
13
|
+
|
14
|
+
fill_sequencial(lines.flatten)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Kinabo
|
2
|
+
module Bradesco
|
3
|
+
module Remessa
|
4
|
+
class Header < Hashie::Dash
|
5
|
+
include Kinabo::Utils
|
6
|
+
|
7
|
+
property :codigo_empresa, required: true, default: Kinabo.config.bradesco&.dig(:numero_empresa)
|
8
|
+
property :nome_empresa, required: true, default: Kinabo.config.bradesco&.dig(:nome_empresa)
|
9
|
+
property :data_gravacao, required: true
|
10
|
+
property :sequencial, required: true
|
11
|
+
|
12
|
+
def build
|
13
|
+
parts = '01REMESSA01'
|
14
|
+
|
15
|
+
parts << justify_string('COBRANCA', 15)
|
16
|
+
parts << justify_number(codigo_empresa, 20)
|
17
|
+
parts << justify_string(nome_empresa, 30)
|
18
|
+
parts << '237'
|
19
|
+
parts << justify_string('BRADESCO', 15)
|
20
|
+
parts << justify_number(data_gravacao, 6)
|
21
|
+
parts << justify_string('', 8)
|
22
|
+
parts << 'MX'
|
23
|
+
parts << justify_number(sequencial, 7)
|
24
|
+
parts << justify_string('', 277)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Kinabo
|
2
|
+
module Bradesco
|
3
|
+
module Remessa
|
4
|
+
class Mensagem < Hashie::Dash
|
5
|
+
include Kinabo::Utils
|
6
|
+
|
7
|
+
property :mensagem_1
|
8
|
+
property :mensagem_2
|
9
|
+
property :mensagem_3
|
10
|
+
property :mensagem_4
|
11
|
+
property :data_desconto_2
|
12
|
+
property :valor_desconto_2
|
13
|
+
property :data_desconto_3
|
14
|
+
property :valor_desconto_3
|
15
|
+
property :nosso_numero
|
16
|
+
property :nosso_numero_dv
|
17
|
+
|
18
|
+
|
19
|
+
def build
|
20
|
+
parts = '2'
|
21
|
+
|
22
|
+
parts << justify_string(mensagem_1, 80)
|
23
|
+
parts << justify_string(mensagem_2, 80)
|
24
|
+
parts << justify_string(mensagem_3, 80)
|
25
|
+
parts << justify_string(mensagem_4, 80)
|
26
|
+
parts << justify_number(data_desconto_2, 6)
|
27
|
+
parts << justify_number(valor_desconto_2, 13)
|
28
|
+
parts << justify_number(data_desconto_3, 6)
|
29
|
+
parts << justify_number(valor_desconto_3, 13)
|
30
|
+
parts << justify_string('', 7)
|
31
|
+
parts << justify_number(carteira, 3)
|
32
|
+
parts << justify_number(agencia, 5)
|
33
|
+
parts << justify_number(conta_corrente, 7)
|
34
|
+
parts << justify_string(conta_corrente_dv, 1)
|
35
|
+
parts << justify_number(nosso_numero, 11)
|
36
|
+
parts << justify_string(nosso_numero_dv, 1)
|
37
|
+
end
|
38
|
+
|
39
|
+
def carteira
|
40
|
+
Kinabo.config.bradesco[:carteira]
|
41
|
+
end
|
42
|
+
|
43
|
+
def agencia
|
44
|
+
Kinabo.config.bradesco[:agencia]
|
45
|
+
end
|
46
|
+
|
47
|
+
def conta_corrente
|
48
|
+
Kinabo.config.bradesco[:conta_corrente].split('-')[0]
|
49
|
+
end
|
50
|
+
|
51
|
+
def conta_corrente_dv
|
52
|
+
Kinabo.config.bradesco[:conta_corrente].split('-')[1]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Kinabo
|
2
|
+
module Bradesco
|
3
|
+
module Remessa
|
4
|
+
class Pagador < Hashie::Dash
|
5
|
+
include Kinabo::Utils
|
6
|
+
|
7
|
+
property :endereco
|
8
|
+
property :cep
|
9
|
+
property :cidade
|
10
|
+
property :uf
|
11
|
+
property :nosso_numero
|
12
|
+
property :nosso_numero_dv
|
13
|
+
|
14
|
+
def build
|
15
|
+
parts = '7'
|
16
|
+
|
17
|
+
parts << justify_string(endereco, 45)
|
18
|
+
parts << justify_number(cep_pagador, 5)
|
19
|
+
parts << justify_number(cep_sufixo_pagador, 3)
|
20
|
+
parts << justify_string(cidade, 20)
|
21
|
+
parts << justify_string(uf, 2)
|
22
|
+
parts << justify_string('', 290)
|
23
|
+
parts << justify_number(carteira, 3)
|
24
|
+
parts << justify_number(agencia, 5)
|
25
|
+
parts << justify_number(conta_corrente, 7)
|
26
|
+
parts << justify_string(conta_corrente_dv, 1)
|
27
|
+
parts << justify_number(nosso_numero, 11)
|
28
|
+
parts << justify_string(nosso_numero_dv, 1)
|
29
|
+
end
|
30
|
+
|
31
|
+
def carteira
|
32
|
+
Kinabo.config.bradesco[:carteira]
|
33
|
+
end
|
34
|
+
|
35
|
+
def agencia
|
36
|
+
Kinabo.config.bradesco[:agencia]
|
37
|
+
end
|
38
|
+
|
39
|
+
def conta_corrente
|
40
|
+
Kinabo.config.bradesco[:conta_corrente].split('-')[0]
|
41
|
+
end
|
42
|
+
|
43
|
+
def conta_corrente_dv
|
44
|
+
Kinabo.config.bradesco[:conta_corrente].split('-')[1]
|
45
|
+
end
|
46
|
+
|
47
|
+
def cep_pagador
|
48
|
+
cep[0..4]
|
49
|
+
end
|
50
|
+
|
51
|
+
def cep_sufixo_pagador
|
52
|
+
cep[-3..-1]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
module Kinabo
|
2
|
+
module Bradesco
|
3
|
+
module Remessa
|
4
|
+
class Transacao < Hashie::Dash
|
5
|
+
include Kinabo::Utils
|
6
|
+
|
7
|
+
property :agencia_debito, default: '00000'
|
8
|
+
property :agencia_debito_dv, default: '0'
|
9
|
+
property :razao_cc_pagador, default: '00000'
|
10
|
+
property :cc_pagador, default: '0000000'
|
11
|
+
property :cc_pagador_dv, default: '0'
|
12
|
+
property :numero_controle
|
13
|
+
property :codigo_banco_c3, default: '000'
|
14
|
+
property :campo_multa
|
15
|
+
property :percentual_multa
|
16
|
+
property :nosso_numero
|
17
|
+
property :nosso_numero_dv
|
18
|
+
property :desconto_por_dia
|
19
|
+
property :emissao, default: 1
|
20
|
+
property :debito_automatico, default: 'N'
|
21
|
+
property :rateio
|
22
|
+
property :aviso_debito_automatico, default: '2'
|
23
|
+
property :ocorrencia, required: true, default: 1
|
24
|
+
property :numero_documento, required: true
|
25
|
+
property :data_vencimento, required: true
|
26
|
+
property :valor, required: true
|
27
|
+
property :especie, required: true, default: 1
|
28
|
+
property :data_emissao, required: true
|
29
|
+
property :instrucao_1
|
30
|
+
property :instrucao_2
|
31
|
+
property :valor_mora
|
32
|
+
property :data_limite_desconto
|
33
|
+
property :valor_desconto
|
34
|
+
property :valor_iof
|
35
|
+
property :valor_abatimento
|
36
|
+
property :tipo_inscricao_pagador, required: true, default: 1
|
37
|
+
property :inscricao_pagador, required: true
|
38
|
+
property :nome_pagador, required: true
|
39
|
+
property :endereco_pagador, required: true
|
40
|
+
property :mensagem_1
|
41
|
+
property :cep, required: true
|
42
|
+
property :mensagem_2
|
43
|
+
|
44
|
+
def build
|
45
|
+
parts = '1'
|
46
|
+
|
47
|
+
parts << justify_number(agencia_debito, 5)
|
48
|
+
parts << justify_string(agencia_debito_dv, 1)
|
49
|
+
parts << justify_string(razao_cc_pagador, 5)
|
50
|
+
parts << justify_number(cc_pagador, 7)
|
51
|
+
parts << justify_string(cc_pagador_dv, 1)
|
52
|
+
parts << justify_string(id_empresa, 17)
|
53
|
+
parts << justify_string(numero_controle, 25)
|
54
|
+
parts << justify_number(codigo_banco_c3, 3)
|
55
|
+
parts << justify_number(campo_multa, 1)
|
56
|
+
parts << justify_number(percentual_multa, 4)
|
57
|
+
parts << justify_number(nosso_numero, 11)
|
58
|
+
parts << justify_string(nosso_numero_dv, 1)
|
59
|
+
parts << justify_number(desconto_por_dia, 10)
|
60
|
+
parts << justify_string(emissao, 1)
|
61
|
+
parts << justify_string(debito_automatico, 1)
|
62
|
+
parts << justify_string('', 10)
|
63
|
+
parts << justify_string(rateio, 1)
|
64
|
+
parts << justify_number(aviso_debito_automatico, 1)
|
65
|
+
parts << justify_string('', 2)
|
66
|
+
parts << justify_number(ocorrencia, 2)
|
67
|
+
parts << justify_string(numero_documento, 10)
|
68
|
+
parts << justify_number(data_vencimento, 6)
|
69
|
+
parts << justify_number(valor, 13)
|
70
|
+
parts << '00000000'
|
71
|
+
parts << justify_number(especie, 2)
|
72
|
+
parts << 'N'
|
73
|
+
parts << justify_number(data_emissao, 6)
|
74
|
+
parts << justify_number(instrucao_1, 2)
|
75
|
+
parts << justify_number(instrucao_2, 2)
|
76
|
+
parts << justify_number(valor_mora, 13)
|
77
|
+
parts << justify_number(data_limite_desconto, 6)
|
78
|
+
parts << justify_number(valor_desconto, 13)
|
79
|
+
parts << justify_number(valor_iof, 13)
|
80
|
+
parts << justify_number(valor_abatimento, 13)
|
81
|
+
parts << justify_number(tipo_inscricao_pagador, 2)
|
82
|
+
parts << justify_number(inscricao_pagador, 14)
|
83
|
+
parts << justify_string(nome_pagador, 40)
|
84
|
+
parts << justify_string(endereco_pagador, 40)
|
85
|
+
parts << justify_string(mensagem_1, 12)
|
86
|
+
parts << justify_number(cep_pagador, 5)
|
87
|
+
parts << justify_number(cep_sufixo_pagador, 3)
|
88
|
+
parts << justify_string(mensagem_2, 60)
|
89
|
+
end
|
90
|
+
|
91
|
+
def id_empresa
|
92
|
+
parts = '0'
|
93
|
+
parts << justify_number(carteira, 3)
|
94
|
+
parts << justify_number(agencia, 5)
|
95
|
+
parts << justify_number(conta_corrente, 7)
|
96
|
+
parts << justify_number(conta_corrente_dv, 1)
|
97
|
+
end
|
98
|
+
|
99
|
+
def carteira
|
100
|
+
Kinabo.config.bradesco[:carteira]
|
101
|
+
end
|
102
|
+
|
103
|
+
def agencia
|
104
|
+
Kinabo.config.bradesco[:agencia]
|
105
|
+
end
|
106
|
+
|
107
|
+
def conta_corrente
|
108
|
+
Kinabo.config.bradesco[:conta_corrente].split('-')[0]
|
109
|
+
end
|
110
|
+
|
111
|
+
def conta_corrente_dv
|
112
|
+
Kinabo.config.bradesco[:conta_corrente].split('-')[1]
|
113
|
+
end
|
114
|
+
|
115
|
+
def cep_pagador
|
116
|
+
cep[0..4]
|
117
|
+
end
|
118
|
+
|
119
|
+
def cep_sufixo_pagador
|
120
|
+
cep[-3..-1]
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
module Kinabo
|
2
|
+
module Bradesco
|
3
|
+
class Retorno
|
4
|
+
def initialize(path)
|
5
|
+
@path = path
|
6
|
+
end
|
7
|
+
|
8
|
+
def lines
|
9
|
+
@lines ||= content.split("\n")
|
10
|
+
end
|
11
|
+
|
12
|
+
def header
|
13
|
+
header_line = lines.first
|
14
|
+
|
15
|
+
{
|
16
|
+
id_registro: pos(header_line, '1-1'),
|
17
|
+
id_arquivo_retorno: pos(header_line, '2-2'),
|
18
|
+
literal_retorno: pos(header_line, '3-9'),
|
19
|
+
codigo_servico: pos(header_line, '10-11'),
|
20
|
+
literal_servico: pos(header_line, '12-26'),
|
21
|
+
codigo_empresa: pos(header_line, '27-46'),
|
22
|
+
nome_empresa: pos(header_line, '47-76'),
|
23
|
+
numero_bradesco_c3: pos(header_line, '77-79'),
|
24
|
+
nome_banco: pos(header_line, '80-94'),
|
25
|
+
data_gravacao_arquivo: pos(header_line, '95-100'),
|
26
|
+
densidade_gravacao: pos(header_line, '101-108'),
|
27
|
+
numero_aviso_bancario: pos(header_line, '109-113'),
|
28
|
+
data_credito: pos(header_line, '380-385'),
|
29
|
+
numero_sequencial: pos(header_line, '395-400')
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
def trailler
|
34
|
+
trailler_line = @lines.last
|
35
|
+
|
36
|
+
{
|
37
|
+
id_registro: pos(trailler_line, '1-1'),
|
38
|
+
id_retorno: pos(trailler_line, '2-2'),
|
39
|
+
id_tipo_registro: pos(trailler_line, '3-4'),
|
40
|
+
codigo_banco: pos(trailler_line, '5-7'),
|
41
|
+
quantidade_titulos_cobranca: pos(trailler_line, '18-25'),
|
42
|
+
valor_total_cobranca: pos(trailler_line, '26-39'),
|
43
|
+
numero_aviso_bancario: pos(trailler_line, '40-47')
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
def entries
|
48
|
+
entries_lines = lines[1...-1]
|
49
|
+
|
50
|
+
entries_lines.map do |entry_line|
|
51
|
+
{
|
52
|
+
id_registro: pos(entry_line, '1-1'),
|
53
|
+
tipo_empresa: pos(entry_line, '2-3'),
|
54
|
+
numero_empresa: pos(entry_line, '4-17'),
|
55
|
+
id_empresa: pos(entry_line, '21-37'),
|
56
|
+
numero_controle: pos(entry_line, '38-62'),
|
57
|
+
id_titulo: pos(entry_line, '71-82'),
|
58
|
+
indicador_rateio: pos(entry_line, '105-105'),
|
59
|
+
carteira: pos(entry_line, '108-108'),
|
60
|
+
id_ocorrencia: pos(entry_line, '109-110'),
|
61
|
+
data_ocorrencia: pos(entry_line, '111-116'),
|
62
|
+
numero_documento: pos(entry_line, '117-126'),
|
63
|
+
data_vencimento: pos(entry_line, '147-152'),
|
64
|
+
valor: pos(entry_line, '153-165'),
|
65
|
+
banco_cobrador: pos(entry_line, '166-168'),
|
66
|
+
agencia_cobradora: pos(entry_line, '169-173'),
|
67
|
+
especie_titulo: pos(entry_line, '174-175'),
|
68
|
+
despesas_cobranca: pos(entry_line, '176-188'),
|
69
|
+
outras_despesas: pos(entry_line, '189-201'),
|
70
|
+
juros_operacao: pos(entry_line, '202-214'),
|
71
|
+
iof: pos(entry_line, '215-227'),
|
72
|
+
abatimento: pos(entry_line, '228-240'),
|
73
|
+
desconto: pos(entry_line, '241-253'),
|
74
|
+
valor_pago: pos(entry_line, '254-266'),
|
75
|
+
juros_mora: pos(entry_line, '267-279'),
|
76
|
+
outros_creditos: pos(entry_line, '280-292'),
|
77
|
+
motivo_ocorrencia: pos(entry_line, '295-295'),
|
78
|
+
data_credito: pos(entry_line, '296-301'),
|
79
|
+
origem_pagamento: pos(entry_line, '302-304'),
|
80
|
+
cheque_bradesco: pos(entry_line, '315-318'),
|
81
|
+
motivo_rejeicao: pos(entry_line, '319-328'),
|
82
|
+
numero_cartorio: pos(entry_line, '369-370'),
|
83
|
+
numero_protocolo: pos(entry_line, '371-380'),
|
84
|
+
numero_sequencial: pos(entry_line, '395-400')
|
85
|
+
}
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
private
|
90
|
+
|
91
|
+
def content
|
92
|
+
@content ||= file.read.gsub(/\r\n/, "\n")
|
93
|
+
end
|
94
|
+
|
95
|
+
def file
|
96
|
+
@file ||= File.open(@path)
|
97
|
+
end
|
98
|
+
|
99
|
+
def pos(line, position)
|
100
|
+
i = position.split('-').map { |i| i.to_i - 1 }
|
101
|
+
range = (i[0]..i[1])
|
102
|
+
|
103
|
+
line[range]
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'erb'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
module Kinabo
|
5
|
+
class Configuration
|
6
|
+
attr_accessor :environment, :logger, :config_file_path
|
7
|
+
|
8
|
+
def config_file_path
|
9
|
+
@config_file_path || 'config/kinabo.yml'
|
10
|
+
end
|
11
|
+
|
12
|
+
def environment
|
13
|
+
@environment || ENV['RACK_ENV'] || ENV['RAILS_ENV'] || 'development'
|
14
|
+
end
|
15
|
+
|
16
|
+
def bradesco
|
17
|
+
config[:bradesco]
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def config
|
23
|
+
@config ||= Hashie::Mash.load(config_file_path)[environment]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/kinabo/utils.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
module Kinabo
|
2
|
+
module Utils
|
3
|
+
def justify_string(string, length)
|
4
|
+
I18n.transliterate(string.to_s).truncate(length, omission: '').ljust(length, ' ')
|
5
|
+
end
|
6
|
+
|
7
|
+
def justify_number(number, length)
|
8
|
+
number.to_s.rjust(length, '0')
|
9
|
+
end
|
10
|
+
|
11
|
+
def justify_value(value, length, decimal_places = 2)
|
12
|
+
("%.#{decimal_places}f" % (value || 0)).gsub(/[.,]/, '').rjust(length, '0')
|
13
|
+
end
|
14
|
+
|
15
|
+
def fill_sequencial(lines)
|
16
|
+
lines.map.with_index(1) { |line, index| line + justify_number(index, 6) }.join("\r\n") + "\r\n"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/kinabo.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
module Kinabo
|
2
|
+
class RequiredFieldError < StandardError; end
|
3
|
+
|
4
|
+
def self.config
|
5
|
+
@config ||= Kinabo::Configuration.new
|
6
|
+
yield @config if block_given?
|
7
|
+
@config
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
require 'hashie'
|
12
|
+
require "kinabo/version"
|
13
|
+
require 'kinabo/utils'
|
14
|
+
require 'kinabo/configuration'
|
15
|
+
require 'active_support/inflector/transliterate'
|
16
|
+
require 'active_support/core_ext/string'
|
17
|
+
|
18
|
+
require 'kinabo/bradesco/remessa/header'
|
19
|
+
require 'kinabo/bradesco/remessa/transacao'
|
20
|
+
require 'kinabo/bradesco/remessa/mensagem'
|
21
|
+
require 'kinabo/bradesco/remessa/pagador'
|
22
|
+
require 'kinabo/bradesco/remessa/trailler'
|
23
|
+
require 'kinabo/bradesco/remessa/boleto'
|
24
|
+
require 'kinabo/bradesco/remessa/builder'
|
25
|
+
|
26
|
+
require 'kinabo/bradesco/retorno'
|
metadata
ADDED
@@ -0,0 +1,155 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kinabo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Noverde Team
|
8
|
+
- Rafael Izidoro
|
9
|
+
autorequire:
|
10
|
+
bindir: exe
|
11
|
+
cert_chain: []
|
12
|
+
date: 2017-02-16 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: hashie
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '3.5'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '3.5'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: activesupport
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '5.0'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '5.0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: bundler
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '1.13'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '1.13'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rake
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '10.0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '10.0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rspec
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '3.0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '3.0'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: pry-byebug
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: 3.4.2
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: 3.4.2
|
98
|
+
description: This gem is responsible for generates cnabs files for main Brazilian
|
99
|
+
banks
|
100
|
+
email:
|
101
|
+
- dev@noverde.com.br
|
102
|
+
- izidoro.rafa@gmail.com
|
103
|
+
executables: []
|
104
|
+
extensions: []
|
105
|
+
extra_rdoc_files: []
|
106
|
+
files:
|
107
|
+
- ".DS_Store"
|
108
|
+
- ".gitignore"
|
109
|
+
- ".rspec"
|
110
|
+
- ".travis.yml"
|
111
|
+
- Gemfile
|
112
|
+
- LICENSE.txt
|
113
|
+
- README.md
|
114
|
+
- Rakefile
|
115
|
+
- bin/console
|
116
|
+
- bin/setup
|
117
|
+
- config/kinabo.yml
|
118
|
+
- kinabo.gemspec
|
119
|
+
- lib/kinabo.rb
|
120
|
+
- lib/kinabo/bradesco/remessa/boleto.rb
|
121
|
+
- lib/kinabo/bradesco/remessa/builder.rb
|
122
|
+
- lib/kinabo/bradesco/remessa/header.rb
|
123
|
+
- lib/kinabo/bradesco/remessa/mensagem.rb
|
124
|
+
- lib/kinabo/bradesco/remessa/pagador.rb
|
125
|
+
- lib/kinabo/bradesco/remessa/trailler.rb
|
126
|
+
- lib/kinabo/bradesco/remessa/transacao.rb
|
127
|
+
- lib/kinabo/bradesco/retorno.rb
|
128
|
+
- lib/kinabo/configuration.rb
|
129
|
+
- lib/kinabo/utils.rb
|
130
|
+
- lib/kinabo/version.rb
|
131
|
+
homepage: https://github.com/noverde/kinabo
|
132
|
+
licenses:
|
133
|
+
- MIT
|
134
|
+
metadata: {}
|
135
|
+
post_install_message:
|
136
|
+
rdoc_options: []
|
137
|
+
require_paths:
|
138
|
+
- lib
|
139
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - ">="
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
144
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - ">="
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '0'
|
149
|
+
requirements: []
|
150
|
+
rubyforge_project:
|
151
|
+
rubygems_version: 2.5.1
|
152
|
+
signing_key:
|
153
|
+
specification_version: 4
|
154
|
+
summary: Generate CNAB (Centro Nacional Automação Bancária) files
|
155
|
+
test_files: []
|