Class: Cnab240::TransferenciaSicoob
- Defined in:
- lib/cnab240/helper/transferencia_sicoob.rb
Instance Attribute Summary
Attributes inherited from Helper
Instance Method Summary collapse
- #<<(campos) ⇒ Object
- #add_lote(campos = {}) ⇒ Object
-
#initialize(campos = {}) ⇒ TransferenciaSicoob
constructor
A new instance of TransferenciaSicoob.
Methods inherited from Helper
Methods included from Filler
Constructor Details
#initialize(campos = {}) ⇒ TransferenciaSicoob
Returns a new instance of TransferenciaSicoob.
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/cnab240/helper/transferencia_sicoob.rb', line 3 def initialize(campos = {}) campos[:controle_banco] ||= '756' campos[:banco_nome] ||= 'BANCO COOPERATIVO DO BRASIL S.A.' campos[:empresa_tipo] ||= '2' 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') campos[:arquivo_codigo] ||= '1' @arquivo = Cnab240::Arquivo::Arquivo.new('V87') fill campos, arquivo.header, arquivo.trailer end |
Instance Method Details
#<<(campos) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/cnab240/helper/transferencia_sicoob.rb', line 26 def <<(campos) lote = @arquivo.lotes.last campos[:controle_banco] ||= '756' campos[:controle_lote] = @arquivo.lotes.length.to_s campos[:servico_numero_registro] = (lote.segmentos.length + 1).to_s # 000 para inclusao e 999 para exclusao campos[:servico_tipo_movimento] ||= '000' campos[:credito_moeda_tipo] ||= 'BRL' segmento_a = Cnab240::V87::SegmentoA.new fill campos, segmento_a lote << segmento_a campos[:controle_lote] = @arquivo.lotes.length.to_s campos[:servico_numero_registro] = (lote.segmentos.length + 1).to_s segmento_b = Cnab240::V87::SegmentoB.new fill campos, segmento_b lote << segmento_b end |
#add_lote(campos = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/cnab240/helper/transferencia_sicoob.rb', line 16 def add_lote(campos = {}) @arquivo.lotes << lote = Cnab240::Lote.new(operacao: :pagamento, tipo: :remessa, versao: 'V87') campos[:controle_banco] ||= '756' campos[:servico_operacao] ||= 'C' campos[:controle_lote] = (@arquivo.lotes.length).to_s fill campos, lote.header, lote.trailer end |