display v2 and v3 bilans bdf
This commit is contained in:
parent
0f083db32b
commit
42acc71cbe
4 changed files with 101 additions and 5 deletions
|
@ -1,14 +1,23 @@
|
|||
module EtablissementHelper
|
||||
def value_for_bilan_key(bilan, key)
|
||||
if bilan["data"]
|
||||
return "NA" if key == "resultat_exercice"
|
||||
bilan["data"][key].presence || bilan["data"]["valeurs_calculees"][0][key].present? ? bilan["data"]["valeurs_calculees"][0][key]["valeur"] : nil
|
||||
else
|
||||
bilan[key]
|
||||
end
|
||||
end
|
||||
|
||||
def pretty_siret(siret)
|
||||
"#{siret[0..2]} #{siret[3..5]} #{siret[6..8]} #{siret[9..]}"
|
||||
end
|
||||
|
||||
def pretty_currency(capital_social, unit: '€')
|
||||
number_to_currency(capital_social, locale: :fr, unit: unit, precision: 0)
|
||||
def pretty_currency(value, unit: '€')
|
||||
number_to_currency(value, locale: :fr, unit: unit, precision: 0)
|
||||
end
|
||||
|
||||
def pretty_currency_unit(unit)
|
||||
dict = { 'kEuros' => 'k€' }
|
||||
dict = { 'kEuros' => 'k€', 'euros' => '€' }
|
||||
dict[unit]
|
||||
end
|
||||
|
||||
|
|
|
@ -5,6 +5,6 @@
|
|||
%details
|
||||
- etablissement.entreprise_bilans_bdf.each do |bilan|
|
||||
= "#{pretty_date_exercice(bilan["date_arret_exercice"])} : "
|
||||
= pretty_currency(bilan[key], unit: pretty_currency_unit(etablissement.entreprise_bilans_bdf_monnaie))
|
||||
= pretty_currency(value_for_bilan_key(bilan, key), unit: pretty_currency_unit(etablissement.entreprise_bilans_bdf_monnaie))
|
||||
%br
|
||||
|
||||
|
|
51
spec/fixtures/files/api_entreprise/bilans_entreprise_bdf_v2.json
vendored
Normal file
51
spec/fixtures/files/api_entreprise/bilans_entreprise_bdf_v2.json
vendored
Normal file
|
@ -0,0 +1,51 @@
|
|||
{
|
||||
"monnaie": "kEuros",
|
||||
"bilans": [
|
||||
{
|
||||
"duree_exercice": "12",
|
||||
"valeur_ajoutee_bdf": "7848792",
|
||||
"resultat_exercice": "347126",
|
||||
"capitaux_propres_et_assimiles": "5928663",
|
||||
"total_provisions_pour_risques_et_charges": "1957919",
|
||||
"dettes1_emprunts_obligataires_et_convertibles": "0",
|
||||
"dettes2_autres_emprunts_obligataires": "6552306",
|
||||
"total_dettes_stables": "6552306",
|
||||
"emprunts_et_dettes_financieres_divers": "430634",
|
||||
"groupes_et_associes": "0",
|
||||
"besoin_en_fonds_de_roulement": "-721507",
|
||||
"disponibilites": "1983051",
|
||||
"total_passif": "18478051",
|
||||
"evolution_valeur_ajoutee_bdf": "",
|
||||
"evolution_resultat_exercice": "",
|
||||
"evolution_capitaux_propres_et_assimiles": "",
|
||||
"evolution_total_provisions_pour_risques_et_charges": "",
|
||||
"evolution_dettes1_emprunts_obligataires_et_convertibles": "",
|
||||
"evolution_dettes2_autres_emprunts_obligataires": "",
|
||||
"evolution_emprunts_et_dettes_financieres_divers": "",
|
||||
"evolution_groupes_et_associes": "",
|
||||
"evolution_besoin_en_fonds_de_roulement": "",
|
||||
"evolution_disponibilites": "",
|
||||
"evolution_total_passif": "",
|
||||
"chiffre_affaires_ht": "12030700",
|
||||
"capacite_autofinancement": "891914",
|
||||
"date_arret_exercice": "201512",
|
||||
"dettes3_emprunts_et_dettes_aupres_des_etablissements_de_credit": "0",
|
||||
"dettes4_maturite_a_un_an_au_plus": "0",
|
||||
"autres_fonds_propres": "0",
|
||||
"capital_social_inclus_dans_capitaux_propres_et_assimiles": "3800000",
|
||||
"excedent_brut_exploitation": "-1876863",
|
||||
"evolution_chiffre_affaires_ht": "",
|
||||
"evolution_capacite_autofinancement": "",
|
||||
"evolution_dettes3_emprunts_et_dettes_aupres_des_etablissements_de_credit": "",
|
||||
"evolution_dettes4_maturite_a_un_an_au_plus": "",
|
||||
"evolution_autres_fonds_propres": "",
|
||||
"evolution_capital_social_inclus_dans_capitaux_propres_et_assimiles": "",
|
||||
"evolution_excedent_brut_exploitation": "",
|
||||
"evolution_fonds_roulement_net_global": "",
|
||||
"evolution_ratio_fonds_roulement_net_global_sur_besoin_en_fonds_de_roulement": "",
|
||||
"evolution_total_dettes_stables": "",
|
||||
"fonds_roulement_net_global": "2464585",
|
||||
"ratio_fonds_roulement_net_global_sur_besoin_en_fonds_de_roulement": "-"
|
||||
}, "bilan 2", "bilan 3"
|
||||
]
|
||||
}
|
|
@ -1,13 +1,16 @@
|
|||
describe 'shared/dossiers/identite_entreprise', type: :view do
|
||||
before { render 'shared/dossiers/identite_entreprise', etablissement: etablissement, profile: 'usager' }
|
||||
subject { render 'shared/dossiers/identite_entreprise', etablissement: etablissement, profile: profile }
|
||||
let(:profile) { 'usager' }
|
||||
|
||||
context "there is an association" do
|
||||
|
||||
let(:etablissement) { create(:etablissement, :is_association) }
|
||||
|
||||
context "date_publication is missing on rna" do
|
||||
before { etablissement.update(association_date_publication: nil) }
|
||||
|
||||
it "can render without error" do
|
||||
subject
|
||||
expect(rendered).to include("Date de publication :")
|
||||
end
|
||||
end
|
||||
|
@ -17,9 +20,42 @@ describe 'shared/dossiers/identite_entreprise', type: :view do
|
|||
let(:etablissement) { create(:etablissement, :non_diffusable, siret: "12345678900001") }
|
||||
|
||||
it "hide any info except siret" do
|
||||
subject
|
||||
expect(rendered).to have_text("123 456 789 00001")
|
||||
expect(rendered).not_to have_text(etablissement.entreprise_raison_sociale)
|
||||
expect(rendered).not_to have_text(etablissement.entreprise.forme_juridique)
|
||||
end
|
||||
end
|
||||
|
||||
context 'for instructeur' do
|
||||
let(:profile) { 'instructeur' }
|
||||
|
||||
context 'with bilans bdf v2' do
|
||||
let(:bilans) { JSON.parse(File.read('spec/fixtures/files/api_entreprise/bilans_entreprise_bdf_v2.json')) }
|
||||
let(:bilans_array) { bilans["bilans"] }
|
||||
let(:bilans_monnaie) { bilans["monnaie"] }
|
||||
let(:etablissement) { create(:etablissement, entreprise_bilans_bdf: bilans_array, entreprise_bilans_bdf_monnaie: bilans_monnaie, dossier: create(:dossier)) }
|
||||
|
||||
it "can render without error" do
|
||||
assign(:dossier, etablissement.dossier)
|
||||
subject
|
||||
expect(rendered).to include("Excédent brut d’exploitation")
|
||||
expect(rendered).to include("-1 876 863 k€")
|
||||
end
|
||||
end
|
||||
|
||||
context 'with bilans bdf v3' do
|
||||
let(:bilans) { JSON.parse(File.read('spec/fixtures/files/api_entreprise/bilans_entreprise_bdf.json')) }
|
||||
let(:bilans_array) { bilans["data"] }
|
||||
let(:bilans_monnaie) { "euros" }
|
||||
let(:etablissement) { create(:etablissement, entreprise_bilans_bdf: bilans_array, entreprise_bilans_bdf_monnaie: bilans_monnaie, dossier: create(:dossier)) }
|
||||
|
||||
it "can render without error" do
|
||||
assign(:dossier, etablissement.dossier)
|
||||
subject
|
||||
expect(rendered).to include("Excédent brut d’exploitation")
|
||||
expect(rendered).to include("9 001")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue