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.
@@ -6,119 +6,93 @@ module Prawn
6
6
 
7
7
  include ActionView::Helpers::TranslationHelper
8
8
 
9
- def esr_recipe(invoice, esr_account, sender, print_payment_for = true)
10
- # VESR form
11
- # =========
12
- bank = esr_account.bank
13
- amount = invoice.amount
14
-
15
- font_size 8
16
- bounding_box [cm2pt(0.2), cm2pt(8.8)], :width => cm2pt(5) do
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
- vcard = sender.vcard
29
- text vcard.full_name
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
- move_down cm2pt(0.8)
35
- indent cm2pt(2.3) do
36
- font_size 9 do
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
- bounding_box [0, cm2pt(4.5)], :width => cm2pt(3.5) do
43
- font_size 9 do
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
- bounding_box [cm2pt(4.7), cm2pt(4.5)], :width => cm2pt(1) do
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
- bounding_box [cm2pt(0.2), cm2pt(3.2)], :width => cm2pt(5) do
55
- text esr9_reference(invoice, esr_account)
56
-
57
- text " "
58
-
59
- vcard = invoice.customer.vcard
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
- text " "
49
+ draw_account(account)
50
+ draw_amount(invoice.amount)
77
51
 
78
- vcard = sender.vcard
79
- text vcard.full_name
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
- move_down cm2pt(0.8)
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
- bounding_box [cm2pt(6), cm2pt(4.5)], :width => cm2pt(3.5) do
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(10.8), cm2pt(4.5)], :width => cm2pt(1) do
99
- font_size 9 do
100
- text sprintf('%02.0f', amount * 100 % 100), :character_spacing => 1
101
- end
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, esr_account), :at => [cm2pt(12.3), cm2pt(5.9)], :character_spacing => 1.1
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.1), cm2pt(4.5)], :width => cm2pt(7.5) do
109
- vcard = invoice.customer.vcard
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
- font_size 11
119
- font ::Rails.root.join('data/ocrb10.ttf') if FileTest.exists?(::Rails.root.join('data/ocrb10.ttf'))
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
- draw_text esr9(invoice, esr_account), :at => [cm2pt(6.3), cm2pt(0.9)]
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
@@ -1,3 +1,3 @@
1
1
  module Vesr
2
- VERSION = "0.5.1"
2
+ VERSION = "0.6.0"
3
3
  end
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: 9
4
+ hash: 7
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 5
9
- - 1
10
- version: 0.5.1
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-08 00:00:00 +01:00
19
+ date: 2011-11-28 00:00:00 +01:00
20
20
  default_executable:
21
21
  dependencies: []
22
22