diff --git a/lib/order_csv.rb b/lib/order_csv.rb index d2c458c2..4fe92a25 100644 --- a/lib/order_csv.rb +++ b/lib/order_csv.rb @@ -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 diff --git a/lib/render_csv.rb b/lib/render_csv.rb index ad79612b..b643e4b4 100644 --- a/lib/render_csv.rb +++ b/lib/render_csv.rb @@ -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