Class: BrBoleto::Remessa::Cnab240::Caixa

Inherits:
Base show all
Defined in:
lib/br_boleto/remessa/cnab240/caixa.rb

Instance Attribute Summary

Attributes inherited from Base

#lotes, #mensagem_1, #mensagem_2

Attributes inherited from Base

#data_hora_arquivo, #sequencial_remessa

Instance Method Summary collapse

Methods inherited from Base

class_for_lote, #dados_do_arquivo, #monta_lote, #pagamento_valid_distribuicao_boleto_length, #pagamento_valid_emissao_boleto_length

Methods included from Helper::TrailerArquivo

#monta_trailer_arquivo, #trailer_arquivo_posicao_001_a_003, #trailer_arquivo_posicao_004_a_007, #trailer_arquivo_posicao_008_a_008, #trailer_arquivo_posicao_009_a_017, #trailer_arquivo_posicao_018_a_023, #trailer_arquivo_posicao_024_a_029, #trailer_arquivo_posicao_030_a_035, #trailer_arquivo_posicao_036_a_240

Methods included from Helper::TrailerLote

#monta_trailer_lote, #trailer_lote_posicao_001_a_003, #trailer_lote_posicao_004_a_007, #trailer_lote_posicao_008_a_008, #trailer_lote_posicao_009_a_017, #trailer_lote_posicao_018_a_023, #trailer_lote_posicao_024_a_240

Methods included from Helper::SegmentoS

#monta_segmento_s, #segmento_s_posicao_001_a_003, #segmento_s_posicao_004_a_007, #segmento_s_posicao_008_a_008, #segmento_s_posicao_009_a_013, #segmento_s_posicao_014_a_014, #segmento_s_posicao_015_a_015, #segmento_s_posicao_016_a_017, #segmento_s_posicao_018_a_018, #segmento_s_posicao_019_a_058_tipo_impressao_3, #segmento_s_posicao_021_a_160_tipo_impressao_1_ou_2, #segmento_s_posicao_059_a_098_tipo_impressao_3, #segmento_s_posicao_099_a_138_tipo_impressao_3, #segmento_s_posicao_139_a_178_tipo_impressao_3, #segmento_s_posicao_163_a_240_tipo_impressao_1_ou_2, #segmento_s_posicao_179_a_218_tipo_impressao_3, #segmento_s_posicao_219_a_240_tipo_impressao_3, #segmento_s_tipo_impressao_1_ou_2, #segmento_s_tipo_impressao_3

Methods included from Helper::SegmentoR

#monta_segmento_r, #segmento_r_posicao_001_a_003, #segmento_r_posicao_004_a_007, #segmento_r_posicao_008_a_008, #segmento_r_posicao_009_a_013, #segmento_r_posicao_014_a_014, #segmento_r_posicao_015_a_015, #segmento_r_posicao_016_a_017, #segmento_r_posicao_018_a_018, #segmento_r_posicao_019_a_026, #segmento_r_posicao_027_a_041, #segmento_r_posicao_042_a_042, #segmento_r_posicao_043_a_050, #segmento_r_posicao_051_a_065, #segmento_r_posicao_066_a_066, #segmento_r_posicao_067_a_074, #segmento_r_posicao_075_a_089, #segmento_r_posicao_090_a_099, #segmento_r_posicao_100_a_139, #segmento_r_posicao_140_a_179, #segmento_r_posicao_180_a_199, #segmento_r_posicao_200_a_207, #segmento_r_posicao_208_a_210, #segmento_r_posicao_211_a_215, #segmento_r_posicao_216_a_216, #segmento_r_posicao_217_a_228, #segmento_r_posicao_229_a_229, #segmento_r_posicao_230_a_230, #segmento_r_posicao_231_a_231, #segmento_r_posicao_232_a_240

Methods included from Helper::SegmentoQ

