diff --git a/app/controllers/instructeurs/dossiers_controller.rb b/app/controllers/instructeurs/dossiers_controller.rb index c88e4108d..3b3bb6efd 100644 --- a/app/controllers/instructeurs/dossiers_controller.rb +++ b/app/controllers/instructeurs/dossiers_controller.rb @@ -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 diff --git a/app/models/etablissement.rb b/app/models/etablissement.rb index 724988afa..04274d820 100644 --- a/app/models/etablissement.rb +++ b/app/models/etablissement.rb @@ -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 diff --git a/app/views/shared/dossiers/_identite_entreprise.html.haml b/app/views/shared/dossiers/_identite_entreprise.html.haml index f9a3e8ed2..51e5625e1 100644 --- a/app/views/shared/dossiers/_identite_entreprise.html.haml +++ b/app/views/shared/dossiers/_identite_entreprise.html.haml @@ -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 : diff --git a/config/routes.rb b/config/routes.rb index ba024c094..c84893b20 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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'