brcobranca 5.0.0 → 5.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/Gemfile +3 -2
  4. data/Gemfile.lock +13 -9
  5. data/README.md +5 -1
  6. data/brcobranca.gemspec +2 -0
  7. data/lib/brcobranca/arquivos/logos/sicoob.eps +209 -0
  8. data/lib/brcobranca/boleto/bradesco.rb +20 -0
  9. data/lib/brcobranca/boleto/sicoob.rb +80 -0
  10. data/lib/brcobranca/remessa/base.rb +1 -1
  11. data/lib/brcobranca/remessa/cnab240/banco_brasil.rb +7 -2
  12. data/lib/brcobranca/remessa/cnab240/base.rb +133 -134
  13. data/lib/brcobranca/remessa/cnab240/caixa.rb +6 -1
  14. data/lib/brcobranca/remessa/cnab240/sicoob.rb +128 -0
  15. data/lib/brcobranca/remessa/cnab400/base.rb +5 -5
  16. data/lib/brcobranca/remessa/cnab400/bradesco.rb +5 -3
  17. data/lib/brcobranca/remessa/cnab400/citibank.rb +140 -0
  18. data/lib/brcobranca/remessa/cnab400/itau.rb +4 -11
  19. data/lib/brcobranca/remessa/pagamento.rb +39 -5
  20. data/lib/brcobranca/retorno/base.rb +1 -0
  21. data/lib/brcobranca/retorno/cnab400/base.rb +40 -0
  22. data/lib/brcobranca/retorno/cnab400/bradesco.rb +117 -0
  23. data/lib/brcobranca/retorno/cnab400/itau.rb +136 -0
  24. data/lib/brcobranca/retorno/retorno_cnab400.rb +6 -1
  25. data/lib/brcobranca/util/empresa.rb +29 -0
  26. data/lib/brcobranca/version.rb +1 -1
  27. data/lib/brcobranca.rb +19 -5
  28. data/spec/arquivos/CNAB400BRADESCO.RET +8 -0
  29. data/spec/arquivos/CNAB400ITAU.RET +54 -0
  30. data/spec/brcobranca/base_spec.rb +175 -179
  31. data/spec/brcobranca/{banco_bradesco_spec.rb → boleto/banco_bradesco_spec.rb} +80 -53
  32. data/spec/brcobranca/{banco_brasil_spec.rb → boleto/banco_brasil_spec.rb} +2 -2
  33. data/spec/brcobranca/{banco_caixa_spec.rb → boleto/banco_caixa_spec.rb} +1 -1
  34. data/spec/brcobranca/{banco_hsbc_spec.rb → boleto/banco_hsbc_spec.rb} +2 -2
  35. data/spec/brcobranca/{banco_itau_spec.rb → boleto/banco_itau_spec.rb} +2 -2
  36. data/spec/brcobranca/{banco_santander_spec.rb → boleto/banco_santander_spec.rb} +2 -2
  37. data/spec/brcobranca/boleto/banco_sicoob_spec.rb +132 -0
  38. data/spec/brcobranca/{banco_sicredi_spec.rb → boleto/banco_sicredi_spec.rb} +2 -2
  39. data/spec/brcobranca/boletos_em_lote_spec.rb +2 -2
  40. data/spec/brcobranca/core_ext_spec.rb +198 -199
  41. data/spec/brcobranca/currency_spec.rb +67 -71
  42. data/spec/brcobranca/remessa/base_spec.rb +1 -17
  43. data/spec/brcobranca/remessa/cnab240/banco_brasil_spec.rb +22 -13
  44. data/spec/brcobranca/remessa/cnab240/base_spec.rb +28 -27
  45. data/spec/brcobranca/remessa/cnab240/caixa_spec.rb +13 -4
  46. data/spec/brcobranca/remessa/cnab240/sicoob_spec.rb +155 -0
  47. data/spec/brcobranca/remessa/cnab400/base_spec.rb +1 -17
  48. data/spec/brcobranca/remessa/cnab400/bradesco_spec.rb +15 -2
  49. data/spec/brcobranca/remessa/cnab400/citibank_spec.rb +117 -0
  50. data/spec/brcobranca/remessa/cnab400/itau_spec.rb +15 -10
  51. data/spec/brcobranca/remessa/pagamento_spec.rb +6 -8
  52. data/spec/brcobranca/retorno/cnab400/base_spec.rb +35 -0
  53. data/spec/brcobranca/retorno/cnab400/bradesco_spec.rb +55 -0
  54. data/spec/brcobranca/retorno/cnab400/itau_spec.rb +55 -0
  55. data/spec/brcobranca/{retorno_cbr643_spec.rb → retorno/retorno_cbr643_spec.rb} +3 -3
  56. data/spec/brcobranca/{retorno_cnab400_spec.rb → retorno/retorno_cnab400_spec.rb} +3 -3
  57. data/spec/brcobranca/{retorno_cnab_240_spec.rb → retorno/retorno_cnab_240_spec.rb} +3 -3
  58. data/spec/brcobranca/rghost_spec.rb +2 -2
  59. data/spec/brcobranca/util/empresa_spec.rb +35 -0
  60. data/spec/brcobranca_spec.rb +25 -10
  61. data/spec/fixtures/remessa/.keep +0 -0
  62. data/spec/fixtures/remessa/remessa-bancoob.rem +6 -0
  63. data/spec/spec_helper.rb +23 -0
  64. data/spec/support/remessa_helpers.rb +12 -0
  65. data/spec/{shared_examples → support/shared_examples}/cnab240.rb +17 -15
  66. data/spec/{shared_examples → support/shared_examples}/cnab400.rb +11 -3
  67. metadata +72 -26
