formatos-febraban 0.2.25 → 0.3.00a

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e0dfe4df7c2f0b4704b79a7da9e5c711913d9e6e
4
- data.tar.gz: 1f338f19f0520664f7f9ab530c19340442dffa7d
3
+ metadata.gz: 4af5eb9732ae0f80477397543dfc48738341bdcb
4
+ data.tar.gz: 5a6c65648d777a0ae5084cce8f997a2fdf3ab975
5
5
  SHA512:
6
- metadata.gz: 31354ae8e856a1b0fe201c9f9c4e6253220cf956c859f4079c374e19f8b93162c7bbbd257e813fa61b1522ef03529708e24659e155849757ec3420994f41336a
7
- data.tar.gz: 0d421331e8718d161ad6edcc306a85817f994e1a95e8736df699d86ff40cf3d4fc536ea4e59c9366efad08a40d46ac5403f0cc06197731c053a8752c92c749c7
6
+ metadata.gz: a5a6602747f4b20e0d61d0d944169880c263ef5281d5f51083e2a357c70208c9ad122609fbde4ee2ef8ab54c555d83565e0b4083da997211cb5e2092d017380b
7
+ data.tar.gz: 14519f47be01df26bb2bcf2ceb7494d34a16c26f07b67ca640410b12c5dae0e326b7e4fb6df737ff73b5a9cacb4451ca3580f9a5ab8402e39833a55f06f3fa12
@@ -0,0 +1 @@
1
+ 2.2.2
data/Gemfile CHANGED
@@ -1,4 +1,7 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ ruby '2.2.2'
4
+
3
5
  # Specify your gem's dependencies in formatos-febraban.gemspec
4
6
  gemspec
7
+ gem 'enumerate_it'
@@ -6,11 +6,11 @@ require 'formatos/febraban/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "formatos-febraban"
8
8
  spec.version = Formatos::Febraban::VERSION
9
- spec.authors = ["josé Ricardo Almeida"]
9
+ spec.authors = ["José Ricardo Almeida"]
10
10
  spec.email = ["jose@trackmob.com.br"]
11
11
 
12
12
  spec.summary = "Formatos bancários EDI FEBRABAN"
13
- spec.description = "Formatos para envido de dados bancários da FEBRABAN"
13
+ spec.description = "Formatos para envio e recebimento de dados bancários da FEBRABAN"
14
14
  spec.homepage = "https://bitbucket.org/jose_ricardo_almeida/formatos-febraban"
15
15
  spec.license = "MIT"
16
16
 
@@ -1,12 +1,12 @@
1
- require "formatos/febraban/version"
1
+ require 'formatos/febraban/version'
2
2
 
3
3
  # Carrega todas as dependências
4
4
  Dir[File.join(File.dirname(__FILE__), '../..', 'base', '**/*.rb')].sort.each do |file|
5
5
  require file
6
6
  end
7
7
 
8
- require "formatos/febraban150/febraban_150"
9
- require "formatos/cielo/cielo"
8
+ require 'formatos/febraban150/febraban_150'
9
+ require 'formatos/cielo/cielo'
10
10
 
11
11
  module Formatos
12
12
  module Febraban
@@ -1,5 +1,5 @@
1
1
  module Formatos
2
2
  module Febraban
3
- VERSION = "0.2.25"
3
+ VERSION = '0.3.00a'
4
4
  end
5
5
  end
@@ -3,6 +3,7 @@ class Febraban150
3
3
  require 'date'
4
4
 
5
5
  VERSAO = "05"
6
+ enum versao_disponivel: { versao_04: '04', versao_05: '05' }
6
7
 
7
8
  # Carrega todas as dependências de Layout
8
9
  Dir[File.join(File.dirname(__FILE__), '../..', 'base', '**/*.rb')].sort.each do |file|
@@ -31,9 +32,23 @@ class Febraban150
31
32
  #-------------------------------------------------------------------
32
33
  #-------------------------------------------------------------------
33
34
  # Construtor
