Class: OrderByGroups

Inherits:
OrderPdf show all
Defined in:
app/documents/order_by_groups.rb

Constant Summary

Constants inherited from RenderPdf

RenderPdf::BOTTOM_MARGIN, RenderPdf::DEFAULT_FONT, RenderPdf::FOOTER_FONT_SIZE, RenderPdf::FOOTER_SPACE, RenderPdf::HEADER_FONT_SIZE, RenderPdf::HEADER_SPACE, RenderPdf::TOP_MARGIN

Instance Attribute Summary

Attributes inherited from OrderPdf

#order

Instance Method Summary collapse

Methods inherited from OrderPdf

#each_group_order_article_for_order_article, #each_group_order_article_for_ordergroup, #each_order_article, #each_ordergroup, #each_ordergroup_batch, #group_order_article_quantity_with_tolerance, #group_order_article_result, #group_order_articles, #initialize, #nice_table, #order_article_price, #order_article_price_per_unit, #order_articles, #ordergroups, #stock_ordergroup_name

Methods inherited from RenderPdf

#down_or_page, #font_path, #font_size, #fontsize, #initialize, #number_to_currency, #pdf_add_page_breaks?, #to_pdf

Methods included from ApplicationHelper

#base_errors, #bootstrap_flash_patched, #close_button, #expand, #foodcoop_css_path, #foodcoop_css_tag, #format_currency, #format_date, #format_datetime, #format_datetime_timespec, #format_iban, #format_roles, #format_time, #heading_helper, #icon, #items_per_page, #link_to_gmaps, #link_to_top, #pagination_links_remote, #remote_link_to, #show_title?, #show_user, #show_user_link, #sort_link_helper, #tab_is_active?, #truncate, #weekday

Methods included from PathHelper

#finance_group_transactions_path

Constructor Details

This class inherits a constructor from OrderPdf

Instance Method Details

#bodyObject



11
12
13
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
# File 'app/documents/order_by_groups.rb', line 11

def body
  each_ordergroup do |oa_name, oa_total, oa_id, oa_transport|
    has_transport = !oa_transport.nil? && oa_transport > 0
    dimrows = []
    rows = [[
      OrderArticle.human_attribute_name(:article),
      Article.human_attribute_name(:supplier),
      GroupOrderArticle.human_attribute_name(:ordered),
      GroupOrderArticle.human_attribute_name(:received),
      GroupOrderArticle.human_attribute_name(:unit_price),
      GroupOrderArticle.human_attribute_name(:total_price)
    ]]

    each_group_order_article_for_ordergroup(oa_id) do |goa|
      dimrows << rows.length if goa.result == 0
      rows << [goa.order_article.article.name,
               goa.group_order.order.name,
               group_order_article_quantity_with_tolerance(goa),
               group_order_article_result(goa),
               order_article_price_per_unit(goa.order_article),
               number_to_currency(goa.total_price)]
    end
    next unless rows.length > 1

    rows << [nil, nil, nil, nil, nil, number_to_currency(oa_total)]
    if has_transport
      rows << [GroupOrder.human_attribute_name(:transport), nil, nil, nil, nil, number_to_currency(oa_transport)]
      rows << [nil, nil, nil, nil, nil, number_to_currency(oa_total + oa_transport)]
    end

    rows.each { |row| row.delete_at 1 } unless @options[:show_supplier]

    nice_table oa_name || stock_ordergroup_name, rows, dimrows do |table|
      if has_transport
        table.row(-4).border_width = 1
        table.row(-4).border_color = '666666'
      end

      table.row(-2).border_width = 1
      table.row(-2).border_color = '666666'
      table.row(-1).borders = []

      if @options[:show_supplier]
        table.column(0).width = bounds.width / 3
        table.column(1).width = bounds.width / 4
      else
        table.column(0).width = bounds.width / 2
      end

      table.columns(-4..-1).align = :right
      table.column(-3).font_style = :bold
      table.column(-1).font_style = :bold
    end
  end
end

#filenameObject



2
3
4
# File 'app/documents/order_by_groups.rb', line 2

def filename
  I18n.t('documents.order_by_groups.filename', name: order.name, date: order.ends.to_date) + '.pdf'
end

#titleObject



6
7
8
9
# File 'app/documents/order_by_groups.rb', line 6

def title
  I18n.t('documents.order_by_groups.title', name: order.name,
                                            date: order.ends.strftime(I18n.t('date.formats.default')))
end