data/lib/brcobranca.rb CHANGED
@@ -97,23 +97,30 @@ module Brcobranca
97
97
  autoload :Hsbc, 'brcobranca/boleto/hsbc'
98
98
  autoload :Bradesco, 'brcobranca/boleto/bradesco'
99
99
  autoload :Caixa, 'brcobranca/boleto/caixa'
100
+ autoload :Sicoob, 'brcobranca/boleto/sicoob'
100
101
  autoload :Sicredi, 'brcobranca/boleto/sicredi'
101
102
  autoload :Santander, 'brcobranca/boleto/santander'
102
103
 
103
104
  # Módulos para classes de template
104
105
  module Template
105
- autoload :Base, 'brcobranca/boleto/template/base'
106
- autoload :Rghost, 'brcobranca/boleto/template/rghost'
106
+ autoload :Base, 'brcobranca/boleto/template/base'
107
+ autoload :Rghost, 'brcobranca/boleto/template/rghost'
107
108
  autoload :RghostCarne, 'brcobranca/boleto/template/rghost_carne'
108
109
  end
109
110
  end
110
111
 
111
112
  # Módulos para classes de retorno bancário
112
113
  module Retorno
113
- autoload :Base, 'brcobranca/retorno/base'
114
- autoload :RetornoCbr643, 'brcobranca/retorno/retorno_cbr643'
114
+ autoload :Base, 'brcobranca/retorno/base'
115
+ autoload :RetornoCbr643, 'brcobranca/retorno/retorno_cbr643'
115
116
  autoload :RetornoCnab240, 'brcobranca/retorno/retorno_cnab240'
116
- autoload :RetornoCnab400, 'brcobranca/retorno/retorno_cnab400'
117
+ autoload :RetornoCnab400, 'brcobranca/retorno/retorno_cnab400' # DEPRECATED
118
+
119
+ module Cnab400
120
+ autoload :Base, 'brcobranca/retorno/cnab400/base'
121
+ autoload :Bradesco, 'brcobranca/retorno/cnab400/bradesco'
122
+ autoload :Itau, 'brcobranca/retorno/cnab400/itau'
123
+ end
117
124
  end
118
125
 
119
126
  # Módulos para as classes que geram os arquivos remessa
@@ -125,12 +132,19 @@ module Brcobranca
125
132
  autoload :Base, 'brcobranca/remessa/cnab400/base'
126
133
  autoload :Bradesco, 'brcobranca/remessa/cnab400/bradesco'
127
134
  autoload :Itau, 'brcobranca/remessa/cnab400/itau'
135
+ autoload :Citibank, 'brcobranca/remessa/cnab400/citibank'
128
136
  end
129
137
 
130
138
  module Cnab240
131
139
  autoload :Base, 'brcobranca/remessa/cnab240/base'
132
140
  autoload :Caixa, 'brcobranca/remessa/cnab240/caixa'
133
141
  autoload :BancoBrasil, 'brcobranca/remessa/cnab240/banco_brasil'
142
+ autoload :Sicoob, 'brcobranca/remessa/cnab240/sicoob'
134
143
  end
135
144
  end
145
+
146
+ # Módulos para classes de utilidades
147
+ module Util
148
+ autoload :Empresa, 'brcobranca/util/empresa'
149
+ end
136
150
  end
