Class: OrderCsv

Inherits:
RenderCsv show all
Defined in:
app/lib/order_csv.rb

Instance Method Summary collapse

Methods inherited from RenderCsv

#initialize, #number_to_currency, #to_csv

Constructor Details

This class inherits a constructor from RenderCsv

Instance Method Details

#dataObject



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/lib/order_csv.rb', line 16

def data
  @object.order_articles.ordered.includes(%i[article article_price]).all.map do |oa|
    yield [
      oa.units_to_order,
      oa.article.order_number,
      oa.article.name,
      oa.article.unit,
      oa.price.unit_quantity > 1 ? oa.price.unit_quantity : nil,
      number_to_currency(oa.price.price * oa.price.unit_quantity),
      number_to_currency(oa.total_price)
    ]
  end
end

#headerObject



4
5
6
7
8
9
10
11
12
13
14
# File 'app/lib/order_csv.rb', line 4

def header
  [
    OrderArticle.human_attribute_name(:units_to_order),
    Article.human_attribute_name(:order_number),
    Article.human_attribute_name(:name),
    Article.human_attribute_name(:unit),
    Article.human_attribute_name(:unit_quantity_short),
    ArticlePrice.human_attribute_name(:price),
    OrderArticle.human_attribute_name(:total_price)
  ]
end