#monta_segmento_q, #segmento_q_posicao_001_a_003, #segmento_q_posicao_004_a_007, #segmento_q_posicao_008_a_008, #segmento_q_posicao_009_a_013, #segmento_q_posicao_014_a_014, #segmento_q_posicao_015_a_015, #segmento_q_posicao_016_a_017, #segmento_q_posicao_018_a_018, #segmento_q_posicao_019_a_033, #segmento_q_posicao_034_a_073, #segmento_q_posicao_074_a_113, #segmento_q_posicao_114_a_128, #segmento_q_posicao_129_a_133, #segmento_q_posicao_134_a_136, #segmento_q_posicao_137_a_151, #segmento_q_posicao_152_a_153, #segmento_q_posicao_154_a_154, #segmento_q_posicao_155_a_169, #segmento_q_posicao_170_a_209, #segmento_q_posicao_210_a_212, #segmento_q_posicao_213_a_232, #segmento_q_posicao_233_a_240

Methods included from Helper::SegmentoP

#monta_segmento_p, #segmento_p_posicao_001_a_003, #segmento_p_posicao_004_a_007, #segmento_p_posicao_008_a_008, #segmento_p_posicao_009_a_013, #segmento_p_posicao_014_a_014, #segmento_p_posicao_015_a_015, #segmento_p_posicao_016_a_017, #segmento_p_posicao_018_a_022, #segmento_p_posicao_023_a_023, #segmento_p_posicao_024_a_057, #segmento_p_posicao_058_a_058, #segmento_p_posicao_059_a_059, #segmento_p_posicao_060_a_060, #segmento_p_posicao_061_a_061, #segmento_p_posicao_062_a_062, #segmento_p_posicao_063_a_077, #segmento_p_posicao_078_a_085, #segmento_p_posicao_086_a_100, #segmento_p_posicao_101_a_105, #segmento_p_posicao_107_a_108, #segmento_p_posicao_109_a_109, #segmento_p_posicao_110_a_117, #segmento_p_posicao_118_a_118, #segmento_p_posicao_119_a_126, #segmento_p_posicao_127_a_141, #segmento_p_posicao_142_a_142, #segmento_p_posicao_143_a_150, #segmento_p_posicao_151_a_165, #segmento_p_posicao_166_a_180, #segmento_p_posicao_181_a_195, #segmento_p_posicao_221_a_221, #segmento_p_posicao_222_a_223, #segmento_p_posicao_224_a_224, #segmento_p_posicao_225_a_227, #segmento_p_posicao_228_a_229, #segmento_p_posicao_230_a_239, #segmento_p_posicao_240_a_240

Methods included from Helper::HeaderLote

#header_lote_posicao_001_a_003, #header_lote_posicao_004_a_007, #header_lote_posicao_008_a_008, #header_lote_posicao_009_a_009, #header_lote_posicao_010_a_011, #header_lote_posicao_012_a_013, #header_lote_posicao_014_a_016, #header_lote_posicao_017_a_017, #header_lote_posicao_018_a_018, #header_lote_posicao_019_a_033, #header_lote_posicao_034_a_053, #header_lote_posicao_054_a_073, #header_lote_posicao_074_a_103, #header_lote_posicao_104_a_143, #header_lote_posicao_144_a_183, #header_lote_posicao_184_a_191, #header_lote_posicao_192_a_199, #header_lote_posicao_200_a_207, #header_lote_posicao_208_a_240, #monta_header_lote

Methods included from Helper::HeaderArquivo