@@ -0,0 +1,8 @@
1
+ 02RETORNO01COBRANCA 00000000000004540691NOME DA EMPRESA 237BRADESCO 1505150160000000405 150515 000001
2
+ 102120958700001700000009014670019669P 0000000000000000030300000000000000000000000009021505150030 00000000000000000030250515000000014500023704157 000000000016000000000000000000000000000000000000000000000000000000000000000000000000014500000000000000000000000000000 150515 0000000000 000002
3
+ 102120958700001700000009014670019669P 0000000051350000004P00000000000000000000000009021505151146 0000000051350000004P250515000000001800023704157 000000000016000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000 000003
4
+ 102120958700001700000009014670019669P 0000000051350000007400000000000000000000000009021505151142 00000000513500000074250515000000007200023704157 000000000016000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000 000004
5
+ 102120958700001700000009014670019669P 0000000051350000009000000000000000000000000009021505151145 00000000513500000090120615000000002000023704157 000000000016000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000 000005
6
+ 102120958700001700000009014670019669P 0000000051350000011200000000000000000000000009021505151144 00000000513500000112250515000000001800023704157 000000000016000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000 000006
7
+ 102120958700001700000009014670019669P 0000000050980000002800000000000000000000000009101505151053 00000000509800000028060515000000002000023700000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000 000007
8
+ 9201237 000000180000000086450000000405 00005000000202000000000000000000000000000000000000100000002000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000 000008
@@ -0,0 +1,54 @@
1
+ 02RETORNO01COBRANCA 073000035110 PLUTO ALTO ELENTAS LTDA ME 341BANCO ITAU S.A.20051301600BPI00025210513 000001
2
+ 10216733872000107073000035110 00000011 109000000114 I06200513 00000011 000000000000000400010418739 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000379000000000000000000000000000 21051300000000000000000000000 B5000002
3
+ 10216733872000107073000035110 00000035 109000000353 I06200513 00000035 000000000000000400010415552 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000379000000000000000000000000000 21051300000000000000000000000 B5000003
4
+ 10216733872000107073000035110 00000052 109000000528 I06200513 00000052 000000000000000400010415552 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000379000000000000000000000000000 21051300000000000000000000000 B5000004
5
+ 10216733872000107073000035110 00000107 109000001070 I06200513 00000107 000000000000000400010415552 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000379000000000000000000000000000 21051300000000000000000000000 B5000005
6
+ 10216733872000107073000035110 00000139 109000001393 I06200513 00000139 000000000000000400010415552 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000379000000000000000000000000000 21051300000000000000000000000 B5000006
7
+ 10216733872000107073000035110 00000195 109000001955 I06200513 00000195 000000000000000400010415552 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000379000000000000000000000000000 21051300000000000000000000000 B5000007
8
+ 10216733872000107073000035110 00000267 109000002672 I06200513 00000267 000000000000000400010415552 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000379000000000000000000000000000 21051300000000000000000000000 B5000008
9
+ 10216733872000107073000035110 00000331 109000003316 I06200513 00000331 000000000000000400010404085 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000379000000000000000000000000000 21051300000000000000000000000 B5000009
10
+ 10216733872000107073000035110 00000541 109000005410 I06200513 00000541 000000000000001050010417848 000000000021000000000000000000000000000000000000000000000000000000000000000000000000001029000000000000000000000000000 21051300000000000000000000000 B5000010
11
+ 10216733872000107073000035110 00000890 109000008901 I06200513 00000890 000000000000000400010418754 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000379000000000000000000000000000 21051300000000000000000000000 B5000011
12
+ 10216733872000107073000035110 00000956 109000009560 I06200513 00000956 000000000000000750010417848 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000729000000000000000000000000000 21051300000000000000000000000 B5000012
13
+ 10216733872000107073000035110 00000975 109000009750 I06200513 00000975 000000000000000750010417848 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000729000000000000000000000000000 21051300000000000000000000000 B2000013
14
+ 10216733872000107073000035110 00001036 109000010360 I06200513 00001036 000000000000000210034178584 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000189000000000000000000000000000 21051300000000000000000000000 CP000014
15
+ 10216733872000107073000035110 00001052 109000010527 I06200513 00001052 000000000000000840010417848 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000819000000000000000000000000000 21051300000000000000000000000 B5000015
16
+ 10216733872000107073000035110 00001109 109000011095 I06200513 00001109 000000000000000460010436921 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000439000000000000000000000000000 21051300000000000000000000000 B5000016
17
+ 10216733872000107073000035110 00001123 109000011236 I06200513 00001123 000000000000000400010418754 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000379000000000000000000000000000 21051300000000000000000000000 B5000017
18
+ 10216733872000107073000035110 00001206 109000012069 I06200513 00001206 000000000000000400010418754 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000379000000000000000000000000000 21051300000000000000000000000 B5000018
19
+ 10216733872000107073000035110 00001324 109000013240 I06200513 00001324 000000000000000400010415552 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000379000000000000000000000000000 21051300000000000000000000000 B5000019
20
+ 10216733872000107073000035110 00001351 109000013513 I06200513 00001351 000000000000000400023729371 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000379000000000000000000000000000 21051300000000000000000000000 B2000020
21
+ 10216733872000107073000035110 00001372 109000013729 I06200513 00001372 000000000000000400010415552 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000379000000000000000000000000000 21051300000000000000000000000 B5000021
22
+ 10216733872000107073000035110 00001373 109000013737 I06200513 00001373 000000000000000400010415552 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000379000000000000000000000000000 21051300000000000000000000000 B5000022
23
+ 10216733872000107073000035110 00001380 109000013802 I06200513 00001380 000000000000000400010415552 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000379000000000000000000000000000 21051300000000000000000000000 B5000023
24
+ 10216733872000107073000035110 00001458 109000014586 I06200513 00001458 000000000000000400000152480 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000379000000000000000000000000000 21051300000000000000000000000 B5000024
25
+ 10216733872000107073000035110 00001498 109000014982 I06200513 00001498 000000000000000400034102899 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000379000000000000000000000000000 21051300000000000000000000000 AA000025
26
+ 10216733872000107073000035110 00001698 109000016987 I06200513 00001698 000000000000000191010415552 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000170000000000000000000000000000 21051300000000000000000000000 B5000026
27
+ 10216733872000107073000035110 00002129 109000021292 I06200513 00002129 000000000000000400010415552 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000379000000000000000000000000000 21051300000000000000000000000 B5000027
28
+ 10216733872000107073000035110 00002236 109000022365 I06200513 00002236 000000000000000400010415552 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000379000000000000000000000000000 21051300000000000000000000000 B5000028
29
+ 10216733872000107073000035110 00002260 109000022605 I06200513 00002260 000000000000000400010436921 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000379000000000000000000000000000 21051300000000000000000000000 B2000029
30
+ 10216733872000107073000035110 00002274 109000022746 I06200513 00002274 000000000000000400034186686 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000379000000000000000000000000000 21051300000000000000000000000 CP000030
31
+ 10216733872000107073000035110 00002286 109000022860 I06200513 00002286 000000000000000400010436921 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000379000000000000000000000000000 21051300000000000000000000000 B5000031
32
+ 10216733872000107073000035110 00002311 109000023116 I06200513 00002311 000000000000000400010418770 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000379000000000000000000000000000 21051300000000000000000000000 B5000032
33
+ 10216733872000107073000035110 00002586 109000025863 I06200513 00002586 000000000000000640010415552 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000619000000000000000000000000000 21051300000000000000000000000 B5000033
34
+ 10216733872000107073000035110 00002597 109000025970 I06200513 00002597 000000000000000440000126385 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000419000000000000000000000000000 21051300000000000000000000000 B5000034
35
+ 10216733872000107073000035110 00002601 109000026010 I06200513 00002601 000000000000000440010415552 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000419000000000000000000000000000 21051300000000000000000000000 B5000035
36
+ 10216733872000107073000035110 00002607 109000026077 I06200513 00002607 000000000000000440010415552 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000419000000000000000000000000000 21051300000000000000000000000 B5000036
37
+ 10216733872000107073000035110 00002617 109000026176 I06200513 00002617 000000000000000440000148322 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000419000000000000000000000000000 21051300000000000000000000000 B1000037
38
+ 10216733872000107073000035110 00002627 109000026275 I06200513 00002627 000000000000000440000148298 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000419000000000000000000000000000 21051300000000000000000000000 B1000038
39
+ 10216733872000107073000035110 00002668 109000026689 I06200513 00002668 000000000000000440023729371 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000419000000000000000000000000000 21051300000000000000000000000 B3000039
40
+ 10216733872000107073000035110 00002674 109000026747 I06200513 00002674 000000000000000440010404085 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000419000000000000000000000000000 21051300000000000000000000000 B5000040
41
+ 10216733872000107073000035110 00002721 109000027216 I06200513 00002721 000000000000000440010415552 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000419000000000000000000000000000 21051300000000000000000000000 B5000041
42
+ 10216733872000107073000035110 00003136 109000031366 I06200513 00003136 000000000000000487534148272 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000476700000000001020000000000000 21051300000000000000000000000 CP000042
43
+ 10216733872000107073000035110 00003238 109000032380 I06200513 00003238 000000000000003500000130478 000000000021000000000000000000000000000000000000000000000000000000000000000000000000003479000000000000000000000000000 21051300000000000000000000000 B2000043
44
+ 10216733872000107073000035110 00003344 109000033446 I06200513 00003344 000000000000000440000148298 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000419000000000000000000000000000 21051300000000000000000000000 B1000044
45
+ 10216733872000107073000035110 00003391 109000033917 I06200513 00003391 000000000000000440034186132 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000419000000000000000000000000000 21051300000000000000000000000 BL000045
46
+ 10216733872000107073000035110 00003456 109000034568 I06200513 00003456 000000000000000571534102899 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000562200000000001170000000000000 21051300000000000000000000000 CP000046
47
+ 10216733872000107073000035110 00003505 109000035052 I06200513 00003505 000000000000000457100148322 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000436100000000000000000000000000 21051300000000000000000000000 B1000047
48
+ 10216733872000107073000035110 00003925 109000039252 I06200513 00003925 000000000000000571034165466 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000561900000000001190000000000000 21051300000000000000000000000 CP000048
49
+ 10216733872000107073000035110 00004012 109000040128 I06200513 00004012 000000000000000500010430783 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000479000000000000000000000000000 21051300000000000000000000000 B5000049
50
+ 10216733872000107073000035110 00004019 109000040193 I06200513 00004019 000000000000000571510415552 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000550500000000000000000000000000 21051300000000000000000000000 B5000050
51
+ 10216733872000107073000035110 00004026 109000040268 I06200513 00004026 000000000000000500039913003 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000479000000000000000000000000000 21051300000000000000000000000 B3000051
52
+ 10216733872000107073000035110 27615123 157276151236 I06200513000000108927615123 100513000000000440034165466 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000428800000000000980000000000000 21051300000000000000000000000DIVA LOUZAMARA DO CASTO BLITTO CP000052
53
+ 10216733872000107073000035110 27714592 157277145922 I09200513000000206827714592 100513000000000400034177099 000000000021000000000000000000000000000000000000000000000000000000000000000000000000000021000000000000000000000000000 00000000000000000000000MIRCALO TIADORO 000053
54
+ 9201341 000000000000000000000000000000 000000000000000000000000000000 000000000000000000000000000000 0000003200000000148705 21/05S000250000005200000000268896 000054
@@ -1,196 +1,192 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  require 'spec_helper'
3
3
 
4
- module Brcobranca #:nodoc:[all]
5
- module Boleto #:nodoc:[all]
6
- describe Base do
7
- before(:each) do
8
- @valid_attributes = {
9
- especie_documento: 'DM',
10
- moeda: '9',
11
- data_documento: Date.today,
12
- dias_vencimento: 1,
13
- aceite: 'S',
14
- quantidade: 1,
15
- valor: 0.0,
16
- local_pagamento: 'QUALQUER BANCO ATÉ O VENCIMENTO',
17
- cedente: 'Kivanio Barbosa',
18
- documento_cedente: '12345678912',
19
- sacado: 'Claudio Pozzebom',
20
- sacado_documento: '12345678900',
21
- agencia: '4042',
22
- conta_corrente: '61900',
23
- convenio: 12_387_989,
24
- numero_documento: '777700168'
25
- }
26
- end
4
+ RSpec.describe Brcobranca::Boleto::Base do
5
+ before do
6
+ @valid_attributes = {
7
+ especie_documento: 'DM',
8
+ moeda: '9',
9
+ data_documento: Date.today,
10
+ dias_vencimento: 1,
11
+ aceite: 'S',
12
+ quantidade: 1,
13
+ valor: 0.0,
14
+ local_pagamento: 'QUALQUER BANCO ATÉ O VENCIMENTO',
15
+ cedente: 'Kivanio Barbosa',
16
+ documento_cedente: '12345678912',
17
+ sacado: 'Claudio Pozzebom',
18
+ sacado_documento: '12345678900',
19
+ agencia: '4042',
20
+ conta_corrente: '61900',
21
+ convenio: 12_387_989,
22
+ numero_documento: '777700168'
23
+ }
24
+ end
27
25
 
