Module: BrBoleto::Remessa::Cnab240::Helper::SegmentoS

Included in:
Base
Defined in:
lib/br_boleto/remessa/cnab240/helper/segmento_s.rb

Instance Method Summary collapse

Instance Method Details

#monta_segmento_s(pagamento, nr_lote, sequencial) ⇒ String

Monta o registro segmento S do arquivo

Parameters:

  • pagamento (BrBoleto::Remessa::Pagamento)

    objeto contendo os detalhes do boleto (valor, vencimento, sacado, etc)

  • nr_lote (Integer)

    numero do lote que o segmento esta inserido

  • sequencial (Integer)

    numero sequencial do registro no lote

Returns:

  • (String)


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/br_boleto/remessa/cnab240/helper/segmento_s.rb', line 17

def monta_segmento_s(pagamento, nr_lote, sequencial)
  segmento_s = ''
  segmento_s << segmento_s_posicao_001_a_003 
  segmento_s << segmento_s_posicao_004_a_007(nr_lote)
  segmento_s << segmento_s_posicao_008_a_008
  segmento_s << segmento_s_posicao_009_a_013(sequencial)
  segmento_s << segmento_s_posicao_014_a_014
  segmento_s << segmento_s_posicao_015_a_015
  segmento_s << segmento_s_posicao_016_a_017(pagamento)
  segmento_s << segmento_s_posicao_018_a_018(pagamento)
  if pagamento.tipo_impressao == '3'
    segmento_s << segmento_s_tipo_impressao_3(pagamento)
  else
    segmento_s << segmento_s_tipo_impressao_1_ou_2(pagamento)
  end
  segmento_s.upcase
end

#segmento_s_posicao_001_a_003Object

Código do banco 3 posições



38
39
40
# File 'lib/br_boleto/remessa/cnab240/helper/segmento_s.rb', line 38

def segmento_s_posicao_001_a_003 
  conta.codigo_banco
end

#segmento_s_posicao_004_a_007(numero_do_lote) ⇒ Object

Lote de Serviço: Número seqüencial para identificar univocamente um lote de serviço. Criado e controlado pelo responsável pela geração magnética dos dados contidos no arquivo. Preencher com ‘0001’ para o primeiro lote do arquivo. Para os demais: número do lote anterior acrescido de 1. O número não poderá ser repetido dentro do arquivo. 4 posições



48
49
50
# File 'lib/br_boleto/remessa/cnab240/helper/segmento_s.rb', line 48

def segmento_s_posicao_004_a_007(numero_do_lote)
  "#{numero_do_lote}".adjust_size_to(4, '0', :right)
end

#segmento_s_posicao_008_a_008Object

Tipo do registro -> Padrão 3 1 posição



55
56
57
# File 'lib/br_boleto/remessa/cnab240/helper/segmento_s.rb', line 55

def segmento_s_posicao_008_a_008
  '3'
end

#segmento_s_posicao_009_a_013(sequencial) ⇒ Object

Nº Sequencial do Registro no Lote 5 posições



62
63
64
# File 'lib/br_boleto/remessa/cnab240/helper/segmento_s.rb', line 62

def segmento_s_posicao_009_a_013(sequencial)
  "#{sequencial}".adjust_size_to(5, '0', :right)
end

#segmento_s_posicao_014_a_014Object

Cód. Segmento do Registro Detalhe 1 posição



69
70
71
# File 'lib/br_boleto/remessa/cnab240/helper/segmento_s.rb', line 69

def segmento_s_posicao_014_a_014
  'S'
end

#segmento_s_posicao_015_a_015Object

Uso Exclusivo FEBRABAN/CNAB 1 posição



76
77
78
# File 'lib/br_boleto/remessa/cnab240/helper/segmento_s.rb', line 76

def segmento_s_posicao_015_a_015
  ' '
end

#segmento_s_posicao_016_a_017(pagamento) ⇒ Object

Código de Movimento Remessa - 01 = Entrada de Titulos 2 posições



83
84
85
86
# File 'lib/br_boleto/remessa/cnab240/helper/segmento_s.rb', line 83

def segmento_s_posicao_016_a_017(pagamento)
  code = "#{pagamento.identificacao_ocorrencia}".rjust(2, '0')
  "#{conta.get_codigo_movimento_remessa(code, 240)}".adjust_size_to(2, '0')
end

#segmento_s_posicao_018_a_018(pagamento) ⇒ Object

Tipo de impressão

1 - Frente do Bloqueto
2 - Verso do Bloauqto
3 - Corpo de instru

1 posição



94
95
96
# File 'lib/br_boleto/remessa/cnab240/helper/segmento_s.rb', line 94

def segmento_s_posicao_018_a_018(pagamento)
  "#{pagamento.tipo_impressao}".adjust_size_to(1)
end

#segmento_s_posicao_019_a_020_tipo_impressao_1_ou_2(pagamento) ⇒ Object

Numero da Linha a ser impressa 2 posições



110
111
112
# File 'lib/br_boleto/remessa/cnab240/helper/segmento_s.rb', line 110

