vesr 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/vesr/prawn/esr_recipe.rb +59 -85
- data/lib/vesr/version.rb +1 -1
- metadata +5 -5
|
@@ -6,119 +6,93 @@ module Prawn
|
|
|
6
6
|
|
|
7
7
|
include ActionView::Helpers::TranslationHelper
|
|
8
8
|
|
|
9
|
-
def
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
text bank.vcard.full_name
|
|
18
|
-
text bank.vcard.postal_code + " " + bank.vcard.locality
|
|
19
|
-
|
|
20
|
-
text " "
|
|
21
|
-
if print_payment_for
|
|
22
|
-
text I18n::translate(:biller, :scope => "activerecord.attributes.invoice")
|
|
23
|
-
else
|
|
24
|
-
text " "
|
|
25
|
-
end
|
|
9
|
+
def draw_account_detail(bank, sender, print_payment_for)
|
|
10
|
+
text bank.vcard.full_name
|
|
11
|
+
text bank.vcard.postal_code + " " + bank.vcard.locality
|
|
12
|
+
|
|
13
|
+
text " "
|
|
14
|
+
if print_payment_for
|
|
15
|
+
text I18n::translate(:biller, :scope => "activerecord.attributes.invoice")
|
|
16
|
+
else
|
|
26
17
|
text " "
|
|
18
|
+
end
|
|
19
|
+
text " "
|
|
27
20
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
text vcard.extended_address if vcard.extended_address.present?
|
|
31
|
-
text vcard.street_address if vcard.street_address
|
|
32
|
-
text vcard.postal_code + " " + vcard.locality if vcard.postal_code and vcard.locality
|
|
21
|
+
draw_address sender.vcard
|
|
22
|
+
end
|
|
33
23
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
text esr_account.pc_id
|
|
38
|
-
end
|
|
39
|
-
end
|
|
24
|
+
def draw_account(account)
|
|
25
|
+
bounding_box [cm2pt(2.6), bounds.top - cm2pt(3.4)], :width => cm2pt(2.5) do
|
|
26
|
+
text account.pc_id
|
|
40
27
|
end
|
|
28
|
+
end
|
|
41
29
|
|
|
42
|
-
|
|
43
|
-
|
|
30
|
+
def draw_amount(amount)
|
|
31
|
+
font_size 9 do
|
|
32
|
+
bounding_box [0, bounds.top - cm2pt(4.2)], :width => cm2pt(3.6) do
|
|
44
33
|
text sprintf('%.0f', amount.floor), :align => :right, :character_spacing => 1
|
|
45
34
|
end
|
|
46
|
-
end
|
|
47
35
|
|
|
48
|
-
|
|
49
|
-
font_size 9 do
|
|
36
|
+
bounding_box [cm2pt(4.7), bounds.top - cm2pt(4.2)], :width => cm2pt(1) do
|
|
50
37
|
text sprintf('%02.0f', amount * 100 % 100), :character_spacing => 1
|
|
51
38
|
end
|
|
52
39
|
end
|
|
40
|
+
end
|
|
53
41
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
text vcard.full_name
|
|
61
|
-
text vcard.extended_address if vcard.extended_address
|
|
62
|
-
text vcard.street_address if vcard.street_address
|
|
63
|
-
text vcard.postal_code + " " + vcard.locality if vcard.postal_code and vcard.locality
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
bounding_box [cm2pt(6), cm2pt(8.8)], :width => cm2pt(5) do
|
|
67
|
-
text bank.vcard.full_name
|
|
68
|
-
text bank.vcard.postal_code + " " + bank.vcard.locality
|
|
69
|
-
|
|
70
|
-
text " "
|
|
71
|
-
if print_payment_for
|
|
72
|
-
text I18n::translate(:biller, :scope => "activerecord.attributes.invoice")
|
|
73
|
-
else
|
|
74
|
-
text " "
|
|
42
|
+
# VESR form
|
|
43
|
+
# =========
|
|
44
|
+
def esr_recipe(invoice, account, sender, print_payment_for)
|
|
45
|
+
bounding_box [cm2pt(0.4), cm2pt(9.6)], :width => cm2pt(5) do
|
|
46
|
+
indent cm2pt(0.2) do
|
|
47
|
+
draw_account_detail(account.bank, sender, print_payment_for)
|
|
75
48
|
end
|
|
76
|
-
|
|
49
|
+
draw_account(account)
|
|
50
|
+
draw_amount(invoice.amount)
|
|
77
51
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
text vcard.extended_address if vcard.extended_address.present?
|
|
81
|
-
text vcard.street_address if vcard.street_address
|
|
82
|
-
text vcard.postal_code + " " + vcard.locality if vcard.postal_code and vcard.locality
|
|
52
|
+
bounding_box [cm2pt(0.2), bounds.top - cm2pt(5.2)], :width => cm2pt(5) do
|
|
53
|
+
text esr9_reference(invoice, account), :size => 7
|
|
83
54
|
|
|
84
|
-
|
|
85
|
-
indent cm2pt(2.6) do
|
|
86
|
-
font_size 9 do
|
|
87
|
-
text esr_account.pc_id
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
end
|
|
55
|
+
text " "
|
|
91
56
|
|
|
92
|
-
|
|
93
|
-
font_size 9 do
|
|
94
|
-
text sprintf('%.0f', amount.floor), :align => :right, :character_spacing => 1
|
|
57
|
+
draw_address invoice.customer.vcard
|
|
95
58
|
end
|
|
96
59
|
end
|
|
97
60
|
|
|
98
|
-
bounding_box [cm2pt(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
61
|
+
bounding_box [cm2pt(6.4), cm2pt(9.6)], :width => cm2pt(5) do
|
|
62
|
+
draw_account_detail(account.bank, sender, print_payment_for)
|
|
63
|
+
draw_account(account)
|
|
64
|
+
draw_amount(invoice.amount)
|
|
102
65
|
end
|
|
103
66
|
|
|
104
67
|
font_size 10 do
|
|
105
|
-
draw_text esr9_reference(invoice,
|
|
68
|
+
draw_text esr9_reference(invoice, account), :at => [cm2pt(12.7), cm2pt(6.8)], :character_spacing => 1.1
|
|
106
69
|
end
|
|
107
70
|
|
|
108
|
-
bounding_box [cm2pt(12.
|
|
109
|
-
|
|
110
|
-
text vcard.honorific_prefix if vcard.honorific_prefix
|
|
111
|
-
text vcard.full_name
|
|
112
|
-
text vcard.extended_address if vcard.extended_address.present?
|
|
113
|
-
text vcard.street_address if vcard.street_address
|
|
114
|
-
text vcard.postal_code + " " + vcard.locality if vcard.postal_code and vcard.locality
|
|
71
|
+
bounding_box [cm2pt(12.7), cm2pt(5.5)], :width => cm2pt(7.5) do
|
|
72
|
+
draw_address(invoice.customer.vcard)
|
|
115
73
|
end
|
|
116
74
|
|
|
117
75
|
# ESR-Reference
|
|
118
|
-
|
|
119
|
-
|
|
76
|
+
if ::Rails.root.join('data/ocrb10.ttf').exist?
|
|
77
|
+
ocr_font = ::Rails.root.join('data/ocrb10.ttf')
|
|
78
|
+
else
|
|
79
|
+
ocr_font = "Helvetica"
|
|
80
|
+
::Rails.logger.warn("No ocrb10.ttf found for ESR reference in #{::Rails.root.join('data')}!")
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
font ocr_font, :size => 10 do
|
|
84
|
+
draw_text esr9(invoice, account), :at => [cm2pt(6.7), cm2pt(1.7)], :character_spacing => 2.2
|
|
85
|
+
end
|
|
86
|
+
end
|
|
120
87
|
|
|
121
|
-
|
|
88
|
+
def draw_esr(invoice, account, sender, print_payment_for = true)
|
|
89
|
+
float do
|
|
90
|
+
canvas do
|
|
91
|
+
font_size 8 do
|
|
92
|
+
esr_recipe(invoice, account, sender, print_payment_for)
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
122
96
|
end
|
|
123
97
|
|
|
124
98
|
private
|
data/lib/vesr/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: vesr
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 7
|
|
5
5
|
prerelease: false
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
version: 0.
|
|
8
|
+
- 6
|
|
9
|
+
- 0
|
|
10
|
+
version: 0.6.0
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Roman Simecek
|
|
@@ -16,7 +16,7 @@ autorequire:
|
|
|
16
16
|
bindir: bin
|
|
17
17
|
cert_chain: []
|
|
18
18
|
|
|
19
|
-
date: 2011-11-
|
|
19
|
+
date: 2011-11-28 00:00:00 +01:00
|
|
20
20
|
default_executable:
|
|
21
21
|
dependencies: []
|
|
22
22
|
|