bank_slip 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.travis.yml +3 -0
- data/Gemfile +10 -0
- data/README.md +39 -0
- data/Rakefile +1 -0
- data/bank_slip.gemspec +25 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/bank_slip/barcode.rb +104 -0
- data/lib/bank_slip/check_digit.rb +30 -0
- data/lib/bank_slip/pdf.rb +232 -0
- data/lib/bank_slip/version.rb +3 -0
- data/lib/bank_slip.rb +8 -0
- metadata +99 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8eab2d7997e6d41a3ec758c29854687d094a8f38
|
4
|
+
data.tar.gz: 568e42044873bb81e08631b092ffcf7916d1a467
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 063764cd326215f48aa2d39b1b8130d118ce13c803a952d11a74dca495d063f5f46631fbf78d3a8c9d82ccc2ce115427e50a9cdb840115ba9d1e819474494166
|
7
|
+
data.tar.gz: d9d80085851d481e5712df3179f9c5a4666823e6eef728c63a66328bdf0d90ac69ae78a6158e087b3b0d4149b2b94ec4f44c286a878c22102cc3c1a36072b900
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in bank_slip.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
|
7
|
+
gem "rake", "~> 10.0" , group: [:development, :test]
|
8
|
+
gem "rspec", "~> 3", group: [:development, :test]
|
9
|
+
gem 'pdf-inspector', :require => "pdf/inspector", group: [:development, :test]
|
10
|
+
gem 'pry', group: [:development, :test]
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# BankSlip
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/bank_slip`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'bank_slip'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install bank_slip
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
1. Fork it ( https://github.com/[my-github-username]/bank_slip/fork )
|
36
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
37
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
38
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
39
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bank_slip.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'bank_slip/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "bank_slip"
|
8
|
+
spec.version = BankSlip::VERSION
|
9
|
+
spec.licenses = ["MIT"]
|
10
|
+
|
11
|
+
spec.summary = %q{Bank Slip for Municipal Collection Document.}
|
12
|
+
spec.description = %q{Generate Bank Slip for Municipal Collection Document.}
|
13
|
+
spec.homepage = "https://github.com/marcomoura/bank-slip"
|
14
|
+
spec.authors = ["Marco Moura"]
|
15
|
+
spec.email = ["marco.moura@gmail.com"]
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_dependency "bundler", "~> 1.9"
|
23
|
+
spec.add_dependency "barby"
|
24
|
+
spec.add_dependency "prawn"
|
25
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "bank_slip"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
# Barcode data according to febraban specification
|
2
|
+
#
|
3
|
+
# POSITION | SIZE | CONTENT |
|
4
|
+
# 01 – 01 | 1 | Product | Fixed: 8
|
5
|
+
# 02 – 02 | 1 | Segment | Fixed: 1 for City Halls
|
6
|
+
# 03 – 03 | 1 | Real or Reference value | 6 and mod10 for DV or 8 and mod11 for DV
|
7
|
+
# 04 – 04 | 1 | Dígito verificador geral | mod10 or mod11
|
8
|
+
# 05 – 15 | 11 | Value | value in Reais
|
9
|
+
|
10
|
+
# 16 – 19 | 4 | Company or organization | code of 4 digits febraban
|
11
|
+
# 20 – 44 | 25 | Free | AAAAMMDD + free use
|
12
|
+
|
13
|
+
# 16 – 23 | 8 | Company or organization | code of 8 digits bank (start CNPJ)
|
14
|
+
# 24 – 44 | 21 | Free | AAAAMMDD + free use
|
15
|
+
#
|
16
|
+
#
|
17
|
+
require 'barby'
|
18
|
+
require 'barby/barcode/code_25_interleaved'
|
19
|
+
require 'barby/outputter/prawn_outputter'
|
20
|
+
|
21
|
+
module BankSlip
|
22
|
+
class Barcode
|
23
|
+
|
24
|
+
# > options = {value: 1, identification_code: 2, document_number: 10, payment_date: Date.new(2010, 3, 10)}
|
25
|
+
# > barcode = BankSlip::Barcode.new(options)
|
26
|
+
def initialize(value:, identification_code:, payment_date:,
|
27
|
+
segment: 1, effective_reference: 6,
|
28
|
+
free_digits: 0, product: 8)
|
29
|
+
@value = value
|
30
|
+
@segment = segment
|
31
|
+
@identification_code = identification_code
|
32
|
+
@payment_date = payment_date
|
33
|
+
@product = product
|
34
|
+
@effective_reference = effective_reference
|
35
|
+
@free_digits = free_digits
|
36
|
+
fail "identification_code #{identification_code} too long, #{identification_length} characters is the maximum allowed, for the segment #{segment}" unless valid_identification_code?
|
37
|
+
end
|
38
|
+
|
39
|
+
# > barcode.digits
|
40
|
+
# => "81640000000000100022010031000000000000000010"
|
41
|
+
def digits
|
42
|
+
@digits ||= numbers.insert(3, digit(numbers).to_s)
|
43
|
+
end
|
44
|
+
|
45
|
+
# > barcode.numerical_representation
|
46
|
+
# => ["81640000000 5", "00010002201 1", "00310000000 3", "00000000010 9"]
|
47
|
+
def numerical_representation
|
48
|
+
@numerical_representation ||= digits.scan(/\d{11}/).collect {|p| "#{p} #{digit(p)}" }
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def valid_identification_code?
|
54
|
+
@identification_code.to_s.size.eql?(identification_length)
|
55
|
+
end
|
56
|
+
|
57
|
+
def numbers
|
58
|
+
@numbers ||= [
|
59
|
+
@product,
|
60
|
+
@segment,
|
61
|
+
@effective_reference,
|
62
|
+
leading_zeros(@value),
|
63
|
+
mask_id,
|
64
|
+
@payment_date.strftime('%Y%m%d'),
|
65
|
+
free_digits_leading_zeros
|
66
|
+
]
|
67
|
+
.join('')
|
68
|
+
end
|
69
|
+
|
70
|
+
def leading_zeros(n, length = 11)
|
71
|
+
"%0#{length}d" % n
|
72
|
+
end
|
73
|
+
|
74
|
+
def mask_id
|
75
|
+
leading_zeros(@identification_code, identification_length)
|
76
|
+
end
|
77
|
+
|
78
|
+
def free_digits_leading_zeros
|
79
|
+
length = 21 - identification_length
|
80
|
+
leading_zeros(@free_digits, length)
|
81
|
+
end
|
82
|
+
|
83
|
+
def digit(code_number)
|
84
|
+
d = BankSlip::CheckDigit.new(number: code_number)
|
85
|
+
d.calc
|
86
|
+
end
|
87
|
+
|
88
|
+
# The Indentification code is defined by the segment
|
89
|
+
# Use 4 digits (FEBRABAN code) for the segments:
|
90
|
+
# 1. Prefeituras;
|
91
|
+
# 2. Saneamento;
|
92
|
+
# 3. Energia Elétrica e Gás;
|
93
|
+
# 4. Telecomunicações;
|
94
|
+
# 5. Órgãos Governamentais;
|
95
|
+
# 6. Carnes e Assemelhados ou demais
|
96
|
+
#
|
97
|
+
# Use 8 digits (CNPJ) for the segments:
|
98
|
+
# 7. Multas de transito
|
99
|
+
# 9. Uso exclusivo do banco
|
100
|
+
def identification_length
|
101
|
+
%w{7 9}.include?(@segment.to_s) ? 8 : 4
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module BankSlip
|
2
|
+
class CheckDigit
|
3
|
+
def initialize(number:)
|
4
|
+
@number = number
|
5
|
+
end
|
6
|
+
|
7
|
+
def calc
|
8
|
+
r = result
|
9
|
+
r == 10 ? 0 : r
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def result
|
15
|
+
result_string = ""
|
16
|
+
@number.reverse.split("").each_with_index do |c, index|
|
17
|
+
result_string << (c.to_i * ((1 + index) % 2 + 1)).to_s
|
18
|
+
end
|
19
|
+
|
20
|
+
10 - sum(result_string) % 10
|
21
|
+
end
|
22
|
+
|
23
|
+
def sum(result_string)
|
24
|
+
total = 0
|
25
|
+
result_string.each_char { |c| total += c.to_i }
|
26
|
+
total
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
@@ -0,0 +1,232 @@
|
|
1
|
+
require "prawn"
|
2
|
+
require "prawn/measurement_extensions"
|
3
|
+
|
4
|
+
module BankSlip
|
5
|
+
class Pdf
|
6
|
+
include Prawn::View
|
7
|
+
|
8
|
+
def self.render(data)
|
9
|
+
new(data).create.render
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize(data)
|
13
|
+
@data = data
|
14
|
+
# Measures
|
15
|
+
@vHEADER_HEIGHT = 0.82.in
|
16
|
+
@vBODY_HEIGHT = 2.35.in
|
17
|
+
@vINFO_WIDTH = 6.15.in
|
18
|
+
@vVALUES_WIDTH = 7.65.in - @vINFO_WIDTH
|
19
|
+
@vLINE_HEIGHT = 0.335.in
|
20
|
+
@vFOOTER_HEIGHT = 4.25.in - @vHEADER_HEIGHT - @vBODY_HEIGHT
|
21
|
+
@vFOOTER_LEFT_WIDTH = 2.5.in
|
22
|
+
end
|
23
|
+
|
24
|
+
def create
|
25
|
+
content(0, 'CONTRIBUINTE')
|
26
|
+
footer_payer
|
27
|
+
cut_line
|
28
|
+
content(5.3.in, 'BANCO')
|
29
|
+
footer_payeer
|
30
|
+
add_barcode
|
31
|
+
self
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def border
|
37
|
+
stroke_color '999999'
|
38
|
+
line_width 1
|
39
|
+
stroke_bounds
|
40
|
+
end
|
41
|
+
|
42
|
+
def add_digit(numbers, left_padding = 0)
|
43
|
+
bounding_box([0.185.in + left_padding, 0.85.in], width: 1.05.in, height: 0.17.in) do
|
44
|
+
move_down 0.03.in
|
45
|
+
stroke_color '444444'
|
46
|
+
stroke_bounds
|
47
|
+
text numbers, size: 9, style: :bold, align: :center
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def copy_for(caption)
|
52
|
+
bounding_box [bounds.left - 0.05.in, bounds.top_left[1] - 0.7.in], width: bounds.right, height: 0.82.in do
|
53
|
+
text "VIA #{caption}", size: 7, style: :normal, align: :right
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def content(initial_y, caption)
|
58
|
+
bounding_box [0, bounds.top_left()[1] - initial_y], width: 7.65.in, height: 3.17.in do
|
59
|
+
border
|
60
|
+
header_content
|
61
|
+
copy_for(caption)
|
62
|
+
|
63
|
+
# Info to the left
|
64
|
+
bounding_box([0.in, bounds.top_left[1] - @vHEADER_HEIGHT], width: @vINFO_WIDTH, height: @vBODY_HEIGHT) do
|
65
|
+
stroke do
|
66
|
+
stroke_color 'AAAAAA'
|
67
|
+
line bounds.bottom_left, bounds.bottom_right
|
68
|
+
end
|
69
|
+
|
70
|
+
draw_line("Nome Oficial" , @data[:payer][:official_name] , @vINFO_WIDTH , @vLINE_HEIGHT , 0 , 0 , 'E6E6E6')
|
71
|
+
draw_line("CPF/CNPJ" , @data[:payer][:cpf_cnpj] , @vINFO_WIDTH/4 , @vLINE_HEIGHT , 0 , 1)
|
72
|
+
draw_line("Inscrição Municipal" , @data[:payer][:city_registration] , @vINFO_WIDTH/4 , @vLINE_HEIGHT , 1 , 1)
|
73
|
+
draw_line("Emissão" , @data[:stub][:emission_date] , @vINFO_WIDTH/4 , @vLINE_HEIGHT , 2 , 1 , 'E6E6E6')
|
74
|
+
draw_line("Incidência" , @data[:stub][:incidence] , @vINFO_WIDTH/4 , @vLINE_HEIGHT , 3 , 1 , 'E6E6E6')
|
75
|
+
draw_line("Receita" , @data[:stub][:revenue_description] , @vINFO_WIDTH , @vLINE_HEIGHT , 0 , 2)
|
76
|
+
|
77
|
+
move_down 0.1.in
|
78
|
+
indent(0.1.in) do
|
79
|
+
text 'Outras Informações', size: 8
|
80
|
+
text @data[:stub][:other_information]
|
81
|
+
end
|
82
|
+
|
83
|
+
text_box "PAGÁVEL EM QUALQUER AGENTE ARRECADADOR AUTORIZADO ATÉ #{@data[:stub][:expiration_date]}.\n" +
|
84
|
+
"O VALOR PARA PAGAMENTO DESTE DOCUMENTO NÃO PODE SER ATUALIZADO. ",
|
85
|
+
at: [bounds.bottom_left[0] + 0.075.in, bounds.bottom_left[0] + 0.8.in],
|
86
|
+
height: 0.75.in,
|
87
|
+
size: 8,
|
88
|
+
style: :normal,
|
89
|
+
valign: :bottom
|
90
|
+
|
91
|
+
end # Info to the left
|
92
|
+
|
93
|
+
# Values to the right
|
94
|
+
bounding_box([@vINFO_WIDTH, bounds.top_left[1] - @vHEADER_HEIGHT], width: @vVALUES_WIDTH, height: @vBODY_HEIGHT) do
|
95
|
+
# Bottom line
|
96
|
+
stroke do
|
97
|
+
stroke_color 'AAAAAA'
|
98
|
+
line bounds.bottom_left, bounds.bottom_right
|
99
|
+
line bounds.top_left, bounds.bottom_left
|
100
|
+
end
|
101
|
+
|
102
|
+
draw_line("Vencimento da Guia" , @data[:stub][:expiration_date] , @vVALUES_WIDTH , @vLINE_HEIGHT , 0 , 0 , 'E6E6E6' , :right)
|
103
|
+
draw_line("Valor (R$)" , @data[:stub][:value] , @vVALUES_WIDTH , @vLINE_HEIGHT , 0 , 1 , 'FFFFFF' , :right)
|
104
|
+
draw_line("Multa/Juros (R$)" , @data[:stub][:fine_and_interest] , @vVALUES_WIDTH , @vLINE_HEIGHT , 0 , 2 , 'FFFFFF' , :right)
|
105
|
+
draw_line("Outros Acréscimos (R$)" , @data[:stub][:adjustment] , @vVALUES_WIDTH , @vLINE_HEIGHT , 0 , 3 , 'FFFFFF' , :right)
|
106
|
+
draw_line("Descontos (R$)" , "-#{@data[:stub][:discounts]}" , @vVALUES_WIDTH , @vLINE_HEIGHT , 0 , 4 , 'FFFFFF' , :right)
|
107
|
+
draw_line("Taxa de Expediente (R$)" , @data[:stub][:transaction_fee] , @vVALUES_WIDTH , @vLINE_HEIGHT , 0 , 5 , 'FFFFFF' , :right)
|
108
|
+
draw_line("Total (R$)" , @data[:stub][:total] , @vVALUES_WIDTH , @vLINE_HEIGHT , 0 , 6 , 'E6E6E6' , :right , '000000')
|
109
|
+
end # Values to the right
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def footer_payer
|
114
|
+
move_down 0.1.in
|
115
|
+
text "Documento No. #{@data[:stub][:document_number]}", size: 8
|
116
|
+
bounding_box([0, bounds.top_left[1] - 0.4.in - @vHEADER_HEIGHT - @vBODY_HEIGHT],
|
117
|
+
width: 194.mm, height: 22.mm) do
|
118
|
+
|
119
|
+
move_down 0.05.in
|
120
|
+
indent 0.05.in do
|
121
|
+
text 'AUTENTICAÇÃO MECÂNICA', size: 7, align: :left
|
122
|
+
end
|
123
|
+
|
124
|
+
stroke do
|
125
|
+
stroke_color '999999'
|
126
|
+
line bounds.top_left, bounds.top_right
|
127
|
+
line bounds.top_left, bounds.bottom_left
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def footer_payeer
|
133
|
+
move_down 0.1.in
|
134
|
+
text "Documento No. #{@data[:stub][:document_number]}", size: 8
|
135
|
+
bounding_box([bounds.right - 2.55.in, bounds.bottom_left[1] + 0.7.in],
|
136
|
+
width: 65.mm, height: 22.mm) do
|
137
|
+
|
138
|
+
move_down 0.05.in
|
139
|
+
indent 0.03.in do
|
140
|
+
text 'AUTENTICAÇÃO MECÂNICA', size: 7, align: :center
|
141
|
+
end
|
142
|
+
|
143
|
+
stroke do
|
144
|
+
stroke_color '999999'
|
145
|
+
line bounds.top_left, bounds.top_right
|
146
|
+
line [bounds.top_left, 0], [bounds.top_left[0]+50, 0]
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
def draw_line(label, value, width, height, column = 0, line = 0, bg_color = 'FFFFFF', align = :left, stroke = 'AAAAAA')
|
152
|
+
bounding_box([0.in + column * width, bounds.top_left[1] - line * height], width: width, height: height) do
|
153
|
+
if bg_color != 'FFFFFF'
|
154
|
+
fill_color bg_color
|
155
|
+
transparent(0.6) do
|
156
|
+
fill_rectangle [bounds.top_left[0] + 1, bounds.top_left[1] - 1], width, height
|
157
|
+
end
|
158
|
+
fill_color '000000'
|
159
|
+
end
|
160
|
+
|
161
|
+
draw_line_text(label, value, width, height, align)
|
162
|
+
stroke_color stroke
|
163
|
+
line_width 1
|
164
|
+
stroke_bounds
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
def draw_line_text(label, value, width, height, align)
|
169
|
+
bounding_box([bounds.top_left[0], bounds.top_left[1] - 0.05.in], width: width - 0.075.in, height: height - 0.05.in) do
|
170
|
+
indent(0.075.in) do
|
171
|
+
text label, size: 7, style: :normal, leading: 0.025.in
|
172
|
+
text value.to_s, size: 8, style: :bold, align: align
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
def header_content
|
178
|
+
bounding_box [0,bounds.top_left()[1]], width: 7.65.in, height: @vHEADER_HEIGHT do
|
179
|
+
stroke do
|
180
|
+
stroke_color 'AAAAAA'
|
181
|
+
line bounds.bottom_left, bounds.bottom_right
|
182
|
+
end
|
183
|
+
indent 0.1.in do
|
184
|
+
unless @data[:header][:logo].nil?
|
185
|
+
img = image @data[:header][:logo], fit: [0.71.in, 0.68.in], position: :left, vposition: :center
|
186
|
+
image_width = img.scaled_width + 0.15.in
|
187
|
+
move_up img.scaled_height - 0.15.in
|
188
|
+
else
|
189
|
+
image_width = 0
|
190
|
+
move_down 0.2.in
|
191
|
+
end
|
192
|
+
indent image_width do
|
193
|
+
text @data[:header][:title] , size: 10 , style: :bold , leading: -0.01.in
|
194
|
+
text @data[:header][:subtitle], size: 8 , style: :normal, leading: 0.02.in
|
195
|
+
move_down 0.05.in
|
196
|
+
text @data[:header][:document], size: 13, style: :bold
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
def cut_line
|
203
|
+
dash 3
|
204
|
+
stroke_line [bounds.left, 5.3.in, bounds.right + 0.1.in, 5.3.in]
|
205
|
+
undash
|
206
|
+
font 'ZapfDingbats' do
|
207
|
+
text_box "#", size: 18, rotate: 180, at: [bounds.right, 5.3.in + 0.13.in]
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
def add_barcode
|
212
|
+
bounding_box([-13, 65],
|
213
|
+
width: 7.65.in - @vFOOTER_LEFT_WIDTH,
|
214
|
+
height: @vFOOTER_HEIGHT) do
|
215
|
+
add_digit(barcode.numerical_representation[0])
|
216
|
+
add_digit(barcode.numerical_representation[1], 1.242.in)
|
217
|
+
add_digit(barcode.numerical_representation[2], (1.242.in * 2))
|
218
|
+
add_digit(barcode.numerical_representation[3], (1.242.in * 3))
|
219
|
+
end
|
220
|
+
add_bar
|
221
|
+
end
|
222
|
+
|
223
|
+
def add_bar
|
224
|
+
Barby::Code25Interleaved.new(barcode.digits)
|
225
|
+
.annotate_pdf(self, x: 0, y: -10, xdim: 0.85, height: 0.5.in)
|
226
|
+
end
|
227
|
+
|
228
|
+
def barcode
|
229
|
+
@_barcode ||= BankSlip::Barcode.new(@data[:barcode])
|
230
|
+
end
|
231
|
+
end
|
232
|
+
end
|
data/lib/bank_slip.rb
ADDED
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bank_slip
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Marco Moura
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-10-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.9'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.9'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: barby
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: prawn
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Generate Bank Slip for Municipal Collection Document.
|
56
|
+
email:
|
57
|
+
- marco.moura@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".travis.yml"
|
64
|
+
- Gemfile
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- bank_slip.gemspec
|
68
|
+
- bin/console
|
69
|
+
- bin/setup
|
70
|
+
- lib/bank_slip.rb
|
71
|
+
- lib/bank_slip/barcode.rb
|
72
|
+
- lib/bank_slip/check_digit.rb
|
73
|
+
- lib/bank_slip/pdf.rb
|
74
|
+
- lib/bank_slip/version.rb
|
75
|
+
homepage: https://github.com/marcomoura/bank-slip
|
76
|
+
licenses:
|
77
|
+
- MIT
|
78
|
+
metadata: {}
|
79
|
+
post_install_message:
|
80
|
+
rdoc_options: []
|
81
|
+
require_paths:
|
82
|
+
- lib
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
requirements: []
|
94
|
+
rubyforge_project:
|
95
|
+
rubygems_version: 2.4.5.1
|
96
|
+
signing_key:
|
97
|
+
specification_version: 4
|
98
|
+
summary: Bank Slip for Municipal Collection Document.
|
99
|
+
test_files: []
|