Class: Prawn::LetterDocument
- Inherits:
-
Document
- Object
- Document
- Prawn::LetterDocument
show all
- Includes:
- ActionView::Helpers::TranslationHelper, ApplicationHelper, EsrRecipe, Measurements
- Defined in:
- lib/prawn/letter_document.rb
Instance Method Summary
collapse
#currency_fmt, #current_tenant, #engine_stylesheet_link_tag, #icon_delete_link_to, #icon_edit_link_to, #list_item_actions_for, #show_new_form
Constructor Details
Returns a new instance of LetterDocument.
11
12
13
14
15
16
17
|
# File 'lib/prawn/letter_document.rb', line 11
def initialize(opts = {})
super
font 'Helvetica'
font_size 11
end
|
Instance Method Details
#closing(sender, due_date) ⇒ Object
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/prawn/letter_document.rb', line 78
def closing(sender, due_date)
text I18n.t('letters.debit_invoice.closing', :due_date => due_date), :align => :justify
text " "
text " "
text I18n.t('letters.greetings')
text " "
text "#{sender.vcard.full_name}"
end
|
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/prawn/letter_document.rb', line 36
def (sender, bank_account)
repeat :all do
bounding_box [bounds.left, 35], :width => 120, :height => 40 do
font_size 7 do
vcard = sender.vcard
text "Begünstigter:"
text vcard.full_name
text vcard.extended_address unless vcard.extended_address.blank?
text vcard.street_address
text vcard.postal_code + " " + vcard.locality
end
end
if bank_account and bank_account.bank
bounding_box [bounds.left + 190, 35], :width => 120, :height => 40 do
font_size 7 do
vcard = bank_account.bank.vcard
text "Bank:"
text vcard.full_name
text vcard.street_address if vcard.street_address.present?
locality = [vcard.postal_code, vcard.locality].compact.join(', ')
text locality if locality.present?
end
end
bounding_box [bounds.left + 360, 35], :width => 120, :height => 40 do
font_size 7 do
vcard = bank_account.bank.vcard
text "Konto:"
text "IBAN: " + bank_account.iban if bank_account.iban.present?
text "SWIFT: " + bank_account.bank.swift if bank_account.bank.swift.present?
text "Clearing: " + bank_account.bank.clearing if bank_account.bank.clearing.present?
text "PC-Konto: " + bank_account.pc_id if bank_account.pc_id.present?
end
end
end
end
end
|
#full_address(vcard) ⇒ Object
Draws the full address of a vcard
20
21
22
23
24
|
# File 'lib/prawn/letter_document.rb', line 20
def full_address(vcard)
vcard.full_address_lines.each do |line|
text line
end
end
|
26
27
28
29
30
31
32
33
34
|
# File 'lib/prawn/letter_document.rb', line 26
def (sender)
repeat :all do
logo = ::Rails.root.join("public/system/images/letter-logo.png")
image logo, :height => 50, :at => [0, bounds.top + 20] if logo.exist?
end
end
|
#line_items_table(invoice, line_items) ⇒ Object
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
# File 'lib/prawn/letter_document.rb', line 89
def line_items_table(invoice, line_items)
content = line_items.collect do |item|
if item.times == 1
if item.quantity == "x"
amount = ""
elsif item.quantity == "overall"
amount = t('line_items.quantity.overall')
else
amount = "#{item.times} #{t(item.quantity, :scope => 'line_items.quantity')}"
end
else
amount = "#{currency_fmt(item.times)} #{t(item.quantity, :scope => 'line_items.quantity')}"
end
price = currency_fmt(item.price)
[item.title, item.date, amount, price, currency_fmt(item.total_amount)]
end
total = ["Total", nil, nil, nil, currency_fmt(invoice.amount)]
rows = content + [total]
table(rows, :width => bounds.width) do
cells.valign = :top
cells.borders = []
columns(2..4).align = :right
column(1).width = 65
column(2).width = 75
column(3).width = 65
column(4).width = 65
column(0).padding_left = 0
column(-1).padding_right = 0
row(-1).font_style = :bold
end
end
|
#payment_order(sender, bank_account, invoice) ⇒ Object
132
133
134
|
# File 'lib/prawn/letter_document.rb', line 132
def payment_order(sender, bank_account, invoice)
draw_text invoice.esr9(bank_account), :at => [cm2pt(5.2), 0]
end
|