Class: OrderByArticles

Inherits:
OrderPdf show all
Defined in:
app/documents/order_by_articles.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

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

Methods included from ArticlesHelper

#field_with_preset_value_and_errors, #format_billing_unit, #format_billing_unit_with_ratios, #format_group_order_unit, #format_group_order_unit_with_ratios, #format_price_unit, #format_supplier_order_unit, #format_supplier_order_unit_with_ratios, #highlight_new, #row_classes

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_number, #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
# File 'app/documents/order_by_articles.rb', line 11

def body
  each_order_article do |order_article|
    article_version = order_article.article_version
    dimrows = []
    rows = [[
      GroupOrder.human_attribute_name(:ordergroup),
      GroupOrderArticle.human_attribute_name(:ordered),
      GroupOrderArticle.human_attribute_name(:received),
      GroupOrderArticle.human_attribute_name(:total_price)
    ]]

    each_group_order_article_for_order_article(order_article) do |goa|
      dimrows << rows.length if goa.result == 0
      rows << [goa.group_order.ordergroup_name,
               billing_quantity_with_tolerance(goa),
               number_with_precision(article_version.convert_quantity(goa.result, article_version.group_order_unit,
                                                article_version.billing_unit)),
               number_to_currency(goa.total_price)]
    end
    next unless rows.length > 1

    name = "#{article_version.name}, #{format_billing_unit_with_ratios(article_version)}, #{number_to_currency(article_version.convert_quantity(
                                                                                                                 article_version.fc_price, article_version.billing_unit, article_version.supplier_order_unit
                                                                                                               ))}"
    name += " #{order_article.order.name}" if @options[:show_supplier]
    nice_table name, rows, dimrows do |table|
      table.column(0).width = bounds.width / 2
      table.columns(1..-1).align = :right
      table.column(2).font_style = :bold
    end
  end
end

#filenameObject



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

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

#titleObject



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

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