#header_arquivo_posicao_001_a_003, #header_arquivo_posicao_004_a_007, #header_arquivo_posicao_008_a_008, #header_arquivo_posicao_009_a_017, #header_arquivo_posicao_018_a_018, #header_arquivo_posicao_019_a_032, #header_arquivo_posicao_033_a_052, #header_arquivo_posicao_053_a_072, #header_arquivo_posicao_073_a_102, #header_arquivo_posicao_103_a_132, #header_arquivo_posicao_133_a_142, #header_arquivo_posicao_143_a_143, #header_arquivo_posicao_144_a_151, #header_arquivo_posicao_152_a_157, #header_arquivo_posicao_158_a_163, #header_arquivo_posicao_164_a_166, #header_arquivo_posicao_167_a_171, #header_arquivo_posicao_172_a_191, #header_arquivo_posicao_192_a_211, #header_arquivo_posicao_212_a_240, #monta_header_arquivo

Methods inherited from Base

#data_geracao, #hora_geracao, #pagamento_valid_cod_desconto_length, #pagamento_valid_distribuicao_boleto_length, #pagamento_valid_emissao_boleto_length, #pagamento_valid_tipo_impressao_required, #persisted?

Methods included from HaveConta

#conta, #conta=

Methods inherited from ActiveModelBase

#assign_attributes, #default_values, #initialize

Constructor Details

This class inherits a constructor from BrBoleto::ActiveModelBase

Instance Method Details

#codigo_convenioObject

Uso exclusivo caixa CAMPO TAMANHO


num. convenio 20 Zeros

TOTAL = 20 posições



22
23
24
# File 'lib/br_boleto/remessa/cnab240/caixa.rb', line 22

def codigo_convenio
  ''.rjust(20, '0')
end

#complemento_header_arquivoObject

Complemento do header do arquivo - Chamado em header_arquivo_posicao_212_a_240 DESCRIÇÃO TAMANHO POSIÇÃO


Versão aplicativo CAIXA 04 212 - 215 USO FEBRABAN 25 216 - 240

TOTAL = 29 posições



68
69
70
71
72
# File 'lib/br_boleto/remessa/cnab240/caixa.rb', line 68

def complemento_header_arquivo
  complemento =  "#{conta.versao_aplicativo}".rjust(4, '0') # 04 digitos já ajustado no método
  complemento << ''.rjust(25, ' ')
  complemento
end

#complemento_p(pagamento) ⇒ Object

segmento_p_posicao_024_a_057 DESCRIÇÃO TAMANHO POSIÇÃO


codigo cedente 06 24 - 29 Uso Caixa 11 30 - 40 Modalidade carteira 02 41 - 42 nosso_numero 15 43 - 57

TOTAL = 34 posições



84
85
86
87
88
89
90
# File 'lib/br_boleto/remessa/cnab240/caixa.rb', line 84

def complemento_p(pagamento)
  complemento  = "#{conta.convenio}".adjust_size_to(6, '0', :right)
  complemento << ''.rjust(11, '0')
  complemento << "#{conta.carteira}".adjust_size_to(conta.valid_carteira_length, '1', :right)
  complemento << pagamento.nosso_numero.adjust_size_to(15, '0', :right)
  complemento
end

#complemento_trailer_lote(lote, nr_lote) ⇒ Object

trailer_lote_posicao_024_a_240(lote, nr_lote) DESCRIÇÃO TAMANHO POSIÇÃO


Qtd. cobr. Simples 06 24 - 29 _ Val. Tot Cobr. Simples 17 30 - 46 \ Qtd. cobr. Caucionada 06 47 - 52 \ Val. Tot Cobr. Caucionada 17 53 - 69 > VALORES UTILIZADOS APENAS PARA ARQUIVO DE RETORNO Qtd. cobr. Descontada 06 70 - 75 / Val. Tot Cobr. Descontada 17 76 - 92 _/ Uso FEBRABAN 148 93 - 240

TOTAL = 217 posições



145
146
147
148
149
150
# File 'lib/br_boleto/remessa/cnab240/caixa.rb', line 145

def complemento_trailer_lote(lote, nr_lote)
  complemento = ''
  complemento << ''.rjust(69, '0')  # VALORES UTILIZADOS APENAS PARA ARQUIVO DE RETORNO
  complemento << ''.rjust(148, ' ') # USO EXCLUSIVO FEBRABAN
  complemento
