cnab240 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/cnab240/arquivo/arquivo.rb +34 -9
 - data/lib/cnab240/arquivo/estrutura.rb +1 -0
 - data/lib/cnab240/arquivo/header.rb +5 -5
 - data/lib/cnab240/arquivo/lote.rb +15 -4
 - data/lib/cnab240/arquivo/trailer.rb +2 -2
 - data/lib/cnab240/{core_ext → ext}/bindata.rb +1 -1
 - data/lib/cnab240/{core_ext → ext}/default_mixin.rb +1 -0
 - data/lib/cnab240/ext/segmento_mixin.rb +7 -0
 - data/lib/cnab240/pagamentos/header.rb +2 -2
 - data/lib/cnab240/pagamentos/titulos/header.rb +2 -2
 - data/lib/cnab240/pagamentos/titulos/trailer.rb +1 -1
 - data/lib/cnab240/pagamentos/trailer.rb +1 -1
 - data/lib/cnab240/pagamentos/tributos/header.rb +2 -2
 - data/lib/cnab240/pagamentos/tributos/trailer.rb +1 -1
 - data/lib/cnab240/segmentos/segmento_a.rb +2 -1
 - data/lib/cnab240/segmentos/segmento_b.rb +2 -1
 - data/lib/cnab240/segmentos/segmento_c.rb +2 -1
 - data/lib/cnab240/segmentos/segmento_j.rb +2 -1
 - data/lib/cnab240/segmentos/segmento_j52.rb +3 -2
 - data/lib/cnab240/segmentos/segmento_n.rb +37 -3
 - data/lib/cnab240/segmentos/segmento_n1.rb +21 -0
 - data/lib/cnab240/segmentos/segmento_n2.rb +23 -0
 - data/lib/cnab240/segmentos/segmento_n3.rb +23 -0
 - data/lib/cnab240/segmentos/segmento_n4.rb +25 -0
 - data/lib/cnab240/segmentos/segmento_n5.rb +23 -0
 - data/lib/cnab240/segmentos/segmento_n6.rb +23 -0
 - data/lib/cnab240/segmentos/segmento_n7.rb +23 -0
 - data/lib/cnab240/segmentos/segmento_n8.rb +25 -0
 - data/lib/cnab240/segmentos/segmento_o.rb +2 -1
 - data/lib/cnab240/segmentos/segmento_w.rb +2 -1
 - data/lib/cnab240/segmentos/segmento_w1.rb +1 -0
 - data/lib/cnab240/segmentos/segmento_z.rb +2 -1
 - data/lib/cnab240/version.rb +1 -1
 - data/lib/cnab240.rb +12 -3
 - data/spec/arquivo/arquivo_spec.rb +29 -2
 - data/spec/arquivo/header_spec.rb +43 -0
 - data/spec/bindata/bindata_spec.rb +40 -0
 - data/spec/segmentos/segmento_a_spec.rb +9 -0
 - data/spec/segmentos/segmento_b_spec.rb +9 -0
 - data/spec/segmentos/segmento_c_spec.rb +9 -0
 - data/spec/segmentos/segmento_j52_spec.rb +9 -0
 - data/spec/segmentos/segmento_j_spec.rb +9 -0
 - data/spec/segmentos/segmento_n1_spec.rb +43 -0
 - data/spec/segmentos/segmento_n2_spec.rb +46 -0
 - data/spec/segmentos/segmento_n3_spec.rb +45 -0
 - data/spec/segmentos/segmento_n4_spec.rb +47 -0
 - data/spec/segmentos/segmento_n5_spec.rb +45 -0
 - data/spec/segmentos/segmento_n6_spec.rb +45 -0
 - data/spec/segmentos/segmento_n7_spec.rb +46 -0
 - data/spec/segmentos/segmento_n8_spec.rb +45 -0
 - data/spec/segmentos/segmento_n_spec.rb +34 -1
 - data/spec/segmentos/segmento_o_spec.rb +9 -0
 - data/spec/segmentos/segmento_spec.rb +12 -0
 - data/spec/segmentos/segmento_w_spec.rb +9 -0
 - data/spec/segmentos/segmento_z_spec.rb +9 -0
 - metadata +36 -7
 - /data/lib/cnab240/{core_ext → ext}/attribute_accessors.rb +0 -0
 
| 
         @@ -42,24 +42,49 @@ module Cnab240::Arquivo 
     | 
|
| 
       42 
42 
     | 
    
         
             
            				line.gsub!("\n", "")
         
     | 
| 
       43 
43 
     | 
    
         
             
            				line_number = line_number + 1
         
     | 
| 
       44 
44 
     | 
    
         
             
            				raise "Invalid line length: #{line.length} expected 240 at line number #{line_number}\n\t Line: [#{line}]" unless line.length == 240
         
     | 
| 
       45 
     | 
    
         
            -
            				case line[7..7] # ruby 1.8.7  
     | 
| 
      
 45 
     | 
    
         
            +
            				case line[7..7] # ruby 1.8.7 
         
     | 
| 
       46 
46 
     | 
    
         
             
            				when '0' # header de arquivo
         
     | 
| 
       47 
47 
     | 
    
         
             
            					arquivos << Arquivo.new
         
     | 
| 
       48 
48 
     | 
    
         
             
            					arquivos.last.header = Header.read(line)
         
     | 
| 
       49 
49 
     | 
    
         
             
            				when '1'
         
     | 
| 
       50 
     | 
    
         
            -
            					 
     | 
| 
      
 50 
     | 
    
         
            +
            					case line[13..15]
         
     | 
| 
      
 51 
     | 
    
         
            +
            					when '044'
         
     | 
| 
      
 52 
     | 
    
         
            +
            						arquivos.last.lotes << Cnab240::Lote.new(:operacao => :pagamento, :tipo => :none) do |l|
         
     | 
| 
      
 53 
     | 
    
         
            +
            							l.header = Cnab240::Pagamentos::Header.read(line)
         
     | 
| 
      
 54 
     | 
    
         
            +
            						end
         
     | 
| 
      
 55 
     | 
    
         
            +
            					when '040'
         
     | 
| 
      
 56 
     | 
    
         
            +
            						arquivos.last.lotes << Cnab240::Lote.new(:operacao => :pagamento_titulo_cobranca, :tipo => :none) do |l|
         
     | 
| 
      
 57 
     | 
    
         
            +
            							l.header = Cnab240::PagamentosTitulos::Header.read(line)
         
     | 
| 
      
 58 
     | 
    
         
            +
            						end
         
     | 
| 
      
 59 
     | 
    
         
            +
            					when '011'
         
     | 
| 
      
 60 
     | 
    
         
            +
            						arquivos.last.lotes << Cnab240::Lote.new(:operacao => :pagamento_titulo_tributos, :tipo => :none) do |l|
         
     | 
| 
      
 61 
     | 
    
         
            +
            							l.header = Cnab240::PagamentosTributos::Header.read(line)
         
     | 
| 
      
 62 
     | 
    
         
            +
            						end
         
     | 
| 
      
 63 
     | 
    
         
            +
            					else
         
     | 
