export + encoding fix (ruby 1.9.3)
Conflicts: lib/order_csv.rb
This commit is contained in:
parent
03b307d359
commit
3f3d7c4e3b
2 changed files with 7 additions and 4 deletions
|
@ -8,6 +8,7 @@ class OrderCsv < RenderCSV
|
|||
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)
|
||||
]
|
||||
|
@ -19,10 +20,12 @@ class OrderCsv < RenderCSV
|
|||
oa.units_to_order,
|
||||
oa.article.order_number,
|
||||
oa.article.name,
|
||||
oa.article.unit + (oa.price.unit_quantity > 1 ? " × #{oa.price.unit_quantity}" : ''),
|
||||
number_to_currency(oa.article.price * oa.article.unit_quantity),
|
||||
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
|
||||
|
||||
end
|
||||
|
|
|
@ -36,8 +36,8 @@ class RenderCSV
|
|||
File.open("#{Rails.root}/tmp/#{self.class.to_s.underscore}.csv", 'w') {|f| f.write(to_csv.force_encoding(encoding)) }
|
||||
end
|
||||
|
||||
# XXX avoid encoding confusion when using unicode whitespace
|
||||
# XXX disable unit to avoid encoding problems, both in unit and whitespace. Also allows computations in spreadsheet.
|
||||
def number_to_currency(number, options={})
|
||||
super(number, options).gsub("\u202f", ' ')
|
||||
super(number, options.merge({unit: nil}))
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue