brcobranca 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. data/History.txt +4 -0
  2. data/Manifest.txt +39 -0
  3. data/README.rdoc +71 -0
  4. data/Rakefile +32 -0
  5. data/brcobranca.gemspec +49 -0
  6. data/config/website.yml +2 -0
  7. data/lib/brcobranca/arquivos/logos/bb.jpg +0 -0
  8. data/lib/brcobranca/arquivos/logos/hsbc.jpg +0 -0
  9. data/lib/brcobranca/arquivos/logos/itau.jpg +0 -0
  10. data/lib/brcobranca/arquivos/templates/modelo_generico.eps +0 -0
  11. data/lib/brcobranca/boleto/banco_brasil.rb +79 -0
  12. data/lib/brcobranca/boleto/banco_hsbc.rb +63 -0
  13. data/lib/brcobranca/boleto/banco_itau.rb +105 -0
  14. data/lib/brcobranca/boleto/base.rb +142 -0
  15. data/lib/brcobranca/boleto/template/rghost.rb +151 -0
  16. data/lib/brcobranca/boleto/template/util.rb +24 -0
  17. data/lib/brcobranca/config.rb +9 -0
  18. data/lib/brcobranca/core_ext.rb +250 -0
  19. data/lib/brcobranca/currency.rb +70 -0
  20. data/lib/brcobranca/retorno/retorno_cbr643.rb +84 -0
  21. data/lib/brcobranca.rb +27 -0
  22. data/script/console +10 -0
  23. data/script/destroy +14 -0
  24. data/script/generate +14 -0
  25. data/script/txt2html +71 -0
  26. data/test/arquivos/CBR64310.RET +51 -0
  27. data/test/test_banco_brasil.rb +276 -0
  28. data/test/test_banco_hsbc.rb +66 -0
  29. data/test/test_banco_itau.rb +103 -0
  30. data/test/test_base.rb +162 -0
  31. data/test/test_core_ext.rb +227 -0
  32. data/test/test_currency.rb +51 -0
  33. data/test/test_helper.rb +5 -0
  34. data/test/test_retorno_cbr643.rb +17 -0
  35. data/website/index.html +74 -0
  36. data/website/index.txt +41 -0
  37. data/website/javascripts/rounded_corners_lite.inc.js +285 -0
  38. data/website/stylesheets/screen.css +159 -0
  39. data/website/template.html.erb +49 -0
  40. data.tar.gz.sig +0 -0
  41. metadata +175 -0
  42. metadata.gz.sig +0 -0
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,51 @@
1
+ 70000000000000000335210001414731123725 1123725000004756510000001 01900000000000 1806080708 000000000000010846139911140001007080000175000000000000000000000000000000000000000000000000000000000000000000000000108461000000000000000000000000000000000000000000000010828620000000000000 0000000000000000000000000000000000000000000000000010000002
2
+ 70000000000000000335210001414731123725 1123725000004756710000001 01900000000000 1806080708 000000000000000484839911140001007080000175000000000000000000000000000000000000000000000000000000000000000000000000004848000000000000000000000000000000000000000000000000467320000000000000 0000000000000000000000000000000000000000000000000010000003
3
+ 70000000000000000335210001414731123725 1123725000004756810000001 01900000000000 1806080708 000000000000000323239911140001007080000175000000000000000000000000000000000000000000000000000000000000000000000000003232000000000000000000000000000000000000000000000000305720000000000000 0000000000000000000000000000000000000000000000000010000004
4
+ 70000000000000000335210001414731123725 1123725000004757410000001 01900000000000 1806080708 000000000000011752600132905001007080000175000000000000000000000000000000000000000000000000000000000000000000000000117526000000000000000000000000000000000000000000000011735120000000000000 0000000000000000000000000000000000000000000000000008000005
5
+ 70000000000000000335210001414731123725 1123725000004757510000001 01900000000000 1806080708 000000000000011708200132905001007080000175000000000000000000000000000000000000000000000000000000000000000000000000117082000000000000000000000000000000000000000000000011690720000000000000 0000000000000000000000000000000000000000000000000008000006
6
+ 70000000000000000335210001414731123725 1123725000004757610000001 01900000000000 1806080708 000000000000012526400132905001007080000175000000000000000000000000000000000000000000000000000000000000000000000000125264000000000000000000000000000000000000000000000012508920000000000000 0000000000000000000000000000000000000000000000000008000007
7
+ 70000000000000000335210001414731123725 1123725000004757710000001 01900000000000 1806080708 000000000000010868800132905001007080000175000000000000000000000000000000000000000000000000000000000000000000000000108688000000000000000000000000000000000000000000000010851320000000000000 0000000000000000000000000000000000000000000000000008000008
8
+ 70000000000000000335210001414731123725 1123725000004757810000001 01900000000000 1806080708 000000000000010959500132905001007080000175000000000000000000000000000000000000000000000000000000000000000000000000109595000000000000000000000000000000000000000000000010942020000000000000 0000000000000000000000000000000000000000000000000008000009
9
+ 70000000000000000335210001414731123725 1123725000004757910000001 01900000000000 1806080708 000000000000010847800132905001007080000175000000000000000000000000000000000000000000000000000000000000000000000000108478000000000000000000000000000000000000000000000010830320000000000000 0000000000000000000000000000000000000000000000000008000010
10
+ 70000000000000000335210001414731123725 1123725000004758010000001 01900000000000 1806080708 000000000000010967300132905001007080000175000000000000000000000000000000000000000000000000000000000000000000000000109673000000000000000000000000000000000000000000000010949820000000000000 0000000000000000000000000000000000000000000000000008000011
11
+ 70000000000000000335210001414731123725 1123725000004759010000001 01900000000000 1806080708 000000000000009478600105517001007080000175000000000000000000000000000000000000000000000000000000000000000000000000094786000000000000000000000000000000000000000000000009461120000000000000 0000000000000000000000000000000000000000000000000002000012
12
+ 70000000000000000335210001414731123725 1123725000004759110000001 01900000000000 1806080708 000000000000010896900132905001007080000175000000000000000000000000000000000000000000000000000000000000000000000000108969000000000000000000000000000000000000000000000010879420000000000000 0000000000000000000000000000000000000000000000000008000013
13
+ 70000000000000000335210001414731123725 1123725000004759210000001 01900000000000 1806080708 000000000000010326100132905001007080000175000000000000000000000000000000000000000000000000000000000000000000000000103261000000000000000000000000000000000000000000000010308620000000000000 0000000000000000000000000000000000000000000000000008000014
14
+ 70000000000000000335210001414731123725 1123725000004759310000001 01900000000000 1806080708 000000000000010405100132905001007080000175000000000000000000000000000000000000000000000000000000000000000000000000104051000000000000000000000000000000000000000000000010387620000000000000 0000000000000000000000000000000000000000000000000008000015
15
+ 70000000000000000335210001414731123725 1123725000004759410000001 01900000000000 1806080708 000000000000004536139916870001007080000175000000000000000000000000000000000000000000000000000000000000000000000000045361000000000000000000000000000000000000000000000004518620000000000000 0000000000000000000000000000000000000000000000000010000016
16
+ 70000000000000000335210001414731123725 1123725000004759510000001 01900000000000 1806080708 000000000000009476739916870001007080000175000000000000000000000000000000000000000000000000000000000000000000000000094767000000000000000000000000000000000000000000000009459220000000000000 0000000000000000000000000000000000000000000000000010000017
17
+ 70000000000000000335210001414731123725 1123725000004759610000001 01900000000000 1806080708 000000000000010976600132905001007080000175000000000000000000000000000000000000000000000000000000000000000000000000109766000000000000000000000000000000000000000000000010959120000000000000 0000000000000000000000000000000000000000000000000008000018
18
+ 70000000000000000335210001414731123725 1123725000004759710000001 01900000000000 1806080708 000000000000006471539916870001007080000175000000000000000000000000000000000000000000000000000000000000000000000000064715000000000000000000000000000000000000000000000006454020000000000000 0000000000000000000000000000000000000000000000000010000019
19
+ 70000000000000000335210001414731123725 1123725000004759810000001 01900000000000 1806080708 000000000000002086639916870001007080000175000000000000000000000000000000000000000000000000000000000000000000000000020866000000000000000000000000000000000000000000000002069120000000000000 0000000000000000000000000000000000000000000000000010000020
20
+ 70000000000000000335210001414731123725 1123725000004759910000001 01900000000000 1806080708 000000000000000824139916870001007080000175000000000000000000000000000000000000000000000000000000000000000000000000008241000000000000000000000000000000000000000000000000806620000000000000 0000000000000000000000000000000000000000000000000010000021
21
+ 70000000000000000335210001414731123725 1123725000004760010000001 01900000000000 1806080708 000000000000000544339916870001007080000175000000000000000000000000000000000000000000000000000000000000000000000000005443000000000000000000000000000000000000000000000000526820000000000000 0000000000000000000000000000000000000000000000000010000022
22
+ 70000000000000000335210001414731123725 1123725000004760110000001 01900000000000 1806080708 000000000000009348239916870001007080000175000000000000000000000000000000000000000000000000000000000000000000000000093482000000000000000000000000000000000000000000000009330720000000000000 0000000000000000000000000000000000000000000000000010000023
23
+ 70000000000000000335210001414731123725 1123725000004760210000001 01900000000000 1806080708 000000000000001587639916870001007080000175000000000000000000000000000000000000000000000000000000000000000000000000015876000000000000000000000000000000000000000000000001570120000000000000 0000000000000000000000000000000000000000000000000010000024
24
+ 70000000000000000335210001414731123725 1123725000004760310000001 01900000000000 1806080708 000000000000000075639916870001007080000175000000000000000000000000000000000000000000000000000000000000000000000000000756000000000000000000000000000000000000000000000000058120000000000000 0000000000000000000000000000000000000000000000000010000025
25
+ 70000000000000000335210001414731123725 1123725000004760410000001 01900000000000 1806080708 000000000000000245739916870001007080000175000000000000000000000000000000000000000000000000000000000000000000000000002457000000000000000000000000000000000000000000000000228220000000000000 0000000000000000000000000000000000000000000000000010000026
26
+ 70000000000000000335210001414731123725 1123725000004760610000001 01900000000000 1806080708 000000000000010123500105517001007080000175000000000000000000000000000000000000000000000000000000000000000000000000101235000000000000000000000000000000000000000000000010106020000000000000 0000000000000000000000000000000000000000000000000008000027
27
+ 70000000000000000335210001414731123725 1123725000004760710000001 01900000000000 1806080708 000000000000010278900105517001007080000175000000000000000000000000000000000000000000000000000000000000000000000000102789000000000000000000000000000000000000000000000010261420000000000000 0000000000000000000000000000000000000000000000000008000028
28
+ 70000000000000000335210001414731123725 1123725000004760810000001 01900000000000 1806080708 000000000000010335200105517001007080000175000000000000000000000000000000000000000000000000000000000000000000000000103352000000000000000000000000000000000000000000000010317720000000000000 0000000000000000000000000000000000000000000000000008000029
29
+ 70000000000000000335210001414731123725 1123725000004760910000001 01900000000000 1806080708 000000000000010351200105517001007080000175000000000000000000000000000000000000000000000000000000000000000000000000103512000000000000000000000000000000000000000000000010333720000000000000 0000000000000000000000000000000000000000000000000008000030
30
+ 70000000000000000335210001414731123725 1123725000004761010000001 01900000000000 1806080708 000000000000011946500130376001007080000175000000000000000000000000000000000000000000000000000000000000000000000000119465000000000000000000000000000000000000000000000011929020000000000000 0000000000000000000000000000000000000000000000000004000031
31
+ 70000000000000000335210001414731123725 1123725000004761110000001 01900000000000 1806080708 000000000000012273800130376001007080000175000000000000000000000000000000000000000000000000000000000000000000000000122738000000000000000000000000000000000000000000000012256320000000000000 0000000000000000000000000000000000000000000000000004000032
32
+ 70000000000000000335210001414731123725 1123725000004761210000001 01900000000000 1806080708 000000000000012349600130376001007080000175000000000000000000000000000000000000000000000000000000000000000000000000123496000000000000000000000000000000000000000000000012332120000000000000 0000000000000000000000000000000000000000000000000004000033
33
+ 70000000000000000335210001414731123725 1123725000004761310000001 01900000000000 1806080708 000000000000001872600132905001007080000175000000000000000000000000000000000000000000000000000000000000000000000000018726000000000000000000000000000000000000000000000001855120000000000000 0000000000000000000000000000000000000000000000000002000034
34
+ 70000000000000000335210001414731123725 1123725000004761410000001 01900000000000 1806080708 000000000000000087300132905001007080000175000000000000000000000000000000000000000000000000000000000000000000000000000873000000000000000000000000000000000000000000000000069820000000000000 0000000000000000000000000000000000000000000000000008000035
35
+ 70000000000000000335210001414731123725 1123725000004761510000001 01900000000000 1806080708 000000000000010889100132905001007080000175000000000000000000000000000000000000000000000000000000000000000000000000108891000000000000000000000000000000000000000000000010871620000000000000 0000000000000000000000000000000000000000000000000008000036
36
+ 70000000000000000335210001414731123725 1123725000004761610000001 01900000000000 1806080708 000000000000001653800132905001007080000175000000000000000000000000000000000000000000000000000000000000000000000000016538000000000000000000000000000000000000000000000001636320000000000000 0000000000000000000000000000000000000000000000000008000037
37
+ 70000000000000000335210001414731123725 1123725000004761710000001 01900000000000 1806080708 000000000000009108800132905001007080000175000000000000000000000000000000000000000000000000000000000000000000000000091088000000000000000000000000000000000000000000000009091320000000000000 0000000000000000000000000000000000000000000000000008000038
38
+ 70000000000000000335210001414731123725 1123725000004761810000001 01900000000000 1806080708 000000000000011136500132905001007080000175000000000000000000000000000000000000000000000000000000000000000000000000111365000000000000000000000000000000000000000000000011119020000000000000 0000000000000000000000000000000000000000000000000008000039
39
+ 70000000000000000335210001414731123725 1123725000004761910000001 01900000000000 1806080708 000000000000011209100132905001007080000175000000000000000000000000000000000000000000000000000000000000000000000000112091000000000000000000000000000000000000000000000011191620000000000000 0000000000000000000000000000000000000000000000000008000040
40
+ 70000000000000000335210001414731123725 1123725000004762010000001 01900000000000 1806080708 000000000000010884300132905001007080000175000000000000000000000000000000000000000000000000000000000000000000000000108843000000000000000000000000000000000000000000000010866820000000000000 0000000000000000000000000000000000000000000000000008000041
41
+ 70000000000000000335210001414731123725 1123725000004762110000001 01900000000000 1806080708 00000000000001040610012970X001007080000175000000000000000000000000000000000000000000000000000000000000000000000000104061000000000000000000000000000000000000000000000010388620000000000000 0000000000000000000000000000000000000000000000000002000042
42
+ 70000000000000000335210001414731123725 1123725000004762210000001 01900000000000 1806080708 000000000000012373000132905001007080000175000000000000000000000000000000000000000000000000000000000000000000000000123730000000000000000000000000000000000000000000000012355520000000000000 0000000000000000000000000000000000000000000000000009000043
43
+ 70000000000000000335210001414731123725 1123725000004762310000001 01900000000000 1806080708 000000000000012251700132905001007080000175000000000000000000000000000000000000000000000000000000000000000000000000122517000000000000000000000000000000000000000000000012234220000000000000 0000000000000000000000000000000000000000000000000009000044
44
+ 70000000000000000335210001414731123725 1123725000004762410000001 01900000000000 1806080708 000000000000010641700130376001007080000175000000000000000000000000000000000000000000000000000000000000000000000000106417000000000000000000000000000000000000000000000010624220000000000000 0000000000000000000000000000000000000000000000000002000045
45
+ 70000000000000000335210001414731123725 1123725000004762510000001 01900000000000 1806080708 000000000000002131000132905001007080000175000000000000000000000000000000000000000000000000000000000000000000000000021310000000000000000000000000000000000000000000000002113520000000000000 0000000000000000000000000000000000000000000000000002000046
46
+ 70000000000000000335210001414731123725 1123725000004762610000001 01900000000000 1806080708 000000000000009677539918860001007080000175000000000000000000000000000000000000000000000000000000000000000000000000096775000000000000000000000000000000000000000000000009660020000000000000 0000000000000000000000000000000000000000000000000010000047
47
+ 70000000000000000335210001414731123725 1123725000004762710000001 01900000000000 1806080708 000000000000009677539918860001007080000175000000000000000000000000000000000000000000000000000000000000000000000000096775000000000000000000000000000000000000000000000009660020000000000000 0000000000000000000000000000000000000000000000000010000048
48
+ 70000000000000000335210001414731123725 1123725000004762810000001 01900000000000 1806080708 000000000000000633239918860001007080000175000000000000000000000000000000000000000000000000000000000000000000000000006332000000000000000000000000000000000000000000000000615720000000000000 0000000000000000000000000000000000000000000000000010000049
49
+ 70000000000000000335210001414731123725 1123725000004762910000001 01900000000000 1806080708 000000000000010583400114923001007080000175000000000000000000000000000000000000000000000000000000000000000000000000105834000000000000000000000000000000000000000000000010565920000000000000 0000000000000000000000000000000000000000000000000004000050
50
+ 70000000000000000335210001414731123725 1123725000004763110000001 01900000000000 1806080708 000000000000011637600130368001007080000175000000000000000000000000000000000000000000000000000000000000000000000000116376000000000000000000000000000000000000000000000011620120000000000000 0000000000000000000000000000000000000000000000000001000051
51
+ 70000000000000000335210001414731123725 1123725000004763210000001 01900000000000 1806080708 000000000000011705200130368001007080000175000000000000000000000000000000000000000000000000000000000000000000000000117052000000000000000000000000000000000000000000000011687720000000000000 0000000000000000000000000000000000000000000000000001000052
@@ -0,0 +1,276 @@
1
+ require File.join(File.dirname(__FILE__),'test_helper.rb')
2
+
3
+ class BancoBrasilTest < 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
@@ -0,0 +1,66 @@
1
+ require File.join(File.dirname(__FILE__),'test_helper.rb')
2
+
3
+ class BancoHsbcTest < Test::Unit::TestCase #:nodoc:[all]
4
+
5
+ def setup
6
+ @boleto_novo = BancoHsbc.new(:data_documento => Date.parse("2008-02-01"))
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.valor = 2952.95
14
+ end
15
+
16
+ def test_should_initialize_correctly
17
+ assert_equal '399', @boleto_novo.banco
18
+ assert_equal "DM", @boleto_novo.especie_documento
19
+ assert_equal "R$", @boleto_novo.especie
20
+ assert_equal "9", @boleto_novo.moeda
21
+ assert_equal Date.parse("2008-02-01"), @boleto_novo.data_documento
22
+ assert_equal 1, @boleto_novo.dias_vencimento
23
+ assert_equal((@boleto_novo.data_documento + 1), @boleto_novo.data_vencimento)
24
+ assert_equal "S", @boleto_novo.aceite
25
+ assert_equal 1, @boleto_novo.quantidade
26
+ assert_equal 2952.95, @boleto_novo.valor
27
+ assert_equal 2952.95, @boleto_novo.valor_documento
28
+ assert_equal "QUALQUER BANCO ATÉ O VENCIMENTO", @boleto_novo.local_pagamento
29
+ end
30
+
31
+ def test_should_return_correct_nosso_numero
32
+ @boleto_novo.conta_corrente = "1122334"
33
+ @boleto_novo.numero_documento = "12345678"
34
+ @boleto_novo.dias_vencimento = 5
35
+ @boleto_novo.data_documento = Date.parse("2000-07-04")
36
+ assert_equal "12345678942", @boleto_novo.nosso_numero
37
+ @boleto_novo.conta_corrente = "351202"
38
+ @boleto_novo.numero_documento = "39104766"
39
+ @boleto_novo.dias_vencimento = 0
40
+ @boleto_novo.data_documento = Date.parse("2000-07-04")
41
+ assert_equal "39104766340", @boleto_novo.nosso_numero
42
+ @boleto_novo.conta_corrente = "351202"
43
+ @boleto_novo.numero_documento = "39104766"
44
+ @boleto_novo.dias_vencimento = 0
45
+ @boleto_novo.data_documento = ""
46
+ assert_equal "39104766354", @boleto_novo.nosso_numero
47
+ end
48
+
49
+ def test_should_mont_correct_codigo_barras
50
+ @boleto_novo.conta_corrente = "1122334"
51
+ @boleto_novo.numero_documento = "12345678"
52
+ @boleto_novo.dias_vencimento = 5
53
+ @boleto_novo.data_documento = Date.parse("2009-04-03")
54
+ assert_equal "3999420100002952951122334000001234567809892", @boleto_novo.monta_codigo_43_digitos
55
+ assert_equal "39998420100002952951122334000001234567809892", @boleto_novo.codigo_barras
56
+ end
57
+
58
+ def test_should_mont_correct_linha_digitalvel
59
+ @boleto_novo.conta_corrente = "1122334"
60
+ @boleto_novo.numero_documento = "12345678"
61
+ @boleto_novo.dias_vencimento = 5
62
+ @boleto_novo.data_documento = Date.parse("2009-04-03")
63
+ assert_equal("39991.12232 34000.001239 45678.098927 8 42010000295295", @boleto_novo.codigo_barras.linha_digitavel)
64
+ end
65
+
66
+ end
@@ -0,0 +1,103 @@
1
+ require File.join(File.dirname(__FILE__),'test_helper.rb')
2
+
3
+ class BancoItauTest < Test::Unit::TestCase #:nodoc:[all]
4
+
5
+ BOLETO_ITAU_CARTEIRA_175 = {
6
+ :carteira => "175",
7
+ :moeda => "9",
8
+ :valor => 135.00,
9
+ :convenio => 0,
10
+ :numero_documento => "12345678",
11
+ :data_documento => Date.parse("2008-02-01"),
12
+ :dias_vencimento => 0,
13
+ :agencia => "0810",
14
+ :conta_corrente => "53678"
15
+ }
16
+
17
+ def setup
18
+ @boleto_novo = BancoItau.new # (BOLETO_CARTEIRA_175)
19
+ BOLETO_ITAU_CARTEIRA_175.each do |nome, valor|
20
+ @boleto_novo.send("#{nome}=".to_sym, valor)
21
+ end
22
+ end
23
+
24
+ def test_should_initialize_correctly
25
+ assert_equal '341', @boleto_novo.banco
26
+ assert_equal "DM", @boleto_novo.especie_documento
27
+ assert_equal "R$", @boleto_novo.especie
28
+ assert_equal "9", @boleto_novo.moeda
29
+ assert_equal Date.parse("2008-02-01"), @boleto_novo.data_documento
30
+ assert_equal 0, @boleto_novo.dias_vencimento
31
+ assert_equal((@boleto_novo.data_documento + 0), @boleto_novo.data_vencimento)
32
+ assert_equal "S", @boleto_novo.aceite
33
+ assert_equal 1, @boleto_novo.quantidade
34
+ assert_equal 135.00, @boleto_novo.valor
35
+ assert_equal 135.00, @boleto_novo.valor_documento
36
+ assert_equal "QUALQUER BANCO ATÉ O VENCIMENTO", @boleto_novo.local_pagamento
37
+ end
38
+
39
+ def test_should_return_correct_agencia_conta_corrente_dv
40
+ @boleto_novo.agencia = "0607"
41
+ @boleto_novo.conta_corrente = "15255"
42
+ assert_equal 0, @boleto_novo.agencia_conta_corrente_dv
43
+ @boleto_novo.agencia = "1547"
44
+ @boleto_novo.conta_corrente = "85547"
45
+ assert_equal 6, @boleto_novo.agencia_conta_corrente_dv
46
+ @boleto_novo.agencia = "1547"
47
+ @boleto_novo.conta_corrente = "10207"
48
+ assert_equal 7, @boleto_novo.agencia_conta_corrente_dv
49
+ @boleto_novo.agencia = "0811"
50
+ @boleto_novo.conta_corrente = "53678"
51
+ assert_equal 8, @boleto_novo.agencia_conta_corrente_dv
52
+ end
53
+
54
+ def test_should_verify_nosso_numero_dv_calculation
55
+ @boleto_novo.numero_documento = "00015448"
56
+ assert_equal 6, @boleto_novo.nosso_numero_dv
57
+ @boleto_novo.numero_documento = "15448"
58
+ assert_equal 6, @boleto_novo.nosso_numero_dv
59
+ @boleto_novo.numero_documento = "12345678"
60
+ assert_equal 4, @boleto_novo.nosso_numero_dv
61
+ @boleto_novo.numero_documento = "34230"
62
+ assert_equal 5, @boleto_novo.nosso_numero_dv
63
+ @boleto_novo.numero_documento = "258281"
64
+ assert_equal 7, @boleto_novo.nosso_numero_dv
65
+ end
66
+
67
+ def test_should_build_correct_barcode
68
+ assert_equal "3419376900000135001751234567840810536789000", @boleto_novo.monta_codigo_43_digitos
69
+ assert_equal "34195376900000135001751234567840810536789000", @boleto_novo.codigo_barras
70
+
71
+ @boleto_novo.numero_documento = "258281"
72
+ @boleto_novo.data_documento = Date.parse("2004/09/03")
73
+ assert_equal "3419252300000135001750025828170810536789000", @boleto_novo.monta_codigo_43_digitos
74
+ assert_equal "34195252300000135001750025828170810536789000", @boleto_novo.codigo_barras
75
+
76
+ @boleto_novo.numero_documento = "258281"
77
+ @boleto_novo.data_documento = Date.parse("2004/09/03")
78
+ @boleto_novo.carteira = 168
79
+ assert_equal "3419252300000135001680025828120810536789000", @boleto_novo.monta_codigo_43_digitos
80
+ assert_equal "34193252300000135001680025828120810536789000", @boleto_novo.codigo_barras
81
+
82
+ @boleto_novo.carteira = 196
83
+ @boleto_novo.convenio = "12345"
84
+ @boleto_novo.seu_numero = "1234567"
85
+ assert_equal "3419252300000135001960025828112345671234550", @boleto_novo.monta_codigo_43_digitos
86
+ assert_equal "34199252300000135001960025828112345671234550", @boleto_novo.codigo_barras
87
+ @boleto_novo.seu_numero = "123456"
88
+ assert_equal "3419252300000135001960025828101234561234550", @boleto_novo.monta_codigo_43_digitos
89
+ assert_equal "34191252300000135001960025828101234561234550", @boleto_novo.codigo_barras
90
+
91
+ @boleto_novo.convenio = "1234"
92
+ assert_equal "3419252300000135001960025828101234560123440", @boleto_novo.monta_codigo_43_digitos
93
+ assert_equal "34191252300000135001960025828101234560123440", @boleto_novo.codigo_barras
94
+ end
95
+
96
+ def test_should_build_correct_typeable_line
97
+ assert_equal "34191.75124 34567.840813 05367.890000 5 37690000013500", @boleto_novo.codigo_barras.linha_digitavel
98
+ @boleto_novo.numero_documento = "258281"
99
+ @boleto_novo.data_documento = Date.parse("2004/09/03")
100
+ assert_equal "34191.75009 25828.170818 05367.890000 5 25230000013500", @boleto_novo.codigo_barras.linha_digitavel
101
+ end
102
+
103
+ end