| 
      
 64 
     | 
    
         
            +
            						raise "Invalid tipo de lote: #{line[13..15]} at line #{line_number}"
         
     | 
| 
      
 65 
     | 
    
         
            +
            					end
         
     | 
| 
       51 
66 
     | 
    
         
             
            				when '2'
         
     | 
| 
       52 
     | 
    
         
            -
            					 
     | 
| 
       53 
     | 
    
         
            -
            				when '3'
         
     | 
| 
       54 
     | 
    
         
            -
            					 
     | 
| 
      
 67 
     | 
    
         
            +
            					raise NotImplementedError.new("Tipo de registro not implemented")
         
     | 
| 
      
 68 
     | 
    
         
            +
            				when '3' 
         
     | 
| 
      
 69 
     | 
    
         
            +
            					raise "Invalid segmento de lote: #{line[13..13]} at line #{line_number}" unless ESTRUTURA[:segmentos_implementados].include? line[13..13].downcase.intern
         
     | 
| 
      
 70 
     | 
    
         
            +
            					case line[13..13]
         
     | 
| 
      
 71 
     | 
    
         
            +
            					when 'J'
         
     | 
| 
      
 72 
     | 
    
         
            +
            						if line[17..18] == '52'
         
     | 
| 
      
 73 
     | 
    
         
            +
            							arquivos.last.lotes.last.read_segmento('J52', line)
         
     | 
| 
      
 74 
     | 
    
         
            +
            						else
         
     | 
| 
      
 75 
     | 
    
         
            +
            							arquivos.last.lotes.last.read_segmento('J', line)
         
     | 
| 
      
 76 
     | 
    
         
            +
            						end
         
     | 
| 
      
 77 
     | 
    
         
            +
            					else
         
     | 
| 
      
 78 
     | 
    
         
            +
            						arquivos.last.lotes.last.read_segmento(line[13..13], line)
         
     | 
| 
      
 79 
     | 
    
         
            +
            					end
         
     | 
| 
       55 
80 
     | 
    
         
             
            				when '4'
         
     | 
| 
       56 
     | 
    
         
            -
            					 
     | 
| 
      
 81 
     | 
    
         
            +
            					raise NotImplementedError.new("Tipo de registro not implemented")
         
     | 
| 
       57 
82 
     | 
    
         
             
            				when '5'
         
     | 
| 
       58 
     | 
    
         
            -
            					 
     | 
| 
      
 83 
     | 
    
         
            +
            					arquivos.last.lotes.last.trailer.read(line) 
         
     | 
| 
       59 
84 
     | 
    
         
             
            				when '9'
         
     | 
| 
       60 
     | 
    
         
            -
            					arquivos.last. 
     | 
| 
      
 85 
     | 
    
         
            +
            					arquivos.last.trailer = Trailer.read(line)
         
     | 
| 
       61 
86 
     | 
    
         
             
            				else
         
     | 
| 
       62 
     | 
    
         
            -
            					raise "Invalid tipo de registro: #{line[7]} at line #{line_number} \n\t Line: [#{line}]"
         
     | 
| 
      
 87 
     | 
    
         
            +
            					raise "Invalid tipo de registro: #{line[7..7]} at line #{line_number} \n\t Line: [#{line}]"
         
     | 
| 
       63 
88 
     | 
    
         
             
            				end
         
     | 
| 
       64 
89 
     | 
    
         
             
            			end
         
     | 
| 
       65 
90 
     | 
    
         
             
            			arquivos
         
     | 
| 
         @@ -1,13 +1,13 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module Cnab240::Arquivo
         
     | 
| 
       2 
2 
     | 
    
         
             
            	class Header < BinData::Record
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
      
 4 
     | 
    
         
            +
            	 include Cnab240::DefaultMixin
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
            		string :controle_banco, :length => 3, :pad_byte => '0'
         
     | 
| 
       7 
     | 
    
         
            -
            		string :controle_lote, : 
     | 
| 
       8 
     | 
    
         
            -
            		string :controle_registro, : 
     | 
| 
      
 7 
     | 
    
         
            +
            		string :controle_lote, :length => 4, :initial_value => '0000', :pad_byte => '0'
         
     | 
| 
      
 8 
     | 
    
         
            +
            		string :controle_registro, :length => 1, :initial_value => '0', :pad_byte => '0'
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
     | 
    
         
            -
            		string :cnab_g004_1, :length => 9, :pad_byte => ' '
         
     | 
| 
      
 10 
     | 
    
         
            +
            		string :cnab_g004_1, :length => 9, :initial_value => ' ', :pad_byte => ' '
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
12 
     | 
    
         
             
            		string :empresa_tipo, :length => 1, :pad_byte => '0'
         
     | 
| 
       13 
13 
     | 
    
         
             
            		string :empresa_numero, :length => 14, :pad_byte => '0'
         
     | 
| 
         @@ -27,7 +27,7 @@ module Cnab240::Arquivo 
     | 
|
| 
       27 
27 
     | 
    
         
             
            		string :arquivo_data_geracao, :length => 8, :pad_byte => '0'
         
     | 
| 
       28 
28 
     | 
    
         
             
            		string :arquivo_hora_geracao,:length => 6, :pad_byte => '0'
         
     | 
| 
       29 
29 
     | 
    
         
             
            		string :arquivo_sequencia, :length => 6, :pad_byte => '0'
         
     | 
| 
       30 
     | 
    
         
            -
            		string :arquivo_layout, : 
     | 
| 
      
 30 
     | 
    
         
            +
            		string :arquivo_layout, :length => 3, :initial_value => '085'
         
     | 
| 
       31 
31 
     | 
    
         
             
            		string :arquivo_densidade, :length => 5, :pad_byte => '0'
         
     | 
| 
       32 
32 
     | 
    
         | 
| 
       33 
33 
     | 
    
         
             
            		string :reservado_banco, :length => 20, :pad_byte => ' '
         
     | 
    
        data/lib/cnab240/arquivo/lote.rb
    CHANGED
    
    | 
         @@ -19,17 +19,28 @@ module Cnab240 
     | 
|
| 
       19 
19 
     | 
    
         
             
            			@header = estrutura[:header].new
         
     | 
| 
       20 
20 
     | 
    
         
             
            			@trailer = estrutura[:trailer].new
         
     | 
| 
       21 
21 
     | 
    
         | 
| 
       22 
     | 
    
         
            -
            			 
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
      
 22 
     | 
    
         
            +
            			yield self if block_given?
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            			if tipo != :none
         
     | 
| 
      
 25 
     | 
    
         
            +
            				estrutura[:segmentos].each do |s|
         
     | 
| 
      
 26 
     | 
    
         
            +
            					raise "Tipo nao suportado: [#{s}][#{tipo}]" if (estrutura[s][tipo].nil?) && tipo != :any
         
     | 
| 
      
 27 
     | 
    
         
            +
            					if (tipo == :any) || (estrutura[s][tipo] == true)
         
     | 
| 
      
 28 
     | 
    
         
            +
            						self << s 
         
     | 
