formatos-febraban 0.3.09 → 0.3.10

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: 92830bc5e81ed63a250ee970b65311b5721d62c1
4
- data.tar.gz: 21d8f14dec053c15208cdf132fa173f872212a69
3
+ metadata.gz: d46b242370c1c7229cc98c62581e4bc36729b5f2
4
+ data.tar.gz: 21e64b390cdab99f902be1145162e789f65c5c22
5
5
  SHA512:
6
- metadata.gz: 4e5a21529dec16068b5e3ef6cef256997629bd08adbb7a97f6a6287f099fdf4ef1551677f50bba7147799699effa40bc74815ca3e1c66f02170094380e222c49
7
- data.tar.gz: 9ef0780cf3df6f7795aee43f54a225466a8f586107c69001033945a3001abd5c6b95944a3d4ace96f2c4471aa8ee243fae396560149a62327f5d37548d71c02c
6
+ metadata.gz: 5b4f1263ac58f538c37889f1f6225072ea9f377833d67c54217b49e99adefa008317dc41143f78253e4e16492de233f32a24170fc4ee83893494d324cc87694b
7
+ data.tar.gz: 0e23bcdab79cf50b34a4a0bbb5416b3bef39119ff341f597d793f0e4cd5ea519be9caee15b06585276f791262017e18ae6af2babcd3dbc2fa7e671e20ca14e03
@@ -1,5 +1,5 @@
1
1
  module Formatos
2
2
  module Febraban
3
- VERSION = '0.3.09'
3
+ VERSION = '0.3.10'
4
4
  end
5
5
  end
@@ -10,7 +10,9 @@ class Febraban150A < FormatSection
10
10
  def initialize(master, versao = Febraban150::VERSAO)
11
11
  super(master, true, true, false)
12
12
 
13
- case versao
13
+ @varsao = versao
14
+
15
+ case @versao
14
16
  when '04'
15
17
  self.monta_versao_04
16
18
  when '05'
@@ -34,6 +36,7 @@ class Febraban150A < FormatSection
34
36
  10 => Position.new(11, 52, false), # Reservado pelo Sistema
35
37
  })
36
38
  end
39
+
37
40
  def monta_versao_05