def segmento_s_posicao_019_a_020_tipo_impressao_1_ou_2(pagamento)
  '01'
end

#segmento_s_posicao_019_a_058_tipo_impressao_3(pagamento) ⇒ Object

Informação 5 40 posições



151
152
153
# File 'lib/br_boleto/remessa/cnab240/helper/segmento_s.rb', line 151

def segmento_s_posicao_019_a_058_tipo_impressao_3(pagamento)
  ''.rjust(40, ' ')
end

#segmento_s_posicao_021_a_160_tipo_impressao_1_ou_2(pagamento) ⇒ Object

Mensagem a ser impresas 140 posições



116
117
118
# File 'lib/br_boleto/remessa/cnab240/helper/segmento_s.rb', line 116

def segmento_s_posicao_021_a_160_tipo_impressao_1_ou_2(pagamento)
  ''.rjust(140, ' ')
end

#segmento_s_posicao_059_a_098_tipo_impressao_3(pagamento) ⇒ Object

Informação 6 40 posições



158
159
160
# File 'lib/br_boleto/remessa/cnab240/helper/segmento_s.rb', line 158

def segmento_s_posicao_059_a_098_tipo_impressao_3(pagamento)
  ''.rjust(40, ' ')
end

#segmento_s_posicao_099_a_138_tipo_impressao_3(pagamento) ⇒ Object

Informação 7 40 posições



165
166
167
# File 'lib/br_boleto/remessa/cnab240/helper/segmento_s.rb', line 165

def segmento_s_posicao_099_a_138_tipo_impressao_3(pagamento)
  ''.rjust(40, ' ')
end

#segmento_s_posicao_139_a_178_tipo_impressao_3(pagamento) ⇒ Object

Informação 8 40 posições



172
173
174
# File 'lib/br_boleto/remessa/cnab240/helper/segmento_s.rb', line 172

def segmento_s_posicao_139_a_178_tipo_impressao_3(pagamento)
  ''.rjust(40, ' ')
end

#segmento_s_posicao_161_a_162_tipo_impressao_1_ou_2(pagamento) ⇒ Object

Tipo de caractere a ser impresso

'01' = Normal
'02' = It

2 posições



126
127
128
# File 'lib/br_boleto/remessa/cnab240/helper/segmento_s.rb', line 126

def segmento_s_posicao_161_a_162_tipo_impressao_1_ou_2(pagamento)
  '01'
end

#segmento_s_posicao_163_a_240_tipo_impressao_1_ou_2Object

Uso exclusivo 78 posições



132
133
134
# File 'lib/br_boleto/remessa/cnab240/helper/segmento_s.rb', line 132

def segmento_s_posicao_163_a_240_tipo_impressao_1_ou_2
  ''.rjust(78, ' ')
end

#segmento_s_posicao_179_a_218_tipo_impressao_3(pagamento) ⇒ Object

Informação 9 40 posições



179
180
181
# File 'lib/br_boleto/remessa/cnab240/helper/segmento_s.rb', line 179

def segmento_s_posicao_179_a_218_tipo_impressao_3(pagamento)
  ''.rjust(40, ' ')
end

#segmento_s_posicao_219_a_240_tipo_impressao_3Object

Uso exclusivo 78 posições



185
186
187
# File 'lib/br_boleto/remessa/cnab240/helper/segmento_s.rb', line 185

def segmento_s_posicao_219_a_240_tipo_impressao_3
  ''.rjust(22, ' ')
end

#segmento_s_tipo_impressao_1_ou_2(pagamento) ⇒ Object

TIPO DE IMPRESÃO 1 OU 2 ################



99
100
101
102
103
104
105
106
# File 'lib/br_boleto/remessa/cnab240/helper/segmento_s.rb', line 99

def segmento_s_tipo_impressao_1_ou_2(pagamento)
  segmento = ''
  segmento << segmento_s_posicao_019_a_020_tipo_impressao_1_ou_2(pagamento)
  segmento << segmento_s_posicao_021_a_160_tipo_impressao_1_ou_2(pagamento)
  segmento << segmento_s_posicao_161_a_162_tipo_impressao_1_ou_2(pagamento)
  segmento << segmento_s_posicao_163_a_240_tipo_impressao_1_ou_2
  segmento
end

#segmento_s_tipo_impressao_3(pagamento) ⇒ Object

TIPO DE IMPRESSÃO 3 #####################



138
139
140
141
142
143
144
145
146
147
# File 'lib/br_boleto/remessa/cnab240/helper/segmento_s.rb', line 138

def segmento_s_tipo_impressao_3(pagamento)
  segmento = ''
  segmento << segmento_s_posicao_019_a_058_tipo_impressao_3(pagamento)
  segmento << segmento_s_posicao_059_a_098_tipo_impressao_3(pagamento)
  segmento << segmento_s_posicao_099_a_138_tipo_impressao_3(pagamento)
  segmento << segmento_s_posicao_139_a_178_tipo_impressao_3(pagamento)
  segmento << segmento_s_posicao_179_a_218_tipo_impressao_3(pagamento)
  segmento << segmento_s_posicao_219_a_240_tipo_impressao_3
  segmento
end