| 
      
 29 
     | 
    
         
            +
            					end
         
     | 
| 
       26 
30 
     | 
    
         
             
            				end
         
     | 
| 
       27 
31 
     | 
    
         
             
            			end
         
     | 
| 
       28 
32 
     | 
    
         
             
            		end
         
     | 
| 
       29 
33 
     | 
    
         | 
| 
      
 34 
     | 
    
         
            +
            		def read_segmento(s, line)
         
     | 
| 
      
 35 
     | 
    
         
            +
            			segmento = self << s
         
     | 
| 
      
 36 
     | 
    
         
            +
            			segmentos[s] = segmento.read(line)
         
     | 
| 
      
 37 
     | 
    
         
            +
            		end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
       30 
39 
     | 
    
         
             
            		def <<(s)
         
     | 
| 
       31 
40 
     | 
    
         
             
            			segmentos[s] = eval("Segmento#{s.to_s.upcase}.new")
         
     | 
| 
      
 41 
     | 
    
         
            +
            			segmentos[s].lote = self
         
     | 
| 
       32 
42 
     | 
    
         
             
            			add_segmento_accessors(s)
         
     | 
| 
      
 43 
     | 
    
         
            +
            			segmentos[s]
         
     | 
| 
       33 
44 
     | 
    
         
             
            		end
         
     | 
| 
       34 
45 
     | 
    
         | 
| 
       35 
46 
     | 
    
         
             
            		def linhas
         
     | 
| 
         @@ -4,8 +4,8 @@ module Cnab240::Arquivo 
     | 
|
| 
       4 
4 
     | 
    
         
             
            		include Cnab240::DefaultMixin
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
            		string :controle_banco, :length => 3, :pad_byte => '0'
         
     | 
| 
       7 
     | 
    
         
            -
            		string :controle_lote, : 
     | 
| 
       8 
     | 
    
         
            -
            		string :controle_registro, 
     | 
| 
      
 7 
     | 
    
         
            +
            		string :controle_lote, :length => 4, :initial_value => '9999', :pad_byte => '0'
         
     | 
| 
      
 8 
     | 
    
         
            +
            		string :controle_registro, :length => 1, :initial_value => '9', :pad_byte => '0'
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
            		string :cnab_g004_1, :length => 9, :pad_byte => ' '
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
         @@ -4,7 +4,7 @@ module BinData 
     | 
|
| 
       4 
4 
     | 
    
         
             
            			self.auto_fill if self.respond_to?(:auto_fill) 
         
     | 
| 
       5 
5 
     | 
    
         
             
            			s = StringIO.new
         
     | 
| 
       6 
6 
     | 
    
         
             
            			self.write(s)
         
     | 
| 
       7 
     | 
    
         
            -
            			raise "Invalid line length #{s.string.length}" unless s.string.length == 240
         
     | 
| 
      
 7 
     | 
    
         
            +
            			raise "Invalid line length #{s.string.length}" unless (s.string.length == 240)  || self.respond_to?(:lote)
         
     | 
| 
       8 
8 
     | 
    
         
             
            			s.string
         
     | 
| 
       9 
9 
     | 
    
         
             
            		end
         
     | 
| 
       10 
10 
     | 
    
         
             
            	end
         
     | 
| 
         @@ -7,10 +7,10 @@ module Cnab240::Pagamentos 
     | 
|
| 
       7 
7 
     | 
    
         
             
            		string :controle_lote, :length => 4, :pad_byte => '0'
         
     | 
| 
       8 
8 
     | 
    
         
             
            		string :controle_registro, :length => 1, :initial_value => '1', :pad_byte => '0'
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
     | 
    
         
            -
            		string :servico_operacao, : 
     | 
| 
      
 10 
     | 
    
         
            +
            		string :servico_operacao, :length => 1, :initial_value => 'C', :pad_byte => ' '
         
     | 
| 
       11 
11 
     | 
    
         
             
            		string :servico_tipo, :length => 2 , :pad_byte => '0'
         
     | 
| 
       12 
12 
     | 
    
         
             
            		string :servico_forma, :length => 2, :pad_byte => '0'
         
     | 
| 
       13 
     | 
    
         
            -
            		string :servico_layout, : 
     | 
| 
      
 13 
     | 
    
         
            +
            		string :servico_layout, :length => 3, :initial_value => '044', :pad_byte => '0'
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
15 
     | 
    
         
             
            		string :cnab_g004_1, :length => 1, :pad_byte => ' '
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
         @@ -7,10 +7,10 @@ module Cnab240::PagamentosTitulos 
     | 
|
| 
       7 
7 
     | 
    
         
             
            		string :controle_lote, :length => 4, :pad_byte => '0'
         
     | 
| 
       8 
8 
     | 
    
         
             
            		string :controle_registro, :length => 1, :initial_value => '1', :pad_byte => '0'
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
     | 
    
         
            -
            		string :servico_operacao, : 
     | 
| 
      
 10 
     | 
    
         
            +
            		string :servico_operacao, :length => 1, :initial_value => 'C', :pad_byte => ' '
         
     | 
| 
       11 
11 
     | 
    
         
             
            		string :servico_tipo, :length => 2 , :pad_byte => '0'
         
     | 
| 
       12 
12 
     | 
    
         
             
            		string :servico_forma, :length => 2, :pad_byte => '0'
         
     | 
| 
       13 
     | 
    
         
            -
            		string :servico_layout, : 
     | 
| 
      
 13 
     | 
    
         
            +
            		string :servico_layout,  :length => 3, :initial_value => '040', :pad_byte => '0'
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
15 
     | 
    
         
             
            		string :cnab_g004_1, :length => 1, :pad_byte => ' '
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
         @@ -5,7 +5,7 @@ module Cnab240::PagamentosTitulos 
     | 
|
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
            		string :controle_banco, :length => 3, :pad_byte => '0'
         
     | 
| 
       7 
7 
     | 
    
         
             
            		string :controle_lote, :length => 4, :pad_byte => '0'
         
     | 
| 
       8 
     | 
    
         
            -
            		string :controle_registro, : 
     | 
| 
      
 8 
     | 
    
         
            +
            		string :controle_registro, :length => 1, :initial_value => '5', :pad_byte => '0'
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
            		string :cnab_g004_1, :length => 9, :pad_byte => '0'
         
     | 
| 
       11 
11 
     | 
    
         
             
            		string :totais_qtde_registros, :length => 6, :pad_byte => '0'
         
     | 
| 
         @@ -5,7 +5,7 @@ module Cnab240::Pagamentos 
     | 
|
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
            		string :controle_banco, :length => 3, :pad_byte => '0'
         
     | 
| 
       7 
7 
     | 
    
         
             
            		string :controle_lote, :length => 4, :pad_byte => '0'
         
     | 
| 
       8 
     | 
    
         
            -
            		string :controle_registro, : 
     | 
| 
      
 8 
     | 
    
         
            +
            		string :controle_registro, :length => 1, :initial_value => '5', :pad_byte => '0'
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
            		string :cnab_g004_1, :length => 9, :pad_byte => '0'
         
     | 
| 
       11 
11 
     | 
    
         
             
            		string :totais_qtde_registros, :length => 6, :pad_byte => '0'
         
     | 
| 
         @@ -7,10 +7,10 @@ module Cnab240::PagamentosTributos 
     | 
|
| 
       7 
7 
     | 
    
         
             
            		string :controle_lote, :length => 4, :pad_byte => '0'
         
     | 
| 
       8 
8 
     | 
    
         
             
            		string :controle_registro, :length => 1, :initial_value => '1', :pad_byte => '0'
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
     | 
    
         
            -
            		string :servico_operacao, : 
     | 
| 
      
 10 
     | 
    
         
            +
            		string :servico_operacao, :length => 1, :initial_value => 'C', :pad_byte => ' '
         
     | 
| 
       11 
11 
     | 
    
         
             
            		string :servico_tipo, :length => 2 , :pad_byte => '0'
         
     | 
| 
       12 
12 
     | 
    
         
             
            		string :servico_forma, :length => 2, :pad_byte => '0'
         
     | 
| 
       13 
     | 
    
         
            -
            		string :servico_layout, : 
     | 
| 
      
 13 
     | 
    
         
            +
            		string :servico_layout, :length => 3, :initial_value => '011', :pad_byte => '0'
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
15 
     | 
    
         
             
            		string :cnab_g004_1, :length => 1, :pad_byte => ' '
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
         @@ -5,7 +5,7 @@ module Cnab240::PagamentosTributos 
     | 
|
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
            		string :controle_banco, :length => 3, :pad_byte => '0'
         
     | 
| 
       7 
7 
     | 
    
         
             
            		string :controle_lote, :length => 4, :pad_byte => '0'
         
     | 
| 
       8 
     | 
    
         
            -
            		string :controle_registro, : 
     | 
| 
      
 8 
     | 
    
         
            +
            		string :controle_registro, :length => 1, :initial_value => '5', :pad_byte => '0'
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
            		string :cnab_g004_1, :length => 9, :pad_byte => '0'
         
     | 
| 
       11 
11 
     | 
    
         
             
            		string :totais_qtde_registros, :length => 6, :pad_byte => '0'
         
     | 
| 
         @@ -2,13 +2,14 @@ module Cnab240 
     | 
|
| 
       2 
2 
     | 
    
         
             
            	class SegmentoA < BinData::Record
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
4 
     | 
    
         
             
            		include Cnab240::DefaultMixin
         
     | 
| 
      
 5 
     | 
    
         
            +
            		include Cnab240::SegmentoMixin
         
     | 
| 
       5 
6 
     | 
    
         | 
| 
       6 
7 
     | 
    
         
             
            		string :controle_banco, :length => 3, :pad_byte => '0'
         
     | 
| 
       7 
8 
     | 
    
         
             
            		string :controle_lote, :length => 4, :pad_byte => '0'
         
     | 
| 
       8 
9 
     | 
    
         
             
            		string :controle_registro, :length => 1, :initial_value => '3', :pad_byte => '0'
         
     | 
| 
       9 
10 
     | 
    
         | 
| 
       10 
11 
     | 
    
         
             
            		string :servico_numero_registro, :length => 5, :pad_byte => '0'
         
     | 
| 
       11 
     | 
    
         
            -
            		string :servico_codigo_segmento, : 
     | 
| 
      
 12 
     | 
    
         
            +
            		string :servico_codigo_segmento, :length => 1, :initial_value => 'A', :pad_byte => ' '
         
     | 
| 
       12 
13 
     | 
    
         
             
            		string :servico_tipo_movimento, :length => 1, :pad_byte => '0'
         
     | 
| 
       13 
14 
     | 
    
         
             
            		string :servico_codigo_movimento, :length => 2, :pad_byte => '0'
         
     | 
| 
       14 
15 
     | 
    
         | 
| 
         @@ -2,13 +2,14 @@ module Cnab240 
     | 
|
| 
       2 
2 
     | 
    
         
             
            	class SegmentoB < BinData::Record
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
4 
     | 
    
         
             
            		include Cnab240::DefaultMixin
         
     | 
| 
      
 5 
     | 
    
         
            +
            		include Cnab240::SegmentoMixin
         
     | 
| 
       5 
6 
     | 
    
         | 
| 
       6 
7 
     | 
    
         
             
            		string :controle_banco, :length => 3, :pad_byte => '0'
         
     | 
| 
       7 
8 
     | 
    
         
             
            		string :controle_lote, :length => 4, :pad_byte => '0'
         
     | 
| 
       8 
9 
     | 
    
         
             
            		string :controle_registro, :length => 1, :initial_value => '3', :pad_byte => '0'
         
     | 
| 
       9 
10 
     | 
    
         | 
| 
       10 
11 
     | 
    
         
             
            		string :servico_numero_registro, :length => 5, :pad_byte => '0'
         
     | 
| 
       11 
     | 
    
         
            -
            		string :servico_codigo_segmento, : 
     | 
| 
      
 12 
     | 
    
         
            +
            		string :servico_codigo_segmento, :length => 1, :initial_value => 'B', :pad_byte => ' '
         
     | 
| 
       12 
13 
     | 
    
         | 
| 
       13 
14 
     | 
    
         
             
            		string :cnab240_g004_1, :length => 3, :pad_byte => ' '
         
     | 
| 
       14 
15 
     | 
    
         | 
| 
         @@ -2,13 +2,14 @@ module Cnab240 
     | 
|
| 
       2 
2 
     | 
    
         
             
            	class SegmentoC < BinData::Record
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
4 
     | 
    
         
             
            		include Cnab240::DefaultMixin
         
     | 
| 
      
 5 
     | 
    
         
            +
            		include Cnab240::SegmentoMixin
         
     | 
| 
       5 
6 
     | 
    
         | 
| 
       6 
7 
     | 
    
         
             
            		string :controle_banco, :length => 3, :pad_byte => '0'
         
     | 
| 
       7 
8 
     | 
    
         
             
            		string :controle_lote, :length => 4, :pad_byte => '0'
         
     | 
| 
       8 
9 
     | 
    
         
             
            		string :controle_registro, :length => 1, :initial_value => '3', :pad_byte => '0'
         
     | 
| 
       9 
10 
     | 
    
         | 
| 
       10 
11 
     | 
    
         
             
            		string :servico_numero_registro, :length => 5, :pad_byte => '0'
         
     | 
| 
       11 
     | 
    
         
            -
            		string :servico_codigo_segmento, : 
     | 
| 
      
 12 
     | 
    
         
            +
            		string :servico_codigo_segmento, :length => 1, :initial_value => 'C', :pad_byte => ' '
         
     | 
| 
       12 
13 
     | 
    
         | 
| 
       13 
14 
     | 
    
         
             
            		string :cnab240_g004_1, :length => 3, :pad_byte => ' '
         
     | 
| 
       14 
15 
     | 
    
         | 
| 
         @@ -2,13 +2,14 @@ module Cnab240 
     | 
|
| 
       2 