34
- def initialize file = ""
35
+ def initialize(file = '', versao = versao_disponivels[:versao_05])
35
36
  @sections = []
37
+ @versao = versao
36
38
 
39
+ self.valida_versao
40
+ self. valida_arquivo(file)
41
+ end
42
+
43
+ private
44
+ def valida_versao
45
+ unless versao_disponivels.list.contains?(@versao)
46
+ raise "Versão #{@versao} não suportada.
47
+ Utilizar versões #{versao_disponivels.list.inspect}"
48
+ end
49
+ end
50
+
51
+ def valida_arquivo(file = '')
37
52
  if file.length > 0
38
53
  self.process_file file
39
54
  end
@@ -488,33 +503,33 @@ class Febraban150
488
503
  def get_new_section section_type
489
504
  case section_type
490
505
  when "A"
491
- Febraban150A.new(self)
506
+ Febraban150A.new(self, @versao)
492
507
  when "B"
493
- Febraban150B.new(self)
508
+ Febraban150B.new(self, @versao)
494
509
  when "C"
495
- Febraban150C.new(self)
510
+ Febraban150C.new(self, @versao)
496
511
  when "D"
497
- Febraban150D.new(self)
512
+ Febraban150D.new(self, @versao)
498
513
  when "E"
499
- Febraban150E.new(self)
514
+ Febraban150E.new(self, @versao)
500
515
  when "F"
501
- Febraban150F.new(self)
516
+ Febraban150F.new(self, @versao)
502
517
  when "H"
503
- Febraban150H.new(self)
518
+ Febraban150H.new(self, @versao)
504
519
  when "I"
505
- Febraban150I.new(self)
520
+ Febraban150I.new(self, @versao)
506
521
  when "J"
507
- Febraban150J.new(self)
522
+ Febraban150J.new(self, @versao)
508
523
  when "K"
509
- Febraban150K.new(self)
524
+ Febraban150K.new(self, @versao)
510
525
  when "L"
511
- Febraban150L.new(self)
526
+ Febraban150L.new(self, @versao)
512
527
  when "T"
513
- Febraban150T.new(self)
528
+ Febraban150T.new(self, @versao)
514
529
  when "X"
515
- Febraban150X.new(self)
530
+ Febraban150X.new(self, @versao)
516
531
  when "Z"
517
- Febraban150Z.new(self)
532
+ Febraban150Z.new(self, @versao)
518
533
  end
519
534
  end
520
535
  end
@@ -7,11 +7,36 @@ class Febraban150A < FormatSection
7
7
 
8
8
  ID_SERVICO = "DÉBITO AUTOMÁTICO"
9
9
 
10
- def initialize master
10
+ def initialize(master, versao = Febraban150.versao_disponivels[:versao_05])
11
11
  super(master, true, true, false)
12
12
 
