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::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

#attachments, #bm_currency, #build, #build_contact_infos, #build_customer, #build_document_infos, #build_footer, #build_footer_bottom, #build_footer_line, #build_footer_top, #build_header, #build_logo, #build_middle, #build_page_numbers, #build_subject, #build_title, #contact_infos_content, #contact_infos_height, #customer_content, #document_infos_content, #footer_bottom_content, #footer_bottom_height, #footer_height, #footer_pagination_height, #footer_top_content, #footer_top_height, #has_advance, #has_discount, #header_height, #initialize, #logo_height, #logo_path, #logo_width, #middle_height, #products_table_height, #setup

Methods included from PrawnHelpers

#bb, #btb, #draw_debug_bounds!, #draw_debug_bounds?, #get_image, #page_height, #page_width, #placeholder, #t, #tb

Methods included from UsersHelper

#avatar_img, #default_avatar_url

Methods included from ExpenseGun::ApplicationHelper

#expense_states_for_filters_select

Methods included from Flyboy::ApplicationHelper

#flyboy_reminder_type_units_for_select, #flyboy_reminder_types_for_select, #flyboy_status_for_filters_select, #flyboy_tasks_owners_for_filters_select, #flyboy_tasks_owners_for_select, #flyboy_tasks_tags_for_filters_select, #flyboy_tasks_tags_for_select, #show_tasks_summary, #task_term_values_for_select, #tasks_for

Methods included from CustomerVault::ApplicationHelper

#customer_vault_activity_types_for_select, #customer_vault_event_actions_for_filter_select, #customer_vault_event_contact_types_for_filter_select, #customer_vault_link_form_path, #customer_vault_origins_for_select, #customer_vault_tag_list, #new_event_for, #person_address_blank?, #person_related_people_blank?, #person_social_blank?, #person_types_for_filter_select

Methods included from ApplicationHelper

#billing_machine_invoices_chart, #billing_machine_payment_status_for_filter_select, #billing_machine_quotation_states_for_filter_select, #billing_machine_quotation_states_for_select, #bm_currency, #quotation_state_classes

Methods included from Alexandrie::AttachmentsHelper

#attachments_for

Methods included from CommentsHelper

#comments_for, #new_comment_for, #truncate_comment_text, #truncate_comments_in_this_page?

Methods included from ContextHelper

#actions_for, #render_dorsale_page

Constructor Details

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

Instance Method Details

#build_tableObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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
# File 'app/pdfs/dorsale/billing_machine/invoice_multiple_vat_pdf.rb', line 14

def build_table
  height = products_table_height

  # Empty table to draw lines
  bb height: products_table_height 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: products_table_height} 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 # table
      end # float
    end # repeat
  end # bb

  # Products table
  bb height: height do
    table_products = [[
      main_document.t(:designation).mb_chars.upcase.to_s,
      main_document.t(:quantity).mb_chars.upcase.to_s,
      main_document.t(:unit).mb_chars.upcase.to_s,
      main_document.t(:tax).mb_chars.upcase.to_s,
      main_document.t(:unit_price).mb_chars.upcase.to_s,
      main_document.t(:line_total).mb_chars.upcase.to_s,
    ]]

    main_document.lines.each do |line|
      table_products.push [
        line.label,
        number(line.quantity).gsub(",00", "").gsub(".00", ""),
        line.unit,
        percentage(line.vat_rate),
        bm_currency(line.unit_price),
        bm_currency(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 { |c| c.align = c.column.zero? ? :left : :right }
    end # table
  end # bb
end

#build_totalObject

build_table



75
76
77
78
79
80
81
82
83
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
127
128
129
130
131
132
133
# File 'app/pdfs/dorsale/billing_machine/invoice_multiple_vat_pdf.rb', line 75

def build_total
  top    = bounds.top - products_table_height - 5.mm
  height = middle_height - products_table_height - 5.mm

  bb top: top, height: height do
    table_totals = [[]]

    if has_discount
      table_totals.push [
        main_document.t(:commercial_discount).mb_chars.upcase.to_s,
        bm_currency(-main_document.commercial_discount),
      ]
    end

    table_totals.push [
      main_document.t(:total_excluding_taxes).mb_chars.upcase.to_s,
      bm_currency(main_document.total_excluding_taxes),
    ]

    table_totals.push [
      main_document.t(:vat_amount).mb_chars.upcase.to_s,
      bm_currency(main_document.vat_amount),
    ]

    if has_advance
      table_totals.push [
        main_document.t(:advance).mb_chars.upcase.to_s,
        bm_currency(main_document.advance),
      ]

      table_totals.push [
        main_document.t(:total_including_taxes).mb_chars.upcase.to_s,
        bm_currency(main_document.balance),
      ]
    else
      table_totals.push [
        main_document.t(:total_including_taxes).mb_chars.upcase.to_s,
        bm_currency(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



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

def fifth_column_width;  29.mm; end

#first_column_widthObject

rubocop:disable Style/SingleLineMethods, Layout/EmptyLineBetweenDefs



3
# File 'app/pdfs/dorsale/billing_machine/invoice_multiple_vat_pdf.rb', line 3

def first_column_width;  64.mm; end

#fourth_column_widthObject



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

def fourth_column_width; 20.mm; end

#last_column_widthObject

rubocop:enable Style/SingleLineMethods, Layout/EmptyLineBetweenDefs



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

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



4
# File 'app/pdfs/dorsale/billing_machine/invoice_multiple_vat_pdf.rb', line 4

def second_column_width; 22.mm; end

#third_column_widthObject



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

def third_column_width;  20.mm; end