end

#conta_classObject



6
7
8
# File 'lib/br_boleto/remessa/cnab240/caixa.rb', line 6

def conta_class
  BrBoleto::Conta::Caixa
end

#convenio_lote(lote) ⇒ Object

Convênio do Lote

DESCRI

Cód. Cedente (convênio) 06 34-39 Uso CAIXA 14 40-53

TOTAL = 20 posições



34
35
36
37
38
# File 'lib/br_boleto/remessa/cnab240/caixa.rb', line 34

def convenio_lote(lote)
  conv_lote = "#{conta.convenio}".adjust_size_to(6, '0', :right)
  conv_lote << ''.to_s.rjust(14, '0') #Padrão '0'
  conv_lote
end

#informacoes_da_contaObject

Informação da conta DESCRIÇÃO TAMANHO POSIÇÃO


agencia 05 54 - 58 digito Verif. agencia 01 59 - 59 código convenio 06 60 - 65 código modelo pers. 07 66 - 72 uso exclusivo CAIXA 01 73 - 73

TOTAL = 20 posições



51
52
53
54
55
56
57
58
# File 'lib/br_boleto/remessa/cnab240/caixa.rb', line 51

def informacoes_da_conta
  informacoes =   "#{conta.agencia}".adjust_size_to(5, '0', :right)
  informacoes <<  conta.agencia_dv
  informacoes <<  "#{conta.convenio}".adjust_size_to(6, '0', :right)
  informacoes <<  ''.rjust(7, '0')
  informacoes <<  '0'
  informacoes
end

#segmento_p_numero_do_documento(pagamento) ⇒ Object

Segmento P para numero do documento DESCRIÇÃO TAMANHO POSIÇÃO


Nr Doc. cobrança 11 63 - 73 Uso da CAIXA 04 74 - 77

TOTAL = 15 posições



100
101
102
103
104
# File 'lib/br_boleto/remessa/cnab240/caixa.rb', line 100

def segmento_p_numero_do_documento(pagamento)
  complemento =  "#{pagamento.numero_documento}".adjust_size_to(11, '0', :right)
  complemento << ''.rjust(4, ' ')
  complemento
end

#segmento_p_posicao_106_a_106Object

Digito verificador da agência Segundo a documentação nessa posição vai o valor ‘0’

TOTAL = 01 posição



111
112
113
# File 'lib/br_boleto/remessa/cnab240/caixa.rb', line 111

def segmento_p_posicao_106_a_106
  '0'
end

#segmento_p_posicao_196_a_220(pagamento) ⇒ Object

Identificação do Título na Empresa Campo destinado para uso da Empresa Cedente para identificação do Título. Informar o Número do Documento - Seu Número (mesmo das posições 63-73 do Segmento P)

TOTAL = 25 posições



121
122
123
# File 'lib/br_boleto/remessa/cnab240/caixa.rb', line 121

def segmento_p_posicao_196_a_220(pagamento)
  "#{pagamento.numero_documento}".adjust_size_to(25, '0', :right)
end

#segmento_s_posicao_019_a_020_tipo_impressao_1_ou_2(pagamento) ⇒ Object



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

def segmento_s_posicao_019_a_020_tipo_impressao_1_ou_2(pagamento)
  '00'
end

#segmento_s_posicao_161_a_162_tipo_impressao_1_ou_2(pagamento) ⇒ Object



128
129
130
# File 'lib/br_boleto/remessa/cnab240/caixa.rb', line 128

def segmento_s_posicao_161_a_162_tipo_impressao_1_ou_2(pagamento)
  '00'
end

#valid_versao_aplicativo_requiredObject

VALIDAÇÕES ESPECÍFICAS DA DESTE OBJETO PARA A CONTA ##########



12
# File 'lib/br_boleto/remessa/cnab240/caixa.rb', line 12

def valid_versao_aplicativo_required; true end