render csv bidf bilans

This commit is contained in:
Christophe Robillard 2020-04-30 11:25:22 +02:00
parent b12226c667
commit 22e2c2e133
4 changed files with 21 additions and 0 deletions

View file

@ -31,6 +31,10 @@ module Instructeurs
render 'admin/attestation_templates/show', formats: [:pdf]
end
def bilans_bdf
render csv: dossier.etablissement.entreprise_bilans_bdf_to_csv
end
def show
@demande_seen_at = current_instructeur.follows.find_by(dossier: dossier)&.demande_seen_at

View file

@ -138,6 +138,15 @@ class Etablissement < ApplicationRecord
upload_attestation(url, entreprise_attestation_fiscale)
end
def entreprise_bilans_bdf_to_csv
headers = ["bilans"].concat(entreprise_bilans_bdf[0].keys)
data = entreprise_bilans_bdf.each_with_index.map do |bilan, i|
month = I18n.l(Date.current - (i + 1).year, format: "%m/%Y")
[month].concat(bilan.values)
end
SpreadsheetArchitect.to_csv(headers: headers, data: data)
end
private
def dossier_id_for_export

View file

@ -78,6 +78,13 @@
%th.libelle Attestation fiscale
%td= link_to "Consulter l'attestation", url_for(etablissement.entreprise_attestation_fiscale)
- if etablissement.entreprise_bilans_bdf_to_csv.present?
%tr
%th.libelle
Bilans Banque de France
= "en #{etablissement.entreprise_bilans_bdf_monnaie}"
%td= link_to "Consulter les bilans", bilans_bdf_instructeur_dossier_path
- if etablissement.association?
%tr
%th.libelle Numéro RNA :

View file

@ -318,6 +318,7 @@ Rails.application.routes.draw do
get 'attestation'
get 'geo_data'
get 'apercu_attestation'
get 'bilans_bdf'
get 'messagerie'
get 'annotations-privees' => 'dossiers#annotations_privees'
get 'avis'