2 
     | 
    
         
             
            	class SegmentoJ < BinData::Record
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
4 
     | 
    
         
             
            		include Cnab240::DefaultMixin
         
     | 
| 
      
 5 
     | 
    
         
            +
            		include Cnab240::SegmentoMixin
         
     | 
| 
       5 
6 
     | 
    
         | 
| 
       6 
7 
     | 
    
         
             
            		string :controle_banco, :length => 3, :pad_byte => '0'
         
     | 
| 
       7 
8 
     | 
    
         
             
            		string :controle_lote, :length => 4, :pad_byte => '0'
         
     | 
| 
       8 
9 
     | 
    
         
             
            		string :controle_registro, :length => 1, :initial_value => '3', :pad_byte => '0'
         
     | 
| 
       9 
10 
     | 
    
         | 
| 
       10 
11 
     | 
    
         
             
            		string :servico_numero_registro, :length => 5, :pad_byte => '0'
         
     | 
| 
       11 
     | 
    
         
            -
            		string :servico_codigo_segmento, : 
     | 
| 
      
 12 
     | 
    
         
            +
            		string :servico_codigo_segmento, :length => 1, :initial_value => 'J', :pad_byte => ' '
         
     | 
| 
       12 
13 
     | 
    
         
             
            		string :servico_tipo_movimento, :length => 1, :pad_byte => '0'
         
     | 
| 
       13 
14 
     | 
    
         
             
            		string :servico_codigo_movimento, :length => 2, :pad_byte => '0'
         
     | 
| 
       14 
15 
     | 
    
         | 
| 
         @@ -2,17 +2,18 @@ module Cnab240 
     | 
|
| 
       2 
2 
     | 
    
         
             
            	class SegmentoJ52 < BinData::Record
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
4 
     | 
    
         
             
            		include Cnab240::DefaultMixin
         
     | 
| 
      
 5 
     | 
    
         
            +
            		include Cnab240::SegmentoMixin
         
     | 
| 
       5 
6 
     | 
    
         | 
| 
       6 
7 
     | 
    
         
             
            		string :controle_banco, :length => 3, :pad_byte => '0'
         
     | 
| 
       7 
8 
     | 
    
         
             
            		string :controle_lote, :length => 4, :pad_byte => '0'
         
     | 
| 
       8 
9 
     | 
    
         
             
            		string :controle_registro, :length => 1, :initial_value => '3', :pad_byte => '0'
         
     | 
| 
       9 
10 
     | 
    
         | 
| 
       10 
11 
     | 
    
         
             
            		string :servico_numero_registro, :length => 5, :pad_byte => '0'
         
     | 
| 
       11 
     | 
    
         
            -
            		string :servico_codigo_segmento, : 
     | 
| 
      
 12 
     | 
    
         
            +
            		string :servico_codigo_segmento, :length => 1, :initial_value => 'J', :pad_byte => ' '
         
     | 
| 
       12 
13 
     | 
    
         
             
            		string :servico_tipo_movimento, :length => 1, :pad_byte => '0'
         
     | 
| 
       13 
14 
     | 
    
         
             
            		string :servico_codigo_movimento, :length => 2, :pad_byte => '0'
         
     | 
| 
       14 
15 
     | 
    
         | 
| 
       15 
     | 
    
         
            -
            		string :cod_registro_opcional, : 
     | 
| 
      
 16 
     | 
    
         
            +
            		string :cod_registro_opcional, :length => 2, :initial_value => '52'
         
     | 
| 
       16 
17 
     | 
    
         | 
| 
       17 
18 
     | 
    
         
             
            		string :sacado_tipo_inscricao, :length => 1, :pad_byte => '0'
         
     | 
| 
       18 
19 
     | 
    
         
             
            		string :sacado_numero_inscricao, :length => 15, :pad_byte => '0'
         
     | 
| 
         @@ -2,13 +2,14 @@ module Cnab240 
     | 
|
| 
       2 
2 
     | 
    
         
             
            	class SegmentoN < BinData::Record
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
4 
     | 
    
         
             
            		include Cnab240::DefaultMixin
         
     | 
| 
      
 5 
     | 
    
         
            +
            		include Cnab240::SegmentoMixin
         
     | 
| 
       5 
6 
     | 
    
         | 
| 
       6 
7 
     | 
    
         
             
            		string :controle_banco, :length => 3, :pad_byte => '0'
         
     | 
| 
       7 
8 
     | 
    
         
             
            		string :controle_lote, :length => 4, :pad_byte => '0'
         
     | 
| 
       8 
9 
     | 
    
         
             
            		string :controle_registro, :length => 1, :initial_value => '3', :pad_byte => '0'
         
     | 
| 
       9 
10 
     | 
    
         | 
| 
       10 
11 
     | 
    
         
             
            		string :servico_numero_registro, :length => 5, :pad_byte => '0'
         
     | 
| 
       11 
     | 
    
         
            -
            		string :servico_codigo_segmento, : 
     | 
| 
      
 12 
     | 
    
         
            +
            		string :servico_codigo_segmento, :length => 1, :initial_value  => 'N', :pad_byte => ' '
         
     | 
| 
       12 
13 
     | 
    
         
             
            		string :servico_tipo_movimento, :length => 1, :pad_byte => '0'
         
     | 
| 
       13 
14 
     | 
    
         
             
            		string :servico_codigo_movimento, :length => 2, :pad_byte => '0'
         
     | 
| 
       14 
15 
     | 
    
         | 
| 
         @@ -18,9 +19,42 @@ module Cnab240 
     | 
|
| 
       18 
19 
     | 
    
         
             
            		string :data_pagamento, :length => 8, :pad_byte => '0'
         
     | 
| 
       19 
20 
     | 
    
         
             
            		string :valor_pagamento, :length => 15, :pad_byte => '0'
         
     | 
| 
       20 
21 
     | 
    
         | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
      
 22 
     | 
    
         
            +
            	#	string :informacoes_complementares, :length => 120, :pad_byte => ' '
         
     | 
| 
      
 23 
     | 
    
         
            +
            		choice :n_complemento, :selection => :get_n do
         
     | 
| 
      
 24 
     | 
    
         
            +
            			string 0, :length => 120, :pad_byte => ' '
         
     | 
| 
      
 25 
     | 
    
         
            +
                        segmento_n1 1
         
     | 
| 
      
 26 
     | 
    
         
            +
                        segmento_n1 2
         
     | 
| 
      
 27 
     | 
    
         
            +
                        segmento_n3 3
         
     | 
| 
      
 28 
     | 
    
         
            +
                        segmento_n4 4
         
     | 
| 
      
 29 
     | 
    
         
            +
                        segmento_n5 5
         
     | 
| 
      
 30 
     | 
    
         
            +
                        segmento_n6 6
         
     | 
| 
      
 31 
     | 
    
         
            +
                        segmento_n7 7
         
     | 
| 
      
 32 
     | 
    
         
            +
                        segmento_n8 8
         
     | 
| 
      
 33 
     | 
    
         
            +
                	end 
         
     | 
| 
       22 
