Module: Prawn::EsrRecipe
- Includes:
- ActionView::Helpers::TranslationHelper
- Defined in:
- lib/vesr/prawn/esr_recipe.rb
Instance Method Summary collapse
- #draw_account(account) ⇒ Object
- #draw_account_detail(bank, sender, print_payment_for) ⇒ Object
- #draw_amount(amount) ⇒ Object
- #draw_esr(invoice, account, sender, print_payment_for = true) ⇒ Object
-
#esr_recipe(invoice, account, sender, print_payment_for) ⇒ Object
VESR form =========.
Instance Method Details
#draw_account(account) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/vesr/prawn/esr_recipe.rb', line 29 def draw_account(account) bounding_box [cm2pt(2.6), bounds.top - cm2pt(3.4)], :width => cm2pt(2.5) do font_size 9 do text account.pc_id end end end |
#draw_account_detail(bank, sender, print_payment_for) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/vesr/prawn/esr_recipe.rb', line 12 def draw_account_detail(bank, sender, print_payment_for) if bank text bank.vcard.full_name text bank.vcard.postal_code + " " + bank.vcard.locality end text " " if print_payment_for text I18n::translate(:biller, :scope => "activerecord.attributes.invoice") else text " " end text " " draw_address sender.vcard end |
#draw_amount(amount) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/vesr/prawn/esr_recipe.rb', line 37 def draw_amount(amount) font_size 10 do bounding_box [0, bounds.top - cm2pt(4.2)], :width => cm2pt(3.6) do text sprintf('%.0f', amount.floor), :align => :right, :character_spacing => 1 end bounding_box [cm2pt(4.7), bounds.top - cm2pt(4.2)], :width => cm2pt(1) do text sprintf('%02.0f', amount * 100 % 100), :character_spacing => 1 end end end |
#draw_esr(invoice, account, sender, print_payment_for = true) ⇒ Object
99 100 101 102 103 104 105 106 107 |
# File 'lib/vesr/prawn/esr_recipe.rb', line 99 def draw_esr(invoice, account, sender, print_payment_for = true) float do canvas do font 'Helvetica', :size => 8 do esr_recipe(invoice, account, sender, print_payment_for) end end end end |
#esr_recipe(invoice, account, sender, print_payment_for) ⇒ Object
VESR form
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 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/vesr/prawn/esr_recipe.rb', line 51 def esr_recipe(invoice, account, sender, print_payment_for) bounding_box [cm2pt(0.4), cm2pt(9.6)], :width => cm2pt(5) do indent cm2pt(0.4) do draw_account_detail(account.bank, sender, print_payment_for) end draw_account(account) draw_amount(invoice.balance.currency_round) bounding_box [cm2pt(0.4), bounds.top - cm2pt(5.2)], :width => cm2pt(5) do text esr9_reference(invoice, account), :size => 7 text " " draw_address invoice.customer.vcard end end bounding_box [cm2pt(6.4), cm2pt(9.6)], :width => cm2pt(5) do draw_account_detail(account.bank, sender, print_payment_for) draw_account(account) draw_amount(invoice.balance.currency_round) end font_size 10 do character_spacing 1.1 do draw_text esr9_reference(invoice, account), :at => [cm2pt(12.7), cm2pt(6.8)] end end bounding_box [cm2pt(12.7), cm2pt(5.5)], :width => cm2pt(7.5) do draw_address(invoice.customer.vcard) end # ESR-Reference if ::Rails.root.join('data/ocrb10.ttf').exist? ocr_font = ::Rails.root.join('data/ocrb10.ttf') else ocr_font = "Helvetica" ::Rails.logger.warn("No ocrb10.ttf found for ESR reference in #{::Rails.root.join('data')}!") end font ocr_font, :size => 11 do character_spacing 0.5 do draw_text esr9(invoice, account), :at => [cm2pt(6.7), cm2pt(1.7)] end end end |