improve csv generation for bilans bdf

This commit is contained in:
Christophe Robillard 2020-04-30 16:03:05 +02:00
parent 9873826dd4
commit 9de2c7c85a
2 changed files with 28 additions and 2 deletions

View file

@ -139,8 +139,10 @@ class Etablissement < ApplicationRecord
end
def entreprise_bilans_bdf_to_csv
headers = entreprise_bilans_bdf[0].keys
data = entreprise_bilans_bdf.map(&:values)
headers = entreprise_bilans_bdf.flat_map(&:keys).uniq
data = entreprise_bilans_bdf.map do |bilan|
headers.map { |h| bilan[h] }
end
SpreadsheetArchitect.to_csv(headers: headers, data: data)
end