34 
     | 
    
         | 
| 
       23 
     | 
    
         
            -
            		string :ocorrencias, :length => 10, :pad_byte => ' '
         
     | 
| 
      
 35 
     | 
    
         
            +
            		string :ocorrencias, :length => 10, :pad_byte => ' ' 
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
            		def get_n
         
     | 
| 
      
 38 
     | 
    
         
            +
            			servico_forma_nX = {
         
     | 
| 
      
 39 
     | 
    
         
            +
            				'00' => 0,
         
     | 
| 
      
 40 
     | 
    
         
            +
            				'17' => 1,
         
     | 
| 
      
 41 
     | 
    
         
            +
            				'16' => 2,
         
     | 
| 
      
 42 
     | 
    
         
            +
            				'18' => 3,
         
     | 
| 
      
 43 
     | 
    
         
            +
            				'22' => 4,
         
     | 
| 
      
 44 
     | 
    
         
            +
            				'23' => 4,
         
     | 
| 
      
 45 
     | 
    
         
            +
            				'24' => 4,
         
     | 
| 
      
 46 
     | 
    
         
            +
            				'25' => 5,
         
     | 
| 
      
 47 
     | 
    
         
            +
            				'27' => 6,
         
     | 
| 
      
 48 
     | 
    
         
            +
            				'26' => 7,
         
     | 
| 
      
 49 
     | 
    
         
            +
            				'21' => 8
         
     | 
| 
      
 50 
     | 
    
         
            +
               			}
         
     | 
| 
      
 51 
     | 
    
         
            +
               			begin
         
     | 
| 
      
 52 
     | 
    
         
            +
               				servico_forma = lote.header.servico_forma
         
     | 
| 
      
 53 
     | 
    
         
            +
               			rescue
         
     | 
| 
      
 54 
     | 
    
         
            +
               				servico_forma = '00'
         
     | 
| 
      
 55 
     | 
    
         
            +
               			end
         
     | 
| 
      
 56 
     | 
    
         
            +
            			return servico_forma_nX[servico_forma]
         
     | 
| 
      
 57 
     | 
    
         
            +
            		end
         
     | 
| 
       24 
58 
     | 
    
         | 
| 
       25 
59 
     | 
    
         
             
            	end
         
     | 
| 
       26 
60 
     | 
    
         
             
            end
         
     | 
| 
         @@ -0,0 +1,21 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Cnab240
         
     | 
| 
      
 2 
     | 
    
         
            +
            	class SegmentoN1 < BinData::Record
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            		include Cnab240::DefaultMixin
         
     | 
| 
      
 5 
     | 
    
         
            +
            		include Cnab240::SegmentoMixin
         
     | 
| 
      
 6 
     | 
    
         
            +
            		
         
     | 
| 
      
 7 
     | 
    
         
            +
            		string :receita, :length => 6, :pad_byte => ' '
         
     | 
| 
      
 8 
     | 
    
         
            +
            		string :tipo_identificacao_contribuinte, :length => 2, :pad_byte => '0'
         
     | 
| 
      
 9 
     | 
    
         
            +
            		string :identificacao_contribuinte, :length => 14, :pad_byte => '0'
         
     | 
| 
      
 10 
     | 
    
         
            +
            		string :identificacao_tributo, :length => 2, :pad_byte => ' '
         
     | 
| 
      
 11 
     | 
    
         
            +
            		
         
     | 
| 
      
 12 
     | 
    
         
            +
            		string :mes_ano_competencia, :length => 6, :pad_byte => '0'
         
     | 
| 
      
 13 
     | 
    
         
            +
            		string :valor_tributo, :length => 15, :pad_byte => '0'
         
     | 
| 
      
 14 
     | 
    
         
            +
            		string :valor_outras_entidades, :length => 15, :pad_byte => '0'
         
     | 
| 
      
 15 
     | 
    
         
            +
            		string :atualizacao_monetaria, :length => 15, :pad_byte => '0'
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            		string :cnab, :length => 45, :pad_byte => ' '
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            	end
         
     | 
| 
      
 21 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,23 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Cnab240
         
     | 
| 
      
 2 
     | 
    
         
            +
            	class SegmentoN2 < BinData::Record
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            		include Cnab240::DefaultMixin
         
     | 
| 
      
 5 
     | 
    
         
            +
            		include Cnab240::SegmentoMixin
         
     | 
| 
      
 6 
     | 
    
         
            +
            		
         
     | 
| 
      
 7 
     | 
    
         
            +
            		string :receita, :length => 6, :pad_byte => ' '
         
     | 
| 
      
 8 
     | 
    
         
            +
            		string :tipo_identificacao_contribuinte, :length => 2, :pad_byte => '0'
         
     | 
| 
      
 9 
     | 
    
         
            +
            		string :identificacao_contribuinte, :length => 14, :pad_byte => '0'
         
     | 
| 
      
 10 
     | 
    
         
            +
            		string :identificacao_tributo, :length => 2, :pad_byte => ' '
         
     | 
| 
      
 11 
     | 
    
         
            +
            		
         
     | 
| 
      
 12 
     | 
    
         
            +
            		string :periodo_apuracao, :length => 8, :pad_byte => '0'
         
     | 
| 
      
 13 
     | 
    
         
            +
            		string :numero_referencia, :length => 17, :pad_byte => '0'
         
     | 
| 
      
 14 
     | 
    
         
            +
            		string :valor_principal, :length => 15, :pad_byte => '0'
         
     | 
| 
      
 15 
     | 
    
         
            +
            		string :valor_multa, :length => 15, :pad_byte => '0'
         
     | 
| 
      
 16 
     | 
    
         
            +
            		string :valor_juros_encargos, :length => 15, :pad_byte => '0'
         
     | 
| 
      
 17 
     | 
    
         
            +
            		string :data_vencimento, :length => 8, :pad_byte => '0'
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            		string :cnab, :length => 18, :pad_byte => ' '
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            	end
         
     | 
| 
      
 23 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,23 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Cnab240
         
     | 
| 
      
 2 
     | 
    
         
            +
            	class SegmentoN3 < BinData::Record
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            		include Cnab240::DefaultMixin
         
     | 
| 
      
 5 
     | 
    
         
            +
            		include Cnab240::SegmentoMixin
         
     | 
| 
      
 6 
     | 
    
         
            +
            		
         
     | 
| 
      
 7 
     | 
    
         
            +
            		string :receita, :length => 6, :pad_byte => ' '
         
     | 
| 
      
 8 
     | 
    
         
            +
            		string :tipo_identificacao_contribuinte, :length => 2, :pad_byte => '0'
         
     | 
| 
      
 9 
     | 
    
         
            +
            		string :identificacao_contribuinte, :length => 14, :pad_byte => '0'
         
     | 
| 
      
 10 
     | 
    
         
            +
            		string :identificacao_tributo, :length => 2, :pad_byte => ' '
         
     | 
| 
      
 11 
     | 
    
         
            +
            		
         
     | 
| 
      
 12 
     | 
    
         
            +
            		string :periodo_apuracao, :length => 8, :pad_byte => '0'
         
     | 
