cnab240 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ .DS_Store
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.8.7
4
+ - 1.9.3
5
+ - jruby-18mode
6
+ - jruby-19mode
7
+ - rbx-18mode
8
+ - rbx-19mode
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cnab240.gemspec
4
+ gemspec
5
+
6
+ gem "rake", :group => :test
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 J. Eduardo R. Mourao
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # CNAB 240
2
+
3
+ [![Build Status](https://secure.travis-ci.org/eduardordm/cnab240.png)](http://travis-ci.org/eduardordm/cnab240)
4
+
5
+ Esta é uma implementação do Layout Padrão Febraban 240 posições, baseada no BinData.
6
+
7
+ ## Instalação
8
+
9
+ Adicione ao Gemfile:
10
+
11
+ gem 'cnab240'
12
+
13
+ execute:
14
+
15
+ $ bundle
16
+
17
+ Ou adicione no seu chiqueiro:
18
+
19
+ $ gem install cnab240
20
+
21
+ ## Como usar
22
+
23
+ TODO: ...
24
+
25
+ ## Contribuindo
26
+
27
+ Adicione testes, abra o pull request.
28
+
29
+ Regras:
30
+
31
+ 1. Sem bikeshedding.
32
+ 2. Sem bikeshedding.
33
+ 3. Sem bikeshedding.
34
+
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task :default => :spec
data/cnab240.gemspec ADDED
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/cnab240/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.add_development_dependency "rspec"
6
+ gem.add_dependency "bindata"
7
+
8
+ gem.authors = ["Eduardo Mourao"]
9
+ gem.email = ["eduardo.a20@gmail.com"]
10
+ gem.description = %q{Formato CNAB 240.}
11
+ gem.summary = %q{Formato CNAB 240.}
12
+ gem.homepage = ""
13
+
14
+ gem.rubyforge_project = "cnab240"
15
+
16
+ gem.files = `git ls-files`.split($\)
17
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
+ gem.name = "cnab240"
20
+ gem.require_paths = ["lib"]
21
+ gem.version = Cnab240::VERSION
22
+ end
@@ -0,0 +1,32 @@
1
+ module Cnab240::Arquivo
2
+ class Arquivo
3
+ attr_accessor :header
4
+ attr_accessor :lotes
5
+ attr_accessor :trailer
6
+
7
+ def initialize
8
+ @header = Header.new
9
+ @trailer = Trailer.new
10
+ @lotes = []
11
+ end
12
+
13
+
14
+ def linhas
15
+ a = Array.new
16
+ a << @header.linha
17
+ @lotes.each do |lote|
18
+ lote.linhas.each do |linha|
19
+ a << linha
20
+ end
21
+ end
22
+ a << @trailer.linha
23
+ a
24
+ end
25
+
26
+ def string
27
+ a.join("\n")
28
+ end
29
+
30
+ end
31
+
32
+ end
@@ -0,0 +1,39 @@
1
+ module Cnab240::Arquivo
2
+ class Header < BinData::Record
3
+
4
+ include Cnab240::DefaultMixin
5
+
6
+ string :controle_banco, :length => 3
7
+ string :controle_lote, :value => '0000'
8
+ string :controle_registro, :value => '0'
9
+
10
+ string :cnab_g004_1, :length => 9
11
+
12
+ string :empresa_tipo, :length => 1
13
+ string :empresa_numero, :length => 14
14
+ string :empresa_convenio, :length => 20
15
+ string :empresa_agencia_codigo, :length => 5
16
+ string :empresa_agencia_dv, :length => 1
17
+ string :empresa_conta_numero, :length => 12
18
+ string :empresa_conta_dv, :length => 1
19
+ string :empresa_agencia_conta_dv, :length => 1
20
+ string :empresa_nome, :length => 30
21
+
22
+ string :banco_nome, :length => 30
23
+
24
+ string :cnab_g004_2, :length => 10
25
+
26
+ string :arquivo_codigo, :length => 1
27
+ string :arquivo_data_geracao, :length => 8
28
+ string :arquivo_hora_geracao,:length => 6
29
+ string :arquivo_sequencia, :length => 6
30
+ string :arquivo_layout, :value => '085'
31
+ string :arquivo_densidade, :length => 5
32
+
33
+ string :reservado_banco, :length => 20
34
+ string :reservado_empresa, :length => 20
35
+
36
+ string :cnab_g004_3, :length => 29
37
+
38
+ end
39
+ end
@@ -0,0 +1,18 @@
1
+ module Cnab240::Arquivo
2
+ class Trailer < BinData::Record
3
+
4
+ include Cnab240::DefaultMixin
5
+
6
+ string :controle_banco, :length => 3
7
+ string :controle_lote, :value => '9999'
8
+ string :controle_registro, :value => '9'
9
+
10
+ string :cnab_g004_1, :length => 9
11
+
12
+ string :totais_qtde_lotes, :length => 6
13
+ string :totais_qtde_registros, :length => 6
14
+ string :totais_qtde_contas_concil, :length => 6
15
+
16
+ string :cnab_g004_2, :length => 205
17
+ end
18
+ end
@@ -0,0 +1,47 @@
1
+ # Taken from Rails 2.1
2
+ class Module
3
+ def mod_attr_reader(*syms)
4
+ syms.each do |sym|
5
+ next if sym.is_a?(Hash)
6
+ class_eval(<<-EOS, __FILE__, __LINE__)
7
+ unless defined? @@#{sym}
8
+ @@#{sym} = nil
9
+ end
10
+
11
+ def self.#{sym}
12
+ @@#{sym}
13
+ end
14
+
15
+ def #{sym}
16
+ @@#{sym}
17
+ end
18
+ EOS
19
+ end
20
+ end
21
+
22
+ def mod_attr_writer(*syms)
23
+ options = syms
24
+ syms.each do |sym|
25
+ class_eval(<<-EOS, __FILE__, __LINE__)
26
+ unless defined? @@#{sym}
27
+ @@#{sym} = nil
28
+ end
29
+
30
+ def self.#{sym}=(obj)
31
+ @@#{sym} = obj
32
+ end
33
+
34
+ #{"
35
+ def #{sym}=(obj)
36
+ @@#{sym} = obj
37
+ end
38
+ " }
39
+ EOS
40
+ end
41
+ end
42
+
43
+ def mod_attr_accessor(*syms)
44
+ mod_attr_reader(*syms)
45
+ mod_attr_writer(*syms)
46
+ end
47
+ end
@@ -0,0 +1,9 @@
1
+ module BinData
2
+ class Record < BinData::Struct
3
+ def linha # lulz
4
+ s = StringIO.new
5
+ self.write(s)
6
+ s.string
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,12 @@
1
+ module Cnab240
2
+ module DefaultMixin
3
+ def initialize_instance
4
+ super
5
+ Cnab240.defaults.each do |k, v|
6
+ if self.respond_to?("#{k}=")
7
+ self.send("#{k}=", v)
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,41 @@
1
+ module Cnab240::Pagamentos
2
+ class Header < BinData::Record
3
+
4
+ include Cnab240::DefaultMixin
5
+
6
+ string :controle_banco, :length => 3
7
+ string :controle_lote, :length => 4
8
+ string :controle_registro, :length => 1, :initial_value => '1'
9
+
10
+ string :servico_operacao, :value => 'C'
11
+ string :servico_tipo, :length => 2
12
+ string :servico_forma, :length => 2
13
+ string :servico_layout, :value => '044'
14
+
15
+ string :cnab_g004_1, :length => 1
16
+
17
+ string :empresa_tipo, :length => 1
18
+ string :empresa_numero, :length => 14
19
+ string :empresa_convenio, :length => 20
20
+ string :empresa_agencia_codigo, :length => 5
21
+ string :empresa_agencia_dv, :length => 1
22
+ string :empresa_conta_numero, :length => 12
23
+ string :empresa_conta_dv, :length => 1
24
+ string :empresa_agencia_conta_dv, :length => 1
25
+ string :empresa_nome, :length => 30
26
+
27
+ string :informacao_1, :length => 40
28
+
29
+ string :endereco_logradouro, :length => 30
30
+ string :endereco_numero, :length => 5
31
+ string :endereco_complemento, :length => 15
32
+ string :endereco_cidade, :length => 20
33
+ string :endereco_cep, :length => 5
34
+ string :endereco_complemento_cep, :length => 3
35
+ string :endereco_estado, :length => 2
36
+
37
+ string :indicativo_forma_pagamento, :length => 2
38
+ string :cnab_g004_2, :length => 6
39
+ string :ocorrencias, :length => 10
40
+ end
41
+ end
@@ -0,0 +1,25 @@
1
+ module Cnab240::Pagamentos
2
+ class Lote
3
+ attr_accessor :header
4
+ attr_accessor :segmento_a
5
+ attr_accessor :segmento_b
6
+ attr_accessor :segmento_c
7
+ attr_accessor :trailer
8
+
9
+ def initialize
10
+ @header = Header.new
11
+ @segmento_a = SegmentoA.new
12
+ @segmento_b = SegmentoB.new
13
+ @trailer = Trailer.new
14
+ end
15
+
16
+ def linhas
17
+ @segmento_c.nil? ? [@header, @segmento_a, @segmento_b, @trailer] : [@header, @segmento_a, @segmento_b, @segmento_c, @trailer]
18
+ end
19
+
20
+ def string
21
+ linhas.join("\n")
22
+ end
23
+
24
+ end
25
+ end
@@ -0,0 +1,18 @@
1
+ module Cnab240::Pagamentos
2
+ class Trailer < BinData::Record
3
+
4
+ include Cnab240::DefaultMixin
5
+
6
+ string :controle_banco, :length => 3
7
+ string :controle_lote, :length => 4
8
+ string :controle_registro, :value => '5'
9
+
10
+ string :cnab_g004_1, :length => 9
11
+ string :totais_qtde_registros, :length => 6
12
+ string :totais_valor, :length => 18
13
+ string :totais_qtde_moeda, :length => 18
14
+ string :numero_aviso_debito, :length => 6
15
+ string :cnab_g004_2, :length => 165
16
+ string :ocorrencias, :length => 10
17
+ end
18
+ end
@@ -0,0 +1,44 @@
1
+ module Cnab240
2
+ class SegmentoA < BinData::Record
3
+
4
+ include Cnab240::DefaultMixin
5
+
6
+ string :controle_banco, :length => 3
7
+ string :controle_lote, :length => 4
8
+ string :controle_registro, :length => 1, :initial_value => '3'
9
+
10
+ string :servico_numero_registro, :length => 5
11
+ string :servico_codigo_segmento, :value => 'A'
12
+ string :servico_tipo_movimento, :length => 1
13
+ string :servico_codigo_movimento, :length => 2
14
+
15
+ string :favorecido_camara, :length => 3
16
+ string :favorecido_banco, :length => 3
17
+ string :favorecido_agencia_codigo, :length => 5
18
+ string :favorecido_agencia_dv, :length => 1
19
+ string :favorecido_conta_numero, :length => 12
20
+ string :favorecido_conta_dv, :length => 1
21
+ string :favorecido_agencia_conta_dv, :length => 1
22
+ string :favorecido_nome, :length => 30
23
+
24
+ string :credito_seu_numero, :length => 20
25
+ string :credito_data_pagamento, :length => 8
26
+ string :credito_moeda_tipo, :length => 3
27
+ string :credito_moeda_quantidade, :length => 15
28
+ string :credito_valor_pagamento, :length => 15
29
+ string :credito_nosso_numero, :length => 20
30
+ string :credito_data_real, :length => 8
31
+ string :credito_valor_real, :length => 15
32
+
33
+ string :informacao_2, :length => 40
34
+
35
+ string :codigo_finalidade_doc, :length => 2
36
+ string :codigo_finalidade_ted, :length => 5
37
+ string :codigo_finalidade_complementar, :length => 2
38
+
39
+ string :cnab_g004_1, :length => 3
40
+ string :aviso, :length => 1
41
+ string :ocorrencias, :length => 10
42
+
43
+ end
44
+ end
@@ -0,0 +1,40 @@
1
+ module Cnab240
2
+ class SegmentoB < BinData::Record
3
+
4
+ include Cnab240::DefaultMixin
5
+
6
+ string :controle_banco, :length => 3
7
+ string :controle_lote, :length => 4
8
+ string :controle_registro, :length => 1, :initial_value => '3'
9
+
10
+ string :servico_numero_registro, :length => 5
11
+ string :servico_codigo_segmento, :value => 'B'
12
+
13
+ string :cnab240_g004_1, :length => 3
14
+
15
+ string :favorecido_inscricao_tipo, :length => 1
16
+ string :favorecido_inscricao_numero, :length => 14
17
+ string :favorecido_endereco_logradouro, :length => 30
18
+ string :favorecido_endereco_numero, :length => 5
19
+ string :favorecido_endereco_complemento, :length => 15
20
+ string :favorecido_endereco_bairro, :length => 15
21
+ string :favorecido_endereco_cidade, :length => 20
22
+ string :favorecido_endereco_cep, :length => 5
23
+ string :favorecido_endereco_cep_complemento, :length => 3
24
+ string :favorecido_endereco_estado, :length => 2
25
+
26
+ string :pagamento_data_vencimento, :length => 8
27
+ string :pagamento_valor_documento, :length => 15
28
+ string :pagamento_valor_abatimento, :length => 15
29
+ string :pagamento_valor_desconto, :length => 15
30
+ string :pagamento_valor_mora, :length => 15
31
+ string :pagamento_valor_multa, :length => 15
32
+
33
+ string :codigo_documento_favorecido, :length => 15
34
+ string :aviso, :length => 1
35
+ string :codigo_ug, :length => 6
36
+
37
+ string :cnab_g004_2, :length => 8
38
+
39
+ end
40
+ end
@@ -0,0 +1,32 @@
1
+ module Cnab240
2
+ class SegmentoC < BinData::Record
3
+
4
+ include Cnab240::DefaultMixin
5
+
6
+ string :controle_banco, :length => 3
7
+ string :controle_lote, :length => 4
8
+ string :controle_registro, :length => 1, :initial_value => '3'
9
+
10
+ string :servico_numero_registro, :length => 5
11
+ string :servico_codigo_segmento, :value => 'C'
12
+
13
+ string :cnab240_g004_1, :length => 3
14
+
15
+ string :complementar_valor_ir, :length => 15
16
+ string :complementar_valor_iss, :length => 15
17
+ string :complementar_valor_iof, :length => 15
18
+ string :complementar_valor_outras_deducoes, :length => 15
19
+ string :complementar_valor_outros_acrescimos, :length => 15
20
+
21
+ string :substituta_agencia, :length => 5
22
+ string :substituta_agencia_dv, :length => 1
23
+ string :substituta_numero_cc, :length => 12
24
+ string :substituta_conta_dv, :length => 1
25
+ string :substituta_agencia_conta_dv, :length => 1
26
+
27
+ string :valor_inss, :length => 15
28
+
29
+ string :cnab_g004_2, :length => 113
30
+
31
+ end
32
+ end
@@ -0,0 +1,4 @@
1
+ module Cnab240
2
+ VERSION = "0.0.1"
3
+ end
4
+
data/lib/cnab240.rb ADDED
@@ -0,0 +1,41 @@
1
+ require "cnab240/version"
2
+
3
+ require 'bindata'
4
+
5
+ require "cnab240/core_ext/attribute_accessors"
6
+ require "cnab240/core_ext/bindata"
7
+ require "cnab240/core_ext/default_mixin"
8
+
9
+ require "cnab240/segmentos/segmento_a"
10
+ require "cnab240/segmentos/segmento_b"
11
+ require "cnab240/segmentos/segmento_c"
12
+
13
+ require "cnab240/arquivo/arquivo"
14
+ require "cnab240/arquivo/header"
15
+ require "cnab240/arquivo/trailer"
16
+
17
+ require "cnab240/pagamentos/header"
18
+ require "cnab240/pagamentos/trailer"
19
+ require "cnab240/pagamentos/lote"
20
+
21
+
22
+ module Cnab240
23
+
24
+ mod_attr_accessor :defaults
25
+ @@defaults = {}
26
+
27
+
28
+ # Yield self for configuration block:
29
+ #
30
+ # Cnab240.setup do |config|
31
+ # config.banco = "001"
32
+ # end
33
+ #
34
+ def self.setup
35
+ yield self
36
+ end
37
+
38
+ end
39
+
40
+
41
+
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+
3
+ include Cnab240::Pagamentos
4
+ include Cnab240::Arquivo
5
+
6
+ describe Arquivo do
7
+
8
+ it "deve instanciar" do
9
+ arquivo = Cnab240::Arquivo::Arquivo.new
10
+ arquivo.should be_an_instance_of(Cnab240::Arquivo::Arquivo)
11
+ end
12
+
13
+ it "deve aceitar lotes" do
14
+ arquivo = Cnab240::Arquivo::Arquivo.new
15
+ arquivo.should respond_to(:lotes)
16
+
17
+ (1..10).each do |n|
18
+ lote = Cnab240::Pagamentos::Lote.new
19
+ lote.should be_an_instance_of(Cnab240::Pagamentos::Lote)
20
+ arquivo.lotes << lote
21
+ arquivo.lotes.length.should be(n)
22
+ end
23
+ end
24
+
25
+ it "deve manter 240 em todo o arquivo" do
26
+ arquivo = Cnab240::Arquivo::Arquivo.new
27
+ arquivo.should respond_to(:lotes)
28
+
29
+ (1..10).each do |n|
30
+ lote = Cnab240::Pagamentos::Lote.new
31
+ lote.should be_an_instance_of(Cnab240::Pagamentos::Lote)
32
+ arquivo.lotes << lote
33
+ end
34
+
35
+ arquivo.linhas do |linha|
36
+ linha.length.should be(240)
37
+ end
38
+ end
39
+
40
+ end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+
4
+ describe Cnab240::Arquivo::Header do
5
+
6
+ it "deve ter campos de header" do
7
+ header = Cnab240::Arquivo::Header.new
8
+
9
+ header.should respond_to(:controle_banco)
10
+ header.should respond_to(:controle_lote)
11
+ header.should respond_to(:controle_registro)
12
+
13
+ header.should respond_to(:cnab_g004_1)
14
+
15
+ header.should respond_to(:empresa_tipo)
16
+ header.should respond_to(:empresa_numero)
17
+ header.should respond_to(:empresa_convenio)
18
+ header.should respond_to(:empresa_agencia_codigo)
19
+ header.should respond_to(:empresa_agencia_dv)
20
+ header.should respond_to(:empresa_conta_numero)
21
+ header.should respond_to(:empresa_conta_dv)
22
+ header.should respond_to(:empresa_agencia_conta_dv)
23
+ header.should respond_to(:empresa_nome)
24
+
25
+ header.should respond_to(:banco_nome)
26
+
27
+ header.should respond_to(:cnab_g004_2)
28
+
29
+ header.should respond_to(:arquivo_codigo)
30
+ header.should respond_to(:arquivo_data_geracao)
31
+ header.should respond_to(:arquivo_hora_geracao)
32
+ header.should respond_to(:arquivo_sequencia)
33
+ header.should respond_to(:arquivo_layout)
34
+ header.should respond_to(:arquivo_densidade)
35
+
36
+ header.should respond_to(:reservado_banco)
37
+ header.should respond_to(:reservado_empresa)
38
+
39
+ header.should respond_to(:cnab_g004_3)
40
+ end
41
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+
4
+ describe Cnab240::Arquivo::Trailer do
5
+
6
+ it "deve conter campos trailer" do
7
+ header = Cnab240::Arquivo::Trailer.new
8
+
9
+ header.should respond_to(:controle_banco)
10
+ header.should respond_to(:controle_lote)
11
+ header.should respond_to(:controle_registro)
12
+
13
+ header.should respond_to(:cnab_g004_1)
14
+
15
+ header.should respond_to(:totais_qtde_lotes)
16
+ header.should respond_to(:totais_qtde_registros)
17
+ header.should respond_to(:totais_qtde_contas_concil)
18
+
19
+ header.should respond_to(:cnab_g004_2)
20
+ end
21
+
22
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe Cnab240 do
4
+
5
+ it "deve ter campos de configuracao" do
6
+ Cnab240.setup do |config|
7
+ config.should respond_to(:defaults)
8
+ defaults[:empresa_tipo] = "1"
9
+ end
10
+ Cnab240.defaults[:empresa_tipo].should eq("1")
11
+ end
12
+
13
+ it "configuracao deve ter efeito" do
14
+ Cnab240.setup do |config|
15
+ defaults[:empresa_tipo] = "1"
16
+ end
17
+ Cnab240.defaults[:empresa_tipo].should eq("1")
18
+ arquivo = Cnab240::Arquivo::Arquivo.new
19
+ arquivo.header.empresa_tipo.should eq("1")
20
+ end
21
+
22
+ end
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+
3
+ describe Cnab240::Pagamentos::Header do
4
+
5
+ it "deve conter campos header" do
6
+ lote = Cnab240::Pagamentos::Lote.new
7
+
8
+ header = lote.header
9
+
10
+ header.should respond_to(:controle_banco)
11
+ header.should respond_to(:controle_lote)
12
+ header.should respond_to(:controle_registro)
13
+
14
+ header.should respond_to(:servico_operacao)
15
+ header.should respond_to(:servico_tipo)
16
+ header.should respond_to(:servico_forma)
17
+ header.should respond_to(:servico_layout)
18
+
19
+ header.should respond_to(:cnab_g004_1)
20
+
21
+ header.should respond_to(:empresa_tipo)
22
+ header.should respond_to(:empresa_numero)
23
+ header.should respond_to(:empresa_convenio)
24
+ header.should respond_to(:empresa_agencia_codigo)
25
+ header.should respond_to(:empresa_agencia_dv)
26
+ header.should respond_to(:empresa_conta_numero)
27
+ header.should respond_to(:empresa_conta_dv)
28
+ header.should respond_to(:empresa_agencia_conta_dv)
29
+ header.should respond_to(:empresa_nome)
30
+
31
+ header.should respond_to(:informacao_1)
32
+
33
+ header.should respond_to(:endereco_logradouro)
34
+ header.should respond_to(:endereco_numero)
35
+ header.should respond_to(:endereco_complemento)
36
+ header.should respond_to(:endereco_cidade)
37
+ header.should respond_to(:endereco_cep)
38
+ header.should respond_to(:endereco_complemento_cep)
39
+ header.should respond_to(:endereco_estado)
40
+
41
+ header.should respond_to(:indicativo_forma_pagamento)
42
+
43
+ header.should respond_to(:cnab_g004_2)
44
+
45
+ header.should respond_to(:ocorrencias)
46
+
47
+ end
48
+
49
+
50
+ it "header deve ter 240 caracteres" do
51
+ lote = Cnab240::Pagamentos::Lote.new
52
+ lote.header.linha.length.should be(240)
53
+ end
54
+
55
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe Cnab240::Pagamentos::Lote do
4
+
5
+ it "deve conter trailer e header" do
6
+ lote = Cnab240::Pagamentos::Lote.new
7
+ lote.header.should be_an_instance_of(Cnab240::Pagamentos::Header)
8
+ lote.trailer.should be_an_instance_of(Cnab240::Pagamentos::Trailer)
9
+ end
10
+
11
+ it "deve conter segmento a" do
12
+ lote = Cnab240::Pagamentos::Lote.new
13
+ lote.segmento_a.should be_an_instance_of(Cnab240::SegmentoA)
14
+ end
15
+
16
+ it "deve conter segmento b" do
17
+ lote = Cnab240::Pagamentos::Lote.new
18
+ lote.segmento_b.should be_an_instance_of(Cnab240::SegmentoB)
19
+ end
20
+
21
+ it "pode conter segmento c" do
22
+ lote = Cnab240::Pagamentos::Lote.new
23
+ lote.should respond_to(:segmento_c)
24
+ end
25
+
26
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe Cnab240::Pagamentos::Trailer do
4
+
5
+ it "deve conter campos trailer" do
6
+ lote = Cnab240::Pagamentos::Lote.new
7
+
8
+ trailer = lote.trailer
9
+
10
+ trailer.should respond_to(:controle_banco)
11
+ trailer.should respond_to(:controle_lote)
12
+ trailer.should respond_to(:controle_registro)
13
+
14
+ trailer.should respond_to(:cnab_g004_1)
15
+
16
+ trailer.should respond_to(:totais_qtde_registros)
17
+ trailer.should respond_to(:totais_valor)
18
+ trailer.should respond_to(:totais_qtde_moeda)
19
+
20
+ trailer.should respond_to(:numero_aviso_debito)
21
+
22
+ trailer.should respond_to(:cnab_g004_2)
23
+
24
+ trailer.should respond_to(:ocorrencias)
25
+ end
26
+
27
+ it "trailer deve ter 240 caracteres" do
28
+ lote = Cnab240::Pagamentos::Lote.new
29
+ lote.trailer.linha.length.should be(240)
30
+ end
31
+
32
+ end
@@ -0,0 +1,56 @@
1
+ require 'spec_helper'
2
+
3
+ include Cnab240
4
+
5
+ describe SegmentoA do
6
+
7
+ it "deve instanciar segmento" do
8
+ segmento = SegmentoA.new
9
+ segmento.should be_an_instance_of(SegmentoA)
10
+ end
11
+
12
+ it "deve conter campos" do
13
+ segmento = SegmentoA.new
14
+
15
+ segmento.should respond_to(:controle_banco)
16
+ segmento.should respond_to(:controle_lote)
17
+ segmento.should respond_to(:controle_registro)
18
+
19
+ segmento.should respond_to(:servico_numero_registro)
20
+ segmento.should respond_to(:servico_codigo_segmento)
21
+ segmento.should respond_to(:servico_tipo_movimento)
22
+ segmento.should respond_to(:servico_codigo_movimento)
23
+
24
+ segmento.should respond_to(:favorecido_camara)
25
+ segmento.should respond_to(:favorecido_banco)
26
+ segmento.should respond_to(:favorecido_agencia_codigo)
27
+ segmento.should respond_to(:favorecido_agencia_dv)
28
+ segmento.should respond_to(:favorecido_conta_numero)
29
+ segmento.should respond_to(:favorecido_conta_dv)
30
+ segmento.should respond_to(:favorecido_nome)
31
+
32
+ segmento.should respond_to(:credito_seu_numero)
33
+ segmento.should respond_to(:credito_data_pagamento)
34
+ segmento.should respond_to(:credito_moeda_tipo)
35
+ segmento.should respond_to(:credito_moeda_quantidade)
36
+ segmento.should respond_to(:credito_valor_pagamento)
37
+ segmento.should respond_to(:credito_nosso_numero)
38
+ segmento.should respond_to(:credito_data_real)
39
+ segmento.should respond_to(:credito_valor_real)
40
+
41
+ segmento.should respond_to(:informacao_2)
42
+
43
+ segmento.should respond_to(:codigo_finalidade_doc)
44
+ segmento.should respond_to(:codigo_finalidade_ted)
45
+ segmento.should respond_to(:codigo_finalidade_complementar)
46
+ segmento.should respond_to(:cnab_g004_1)
47
+ segmento.should respond_to(:aviso)
48
+ segmento.should respond_to(:ocorrencias)
49
+ end
50
+
51
+ it "deve ter 240 caracteres" do
52
+ segmento = SegmentoA.new
53
+ segmento.linha.length.should be(240)
54
+ end
55
+
56
+ end
@@ -0,0 +1,58 @@
1
+ require 'spec_helper'
2
+
3
+ include Cnab240
4
+
5
+ describe SegmentoB do
6
+
7
+ it "deve instanciar segmento" do
8
+ segmento = SegmentoB.new
9
+ segmento.should be_an_instance_of(SegmentoB)
10
+ end
11
+
12
+ it "deve conter campos" do
13
+ segmento = SegmentoB.new
14
+
15
+ segmento.should respond_to(:controle_banco)
16
+ segmento.should respond_to(:controle_lote)
17
+ segmento.should respond_to(:controle_registro)
18
+
19
+ segmento.should respond_to(:servico_numero_registro)
20
+ segmento.should respond_to(:servico_codigo_segmento)
21
+
22
+ segmento.should respond_to(:cnab240_g004_1)
23
+
24
+ segmento.should respond_to(:favorecido_inscricao_tipo)
25
+ segmento.should respond_to(:favorecido_inscricao_numero)
26
+ segmento.should respond_to(:favorecido_endereco_logradouro)
27
+ segmento.should respond_to(:favorecido_endereco_numero)
28
+ segmento.should respond_to(:favorecido_endereco_complemento)
29
+ segmento.should respond_to(:favorecido_endereco_bairro)
30
+ segmento.should respond_to(:favorecido_endereco_cidade)
31
+ segmento.should respond_to(:favorecido_endereco_cep)
32
+ segmento.should respond_to(:favorecido_endereco_cep_complemento)
33
+ segmento.should respond_to(:favorecido_endereco_estado)
34
+
35
+ segmento.should respond_to(:pagamento_data_vencimento)
36
+ segmento.should respond_to(:pagamento_valor_documento)
37
+ segmento.should respond_to(:pagamento_valor_abatimento)
38
+ segmento.should respond_to(:pagamento_valor_desconto)
39
+ segmento.should respond_to(:pagamento_valor_mora)
40
+ segmento.should respond_to(:pagamento_valor_multa)
41
+
42
+ segmento.should respond_to(:codigo_documento_favorecido)
43
+
44
+ segmento.should respond_to(:aviso)
45
+
46
+ segmento.should respond_to(:codigo_ug)
47
+
48
+ segmento.should respond_to(:cnab_g004_2)
49
+
50
+ end
51
+
52
+
53
+ it "deve ter 240 caracteres" do
54
+ segmento = SegmentoB.new
55
+ segmento.linha.length.should be(240)
56
+ end
57
+
58
+ end
@@ -0,0 +1,42 @@
1
+ require 'spec_helper'
2
+
3
+ include Cnab240
4
+
5
+ describe SegmentoC do
6
+
7
+ it "deve instanciar segmento" do
8
+ segmento = SegmentoC.new
9
+ segmento.should be_an_instance_of(SegmentoC)
10
+ end
11
+
12
+ it "deve conter campos" do
13
+ segmento = SegmentoC.new
14
+
15
+ segmento.should respond_to(:servico_numero_registro)
16
+ segmento.should respond_to(:servico_codigo_segmento)
17
+
18
+ segmento.should respond_to(:cnab240_g004_1)
19
+
20
+ segmento.should respond_to(:complementar_valor_ir)
21
+ segmento.should respond_to(:complementar_valor_iss)
22
+ segmento.should respond_to(:complementar_valor_iof)
23
+ segmento.should respond_to(:complementar_valor_outras_deducoes)
24
+ segmento.should respond_to(:complementar_valor_outros_acrescimos)
25
+
26
+ segmento.should respond_to(:substituta_agencia)
27
+ segmento.should respond_to(:substituta_agencia_dv)
28
+ segmento.should respond_to(:substituta_numero_cc)
29
+ segmento.should respond_to(:substituta_conta_dv)
30
+ segmento.should respond_to(:substituta_agencia_conta_dv)
31
+
32
+ segmento.should respond_to(:valor_inss)
33
+
34
+ segmento.should respond_to(:cnab_g004_2)
35
+ end
36
+
37
+ it "deve ter 240 caracteres" do
38
+ segmento = SegmentoC.new
39
+ segmento.linha.length.should be(240)
40
+ end
41
+
42
+ end
@@ -0,0 +1,8 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ require 'cnab240'
5
+
6
+ RSpec.configure do |config|
7
+
8
+ end
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cnab240
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Eduardo Mourao
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-07-11 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: bindata
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: Formato CNAB 240.
47
+ email:
48
+ - eduardo.a20@gmail.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .gitignore
54
+ - .rspec
55
+ - .travis.yml
56
+ - Gemfile
57
+ - LICENSE
58
+ - README.md
59
+ - Rakefile
60
+ - cnab240.gemspec
61
+ - lib/cnab240.rb
62
+ - lib/cnab240/arquivo/arquivo.rb
63
+ - lib/cnab240/arquivo/header.rb
64
+ - lib/cnab240/arquivo/trailer.rb
65
+ - lib/cnab240/core_ext/attribute_accessors.rb
66
+ - lib/cnab240/core_ext/bindata.rb
67
+ - lib/cnab240/core_ext/default_mixin.rb
68
+ - lib/cnab240/pagamentos/header.rb
69
+ - lib/cnab240/pagamentos/lote.rb
70
+ - lib/cnab240/pagamentos/trailer.rb
71
+ - lib/cnab240/segmentos/segmento_a.rb
72
+ - lib/cnab240/segmentos/segmento_b.rb
73
+ - lib/cnab240/segmentos/segmento_c.rb
74
+ - lib/cnab240/version.rb
75
+ - spec/arquivo/arquivo_spec.rb
76
+ - spec/arquivo/header_spec.rb
77
+ - spec/arquivo/trailer_spec.rb
78
+ - spec/cnab240_spec.rb
79
+ - spec/pagamentos/header_spec.rb
80
+ - spec/pagamentos/lote_spec.rb
81
+ - spec/pagamentos/trailer_spec.rb
82
+ - spec/segmentos/segmento_a_spec.rb
83
+ - spec/segmentos/segmento_b_spec.rb
84
+ - spec/segmentos/segmento_c_spec.rb
85
+ - spec/spec_helper.rb
86
+ homepage: ''
87
+ licenses: []
88
+ post_install_message:
89
+ rdoc_options: []
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ none: false
94
+ requirements:
95
+ - - ! '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ segments:
99
+ - 0
100
+ hash: -3092847186393092884
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
+ none: false
103
+ requirements:
104
+ - - ! '>='
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ segments:
108
+ - 0
109
+ hash: -3092847186393092884
110
+ requirements: []
111
+ rubyforge_project: cnab240
112
+ rubygems_version: 1.8.24
113
+ signing_key:
114
+ specification_version: 3
115
+ summary: Formato CNAB 240.
116
+ test_files:
117
+ - spec/arquivo/arquivo_spec.rb
118
+ - spec/arquivo/header_spec.rb
119
+ - spec/arquivo/trailer_spec.rb
120
+ - spec/cnab240_spec.rb
121
+ - spec/pagamentos/header_spec.rb
122
+ - spec/pagamentos/lote_spec.rb
123
+ - spec/pagamentos/trailer_spec.rb
124
+ - spec/segmentos/segmento_a_spec.rb
125
+ - spec/segmentos/segmento_b_spec.rb
126
+ - spec/segmentos/segmento_c_spec.rb
127
+ - spec/spec_helper.rb