kivanio-brcobranca 2.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +21 -0
- data/Manifest.txt +48 -0
- data/README.rdoc +72 -0
- data/Rakefile +32 -0
- data/brcobranca.gemspec +47 -0
- data/lib/brcobranca/arquivos/logos/bb.jpg +0 -0
- data/lib/brcobranca/arquivos/logos/bradesco.jpg +0 -0
- data/lib/brcobranca/arquivos/logos/hsbc.jpg +0 -0
- data/lib/brcobranca/arquivos/logos/itau.jpg +0 -0
- data/lib/brcobranca/arquivos/logos/real.jpg +0 -0
- data/lib/brcobranca/arquivos/logos/unibanco.jpg +0 -0
- data/lib/brcobranca/arquivos/templates/modelo_generico.eps +0 -0
- data/lib/brcobranca/boleto/banco_bradesco.rb +31 -0
- data/lib/brcobranca/boleto/banco_brasil.rb +79 -0
- data/lib/brcobranca/boleto/banco_hsbc.rb +63 -0
- data/lib/brcobranca/boleto/banco_itau.rb +105 -0
- data/lib/brcobranca/boleto/banco_real.rb +56 -0
- data/lib/brcobranca/boleto/banco_unibanco.rb +65 -0
- data/lib/brcobranca/boleto/base.rb +148 -0
- data/lib/brcobranca/boleto/template/rghost.rb +151 -0
- data/lib/brcobranca/boleto/template/util.rb +30 -0
- data/lib/brcobranca/config.rb +9 -0
- data/lib/brcobranca/core_ext.rb +269 -0
- data/lib/brcobranca/currency.rb +70 -0
- data/lib/brcobranca/retorno/base.rb +43 -0
- data/lib/brcobranca/retorno/retorno_cbr643.rb +44 -0
- data/lib/brcobranca.rb +27 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +71 -0
- data/test/arquivos/CBR64310.RET +28 -0
- data/test/test_banco_bradesco.rb +87 -0
- data/test/test_banco_brasil.rb +276 -0
- data/test/test_banco_hsbc.rb +81 -0
- data/test/test_banco_itau.rb +103 -0
- data/test/test_banco_real.rb +112 -0
- data/test/test_banco_unibanco.rb +92 -0
- data/test/test_base.rb +162 -0
- data/test/test_core_ext.rb +227 -0
- data/test/test_currency.rb +51 -0
- data/test/test_helper.rb +5 -0
- data/test/test_retorno_cbr643.rb +66 -0
- data/website/index.html +89 -0
- data/website/index.txt +46 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +159 -0
- data/website/template.html.erb +57 -0
- metadata +164 -0
@@ -0,0 +1,43 @@
|
|
1
|
+
module Brcobranca
|
2
|
+
module Retorno
|
3
|
+
class Base
|
4
|
+
# Agência com DV, posições 17 à 21
|
5
|
+
attr_accessor :agencia_com_dv
|
6
|
+
attr_accessor :cedente_com_dv
|
7
|
+
attr_accessor :convenio
|
8
|
+
attr_accessor :nosso_numero
|
9
|
+
attr_accessor :tipo_cobranca
|
10
|
+
attr_accessor :tipo_cobranca_anterior
|
11
|
+
attr_accessor :natureza_recebimento
|
12
|
+
attr_accessor :carteira_variacao
|
13
|
+
attr_accessor :desconto
|
14
|
+
attr_accessor :iof
|
15
|
+
attr_accessor :carteira
|
16
|
+
attr_accessor :comando
|
17
|
+
attr_accessor :data_liquidacao
|
18
|
+
attr_accessor :data_vencimento
|
19
|
+
attr_accessor :valor_titulo
|
20
|
+
attr_accessor :banco_recebedor
|
21
|
+
attr_accessor :agencia_recebedora_com_dv
|
22
|
+
attr_accessor :especie_documento
|
23
|
+
attr_accessor :data_credito
|
24
|
+
attr_accessor :valor_tarifa
|
25
|
+
attr_accessor :outras_despesas
|
26
|
+
attr_accessor :juros_desconto
|
27
|
+
attr_accessor :iof_desconto
|
28
|
+
attr_accessor :valor_abatimento
|
29
|
+
attr_accessor :desconto_concedito
|
30
|
+
attr_accessor :valor_recebido
|
31
|
+
attr_accessor :juros_mora
|
32
|
+
attr_accessor :outros_recebimento
|
33
|
+
attr_accessor :abatimento_nao_aproveitado
|
34
|
+
attr_accessor :valor_lancamento
|
35
|
+
attr_accessor :indicativo_lancamento
|
36
|
+
attr_accessor :indicador_valor
|
37
|
+
attr_accessor :valor_ajuste
|
38
|
+
attr_accessor :sequencial
|
39
|
+
attr_accessor :arquivo
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'parseline'
|
2
|
+
|
3
|
+
# Formato de Retorno CNAB 643
|
4
|
+
class RetornoCbr643 < Brcobranca::Retorno::Base
|
5
|
+
# Extendendo parseline
|
6
|
+
extend ParseLine::FixedWidth
|
7
|
+
|
8
|
+
fixed_width_layout do |parse|
|
9
|
+
parse.field :agencia_com_dv,17..21
|
10
|
+
parse.field :cedente_com_dv,22..30
|
11
|
+
parse.field :convenio,31..37
|
12
|
+
parse.field :nosso_numero,63..79
|
13
|
+
parse.field :tipo_cobranca,80..80
|
14
|
+
parse.field :tipo_cobranca_anterior,81..81
|
15
|
+
parse.field :natureza_recebimento,86..87
|
16
|
+
parse.field :carteira_variacao,91..93
|
17
|
+
parse.field :desconto,95..99
|
18
|
+
parse.field :iof,100..104
|
19
|
+
parse.field :carteira,106..107
|
20
|
+
parse.field :comando,108..109
|
21
|
+
parse.field :data_liquidacao,110..115
|
22
|
+
parse.field :data_vencimento,146..151
|
23
|
+
parse.field :valor_titulo,152..164
|
24
|
+
parse.field :banco_recebedor,165..167
|
25
|
+
parse.field :agencia_recebedora_com_dv,168..172
|
26
|
+
parse.field :especie_documento,173..174
|
27
|
+
parse.field :data_credito,175..180
|
28
|
+
parse.field :valor_tarifa,181..187
|
29
|
+
parse.field :outras_despesas,188..200
|
30
|
+
parse.field :juros_desconto,201..213
|
31
|
+
parse.field :iof_desconto,214..226
|
32
|
+
parse.field :valor_abatimento,227..239
|
33
|
+
parse.field :desconto_concedito,240..252
|
34
|
+
parse.field :valor_recebido,253..265
|
35
|
+
parse.field :juros_mora,266..278
|
36
|
+
parse.field :outros_recebimento,279..291
|
37
|
+
parse.field :abatimento_nao_aproveitado,292..304
|
38
|
+
parse.field :valor_lancamento,305..317
|
39
|
+
parse.field :indicativo_lancamento,318..318
|
40
|
+
parse.field :indicador_valor,319..319
|
41
|
+
parse.field :valor_ajuste,320..331
|
42
|
+
parse.field :sequencial,394..399
|
43
|
+
end
|
44
|
+
end
|
data/lib/brcobranca.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
2
|
+
|
3
|
+
%w(core_ext currency config).each {|req| require File.join(File.dirname(__FILE__),"brcobranca",req) }
|
4
|
+
|
5
|
+
%w(base banco_brasil banco_itau banco_hsbc banco_real banco_bradesco banco_unibanco).each {|req| require File.join(File.dirname(__FILE__),"brcobranca","boleto",req) }
|
6
|
+
|
7
|
+
%w(util rghost).each {|req| require File.join(File.dirname(__FILE__),"brcobranca","boleto","template",req) }
|
8
|
+
|
9
|
+
%w(base retorno_cbr643).each {|req| require File.join(File.dirname(__FILE__),"brcobranca","retorno",req) }
|
10
|
+
|
11
|
+
case Brcobranca::Config::OPCOES[:gerador]
|
12
|
+
when 'rghost'
|
13
|
+
|
14
|
+
module Brcobranca::Boleto
|
15
|
+
Base.class_eval do
|
16
|
+
include Brcobranca::Boleto::Template::Rghost
|
17
|
+
include Brcobranca::Boleto::Template::Util
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
else
|
22
|
+
"Configure o gerador na opção 'Brcobranca::Config::OPCOES[:gerador]' corretamente!!!"
|
23
|
+
end
|
24
|
+
|
25
|
+
module Brcobranca
|
26
|
+
VERSION = '2.0.4'
|
27
|
+
end
|
data/script/console
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# File: script/console
|
3
|
+
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
4
|
+
|
5
|
+
libs = " -r irb/completion"
|
6
|
+
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
|
7
|
+
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
|
8
|
+
libs << " -r #{File.dirname(__FILE__) + '/../lib/brcobranca.rb'}"
|
9
|
+
puts "Loading brcobranca gem"
|
10
|
+
exec "#{irb} #{libs} --simple-prompt"
|
data/script/destroy
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/destroy'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/generate'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Generate.new.run(ARGV)
|
data/script/txt2html
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
load File.dirname(__FILE__) + "/../Rakefile"
|
4
|
+
require 'rubyforge'
|
5
|
+
require 'redcloth'
|
6
|
+
require 'syntax/convertors/html'
|
7
|
+
require 'erb'
|
8
|
+
|
9
|
+
download = "http://rubyforge.org/projects/#{$hoe.rubyforge_name}"
|
10
|
+
version = $hoe.version
|
11
|
+
|
12
|
+
def rubyforge_project_id
|
13
|
+
RubyForge.new.configure.autoconfig["group_ids"][$hoe.rubyforge_name]
|
14
|
+
end
|
15
|
+
|
16
|
+
class Fixnum
|
17
|
+
def ordinal
|
18
|
+
# teens
|
19
|
+
return 'th' if (10..19).include?(self % 100)
|
20
|
+
# others
|
21
|
+
case self % 10
|
22
|
+
when 1: return 'st'
|
23
|
+
when 2: return 'nd'
|
24
|
+
when 3: return 'rd'
|
25
|
+
else return 'th'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
class Time
|
31
|
+
def pretty
|
32
|
+
return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def convert_syntax(syntax, source)
|
37
|
+
return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
|
38
|
+
end
|
39
|
+
|
40
|
+
if ARGV.length >= 1
|
41
|
+
src, template = ARGV
|
42
|
+
template ||= File.join(File.dirname(__FILE__), '/../website/template.html.erb')
|
43
|
+
else
|
44
|
+
puts("Usage: #{File.split($0).last} source.txt [template.html.erb] > output.html")
|
45
|
+
exit!
|
46
|
+
end
|
47
|
+
|
48
|
+
template = ERB.new(File.open(template).read)
|
49
|
+
|
50
|
+
title = nil
|
51
|
+
body = nil
|
52
|
+
File.open(src) do |fsrc|
|
53
|
+
title_text = fsrc.readline
|
54
|
+
body_text_template = fsrc.read
|
55
|
+
body_text = ERB.new(body_text_template).result(binding)
|
56
|
+
syntax_items = []
|
57
|
+
body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)</\1>!m){
|
58
|
+
ident = syntax_items.length
|
59
|
+
element, syntax, source = $1, $2, $3
|
60
|
+
syntax_items << "<#{element} class='syntax'>#{convert_syntax(syntax, source)}</#{element}>"
|
61
|
+
"syntax-temp-#{ident}"
|
62
|
+
}
|
63
|
+
title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
|
64
|
+
body = RedCloth.new(body_text).to_html
|
65
|
+
body.gsub!(%r!(?:<pre><code>)?syntax-temp-(\d+)(?:</code></pre>)?!){ syntax_items[$1.to_i] }
|
66
|
+
end
|
67
|
+
stat = File.stat(src)
|
68
|
+
created = stat.ctime
|
69
|
+
modified = stat.mtime
|
70
|
+
|
71
|
+
$stdout << template.result(binding)
|
@@ -0,0 +1,28 @@
|
|
1
|
+
02RETORNO01COBRANCA 33251000289353000000INSTITUTO MATO-GROSSENSE DO AL001BANCO DO BRASIL2001090000007 000000009703754590 1622420 000001
|
2
|
+
70000000000000000332510002893531622420 1622420000000000310000001 01900000000000 1806200109 000000000000000906400114923002201090000500000000000000000000000000000000000000000000000000000000000000000000000000009064000000000000000000000000000000000000000000000000856420000000000000 0000000000000000000000000000000000000000000000000004000002
|
3
|
+
70000000000000000332510002893531622420 1622420000000003010000001 01900000000000 1806200109 000000000000002235239909430002201090000500000000000000000000000000000000000000000000000000000000000000000000000000022352000000000000000000000000000000000000000000000002185220000000000000 0000000000000000000000000000000000000000000000000010000003
|
4
|
+
70000000000000000332510002893531622420 1622420000000003110000001 01900000000000 1806200109 00000000000000165330012970X002201090000500000000000000000000000000000000000000000000000000000000000000000000000000016533000000000000000000000000000000000000000000000001603320000000000000 0000000000000000000000000000000000000000000000000002000004
|
5
|
+
70000000000000000332510002893531622420 1622420000000003210000001 01900000000000 1806200109 00000000000000157740012970X002201090000500000000000000000000000000000000000000000000000000000000000000000000000000015774000000000000000000000000000000000000000000000001527420000000000000 0000000000000000000000000000000000000000000000000002000005
|
6
|
+
70000000000000000332510002893531622420 1622420000000003310000001 01900000000000 1806200109 00000000000000414440012970X002201090000500000000000000000000000000000000000000000000000000000000000000000000000000041444000000000000000000000000000000000000000000000004094420000000000000 0000000000000000000000000000000000000000000000000002000006
|
7
|
+
70000000000000000332510002893531622420 1622420000000003410000001 01900000000000 1806200109 00000000000000610280012970X002201090000500000000000000000000000000000000000000000000000000000000000000000000000000061028000000000000000000000000000000000000000000000006052820000000000000 0000000000000000000000000000000000000000000000000002000007
|
8
|
+
70000000000000000332510002893531622420 1622420000000003510000001 01900000000000 1806200109 00000000000000608040012970X002201090000500000000000000000000000000000000000000000000000000000000000000000000000000060804000000000000000000000000000000000000000000000006030420000000000000 0000000000000000000000000000000000000000000000000002000008
|
9
|
+
70000000000000000332510002893531622420 1622420000000003610000001 01900000000000 1806200109 000000000000005610074808110002201090000500000000000000000000000000000000000000000000000000000000000000000000000000056100000000000000000000000000000000000000000000000005560020000000000000 0000000000000000000000000000000000000000000000000010000009
|
10
|
+
70000000000000000332510002893531622420 1622420000000003710000001 01900000000000 1806200109 000000000000000565474808110002201090000500000000000000000000000000000000000000000000000000000000000000000000000000005654000000000000000000000000000000000000000000000000515420000000000000 0000000000000000000000000000000000000000000000000010000010
|
11
|
+
70000000000000000332510002893531622420 1622420000000003810000001 01900000000000 1806200109 000000000000005610074808110002201090000500000000000000000000000000000000000000000000000000000000000000000000000000056100000000000000000000000000000000000000000000000005560020000000000000 0000000000000000000000000000000000000000000000000010000011
|
12
|
+
70000000000000000332510002893531622420 1622420000000003910000001 01900000000000 1806200109 000000000000000528074808110002201090000500000000000000000000000000000000000000000000000000000000000000000000000000005280000000000000000000000000000000000000000000000000478020000000000000 0000000000000000000000000000000000000000000000000010000012
|
13
|
+
70000000000000000332510002893531622420 1622420000000004010000001 01900000000000 1806200109 000000000000005610074808110002201090000500000000000000000000000000000000000000000000000000000000000000000000000000056100000000000000000000000000000000000000000000000005560020000000000000 0000000000000000000000000000000000000000000000000010000013
|
14
|
+
70000000000000000332510002893531622420 1622420000000004110000001 01900000000000 1806200109 000000000000000528074808110002201090000500000000000000000000000000000000000000000000000000000000000000000000000000005280000000000000000000000000000000000000000000000000478020000000000000 0000000000000000000000000000000000000000000000000010000014
|
15
|
+
70000000000000000332510002893531622420 1622420000000004210000001 01900000000000 1806200109 000000000000005610000136439002201090000500000000000000000000000000000000000000000000000000000000000000000000000000056100000000000000000000000000000000000000000000000005560020000000000000 0000000000000000000000000000000000000000000000000004000015
|
16
|
+
70000000000000000332510002893531622420 1622420000000004310000001 01900000000000 1806200109 000000000000001672000136439002201090000500000000000000000000000000000000000000000000000000000000000000000000000000016720000000000000000000000000000000000000000000000001622020000000000000 0000000000000000000000000000000000000000000000000004000016
|
17
|
+
70000000000000000332510002893531622420 1622420000000004410000001 01900000000000 1806200109 000000000000000535300136439002201090000500000000000000000000000000000000000000000000000000000000000000000000000000005353000000000000000000000000000000000000000000000000485320000000000000 0000000000000000000000000000000000000000000000000004000017
|
18
|
+
70000000000000000332510002893531622420 1622420000000004510000001 01900000000000 1806200109 000000000000005210700130376002201090000500000000000000000000000000000000000000000000000000000000000000000000000000052107000000000000000000000000000000000000000000000005160720000000000000 0000000000000000000000000000000000000000000000000008000018
|
19
|
+
70000000000000000332510002893531622420 1622420000000004610000001 01900000000000 1806200109 000000000000006043600114923002201090000500000000000000000000000000000000000000000000000000000000000000000000000000060436000000000000000000000000000000000000000000000005993620000000000000 0000000000000000000000000000000000000000000000000002000019
|
20
|
+
70000000000000000332510002893531622420 1622420000000004710000001 01900000000000 1806200109 000000000000005610000136439002201090000500000000000000000000000000000000000000000000000000000000000000000000000000056100000000000000000000000000000000000000000000000005560020000000000000 0000000000000000000000000000000000000000000000000004000020
|
21
|
+
70000000000000000332510002893531622420 1622420000000004810000001 01900000000000 1806200109 000000000000000495000136439002201090000500000000000000000000000000000000000000000000000000000000000000000000000000004950000000000000000000000000000000000000000000000000445020000000000000 0000000000000000000000000000000000000000000000000004000021
|
22
|
+
70000000000000000332510002893531622420 1622420000000005010000001 01900000000000 1806200109 000000000000005707000114923002201090000500000000000000000000000000000000000000000000000000000000000000000000000000057070000000000000000000000000000000000000000000000005657020000000000000 0000000000000000000000000000000000000000000000000002000022
|
23
|
+
70000000000000000332510002893531622420 1622420000000005110000001 01900000000000 1806200109 000000000000005638600106599002201090000500000000000000000000000000000000000000000000000000000000000000000000000000056386000000000000000000000000000000000000000000000005588620000000000000 0000000000000000000000000000000000000000000000000002000023
|
24
|
+
70000000000000000332510002893531622420 1622420000000005210000001 01900000000000 1806200109 000000000000005610000106599002201090000500000000000000000000000000000000000000000000000000000000000000000000000000056100000000000000000000000000000000000000000000000005560020000000000000 0000000000000000000000000000000000000000000000000002000024
|
25
|
+
70000000000000000332510002893531622420 1622420000000005310000001 01900000000000 1806200109 000000000000005856400106599002201090000500000000000000000000000000000000000000000000000000000000000000000000000000058564000000000000000000000000000000000000000000000005806420000000000000 0000000000000000000000000000000000000000000000000002000025
|
26
|
+
70000000000000000332510002893531622420 1622420000000005410000001 01900000000000 1806200109 000000000000005704600106599002201090000500000000000000000000000000000000000000000000000000000000000000000000000000057046000000000000000000000000000000000000000000000005654620000000000000 0000000000000000000000000000000000000000000000000002000026
|
27
|
+
70000000000000000332510002893531622420 1622420000000005510000001 01900000000000 1806200109 000000000000005673800106599002201090000500000000000000000000000000000000000000000000000000000000000000000000000000056738000000000000000000000000000000000000000000000005623820000000000000 0000000000000000000000000000000000000000000000000002000027
|
28
|
+
9201001 000000000000000000000000000000 000000000000000000000000000000 000000000000000000000000000000 000000000000000000000000000000 000000000000000000000000000000 000028
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__),'test_helper.rb')
|
2
|
+
|
3
|
+
class TestBancoBradesco < Test::Unit::TestCase #:nodoc:[all]
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@boleto_novo = BancoBradesco.new
|
7
|
+
@boleto_novo.cedente = "Kivanio Barbosa"
|
8
|
+
@boleto_novo.documento_cedente = "12345678912"
|
9
|
+
@boleto_novo.sacado = "Claudio Pozzebom"
|
10
|
+
@boleto_novo.sacado_documento = "12345678900"
|
11
|
+
@boleto_novo.aceite = "S"
|
12
|
+
@boleto_novo.agencia = "4042"
|
13
|
+
@boleto_novo.conta_corrente = "61900"
|
14
|
+
end
|
15
|
+
|
16
|
+
def boleto_1
|
17
|
+
@boleto_novo.agencia = "1172"
|
18
|
+
@boleto_novo.conta_corrente = "0403005"
|
19
|
+
@boleto_novo.carteira = "06"
|
20
|
+
@boleto_novo.moeda = "9"
|
21
|
+
@boleto_novo.valor = 2952.95
|
22
|
+
@boleto_novo.numero_documento = "75896452"
|
23
|
+
@boleto_novo.data_documento = Date.parse("2009-04-30")
|
24
|
+
@boleto_novo.dias_vencimento = 0
|
25
|
+
end
|
26
|
+
|
27
|
+
def boleto_2
|
28
|
+
@boleto_novo.agencia = "4042"
|
29
|
+
@boleto_novo.conta_corrente = "61900"
|
30
|
+
@boleto_novo.carteira = "03"
|
31
|
+
@boleto_novo.moeda = "9"
|
32
|
+
@boleto_novo.valor = 135.00
|
33
|
+
@boleto_novo.numero_documento = "777700168"
|
34
|
+
@boleto_novo.data_documento = Date.parse("2008-02-01")
|
35
|
+
@boleto_novo.dias_vencimento = 1
|
36
|
+
end
|
37
|
+
|
38
|
+
def boleto_nil
|
39
|
+
@boleto_novo.banco = ""
|
40
|
+
@boleto_novo.carteira = ""
|
41
|
+
@boleto_novo.moeda = ""
|
42
|
+
@boleto_novo.valor = 0
|
43
|
+
@boleto_novo.convenio = ""
|
44
|
+
@boleto_novo.numero_documento = ""
|
45
|
+
@boleto_novo.data_documento = Date.parse("2008-02-01")
|
46
|
+
@boleto_novo.dias_vencimento = 0
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_should_initialize_correctly
|
50
|
+
assert_equal '237', @boleto_novo.banco
|
51
|
+
assert_equal '06', @boleto_novo.carteira
|
52
|
+
assert_equal "DM", @boleto_novo.especie_documento
|
53
|
+
assert_equal "R$", @boleto_novo.especie
|
54
|
+
assert_equal "9", @boleto_novo.moeda
|
55
|
+
assert_equal Date.today, @boleto_novo.data_documento
|
56
|
+
assert_equal 1, @boleto_novo.dias_vencimento
|
57
|
+
assert_equal((Date.today + 1), @boleto_novo.data_vencimento)
|
58
|
+
assert_equal "S", @boleto_novo.aceite
|
59
|
+
assert_equal 1, @boleto_novo.quantidade
|
60
|
+
assert_equal 0.0, @boleto_novo.valor
|
61
|
+
assert_equal 0.0, @boleto_novo.valor_documento
|
62
|
+
assert_equal "QUALQUER BANCO ATÉ O VENCIMENTO", @boleto_novo.local_pagamento
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_should_mont_correct_codigo_barras
|
66
|
+
boleto_1
|
67
|
+
assert_equal "2379422300002952951172060007589645204030050", @boleto_novo.monta_codigo_43_digitos
|
68
|
+
assert_equal "23795422300002952951172060007589645204030050", @boleto_novo.codigo_barras
|
69
|
+
boleto_2
|
70
|
+
assert_equal "2379377000000135004042030077770016800619000", @boleto_novo.monta_codigo_43_digitos
|
71
|
+
assert_equal "23791377000000135004042030077770016800619000", @boleto_novo.codigo_barras
|
72
|
+
boleto_nil
|
73
|
+
assert_equal nil, @boleto_novo.codigo_barras
|
74
|
+
assert_raise RuntimeError do
|
75
|
+
boleto_nil
|
76
|
+
raise 'Verifique as informações do boleto!!!'
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_should_mont_correct_linha_digitalvel
|
81
|
+
boleto_1
|
82
|
+
assert_equal("23791.17209 60007.589645 52040.300502 5 42230000295295", @boleto_novo.codigo_barras.linha_digitavel)
|
83
|
+
boleto_2
|
84
|
+
assert_equal("23794.04201 30077.770011 68006.190000 1 37700000013500", @boleto_novo.codigo_barras.linha_digitavel)
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
@@ -0,0 +1,276 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__),'test_helper.rb')
|
2
|
+
|
3
|
+
class TestBancoBrasil < Test::Unit::TestCase #:nodoc:[all]
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@boleto_novo = BancoBrasil.new
|
7
|
+
@boleto_novo.cedente = "Kivanio Barbosa"
|
8
|
+
@boleto_novo.documento_cedente = "12345678912"
|
9
|
+
@boleto_novo.sacado = "Claudio Pozzebom"
|
10
|
+
@boleto_novo.sacado_documento = "12345678900"
|
11
|
+
@boleto_novo.aceite = "S"
|
12
|
+
@boleto_novo.agencia = "4042"
|
13
|
+
@boleto_novo.conta_corrente = "61900"
|
14
|
+
end
|
15
|
+
|
16
|
+
def boleto_convenio8_numero9_um
|
17
|
+
@boleto_novo.banco = "001"
|
18
|
+
@boleto_novo.carteira = "18"
|
19
|
+
@boleto_novo.moeda = "9"
|
20
|
+
@boleto_novo.valor = 135.00
|
21
|
+
@boleto_novo.convenio = 12387989
|
22
|
+
@boleto_novo.numero_documento = "777700168"
|
23
|
+
@boleto_novo.data_documento = Date.parse("2008-02-01")
|
24
|
+
@boleto_novo.dias_vencimento = 0
|
25
|
+
end
|
26
|
+
|
27
|
+
def boleto_convenio8_numero9_dois
|
28
|
+
@boleto_novo.banco = "001"
|
29
|
+
@boleto_novo.carteira = "18"
|
30
|
+
@boleto_novo.moeda = "9"
|
31
|
+
@boleto_novo.valor = 135.00
|
32
|
+
@boleto_novo.convenio = 12387989
|
33
|
+
@boleto_novo.numero_documento = "7700168"
|
34
|
+
@boleto_novo.data_documento = Date.parse("2008-02-01")
|
35
|
+
@boleto_novo.dias_vencimento = 1
|
36
|
+
end
|
37
|
+
|
38
|
+
def boleto_convenio7_numero10_um
|
39
|
+
@boleto_novo.banco = "001"
|
40
|
+
@boleto_novo.carteira = "18"
|
41
|
+
@boleto_novo.moeda = "9"
|
42
|
+
@boleto_novo.valor = 135.00
|
43
|
+
@boleto_novo.convenio = 1238798
|
44
|
+
@boleto_novo.numero_documento = "7777700168"
|
45
|
+
@boleto_novo.data_documento = Date.parse("2008-02-01")
|
46
|
+
@boleto_novo.dias_vencimento = 2
|
47
|
+
end
|
48
|
+
|
49
|
+
def boleto_convenio7_numero10_dois
|
50
|
+
@boleto_novo.banco = "001"
|
51
|
+
@boleto_novo.carteira = "18"
|
52
|
+
@boleto_novo.moeda = "9"
|
53
|
+
@boleto_novo.valor = 723.56
|
54
|
+
@boleto_novo.convenio = 1238798
|
55
|
+
@boleto_novo.numero_documento = "7777700168"
|
56
|
+
@boleto_novo.data_documento = Date.parse("2008-02-01")
|
57
|
+
@boleto_novo.dias_vencimento = 2
|
58
|
+
end
|
59
|
+
|
60
|
+
def boleto_convenio7_numero10_tres
|
61
|
+
@boleto_novo.banco = "001"
|
62
|
+
@boleto_novo.agencia = "4042"
|
63
|
+
@boleto_novo.conta_corrente = "15735"
|
64
|
+
@boleto_novo.carteira = "18"
|
65
|
+
@boleto_novo.moeda = "9"
|
66
|
+
@boleto_novo.valor = 723.56
|
67
|
+
@boleto_novo.convenio = 1238798
|
68
|
+
@boleto_novo.numero_documento = "7777700168"
|
69
|
+
@boleto_novo.data_documento = Date.parse("2008-02-01")
|
70
|
+
@boleto_novo.dias_vencimento = 0
|
71
|
+
end
|
72
|
+
|
73
|
+
def boleto_convenio6_numero5
|
74
|
+
@boleto_novo.banco = "001"
|
75
|
+
@boleto_novo.carteira = "18"
|
76
|
+
@boleto_novo.agencia = "4042"
|
77
|
+
@boleto_novo.conta_corrente = "61900"
|
78
|
+
@boleto_novo.moeda = "9"
|
79
|
+
@boleto_novo.valor = 135.00
|
80
|
+
@boleto_novo.convenio = 123879
|
81
|
+
@boleto_novo.numero_documento = "1234"
|
82
|
+
@boleto_novo.data_documento = Date.parse("2008-02-01")
|
83
|
+
@boleto_novo.dias_vencimento = 0
|
84
|
+
@boleto_novo.codigo_servico = false
|
85
|
+
end
|
86
|
+
|
87
|
+
def boleto_convenio6_numero17_carteira16
|
88
|
+
@boleto_novo.banco = "001"
|
89
|
+
@boleto_novo.carteira = "16"
|
90
|
+
@boleto_novo.agencia = "4042"
|
91
|
+
@boleto_novo.conta_corrente = "61900"
|
92
|
+
@boleto_novo.moeda = "9"
|
93
|
+
@boleto_novo.valor = 135.00
|
94
|
+
@boleto_novo.convenio = 123879
|
95
|
+
@boleto_novo.numero_documento = "1234567899"
|
96
|
+
@boleto_novo.data_documento = Date.parse("2008-02-01")
|
97
|
+
@boleto_novo.dias_vencimento = 0
|
98
|
+
@boleto_novo.codigo_servico = true
|
99
|
+
end
|
100
|
+
|
101
|
+
def boleto_convenio6_numero17_carteira17
|
102
|
+
@boleto_novo.banco = "001"
|
103
|
+
@boleto_novo.carteira = "17"
|
104
|
+
@boleto_novo.agencia = "4042"
|
105
|
+
@boleto_novo.conta_corrente = "61900"
|
106
|
+
@boleto_novo.moeda = "9"
|
107
|
+
@boleto_novo.valor = 135.00
|
108
|
+
@boleto_novo.convenio = 123879
|
109
|
+
@boleto_novo.numero_documento = "1234567899"
|
110
|
+
@boleto_novo.data_documento = Date.parse("2008-02-01")
|
111
|
+
@boleto_novo.dias_vencimento = 0
|
112
|
+
@boleto_novo.codigo_servico = true
|
113
|
+
end
|
114
|
+
|
115
|
+
def boleto_convenio6_numero17_carteira18
|
116
|
+
@boleto_novo.banco = "001"
|
117
|
+
@boleto_novo.carteira = "18"
|
118
|
+
@boleto_novo.agencia = "4042"
|
119
|
+
@boleto_novo.conta_corrente = "61900"
|
120
|
+
@boleto_novo.moeda = "9"
|
121
|
+
@boleto_novo.valor = 135.00
|
122
|
+
@boleto_novo.convenio = 123879
|
123
|
+
@boleto_novo.numero_documento = "1234567899"
|
124
|
+
@boleto_novo.data_documento = Date.parse("2008-02-01")
|
125
|
+
@boleto_novo.dias_vencimento = 0
|
126
|
+
@boleto_novo.codigo_servico = true
|
127
|
+
end
|
128
|
+
|
129
|
+
def boleto_convenio4_numero7
|
130
|
+
@boleto_novo.banco = "001"
|
131
|
+
@boleto_novo.carteira = "18"
|
132
|
+
@boleto_novo.agencia = "4042"
|
133
|
+
@boleto_novo.conta_corrente = "61900"
|
134
|
+
@boleto_novo.moeda = "9"
|
135
|
+
@boleto_novo.valor = 135.00
|
136
|
+
@boleto_novo.convenio = 1238
|
137
|
+
@boleto_novo.numero_documento = "123456"
|
138
|
+
@boleto_novo.data_documento = Date.parse("2008-02-01")
|
139
|
+
@boleto_novo.dias_vencimento = 0
|
140
|
+
end
|
141
|
+
|
142
|
+
def boleto_nil
|
143
|
+
@boleto_novo.banco = ""
|
144
|
+
@boleto_novo.carteira = ""
|
145
|
+
@boleto_novo.moeda = ""
|
146
|
+
@boleto_novo.valor = 0
|
147
|
+
@boleto_novo.convenio = ""
|
148
|
+
@boleto_novo.numero_documento = ""
|
149
|
+
@boleto_novo.data_documento = Date.parse("2008-02-01")
|
150
|
+
@boleto_novo.dias_vencimento = 0
|
151
|
+
end
|
152
|
+
|
153
|
+
def test_should_initialize_correctly
|
154
|
+
assert_equal '001', @boleto_novo.banco
|
155
|
+
assert_equal "DM", @boleto_novo.especie_documento
|
156
|
+
assert_equal "R$", @boleto_novo.especie
|
157
|
+
assert_equal "9", @boleto_novo.moeda
|
158
|
+
assert_equal Date.today, @boleto_novo.data_documento
|
159
|
+
assert_equal 1, @boleto_novo.dias_vencimento
|
160
|
+
assert_equal((Date.today + 1), @boleto_novo.data_vencimento)
|
161
|
+
assert_equal "S", @boleto_novo.aceite
|
162
|
+
assert_equal 1, @boleto_novo.quantidade
|
163
|
+
assert_equal 0.0, @boleto_novo.valor
|
164
|
+
assert_equal 0.0, @boleto_novo.valor_documento
|
165
|
+
assert_equal "QUALQUER BANCO ATÉ O VENCIMENTO", @boleto_novo.local_pagamento
|
166
|
+
end
|
167
|
+
|
168
|
+
def test_should_mont_correct_codigo_barras
|
169
|
+
boleto_convenio8_numero9_um
|
170
|
+
assert_equal "0019376900000135000000001238798977770016818", @boleto_novo.monta_codigo_43_digitos
|
171
|
+
assert_equal "00193376900000135000000001238798977770016818", @boleto_novo.codigo_barras
|
172
|
+
boleto_convenio8_numero9_dois
|
173
|
+
assert_equal "0019377000000135000000001238798900770016818", @boleto_novo.monta_codigo_43_digitos
|
174
|
+
assert_equal "00193377000000135000000001238798900770016818", @boleto_novo.codigo_barras
|
175
|
+
boleto_convenio7_numero10_um
|
176
|
+
assert_equal "0019377100000135000000001238798777770016818", @boleto_novo.monta_codigo_43_digitos
|
177
|
+
assert_equal "00193377100000135000000001238798777770016818", @boleto_novo.codigo_barras
|
178
|
+
boleto_convenio7_numero10_dois
|
179
|
+
assert_equal "0019377100000723560000001238798777770016818", @boleto_novo.monta_codigo_43_digitos
|
180
|
+
assert_equal "00195377100000723560000001238798777770016818", @boleto_novo.codigo_barras
|
181
|
+
boleto_convenio7_numero10_tres
|
182
|
+
assert_equal "0019376900000723560000001238798777770016818", @boleto_novo.monta_codigo_43_digitos
|
183
|
+
assert_equal "00194376900000723560000001238798777770016818", @boleto_novo.codigo_barras
|
184
|
+
boleto_convenio6_numero5
|
185
|
+
assert_equal "0019376900000135001238790123440420006190018", @boleto_novo.monta_codigo_43_digitos
|
186
|
+
assert_equal "00192376900000135001238790123440420006190018", @boleto_novo.codigo_barras
|
187
|
+
boleto_convenio6_numero17_carteira16
|
188
|
+
assert_equal "0019376900000135001238790000000123456789921", @boleto_novo.monta_codigo_43_digitos
|
189
|
+
assert_equal "00199376900000135001238790000000123456789921", @boleto_novo.codigo_barras
|
190
|
+
assert_raise RuntimeError do
|
191
|
+
boleto_convenio6_numero17_carteira17
|
192
|
+
raise 'Verifique as informações do boleto!!!'
|
193
|
+
end
|
194
|
+
boleto_convenio6_numero17_carteira18
|
195
|
+
assert_equal "0019376900000135001238790000000123456789921", @boleto_novo.monta_codigo_43_digitos
|
196
|
+
assert_equal "00199376900000135001238790000000123456789921", @boleto_novo.codigo_barras
|
197
|
+
boleto_convenio4_numero7
|
198
|
+
assert_equal "0019376900000135001238012345640420006190018", @boleto_novo.monta_codigo_43_digitos
|
199
|
+
assert_equal "00191376900000135001238012345640420006190018", @boleto_novo.codigo_barras
|
200
|
+
boleto_nil
|
201
|
+
assert_equal nil, @boleto_novo.codigo_barras
|
202
|
+
assert_raise RuntimeError do
|
203
|
+
boleto_nil
|
204
|
+
raise 'Verifique as informações do boleto!!!'
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
def test_should_mont_correct_linha_digitalvel
|
209
|
+
boleto_convenio8_numero9_um
|
210
|
+
assert_equal("00190.00009 01238.798977 77700.168188 3 37690000013500", @boleto_novo.codigo_barras.linha_digitavel)
|
211
|
+
boleto_convenio8_numero9_dois
|
212
|
+
assert_equal("00190.00009 01238.798902 07700.168185 3 37700000013500", @boleto_novo.codigo_barras.linha_digitavel)
|
213
|
+
boleto_convenio7_numero10_um
|
214
|
+
assert_equal("00190.00009 01238.798779 77700.168188 3 37710000013500", @boleto_novo.codigo_barras.linha_digitavel)
|
215
|
+
boleto_convenio7_numero10_dois
|
216
|
+
assert_equal("00190.00009 01238.798779 77700.168188 5 37710000072356", @boleto_novo.codigo_barras.linha_digitavel)
|
217
|
+
boleto_convenio7_numero10_tres
|
218
|
+
assert_equal("00190.00009 01238.798779 77700.168188 4 37690000072356", @boleto_novo.codigo_barras.linha_digitavel)
|
219
|
+
boleto_convenio6_numero5
|
220
|
+
assert_equal("00191.23876 90123.440423 00061.900189 2 37690000013500", @boleto_novo.codigo_barras.linha_digitavel)
|
221
|
+
boleto_convenio6_numero17_carteira16
|
222
|
+
assert_equal("00191.23876 90000.000126 34567.899215 9 37690000013500", @boleto_novo.codigo_barras.linha_digitavel)
|
223
|
+
assert_raise RuntimeError do
|
224
|
+
boleto_convenio6_numero17_carteira17
|
225
|
+
raise 'Verifique as informações do boleto!!!'
|
226
|
+
end
|
227
|
+
boleto_convenio6_numero17_carteira18
|
228
|
+
assert_equal("00191.23876 90000.000126 34567.899215 9 37690000013500", @boleto_novo.codigo_barras.linha_digitavel)
|
229
|
+
boleto_convenio6_numero5
|
230
|
+
assert_equal("00191.23876 90123.440423 00061.900189 2 37690000013500", @boleto_novo.codigo_barras.linha_digitavel)
|
231
|
+
boleto_convenio4_numero7
|
232
|
+
assert_equal("00191.23801 12345.640424 00061.900189 1 37690000013500", @boleto_novo.codigo_barras.linha_digitavel)
|
233
|
+
assert_kind_of( String, @boleto_novo.codigo_barras.linha_digitavel)
|
234
|
+
end
|
235
|
+
|
236
|
+
def test_should_return_correctly_conta_corrente_dv
|
237
|
+
boleto_convenio8_numero9_um
|
238
|
+
assert_equal 0, @boleto_novo.conta_corrente_dv
|
239
|
+
boleto_convenio8_numero9_dois
|
240
|
+
assert_equal 0, @boleto_novo.conta_corrente_dv
|
241
|
+
boleto_convenio7_numero10_um
|
242
|
+
assert_equal 0, @boleto_novo.conta_corrente_dv
|
243
|
+
boleto_convenio7_numero10_dois
|
244
|
+
assert_equal 0, @boleto_novo.conta_corrente_dv
|
245
|
+
boleto_convenio7_numero10_tres
|
246
|
+
assert_equal "X", @boleto_novo.conta_corrente_dv
|
247
|
+
boleto_convenio6_numero5
|
248
|
+
assert_equal 0, @boleto_novo.conta_corrente_dv
|
249
|
+
boleto_convenio6_numero17_carteira16
|
250
|
+
assert_equal 0, @boleto_novo.conta_corrente_dv
|
251
|
+
boleto_convenio6_numero17_carteira17
|
252
|
+
assert_equal 0, @boleto_novo.conta_corrente_dv
|
253
|
+
boleto_convenio6_numero17_carteira18
|
254
|
+
assert_equal 0, @boleto_novo.conta_corrente_dv
|
255
|
+
boleto_convenio4_numero7
|
256
|
+
assert_equal 0, @boleto_novo.conta_corrente_dv
|
257
|
+
end
|
258
|
+
|
259
|
+
def test_should_verify_nosso_numero_dv_calculation
|
260
|
+
@boleto_novo.numero_documento = "777700168"
|
261
|
+
assert_equal 0, @boleto_novo.nosso_numero_dv
|
262
|
+
@boleto_novo.numero_documento = "77700168"
|
263
|
+
assert_equal 3, @boleto_novo.nosso_numero_dv
|
264
|
+
@boleto_novo.numero_documento = "00015448"
|
265
|
+
assert_equal 2, @boleto_novo.nosso_numero_dv
|
266
|
+
@boleto_novo.numero_documento = "15448"
|
267
|
+
assert_equal 2, @boleto_novo.nosso_numero_dv
|
268
|
+
@boleto_novo.numero_documento = "12345678"
|
269
|
+
assert_equal 9, @boleto_novo.nosso_numero_dv
|
270
|
+
@boleto_novo.numero_documento = "34230"
|
271
|
+
assert_equal 0, @boleto_novo.nosso_numero_dv
|
272
|
+
@boleto_novo.numero_documento = "258281"
|
273
|
+
assert_equal 3, @boleto_novo.nosso_numero_dv
|
274
|
+
end
|
275
|
+
|
276
|
+
end
|