13
+ case versao
14
+ when '04'
15
+ self.monta_versao_04
16
+ when '05'
17
+ self.monta_versao_05
18
+ end
19
+ end
20
+
21
+ private
22
+ def monta_versao_04
23
+ @section = Section.new({
24
+ 0 => Position.new(1, 1, false, 'A', true), # Código do Registro
25
+ 1 => Position.new(2, 1, true), # Código Remessa (1-Remessa, 2-Retorno)
26
+ 2 => Position.new(3, 20, false), # Código de ID enviado pelo Banco
27
+ 3 => Position.new(4, 20, false), # Nome da Empresa
28
+ 4 => Position.new(5, 3, true), # Código do Banco
29
+ 5 => Position.new(6, 20, false), # Nome do Banco
30
+ 6 => Position.new(7, 8, true), # Data de Geração de Arquivo
31
+ 7 => Position.new(8, 6, true), # Número Sequencial do Arquivo
32
+ 8 => Position.new(9, 2, true, 5), # Versão do Layout (5, desde 05.05.2008)
33
+ 9 => Position.new(10, 17, false, Febraban150A::ID_SERVICO), # Identificação ("DÉBITO AUTOMÁTICO")
34
+ 10 => Position.new(11, 52, false), # Reservado pelo Sistema
35
+ })
36
+ end
37
+ def monta_versao_05
13
38
  @section = Section.new({
14
- 0 => Position.new(1, 1, false, "A", true), # Código do Registro
39
+ 0 => Position.new(1, 1, false,'A', true), # Código do Registro
15
40
  1 => Position.new(2, 1, true), # Código Remessa (1-Remessa, 2-Retorno)
16
41
  2 => Position.new(3, 20, false), # Código de ID enviado pelo Banco
17
42
  3 => Position.new(4, 20, false), # Nome da Empresa
@@ -28,6 +53,7 @@ class Febraban150A < FormatSection
28
53
  #-------------------------------------------------------------------
29
54
  #-------------------------------------------------------------------
30
55
  # Gerais
56
+ public
31
57
  def process_section file
32
58
  self.set_codigo_remessa file[1..1]
33
59
  self.set_codigo_convenio file[2..21]
@@ -44,6 +70,7 @@ class Febraban150A < FormatSection
44
70
  #-------------------------------------------------------------------
45
71
  #-------------------------------------------------------------------
46
72
  # Validações
73
+ public
47
74
  def is_valid?
48
75
  result = (self.get_codigo_remessa > 0 and
49
76
  self.get_codigo_convenio.length > 0 and
@@ -59,6 +86,7 @@ class Febraban150A < FormatSection
59
86
  #-------------------------------------------------------------------
60
87
  #-------------------------------------------------------------------
61
88
  # Getters
89
+ public
62
90
  def get_codigo_remessa
63
91
  self.get_section_value(1).to_i
64
92
  end
@@ -99,6 +127,7 @@ class Febraban150A < FormatSection
99
127
  #-------------------------------------------------------------------
100
128
  #-------------------------------------------------------------------
101
129
  # Setters
130
+ public
102
131
  def set_codigo_remessa code
103
132
  code = code.to_i
104
133
 
@@ -3,7 +3,7 @@
3
3
  #-------------------------------------------------------------------
4
4
  # Cadastro Débito Automático - Banco
5
5
  class Febraban150B < FormatSection
6
- def initialize master
6
+ def initialize(master, versao = Febraban150.versao_disponivels[:versao_05])
7
7
  super(master, true, false)
8
8
 
9
9
  @section = Section.new({
@@ -3,7 +3,7 @@
3
3
  #-------------------------------------------------------------------
4
4
  # Ocorrências - Empresa
5
5
  class Febraban150C < FormatSection
6
- def initialize master
6
+ def initialize(master, versao = Febraban150.versao_disponivels[:versao_05])
7
7
  super(master, false, true)
8
8
 
9
9
  @section = Section.new({
@@ -3,7 +3,7 @@
3
3
  #-------------------------------------------------------------------
4
4
  # Alteração da Identificação Cliente/Empresa - Empresa
5
5
  class Febraban150D < FormatSection
6
- def initialize master
6
+ def initialize(master, versao = Febraban150.versao_disponivels[:versao_05])
7
7
  super(master, false, true)
8
8
 
9
9
  @section = Section.new({
@@ -3,11 +3,36 @@
3
3
  #-------------------------------------------------------------------
4
4
  # Débito em Conta - Empresa
5
5
  class Febraban150E < FormatSection
6
- def initialize master
6
+ def initialize(master, versao = Febraban150.versao_disponivels[:versao_05])
7
7
  super(master, false, true)
8
8
 
9
+ case versao
10
+ when '04'
11
+ self.monta_versao_04
12
+ when '05'
13
+ self.monta_versao_05
14
+ end
15
+ end
16
+
17
+ private
18
+ def monta_versao_04
19
+ @section = Section.new({
20
+ 0 => Position.new(1, 1, false, 'E', true), # Código do Registro
21
+ 1 => Position.new(2, 25, false), # Identificação do Cliente Empresa
22
+ 2 => Position.new(3, 4, false), # Agência para Débito
23
+ 3 => Position.new(4, 14, false), # Identificação Cliente Banco
24
+ 4 => Position.new(5, 8, true), # Data do Vencimento
25
+ 5 => Position.new(6, 15, true), # Valor do Débito
26
+ 6 => Position.new(7, 2, false), # Código da Moeda (01-UFIR, 03-REAL)
27
+ 7 => Position.new(8, 60, false), # Uso da Empresa, sem processamento
28
+ 10 => Position.new(9, 20, false), # Reservado pelo Sistema
29
+ 11 => Position.new(10, 1, true) # Código de Movimento (0-Normal, 1-Cancelar)
30
+ })
31
+ end
32
+
33
+ def monta_versao_05
9
34
  @section = Section.new({
10
- 0 => Position.new(1, 1, false, "E", true), # Código do Registro
35
+ 0 => Position.new(1, 1, false, 'E', true), # Código do Registro
11
36
  1 => Position.new(2, 25, false), # Identificação do Cliente Empresa
12
37
  2 => Position.new(3, 4, false), # Agência para Débito
13
38
  3 => Position.new(4, 14, false), # Identificação Cliente Banco
@@ -25,6 +50,7 @@ class Febraban150E < FormatSection
25
50
  #-------------------------------------------------------------------
26
51
  #-------------------------------------------------------------------
27
52
  # Gerais
53
+ public
28
54
  def process_section file
29
55
  self.set_id_cliente_empresa file[1..25]
30
56
  self.set_agencia_debito file[26..29]
@@ -3,7 +3,7 @@
3
3
  #-------------------------------------------------------------------
4
4
  # Retorno do Débito Automático - Banco
5
5
  class Febraban150F < FormatSection
6
- def initialize master
6
+ def initialize(master, versao = Febraban150.versao_disponivels[:versao_05])
7
7
  super(master, true, false)
8
8
 
9
9
  @section = Section.new({
@@ -3,7 +3,7 @@
3
3
  #-------------------------------------------------------------------
4
4
  # Ocorrência da Alteração Cliente/Empresa - Banco
5
5
  class Febraban150H < FormatSection
6
- def initialize master
6
+ def initialize(master, versao = Febraban150.versao_disponivels[:versao_05])
7
7
  super(master, true, false)
8
8
 
9
9
  @section = Section.new({
@@ -3,7 +3,7 @@
3
3
  #-------------------------------------------------------------------
4
4
  # Incentivo de Débito Automático - Empresa
5
5
  class Febraban150I < FormatSection
6
- def initialize master
6
+ def initialize(master, versao = Febraban150.versao_disponivels[:versao_05])
7
7
  super(master, false, true)
8
8
 
9
9
  @section = Section.new({
@@ -3,7 +3,7 @@
3
3
  #-------------------------------------------------------------------
4
4
  # Confirmação de Processamento - Empresa/Banco
5
5
  class Febraban150J < FormatSection
6
- def initialize master
6
+ def initialize(master, versao = Febraban150.versao_disponivels[:versao_05])
7
7
  super(master, true, true)
8
8
 
9
9
  @section = Section.new({
@@ -4,7 +4,7 @@
4
4
  # Lei 10833, Cobrança não-cumulativa COFINS - Empresa
5
5
  # http://www.planalto.gov.br/ccivil_03/leis/2003/L10.833compilado.htm
6
6
  class Febraban150K < FormatSection
7
- def initialize master
7
+ def initialize(master, versao = Febraban150.versao_disponivels[:versao_05])
8
8
  super(master, false, true)
9
9
 
10
10
  @section = Section.new({
@@ -3,7 +3,7 @@
3
3
  #-------------------------------------------------------------------
4
4
  # Cronograma de Faturamento Contas/Tributos - Empresa
5
5
  class Febraban150L < FormatSection
6
- def initialize master
6
+ def initialize(master, versao = Febraban150.versao_disponivels[:versao_05])
7
7
  super(master, false, true)
8
8
 
9
9
  @section = Section.new({
@@ -3,7 +3,7 @@
3
3
  #-------------------------------------------------------------------
4
4
  # Total de Clientes debitados - Banco
5
5
  class Febraban150T < FormatSection
6
- def initialize master
6
+ def initialize(master, versao = Febraban150.versao_disponivels[:versao_05])
7
7
  super(master, true, false)
8
8
 
9
9
  @section = Section.new({
@@ -3,7 +3,7 @@
3
3
  #-------------------------------------------------------------------
4
4
  # Relação de Agências - Banco
5
5
  class Febraban150X < FormatSection
6
- def initialize master
6
+ def initialize(master, versao = Febraban150.versao_disponivels[:versao_05])
7
7
  super(master, true, false, false)
8
8
 
9
9
  @section = Section.new({
@@ -3,20 +3,40 @@
3
3
  #-------------------------------------------------------------------
4
4
  # Footer/Trailler - Empresa/Banco
5
5
  class Febraban150Z < FormatSection
6
- def initialize master
6
+ def initialize(master, versao = Febraban150.versao_disponivels[:versao_05])
7
7
  super(master, true, true, false)
8
8
 
9
+ case versao
10
+ when '04'
11
+ self.monta_versao_04
12
+ when '05'
13
+ self.monta_versao_05
14
+ end
15
+ end
16
+
17
+ private
18
+ def monta_versao_04
19
+ @section = Section.new({
20
+ 0 => Position.new(1, 1, false, 'Z', true), # Código do Registro
21
+ 1 => Position.new(2, 6, true), # Total de Registros no Arquivo
22
+ 2 => Position.new(3, 17, true), # Valor Total dos Registros
23
+ 3 => Position.new(4, 126, false) # Reservado pelo Sistema
24
+ })
25
+ end
26
+
27
+ def monta_versao_05
9
28
  @section = Section.new({
10
- 0 => Position.new(1, 1, false, "Z", true), # Código do Registro
11
- 1 => Position.new(2, 6, true), # Total de Registros no Arquivo
12
- 2 => Position.new(3, 17, true), # Valor Total dos Registros
13
- 3 => Position.new(4, 126, false) # Reservado pelo Sistema
29
+ 0 => Position.new(1, 1, false, 'Z', true), # Código do Registro
30
+ 1 => Position.new(2, 6, true), # Total de Registros no Arquivo
31
+ 2 => Position.new(3, 17, true), # Valor Total dos Registros
32
+ 3 => Position.new(4, 126, false) # Reservado pelo Sistema
14
33
  })
15
34
  end
16
35
 
17
36
  #-------------------------------------------------------------------
18
37
  #-------------------------------------------------------------------
19
38
  # Gerais
39
+ public
20
40
  def process_section file
21
41
  self.set_total_registros file[1..6]
22
42
  self.set_valor_total file[7..23]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: formatos-febraban
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.25
4
+ version: 0.3.00a
5
5
  platform: ruby
6
6
  authors:
7
- - josé Ricardo Almeida
7
+ - José Ricardo Almeida
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-04-29 00:00:00.000000000 Z
11
+ date: 2015-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,7 +52,7 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- description: Formatos para envido de dados bancários da FEBRABAN
55
+ description: Formatos para envio e recebimento de dados bancários da FEBRABAN
56
56
  email:
57
57
  - jose@trackmob.com.br
58
58
  executables: []
@@ -61,6 +61,7 @@ extra_rdoc_files: []
61
61
  files:
62
62
  - ".gitignore"
63
63
  - ".rspec"
64
+ - ".ruby-version"
64
65
  - ".travis.yml"
65
66
  - CODE_OF_CONDUCT.md
66
67
  - Gemfile
@@ -116,9 +117,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
116
117
  version: '0'
117
118
  required_rubygems_version: !ruby/object:Gem::Requirement
118
119
  requirements:
119
- - - ">="
120
+ - - ">"
120
121
  - !ruby/object:Gem::Version
121
- version: '0'
122
+ version: 1.3.1
122
123
  requirements: []
123
124
  rubyforge_project:
124
125
  rubygems_version: 2.4.5