28
- it 'Criar nova instancia com atributos padrões' do
29
- boleto_novo = Brcobranca::Boleto::Base.new
30
- expect(boleto_novo.especie_documento).to eql('DM')
31
- expect(boleto_novo.especie).to eql('R$')
32
- expect(boleto_novo.moeda).to eql('9')
33
- expect(boleto_novo.data_documento).to eql(Date.today)
34
- expect(boleto_novo.dias_vencimento).to eql(1)
35
- expect(boleto_novo.data_vencimento).to eql(Date.today + 1)
36
- expect(boleto_novo.aceite).to eql('S')
37
- expect(boleto_novo.quantidade).to eql(1)
38
- expect(boleto_novo.valor).to eql(0.0)
39
- expect(boleto_novo.valor_documento).to eql(0.0)
40
- expect(boleto_novo.local_pagamento).to eql('QUALQUER BANCO ATÉ O VENCIMENTO')
41
- expect(boleto_novo.valid?).to be_falsey
42
- end
26
+ it 'Criar nova instancia com atributos padrões' do
27
+ boleto_novo = Brcobranca::Boleto::Base.new
28
+ expect(boleto_novo.especie_documento).to eql('DM')
29
+ expect(boleto_novo.especie).to eql('R$')
30
+ expect(boleto_novo.moeda).to eql('9')
31
+ expect(boleto_novo.data_documento).to eql(Date.today)
32
+ expect(boleto_novo.dias_vencimento).to eql(1)
33
+ expect(boleto_novo.data_vencimento).to eql(Date.today + 1)
34
+ expect(boleto_novo.aceite).to eql('S')
35
+ expect(boleto_novo.quantidade).to eql(1)
36
+ expect(boleto_novo.valor).to eql(0.0)
37
+ expect(boleto_novo.valor_documento).to eql(0.0)
38
+ expect(boleto_novo.local_pagamento).to eql('QUALQUER BANCO ATÉ O VENCIMENTO')
39
+ expect(boleto_novo.valid?).to be_falsey
40
+ end
43
41
 
44
- it 'Criar nova instancia com atributos válidos' do
45
- boleto_novo = Brcobranca::Boleto::Base.new(@valid_attributes)
46
- expect(boleto_novo.especie_documento).to eql('DM')
47
- expect(boleto_novo.especie).to eql('R$')
48
- expect(boleto_novo.moeda).to eql('9')
49
- expect(boleto_novo.data_documento).to eql(Date.today)
50
- expect(boleto_novo.dias_vencimento).to eql(1)
51
- expect(boleto_novo.data_vencimento).to eql(Date.today + 1)
52
- expect(boleto_novo.aceite).to eql('S')
53
- expect(boleto_novo.quantidade).to eql(1)
54
- expect(boleto_novo.valor).to eql(0.0)
55
- expect(boleto_novo.valor_documento).to eql(0.00)
56
- expect(boleto_novo.local_pagamento).to eql('QUALQUER BANCO ATÉ O VENCIMENTO')
57
- expect(boleto_novo.cedente).to eql('Kivanio Barbosa')
58
- expect(boleto_novo.documento_cedente).to eql('12345678912')
59
- expect(boleto_novo.sacado).to eql('Claudio Pozzebom')
60
- expect(boleto_novo.sacado_documento).to eql('12345678900')
61
- expect(boleto_novo.conta_corrente).to eql('0061900')
62
- expect(boleto_novo.agencia).to eql('4042')
63
- expect(boleto_novo.convenio).to eql(12_387_989)
64
- expect(boleto_novo.numero_documento).to eql('777700168')
65
- expect(boleto_novo.valid?).to be_truthy
66
- end
42
+ it 'Criar nova instancia com atributos válidos' do
43
+ boleto_novo = Brcobranca::Boleto::Base.new(@valid_attributes)
44
+ expect(boleto_novo.especie_documento).to eql('DM')
45
+ expect(boleto_novo.especie).to eql('R$')
46
+ expect(boleto_novo.moeda).to eql('9')
47
+ expect(boleto_novo.data_documento).to eql(Date.today)
48
+ expect(boleto_novo.dias_vencimento).to eql(1)
49
+ expect(boleto_novo.data_vencimento).to eql(Date.today + 1)
50
+ expect(boleto_novo.aceite).to eql('S')
51
+ expect(boleto_novo.quantidade).to eql(1)
52
+ expect(boleto_novo.valor).to eql(0.0)
53
+ expect(boleto_novo.valor_documento).to eql(0.00)
54
+ expect(boleto_novo.local_pagamento).to eql('QUALQUER BANCO ATÉ O VENCIMENTO')
55
+ expect(boleto_novo.cedente).to eql('Kivanio Barbosa')
56
+ expect(boleto_novo.documento_cedente).to eql('12345678912')
57
+ expect(boleto_novo.sacado).to eql('Claudio Pozzebom')
58
+ expect(boleto_novo.sacado_documento).to eql('12345678900')
59
+ expect(boleto_novo.conta_corrente).to eql('0061900')
60
+ expect(boleto_novo.agencia).to eql('4042')
61
+ expect(boleto_novo.convenio).to eql(12_387_989)
62
+ expect(boleto_novo.numero_documento).to eql('777700168')
63
+ expect(boleto_novo.valid?).to be_truthy
64
+ end
67
65
 
68
- it 'Calcula agencia_dv' do
69
- boleto_novo = Brcobranca::Boleto::Base.new(@valid_attributes)
70
- boleto_novo.agencia = '85068014982'
71
- expect(boleto_novo.agencia_dv).to eql(9)
72
- boleto_novo.agencia = '05009401448'
73
- expect(boleto_novo.agencia_dv).to eql(1)
74
- boleto_novo.agencia = '12387987777700168'
75
- expect(boleto_novo.agencia_dv).to eql(2)
76
- boleto_novo.agencia = '4042'
77
- expect(boleto_novo.agencia_dv).to eql(8)
78
- boleto_novo.agencia = '61900'
79
- expect(boleto_novo.agencia_dv).to eql(0)
80
- boleto_novo.agencia = '0719'
81
- expect(boleto_novo.agencia_dv).to eql(6)
82
- boleto_novo.agencia = 85_068_014_982
83
- expect(boleto_novo.agencia_dv).to eql(9)
84
- boleto_novo.agencia = 5_009_401_448
85
- expect(boleto_novo.agencia_dv).to eql(1)
86
- boleto_novo.agencia = 12_387_987_777_700_168
87
- expect(boleto_novo.agencia_dv).to eql(2)
88
- boleto_novo.agencia = 4042
89
- expect(boleto_novo.agencia_dv).to eql(8)
90
- boleto_novo.agencia = 61_900
91
- expect(boleto_novo.agencia_dv).to eql(0)
92
- boleto_novo.agencia = 719
93
- expect(boleto_novo.agencia_dv).to eql(6)
94
- end
66
+ it 'Calcula agencia_dv' do
67
+ boleto_novo = Brcobranca::Boleto::Base.new(@valid_attributes)
68
+ boleto_novo.agencia = '85068014982'
69
+ expect(boleto_novo.agencia_dv).to eql(9)
70
+ boleto_novo.agencia = '05009401448'
71
+ expect(boleto_novo.agencia_dv).to eql(1)
72
+ boleto_novo.agencia = '12387987777700168'
73
+ expect(boleto_novo.agencia_dv).to eql(2)
74
+ boleto_novo.agencia = '4042'
75
+ expect(boleto_novo.agencia_dv).to eql(8)
76
+ boleto_novo.agencia = '61900'
77
+ expect(boleto_novo.agencia_dv).to eql(0)
78
+ boleto_novo.agencia = '0719'
79
+ expect(boleto_novo.agencia_dv).to eql(6)
80
+ boleto_novo.agencia = 85_068_014_982
81
+ expect(boleto_novo.agencia_dv).to eql(9)
82
+ boleto_novo.agencia = 5_009_401_448
83
+ expect(boleto_novo.agencia_dv).to eql(1)
84
+ boleto_novo.agencia = 12_387_987_777_700_168
85
+ expect(boleto_novo.agencia_dv).to eql(2)
86
+ boleto_novo.agencia = 4042
87
+ expect(boleto_novo.agencia_dv).to eql(8)
88
+ boleto_novo.agencia = 61_900
89
+ expect(boleto_novo.agencia_dv).to eql(0)
90
+ boleto_novo.agencia = 719
91
+ expect(boleto_novo.agencia_dv).to eql(6)
92
+ end
95
93
 
96
- it 'Calcula conta_corrente_dv' do
97
- boleto_novo = Brcobranca::Boleto::Base.new(@valid_attributes)
98
- boleto_novo.conta_corrente = '85068014982'
99
- expect(boleto_novo.conta_corrente_dv).to eql(9)
100
- boleto_novo.conta_corrente = '05009401448'
101
- expect(boleto_novo.conta_corrente_dv).to eql(1)
102
- boleto_novo.conta_corrente = '12387987777700168'
103
- expect(boleto_novo.conta_corrente_dv).to eql(2)
104
- boleto_novo.conta_corrente = '4042'
105
- expect(boleto_novo.conta_corrente_dv).to eql(8)
106
- boleto_novo.conta_corrente = '61900'
107
- expect(boleto_novo.conta_corrente_dv).to eql(0)
108
- boleto_novo.conta_corrente = '0719'
109
- expect(boleto_novo.conta_corrente_dv).to eql(6)
110
- boleto_novo.conta_corrente = 85_068_014_982
111
- expect(boleto_novo.conta_corrente_dv).to eql(9)
112
- boleto_novo.conta_corrente = 5_009_401_448
113
- expect(boleto_novo.conta_corrente_dv).to eql(1)
114
- boleto_novo.conta_corrente = 12_387_987_777_700_168
115
- expect(boleto_novo.conta_corrente_dv).to eql(2)
116
- boleto_novo.conta_corrente = 4042
117
- expect(boleto_novo.conta_corrente_dv).to eql(8)
118
- boleto_novo.conta_corrente = 61_900
119
- expect(boleto_novo.conta_corrente_dv).to eql(0)
120
- boleto_novo.conta_corrente = 719
121
- expect(boleto_novo.conta_corrente_dv).to eql(6)
122
- end
94
+ it 'Calcula conta_corrente_dv' do
95
+ boleto_novo = Brcobranca::Boleto::Base.new(@valid_attributes)
96
+ boleto_novo.conta_corrente = '85068014982'
97
+ expect(boleto_novo.conta_corrente_dv).to eql(9)
98
+ boleto_novo.conta_corrente = '05009401448'
99
+ expect(boleto_novo.conta_corrente_dv).to eql(1)
100
+ boleto_novo.conta_corrente = '12387987777700168'
101
+ expect(boleto_novo.conta_corrente_dv).to eql(2)
102
+ boleto_novo.conta_corrente = '4042'
103
+ expect(boleto_novo.conta_corrente_dv).to eql(8)
104
+ boleto_novo.conta_corrente = '61900'
105
+ expect(boleto_novo.conta_corrente_dv).to eql(0)
106
+ boleto_novo.conta_corrente = '0719'
107
+ expect(boleto_novo.conta_corrente_dv).to eql(6)
108
+ boleto_novo.conta_corrente = 85_068_014_982
109
+ expect(boleto_novo.conta_corrente_dv).to eql(9)
110
+ boleto_novo.conta_corrente = 5_009_401_448
111
+ expect(boleto_novo.conta_corrente_dv).to eql(1)
112
+ boleto_novo.conta_corrente = 12_387_987_777_700_168
113
+ expect(boleto_novo.conta_corrente_dv).to eql(2)
114
+ boleto_novo.conta_corrente = 4042
115
+ expect(boleto_novo.conta_corrente_dv).to eql(8)
116
+ boleto_novo.conta_corrente = 61_900
117
+ expect(boleto_novo.conta_corrente_dv).to eql(0)
118
+ boleto_novo.conta_corrente = 719
119
+ expect(boleto_novo.conta_corrente_dv).to eql(6)
120
+ end
123
121
 
124
- it 'Calcula o valor do documento' do
125
- boleto_novo = Brcobranca::Boleto::Base.new(@valid_attributes)
126
- boleto_novo.quantidade = 1
127
- boleto_novo.valor = 1
128
- expect(boleto_novo.valor_documento).to eql(1.0)
129
- boleto_novo.quantidade = 1
130
- boleto_novo.valor = 1.0
131
- expect(boleto_novo.valor_documento).to eql(1.0)
132
- boleto_novo.quantidade = 100
133
- boleto_novo.valor = 1
134
- expect(boleto_novo.valor_documento).to eql(100.0)
135
- boleto_novo.quantidade = 1
136
- boleto_novo.valor = 1.2
137
- expect(boleto_novo.valor_documento).to eql(1.2)
138
- boleto_novo.quantidade = 1
139
- boleto_novo.valor = 135.43
140
- expect(boleto_novo.valor_documento).to eql(135.43)
141
- boleto_novo.quantidade = 'gh'
142
- boleto_novo.valor = 135.43
143
- expect(boleto_novo.valor_documento).to eql(0.0)
144
- end
122
+ it 'Calcula o valor do documento' do
123
+ boleto_novo = Brcobranca::Boleto::Base.new(@valid_attributes)
124
+ boleto_novo.quantidade = 1
125
+ boleto_novo.valor = 1
126
+ expect(boleto_novo.valor_documento).to eql(1.0)
127
+ boleto_novo.quantidade = 1
128
+ boleto_novo.valor = 1.0
129
+ expect(boleto_novo.valor_documento).to eql(1.0)
130
+ boleto_novo.quantidade = 100
131
+ boleto_novo.valor = 1
132
+ expect(boleto_novo.valor_documento).to eql(100.0)
133
+ boleto_novo.quantidade = 1
134
+ boleto_novo.valor = 1.2
135
+ expect(boleto_novo.valor_documento).to eql(1.2)
136
+ boleto_novo.quantidade = 1
137
+ boleto_novo.valor = 135.43
138
+ expect(boleto_novo.valor_documento).to eql(135.43)
139
+ boleto_novo.quantidade = 'gh'
140
+ boleto_novo.valor = 135.43
141
+ expect(boleto_novo.valor_documento).to eql(0.0)
142
+ end
145
143
 
