Class: Cnab240::PagamentoBradesco
- Defined in:
- lib/cnab240/helper/pagamento_bradesco.rb
Instance Attribute Summary
Attributes inherited from Helper
Instance Method Summary collapse
- #<<(campos) ⇒ Object
- #add_lote(campos = {}) ⇒ Object
-
#initialize(campos = {}) ⇒ PagamentoBradesco
constructor
A new instance of PagamentoBradesco.
Methods inherited from Helper
Methods included from Filler
Constructor Details
#initialize(campos = {}) ⇒ PagamentoBradesco
Returns a new instance of PagamentoBradesco.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/cnab240/helper/pagamento_bradesco.rb', line 3 def initialize(campos = {}) campos[:controle_banco] ||= '237' campos[:arquivo_codigo] ||= '1' campos[:banco_nome] ||= 'BANCO BRADESCO' campos[:arquivo_data_geracao] ||= (Time.respond_to?(:current) ? Time.current : Time.now).strftime('%d%m%Y') campos[:arquivo_hora_geracao] ||= (Time.respond_to?(:current) ? Time.current : Time.now).strftime('%H%M%S') @arquivo = Cnab240::Arquivo::Arquivo.new('V80') @arquivo.lotes << lote = Cnab240::Lote.new(operacao: :pagamento, tipo: :remessa, versao: 'V80') fill campos, arquivo.header, arquivo.trailer campos[:servico_operacao] ||= 'C' campos[:controle_lote] ||= '0001' fill campos, lote.header, lote.trailer end |
Instance Method Details
#<<(campos) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/cnab240/helper/pagamento_bradesco.rb', line 30 def <<(campos) lote = @arquivo.lotes.last campos[:controle_banco] ||= '237' campos[:controle_lote] ||= @arquivo.lotes.length.to_s campos[:servico_numero_registro] ||= (lote.segmentos.length + 1).to_s campos[:servico_tipo_movimento] ||= '000' campos[:credito_moeda_tipo] ||= 'REA' campos[:totais_qtde_registros] ||= (lote.segmentos.length + 2).to_s segmento_a = Cnab240::V80::SegmentoA.new fill campos, segmento_a fill campos, segmento_a.favorecido_agencia_conta lote << segmento_a end |
#add_lote(campos = {}) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/cnab240/helper/pagamento_bradesco.rb', line 21 def add_lote(campos = {}) @arquivo.lotes << lote = Cnab240::Lote.new(operacao: :pagamento, tipo: :remessa, versao: 'V80') campos[:servico_operacao] ||= 'C' campos[:controle_lote] ||= '0001' fill campos, lote.header end |