export bilans in ods and xlsx

This commit is contained in:
Christophe Robillard 2020-06-04 12:32:09 +02:00
parent e803276464
commit cf9d6ccf34
4 changed files with 20 additions and 9 deletions

View file

@ -159,12 +159,8 @@ class Etablissement < ApplicationRecord
entreprise_last_bilan_info_cle("besoin_en_fonds_de_roulement")
end
def entreprise_bilans_bdf_to_csv
headers = bilans_headers.concat(bilans_new_keys)
data = entreprise_bilans_bdf.map do |bilan|
headers.map { |h| bilan[h] }
end
SpreadsheetArchitect.to_csv(headers: headers, data: data)
def entreprise_bilans_bdf_to_sheet(format)
SpreadsheetArchitect.send("to_#{format}".to_sym, bilans_bdf_data)
end
private
@ -178,6 +174,14 @@ class Etablissement < ApplicationRecord
entreprise_bilans_bdf.first[key]
end
def bilans_bdf_data
headers = bilans_headers.concat(bilans_new_keys)
data = entreprise_bilans_bdf.map do |bilan|
headers.map { |h| bilan[h] }
end
{ headers: headers, data: data }
end
def dossier_id_for_export
if dossier_id
dossier_id.to_s