Class: Dorsale::BillingMachine::InvoiceMultipleVatPdf

Inherits:
InvoiceSingleVatPdf show all
Defined in:
app/pdfs/dorsale/billing_machine/invoice_multiple_vat_pdf.rb

Direct Known Subclasses

QuotationMultipleVatPdf

Constant Summary

Constants inherited from InvoiceSingleVatPdf

Dorsale::BillingMachine::InvoiceSingleVatPdf::BLACK, Dorsale::BillingMachine::InvoiceSingleVatPdf::BLUE, Dorsale::BillingMachine::InvoiceSingleVatPdf::DEBUG, Dorsale::BillingMachine::InvoiceSingleVatPdf::GREY, Dorsale::BillingMachine::InvoiceSingleVatPdf::LIGHT_GREY, Dorsale::BillingMachine::InvoiceSingleVatPdf::WHITE

Instance Attribute Summary

Attributes inherited from InvoiceSingleVatPdf

#main_document

Instance Method Summary collapse

Methods inherited from InvoiceSingleVatPdf

#address_line, #build, #build_bank_informations, #build_comments, #build_contact, #build_customer, #build_expiry, #build_footer, #build_header, #build_line, #build_logo, #build_middle, #build_page_numbers, #build_payment_conditions, #build_subject, #build_title, #builds_id_card_informations, #builds_legals, #draw_bounds_debug, #footer_height, #has_advance, #has_discount, #header_height, #initialize, #logo_height, #middle_height, #setup

Methods included from UsersHelper

#avatar_img

Methods included from Flyboy::ApplicationHelper

#folder_color, #show_tasks_summary, #task_color, #tasks_for

Methods included from Alexandrie::AttachmentsHelper

#attachment_form_for, #attachments_for, #attachments_list_for

Methods included from TextHelper

#date, #euros, #hours, #info, #number, #percentage, #text2html

Methods included from RoutesHelper

#engine_polymorphic_path

Methods included from PaginationHelper

#paginate

Methods included from LinkHelper

#email_link, #icon_link_to, #tel_link, #twitter_link, #web_link

Methods included from FormHelper

#form_buttons, #horizontal_form_for, #search_form

Methods included from FiltersHelper

#dorsale_time_periods_for_select, #filter_buttons, #filter_reset_button, #filter_submit_button

Methods included from ContextHelper

#actions_for, #context_icon, #context_info, #context_title, #render_contextual

Methods included from CommentsHelper

#comment_form_for, #comments_for, #comments_list_for

Methods included from Dorsale::ButtonHelper

#complete_button, #copy_button, #create_button, #delete_button, #dorsale_button, #download_button, #lock_button, #read_button, #snooze_button, #unlock_button, #update_button

Methods included from Alexandrie::Prawn

#render_with_attachments

Constructor Details

This class inherits a constructor from Dorsale::BillingMachine::InvoiceSingleVatPdf

Instance Method Details

#build_tableObject



29
30
31
32
33
34
35
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
77
78
79
80
81
82
# File 'app/pdfs/dorsale/billing_machine/invoice_multiple_vat_pdf.rb', line 29

def build_table
  left   = bounds.left
  top    = bounds.top
  width  = bounds.width - left

  bounding_box [left, top], width: width, height: 9.5.cm do
    repeat :all do
      float do
          table [["","","","","",""]],
              :column_widths => [first_column_width, second_column_width, third_column_width, fourth_column_width, fifth_column_width, last_column_width],
              :cell_style => {:height => 9.5.cm} do
                row(0).style :text_color       => BLACK
                row(0).style :font_style       => :bold
                column(0).style :align => :left
                column(1..4).style :align => :right
              end
           end
        end
    end

  bounding_box [left, top], width: width, height: 8.8.cm do
    draw_bounds_debug
    repeat :all do
      build_line
    end
    table_products = [[I18n.t("pdfs.designation"),
      I18n.t("pdfs.quantity"),
      I18n.t("pdfs.unity"),
      I18n.t("pdfs.tax"),
      I18n.t("pdfs.unit_price"),
      I18n.t("pdfs.line_total")]]


    @main_document.lines.each do |line|
      table_products.push [line.label,
          number(line.quantity).gsub(",00","").gsub(".00",""),
          line.unit,
          percentage(line.vat_rate),
          euros(line.unit_price),
          euros(line.total),]
    end

  table table_products,
    :column_widths => [first_column_width, second_column_width, third_column_width, fourth_column_width, fifth_column_width, last_column_width],
    :header => true,
    :cell_style    => {border_width: 0} do
      row(0).font_style = :bold
      row(0).border_width = 1,
      cells.style do |c|
        c.align = c.column == 0 ? :left : :right
      end
    end
  end
end

#build_totalObject



84
85
86
87
88
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
# File 'app/pdfs/dorsale/billing_machine/invoice_multiple_vat_pdf.rb', line 84

def build_total

  left   = bounds.left
  top    = bounds.top - 10.3.cm
  width  = bounds.width - left

  bounding_box [left, top], width: width, height: middle_height - 9.5.cm do
    draw_bounds_debug

    table_totals = [[]]

    if has_discount
      table_totals.push ["#{I18n.t("pdfs.commercial_discount")}", "\- #{euros(@main_document.commercial_discount)}"]
    end

    table_totals.push ["#{I18n.t("pdfs.total_excluding_taxes")}", euros(@main_document.total_excluding_taxes)]

    table_totals.push ["#{I18n.t("pdfs.vat_amount")}", euros(@main_document.vat_amount)]

    if has_advance
      table_totals.push ["#{I18n.t("pdfs.advance")}", euros(@main_document.advance)]
      table_totals.push ["#{I18n.t("pdfs.total_including_taxes")}", euros(@main_document.balance)]
    else
      table_totals.push ["#{I18n.t("pdfs.total_including_taxes")}", euros(@main_document.total_including_taxes)]
    end

    table table_totals,
      :column_widths => [fifth_column_width , last_column_width],
      :cell_style    => {border_width: [0, 1, 0 ,0]},
      :position      => :right do
        row(-1).style :font_style       => :bold
        column(0).padding_right = 0.2.cm
        row(-1).borders = [:top, :right]
        row(-1).border_width = 1
        cells.style do |c|
          c.align = :right
        end
      end
    stroke do
      rectangle [(bounds.right - fifth_column_width - last_column_width), bounds.top], (fifth_column_width + last_column_width), (bounds.top-cursor)
    end
  end
end

#fifth_column_widthObject



21
22
23
# File 'app/pdfs/dorsale/billing_machine/invoice_multiple_vat_pdf.rb', line 21

def fifth_column_width
  2.9.cm
end

#first_column_widthObject



5
6
7
# File 'app/pdfs/dorsale/billing_machine/invoice_multiple_vat_pdf.rb', line 5

def first_column_width
  6.4.cm
end

#fourth_column_widthObject



17
18
19
# File 'app/pdfs/dorsale/billing_machine/invoice_multiple_vat_pdf.rb', line 17

def fourth_column_width
 second_column_width
end

#last_column_widthObject



25
26
27
# File 'app/pdfs/dorsale/billing_machine/invoice_multiple_vat_pdf.rb', line 25

def last_column_width
  bounds.width - first_column_width - second_column_width - third_column_width - fourth_column_width - fifth_column_width
end

#second_column_widthObject



9
10
11
# File 'app/pdfs/dorsale/billing_machine/invoice_multiple_vat_pdf.rb', line 9

def second_column_width
  2.cm
end

#third_column_widthObject



13
14
15
# File 'app/pdfs/dorsale/billing_machine/invoice_multiple_vat_pdf.rb', line 13

def third_column_width
  second_column_width
end