| 
      
 13 
     | 
    
         
            +
            		string :receita_bruta, :length => 15, :pad_byte => '0'
         
     | 
| 
      
 14 
     | 
    
         
            +
            		string :percentual, :length => 7, :pad_byte => '0'
         
     | 
| 
      
 15 
     | 
    
         
            +
            		string :valor_principal, :length => 15, :pad_byte => '0'
         
     | 
| 
      
 16 
     | 
    
         
            +
            		string :valor_multa, :length => 15, :pad_byte => '0'
         
     | 
| 
      
 17 
     | 
    
         
            +
            		string :valor_juros_encargos, :length => 15, :pad_byte => '0'
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            		string :cnab, :length => 21, :pad_byte => ' '
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            	end
         
     | 
| 
      
 23 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,25 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Cnab240
         
     | 
| 
      
 2 
     | 
    
         
            +
            	class SegmentoN4 < BinData::Record
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            		include Cnab240::DefaultMixin
         
     | 
| 
      
 5 
     | 
    
         
            +
            		include Cnab240::SegmentoMixin
         
     | 
| 
      
 6 
     | 
    
         
            +
            		
         
     | 
| 
      
 7 
     | 
    
         
            +
            		string :receita, :length => 6, :pad_byte => ' '
         
     | 
| 
      
 8 
     | 
    
         
            +
            		string :tipo_identificacao_contribuinte, :length => 2, :pad_byte => '0'
         
     | 
| 
      
 9 
     | 
    
         
            +
            		string :identificacao_contribuinte, :length => 14, :pad_byte => '0'
         
     | 
| 
      
 10 
     | 
    
         
            +
            		string :identificacao_tributo, :length => 2, :pad_byte => ' '
         
     | 
| 
      
 11 
     | 
    
         
            +
            		
         
     | 
| 
      
 12 
     | 
    
         
            +
            		string :vencimento, :length => 8, :pad_byte => '0'
         
     | 
| 
      
 13 
     | 
    
         
            +
            		string :ie_munic_declar, :length => 12, :pad_byte => '0'
         
     | 
| 
      
 14 
     | 
    
         
            +
            		string :divida_ativa_etiqueta, :length => 13, :pad_byte => '0'
         
     | 
| 
      
 15 
     | 
    
         
            +
            		string :periodo_referencia, :length => 6, :pad_byte => '0'
         
     | 
| 
      
 16 
     | 
    
         
            +
            		string :numero_parcela_notificacao, :length => 13, :pad_byte => '0'
         
     | 
| 
      
 17 
     | 
    
         
            +
            		string :valor_receita, :length => 15, :pad_byte => '0'
         
     | 
| 
      
 18 
     | 
    
         
            +
            		string :valor_juros_encargos, :length => 14, :pad_byte => '0'
         
     | 
| 
      
 19 
     | 
    
         
            +
            		string :valor_multa, :length => 14, :pad_byte => '0'
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
            		string :cnab, :length => 1, :pad_byte => ' '
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            	end
         
     | 
| 
      
 25 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,23 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Cnab240
         
     | 
| 
      
 2 
     | 
    
         
            +
            	class SegmentoN5 < BinData::Record
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            		include Cnab240::DefaultMixin
         
     | 
| 
      
 5 
     | 
    
         
            +
            		include Cnab240::SegmentoMixin
         
     | 
| 
      
 6 
     | 
    
         
            +
            		
         
     | 
| 
      
 7 
     | 
    
         
            +
            		string :receita, :length => 6, :pad_byte => ' '
         
     | 
| 
      
 8 
     | 
    
         
            +
            		string :tipo_identificacao_contribuinte, :length => 2, :pad_byte => '0'
         
     | 
| 
      
 9 
     | 
    
         
            +
            		string :identificacao_contribuinte, :length => 14, :pad_byte => '0'
         
     | 
| 
      
 10 
     | 
    
         
            +
            		string :identificacao_tributo, :length => 2, :pad_byte => ' '
         
     | 
| 
      
 11 
     | 
    
         
            +
            		
         
     | 
| 
      
 12 
     | 
    
         
            +
            		string :exercicio, :length => 4, :pad_byte => '0'
         
     | 
| 
      
 13 
     | 
    
         
            +
            		string :renavam, :length => 9, :pad_byte => '0'
         
     | 
| 
      
 14 
     | 
    
         
            +
            		string :uf, :length => 2, :pad_byte => ' '
         
     | 
| 
      
 15 
     | 
    
         
            +
            		string :municipio, :length => 5, :pad_byte => '0'
         
     | 
| 
      
 16 
     | 
    
         
            +
            		string :placa, :length => 7, :pad_byte => ' '
         
     | 
| 
      
 17 
     | 
    
         
            +
            		string :opcao_pagamento, :length => 1, :pad_byte => ' '
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            		string :cnab, :length => 68, :pad_byte => ' '
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            	end
         
     | 
| 
      
 23 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,23 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Cnab240
         
     | 
| 
      
 2 
     | 
    
         
            +
            	class SegmentoN6 < BinData::Record
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            		include Cnab240::DefaultMixin
         
     | 
| 
      
 5 
     | 
    
         
            +
            		include Cnab240::SegmentoMixin
         
     | 
| 
      
 6 
     | 
    
         
            +
            		
         
     | 
| 
      
 7 
     | 
    
         
            +
            		string :receita, :length => 6, :pad_byte => ' '
         
     | 
| 
      
 8 
     | 
    
         
            +
            		string :tipo_identificacao_contribuinte, :length => 2, :pad_byte => '0'
         
     | 
| 
      
 9 
     | 
    
         
            +
            		string :identificacao_contribuinte, :length => 14, :pad_byte => '0'
         
     | 
| 
      
 10 
     | 
    
         
            +
            		string :identificacao_tributo, :length => 2, :pad_byte => ' '
         
     | 
| 
      
 11 
     | 
    
         
            +
            		
         
     | 
| 
      
 12 
     | 
    
         
            +
            		string :exercicio, :length => 4, :pad_byte => '0'
         
     | 
| 
      
 13 
     | 
    
         
            +
            		string :renavam, :length => 9, :pad_byte => '0'
         
     | 
| 
      
 14 
     | 
    
         
            +
            		string :uf, :length => 2, :pad_byte => ' '
         
     | 
| 
      
 15 
     | 
    
         
            +
            		string :municipio, :length => 5, :pad_byte => '0'
         
     | 
| 
      
 16 
     | 
    
         
            +
            		string :placa, :length => 7, :pad_byte => ' '
         
     | 
| 
      
 17 
     | 
    
         
            +
            		string :opcao_pagamento, :length => 1, :pad_byte => ' '
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            		string :cnab, :length => 68, :pad_byte => ' '
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            	end
         
     | 
| 
      
 23 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,23 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Cnab240
         
     | 
| 
      
 2 
     | 
    
         
            +
            	class SegmentoN7 < BinData::Record
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            		include Cnab240::DefaultMixin
         
     | 