38
41
  @section = Section.new({
39
42
  0 => Position.new(1, 1, false,'A', true), # Código do Registro
@@ -54,7 +57,30 @@ class Febraban150A < FormatSection
54
57
  #-------------------------------------------------------------------
55
58
  # Gerais
56
59
  public
57
- def process_section file
60
+ def process_section(file)
61
+ case @versao
62
+ when '04'
63
+ self.processa_arquivo_04(file)
64
+ when '05'
65
+ self.processa_arquivo_05(file)
66
+ end
67
+ end
68
+
69
+ protected
70
+ def processa_arquivo_04(file)
71
+ self.set_codigo_remessa file[1..1]
72
+ self.set_codigo_convenio file[2..21]
73
+ self.set_nome_empresa file[22..41]
74
+ self.set_codigo_banco file[42..44]
75
+ self.set_nome_banco file[45..64]
76
+ self.set_data_geracao file[65..72]
77
+ self.set_numero_sequencial file[73..78]
78
+ self.set_versao_layout file[79..80]
79
+ self.set_identificacao_servico file[81..99]
80
+ self.set_reservado file[98..149]
81
+ end
82
+
83
+ def processa_arquivo_05(file)
58
84
  self.set_codigo_remessa file[1..1]
59
85
  self.set_codigo_convenio file[2..21]
60
86
  self.set_nome_empresa file[22..41]
@@ -72,6 +98,28 @@ class Febraban150A < FormatSection
72
98
  # Validações
73
99
  public
74
100
  def is_valid?
101
+ case @versao
102
+ when '04'
103
+ self.is_valid_04?
104
+ when '05'
105
+ self.is_valid_05?
106
+ end
107
+ end
108
+
109
+ protected
110
+ def is_valid_04?
111
+ result = (self.get_codigo_remessa > 0 and
112
+ self.get_codigo_convenio.length > 0 and
113
+ self.get_nome_empresa.length > 0 and
114
+ self.get_codigo_banco > 0 and
115
+ self.get_nome_banco.length > 0 and
116
+ !self.get_data_geracao.nil? and
117
+ self.get_numero_sequencial > 0 and
118
+ self.get_versao_layout > 0 and
119
+ self.get_identificacao_servico.length > 0)
120
+ end
121
+
122
+ def is_valid_05?
75
123
  result = (self.get_codigo_remessa > 0 and
76
124
  self.get_codigo_convenio.length > 0 and
77
125
  self.get_nome_empresa.length > 0 and
@@ -6,6 +6,8 @@ class Febraban150E < FormatSection
6
6
  def initialize(master, versao = Febraban150::VERSAO)
7
7
  super(master, false, true)
8
8
 
9
+ @versao = versao
10
+
9
11
  case versao
10
12
  when '04'
11
13
  self.monta_versao_04
@@ -25,7 +27,7 @@ class Febraban150E < FormatSection
25
27
  5 => Position.new(6, 15, true), # Valor do Débito
26
28
  6 => Position.new(7, 2, false), # Código da Moeda (01-UFIR, 03-REAL)
27
29
  7 => Position.new(8, 60, false), # Uso da Empresa, sem processamento
28
- 10 => Position.new(9, 20, false), # Reservado pelo Sistema
30
+ 10 => Position.new(9, 20, false), # Reservado pelo Sistema
29
31
  11 => Position.new(10, 1, true) # Código de Movimento (0-Normal, 1-Cancelar)
30
32
  })
31
33
  end
@@ -51,7 +53,29 @@ class Febraban150E < FormatSection
51
53
  #-------------------------------------------------------------------
52
54
  # Gerais
53
55
  public
54
- def process_section file
56
+ def process_section(file)
57
+ case @versao
58
+ when '04'
59
+ self.processa_arquivo_04(file)
60
+ when '05'
61
+ self.processa_arquivo_05(file)
62
+ end
63
+ end
64
+
65
+ protected
66
+ def processa_arquivo_04(file)
67
+ self.set_id_cliente_empresa file[1..25]
68
+ self.set_agencia_debito file[26..29]
69
+ self.set_id_cliente_banco file[30..43]
70
+ self.set_data_vencimento file[44..51]
71
+ self.set_valor_debito file[52..66]
72
+ self.set_codigo_moeda file[67..68]
73
+ self.set_obs_empresa file[69..128]
74
+ self.set_reservado file[129..148]
75
+ self.set_cod_movimento file[149..149]
76
+ end
77
+
78
+ def processa_arquivo_05(file)
55
79
  self.set_id_cliente_empresa file[1..25]
56
80
  self.set_agencia_debito file[26..29]
57
81
  self.set_id_cliente_banco file[30..43]
@@ -68,7 +92,29 @@ class Febraban150E < FormatSection
68
92
  #-------------------------------------------------------------------
69
93
  #-------------------------------------------------------------------
70
94
  # Validações
95
+ public
71
96
  def is_valid?
97
+ case @versao
98
+ when '04'
99
+ self.is_valid_04?
100
+ when '05'
101
+ self.is_valid_05?
102
+ end
103
+ end
104
+
105
+ protected
106
+ def is_valid_04?
107
+ result = (self.get_id_cliente_empresa.length > 0 and
108
+ self.get_id_cliente_banco.length > 0 and
109
+ !self.get_data_vencimento.nil? and
110
+ self.get_valor_debito > 0 and
111
+ self.get_codigo_moeda.length > 0 and
112
+ self.get_obs_empresa.length > 0 and
113
+ (self.get_cod_movimento == 0 or
114
+ self.get_cod_movimento == 1))
115
+ end
116
+
117
+ def is_valid_05?
72
118
  result = (self.get_id_cliente_empresa.length > 0 and
73
119
  self.get_id_cliente_banco.length > 0 and
74
120
  !self.get_data_vencimento.nil? and
@@ -76,10 +122,10 @@ class Febraban150E < FormatSection
76
122
  self.get_codigo_moeda.length > 0 and
77
123
  self.get_obs_empresa.length > 0 and
78
124
  (self.get_tipo_id_cliente == 1 or
79
- self.get_tipo_id_cliente == 2) and
125
+ self.get_tipo_id_cliente == 2) and
80
126
  self.get_id_cliente.length == 15 and
81
127
  (self.get_cod_movimento == 0 or
82
- self.get_cod_movimento == 1))
128
+ self.get_cod_movimento == 1))
83
129
  end
84
130
 
85
131
  #-------------------------------------------------------------------
@@ -6,6 +6,8 @@ class Febraban150Z < FormatSection
6
6
  def initialize(master, versao = Febraban150::VERSAO)
7
7
  super(master, true, true, false)
8
8
 
9
+ @varsao = versao
10
+
9
11
  case versao
10
12
  when '04'
11
13
  self.monta_versao_04
@@ -37,7 +39,23 @@ class Febraban150Z < FormatSection
37
39
  #-------------------------------------------------------------------
38
40
  # Gerais
39
41
  public
40
- def process_section file
42
+ def process_section(file)
43
+ case @versao
44
+ when '04'
45
+ self.processa_arquivo_04(file)
46
+ when '05'
47
+ self.processa_arquivo_05(file)
48
+ end
49
+ end
50
+
51
+ protected
52
+ def processa_arquivo_04(file)
53
+ self.set_total_registros file[1..6]
54
+ self.set_valor_total file[7..23]
55
+ self.set_reservado file[24..149]
56
+ end
57
+
58
+ def processa_arquivo_05(file)
41
59
  self.set_total_registros file[1..6]
42
60
  self.set_valor_total file[7..23]
43
61
  self.set_reservado file[24..149]
@@ -47,6 +65,21 @@ class Febraban150Z < FormatSection
47
65
  #-------------------------------------------------------------------
48
66
  # Validações
49
67
  def is_valid?
68
+ case @versao
69
+ when '04'
70
+ self.is_valid_04?
71
+ when '05'
72
+ self.is_valid_05?
73
+ end
74
+ end
75
+
76
+ protected
77
+ def is_valid_04?
78
+ result = (self.get_total_registros > 0 and
79
+ self.get_valor_total > 0)
80
+ end
81
+
82
+ def is_valid_05?
50
83
  result = (self.get_total_registros > 0 and
51
84
  self.get_valor_total > 0)
52
85
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: formatos-febraban
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.09
4
+ version: 0.3.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - José Ricardo Almeida