146
- it 'Calcula data_vencimento' do
147
- boleto_novo = Brcobranca::Boleto::Base.new(@valid_attributes)
148
- boleto_novo.data_documento = Date.parse '2008-02-01'
149
- boleto_novo.dias_vencimento = 1
150
- expect(boleto_novo.data_vencimento.to_s).to eql('2008-02-02')
151
- expect(boleto_novo.data_vencimento).to eql(Date.parse('2008-02-02'))
152
- boleto_novo.data_documento = Date.parse '2008-02-02'
153
- boleto_novo.dias_vencimento = 28
154
- expect(boleto_novo.data_vencimento.to_s).to eql('2008-03-01')
155
- expect(boleto_novo.data_vencimento).to eql(Date.parse('2008-03-01'))
156
- boleto_novo.data_documento = Date.parse '2008-02-06'
157
- boleto_novo.dias_vencimento = 100
158
- expect(boleto_novo.data_vencimento.to_s).to eql('2008-05-16')
159
- expect(boleto_novo.data_vencimento).to eql(Date.parse('2008-05-16'))
160
- boleto_novo.data_documento = Date.parse '2008-02-06'
161
- boleto_novo.dias_vencimento = 'df'
162
- expect(boleto_novo.data_vencimento).to eql(boleto_novo.data_documento)
163
- end
144
+ it 'Calcula data_vencimento' do
145
+ boleto_novo = Brcobranca::Boleto::Base.new(@valid_attributes)
146
+ boleto_novo.data_documento = Date.parse '2008-02-01'
147
+ boleto_novo.dias_vencimento = 1
148
+ expect(boleto_novo.data_vencimento.to_s).to eql('2008-02-02')
149
+ expect(boleto_novo.data_vencimento).to eql(Date.parse('2008-02-02'))
150
+ boleto_novo.data_documento = Date.parse '2008-02-02'
151
+ boleto_novo.dias_vencimento = 28
152
+ expect(boleto_novo.data_vencimento.to_s).to eql('2008-03-01')
153
+ expect(boleto_novo.data_vencimento).to eql(Date.parse('2008-03-01'))
154
+ boleto_novo.data_documento = Date.parse '2008-02-06'
155
+ boleto_novo.dias_vencimento = 100
156
+ expect(boleto_novo.data_vencimento.to_s).to eql('2008-05-16')
157
+ expect(boleto_novo.data_vencimento).to eql(Date.parse('2008-05-16'))
158
+ boleto_novo.data_documento = Date.parse '2008-02-06'
159
+ boleto_novo.dias_vencimento = 'df'
160
+ expect(boleto_novo.data_vencimento).to eql(boleto_novo.data_documento)
161
+ end
164
162
 
165
- it 'Mostrar aviso sobre sobrecarga de métodos padrões' do
166
- boleto_novo = Brcobranca::Boleto::Base.new(@valid_attributes)
167
- expect { boleto_novo.codigo_barras_segunda_parte }.to raise_error(Brcobranca::NaoImplementado, 'Sobreescreva este método na classe referente ao banco que você esta criando')
168
- expect { boleto_novo.nosso_numero_boleto }.to raise_error(Brcobranca::NaoImplementado, 'Sobreescreva este método na classe referente ao banco que você esta criando')
169
- expect { boleto_novo.agencia_conta_boleto }.to raise_error(Brcobranca::NaoImplementado, 'Sobreescreva este método na classe referente ao banco que você esta criando')
170
- end
163
+ it 'Mostrar aviso sobre sobrecarga de métodos padrões' do
164
+ boleto_novo = Brcobranca::Boleto::Base.new(@valid_attributes)
165
+ expect { boleto_novo.codigo_barras_segunda_parte }.to raise_error(Brcobranca::NaoImplementado, 'Sobreescreva este método na classe referente ao banco que você esta criando')
166
+ expect { boleto_novo.nosso_numero_boleto }.to raise_error(Brcobranca::NaoImplementado, 'Sobreescreva este método na classe referente ao banco que você esta criando')
167
+ expect { boleto_novo.agencia_conta_boleto }.to raise_error(Brcobranca::NaoImplementado, 'Sobreescreva este método na classe referente ao banco que você esta criando')
168
+ end
171
169
 
172
- it 'Incluir módulos de template na classe' do
173
- expect(Brcobranca::Boleto::Base.respond_to?(:lote)).to be_truthy
174
- expect(Brcobranca::Boleto::Base.respond_to?(:to)).to be_truthy
175
- end
170
+ it 'Incluir módulos de template na classe' do
171
+ expect(Brcobranca::Boleto::Base.respond_to?(:lote)).to be_truthy
172
+ expect(Brcobranca::Boleto::Base.respond_to?(:to)).to be_truthy
173
+ end
176
174
 
177
- it 'Incluir módulos de template na instancia' do
178
- boleto_novo = Brcobranca::Boleto::Base.new
179
- expect(boleto_novo.respond_to?(:lote)).to be_truthy
180
- expect(boleto_novo.respond_to?(:to)).to be_truthy
181
- end
175
+ it 'Incluir módulos de template na instancia' do
176
+ boleto_novo = Brcobranca::Boleto::Base.new
177
+ expect(boleto_novo.respond_to?(:lote)).to be_truthy
178
+ expect(boleto_novo.respond_to?(:to)).to be_truthy
179
+ end
182
180
 
183
- context 'Validações' do
184
- it 'data_documento em branco' do
185
- boleto_novo = Brcobranca::Boleto::Base.new(data_documento: '')
186
- expect { boleto_novo.data_vencimento }.to raise_error(/Data Documento não pode estar em branco/)
187
- end
181
+ context 'Validações' do
182
+ it 'data_documento em branco' do
183
+ boleto_novo = Brcobranca::Boleto::Base.new(data_documento: '')
184
+ expect { boleto_novo.data_vencimento }.to raise_error(/Data Documento não pode estar em branco/)
185
+ end
188
186
 
189
- it 'data_documento em string' do
190
- boleto_novo = Brcobranca::Boleto::Base.new(data_documento: '2015-06-15')
191
- expect(boleto_novo.data_vencimento).to eql(Date.parse('2015-06-16'))
192
- end
193
- end
187
+ it 'data_documento em string' do
188
+ boleto_novo = Brcobranca::Boleto::Base.new(data_documento: '2015-06-15')
189
+ expect(boleto_novo.data_vencimento).to eql(Date.parse('2015-06-16'))
194
190
  end
195
191
  end
196
192
  end