| 
      
 5 
     | 
    
         
            +
            		include Cnab240::SegmentoMixin
         
     | 
| 
      
 6 
     | 
    
         
            +
            		
         
     | 
| 
      
 7 
     | 
    
         
            +
            		string :receita, :length => 6, :pad_byte => ' '
         
     | 
| 
      
 8 
     | 
    
         
            +
            		string :tipo_identificacao_contribuinte, :length => 2, :pad_byte => '0'
         
     | 
| 
      
 9 
     | 
    
         
            +
            		string :identificacao_contribuinte, :length => 14, :pad_byte => '0'
         
     | 
| 
      
 10 
     | 
    
         
            +
            		string :identificacao_tributo, :length => 2, :pad_byte => ' '
         
     | 
| 
      
 11 
     | 
    
         
            +
            		
         
     | 
| 
      
 12 
     | 
    
         
            +
            		string :exercicio, :length => 4, :pad_byte => '0'
         
     | 
| 
      
 13 
     | 
    
         
            +
            		string :renavam, :length => 9, :pad_byte => '0'
         
     | 
| 
      
 14 
     | 
    
         
            +
            		string :uf, :length => 2, :pad_byte => ' '
         
     | 
| 
      
 15 
     | 
    
         
            +
            		string :municipio, :length => 5, :pad_byte => '0'
         
     | 
| 
      
 16 
     | 
    
         
            +
            		string :placa, :length => 7, :pad_byte => ' '
         
     | 
| 
      
 17 
     | 
    
         
            +
            		string :opcao_pagamento, :length => 1, :pad_byte => ' '
         
     | 
| 
      
 18 
     | 
    
         
            +
            		string :opcao_retirada, :length => 1, :pad_byte => ' '
         
     | 
| 
      
 19 
     | 
    
         
            +
            		string :cnab, :length => 67, :pad_byte => ' '
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            	end
         
     | 
| 
      
 23 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,25 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Cnab240
         
     | 
| 
      
 2 
     | 
    
         
            +
            	class SegmentoN8 < BinData::Record
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            		include Cnab240::DefaultMixin
         
     | 
| 
      
 5 
     | 
    
         
            +
            		include Cnab240::SegmentoMixin
         
     | 
| 
      
 6 
     | 
    
         
            +
            		
         
     | 
| 
      
 7 
     | 
    
         
            +
            		string :receita, :length => 6, :pad_byte => ' '
         
     | 
| 
      
 8 
     | 
    
         
            +
            		string :tipo_identificacao_contribuinte, :length => 2, :pad_byte => '0'
         
     | 
| 
      
 9 
     | 
    
         
            +
            		string :identificacao_contribuinte, :length => 14, :pad_byte => '0'
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            		string :ie_munic_declar, :length => 8, :pad_byte => ' '
         
     | 
| 
      
 13 
     | 
    
         
            +
            		
         
     | 
| 
      
 14 
     | 
    
         
            +
            		string :origem, :length => 16, :pad_byte => '0'
         
     | 
| 
      
 15 
     | 
    
         
            +
            		string :valor_principal, :length => 15, :pad_byte => '0'
         
     | 
| 
      
 16 
     | 
    
         
            +
            		string :atualizacao_monetaria, :length => 15, :pad_byte => ' '
         
     | 
| 
      
 17 
     | 
    
         
            +
            		string :valor_mora, :length => 15, :pad_byte => '0'
         
     | 
| 
      
 18 
     | 
    
         
            +
            		string :valor_multa, :length => 15, :pad_byte => ' '
         
     | 
| 
      
 19 
     | 
    
         
            +
            		string :data_vencimento, :length => 8, :pad_byte => ' '
         
     | 
| 
      
 20 
     | 
    
         
            +
            		string :periodo_parcela, :length => 6, :pad_byte => ' '
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            	end
         
     | 
| 
      
 25 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -2,13 +2,14 @@ module Cnab240 
     | 
|
| 
       2 
2 
     | 
    
         
             
            	class SegmentoO < BinData::Record
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
4 
     | 
    
         
             
            		include Cnab240::DefaultMixin
         
     | 
| 
      
 5 
     | 
    
         
            +
            		include Cnab240::SegmentoMixin
         
     | 
| 
       5 
6 
     | 
    
         | 
| 
       6 
7 
     | 
    
         
             
            		string :controle_banco, :length => 3, :pad_byte => '0'
         
     | 
| 
       7 
8 
     | 
    
         
             
            		string :controle_lote, :length => 4, :pad_byte => '0'
         
     | 
| 
       8 
9 
     | 
    
         
             
            		string :controle_registro, :length => 1, :initial_value => '3', :pad_byte => '0'
         
     | 
| 
       9 
10 
     | 
    
         | 
| 
       10 
11 
     | 
    
         
             
            		string :servico_numero_registro, :length => 5, :pad_byte => '0'
         
     | 
| 
       11 
     | 
    
         
            -
            		string :servico_codigo_segmento, : 
     | 
| 
      
 12 
     | 
    
         
            +
            		string :servico_codigo_segmento, :length => 1, :initial_value  => 'O', :pad_byte => ' '
         
     | 
| 
       12 
13 
     | 
    
         
             
            		string :servico_tipo_movimento, :length => 1, :pad_byte => '0'
         
     | 
| 
       13 
14 
     | 
    
         
             
            		string :servico_codigo_movimento, :length => 2, :pad_byte => '0'
         
     | 
| 
       14 
15 
     | 
    
         | 
| 
         @@ -2,13 +2,14 @@ module Cnab240 
     | 
|
| 
       2 
2 
     | 
    
         
             
            	class SegmentoW < BinData::Record
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
4 
     | 
    
         
             
            		include Cnab240::DefaultMixin
         
     | 
| 
      
 5 
     | 
    
         
            +
            		include Cnab240::SegmentoMixin
         
     | 
| 
       5 
6 
     | 
    
         | 
| 
       6 
7 
     | 
    
         
             
            		string :controle_banco, :length => 3, :pad_byte => '0'
         
     | 
| 
       7 
8 
     | 
    
         
             
            		string :controle_lote, :length => 4, :pad_byte => '0'
         
     | 
| 
       8 
9 
     | 
    
         
             
            		string :controle_registro, :length => 1, :initial_value => '3', :pad_byte => '0'
         
     | 
| 
       9 
10 
     | 
    
         | 
| 
       10 
11 
     | 
    
         
             
            		string :servico_numero_registro, :length => 5, :pad_byte => '0'
         
     | 
| 
       11 
     | 
    
         
            -
            		string :servico_codigo_segmento, : 
     | 
| 
      
 12 
     | 
    
         
            +
            		string :servico_codigo_segmento, :length => 1, :initial_value  => 'W', :pad_byte => ' '
         
     | 
| 
       12 
13 
     | 
    
         
             
            		string :complemento, :length => 1, :pad_byte => '0'
         
     | 
| 
       13 
14 
     | 
    
         | 
| 
       14 
15 
     | 
    
         
             
            		string :uso_informacoes_1_e_2, :length => 1, :pad_byte => ' '
         
     |