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
  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_017Object

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



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

def segmento_s_posicao_016_a_017
  '01'
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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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 ################



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

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 #####################



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

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