migrate bilans bdf adapter to v3
This commit is contained in:
parent
c2f2b4ef2a
commit
0f083db32b
5 changed files with 88 additions and 60 deletions
|
@ -9,7 +9,7 @@ class APIEntreprise::API
|
|||
EFFECTIFS_ANNUELS_RESOURCE_NAME = "v2/effectifs_annuels_acoss_covid/%{id}"
|
||||
ATTESTATION_SOCIALE_RESOURCE_NAME = "v4/urssaf/unites_legales/%{id}/attestation_vigilance"
|
||||
ATTESTATION_FISCALE_RESOURCE_NAME = "v4/dgfip/unites_legales/%{id}/attestation_fiscale"
|
||||
BILANS_BDF_RESOURCE_NAME = "v2/bilans_entreprises_bdf/%{id}"
|
||||
BILANS_BDF_RESOURCE_NAME = "v3/banque_de_france/unites_legales/%{id}/bilans"
|
||||
PRIVILEGES_RESOURCE_NAME = "v2/privileges"
|
||||
|
||||
TIMEOUT = 20
|
||||
|
|
|
@ -11,13 +11,17 @@ class APIEntreprise::BilansBdfAdapter < APIEntreprise::Adapter
|
|||
end
|
||||
|
||||
def process_params
|
||||
if data_source[:bilans].present?
|
||||
{
|
||||
entreprise_bilans_bdf: data_source[:bilans],
|
||||
entreprise_bilans_bdf_monnaie: data_source[:monnaie]
|
||||
}
|
||||
else
|
||||
{}
|
||||
Sentry.with_scope do |scope|
|
||||
data = data_source[:data]
|
||||
scope.set_tags(siret: @siret)
|
||||
scope.set_extras(source: data)
|
||||
|
||||
result = {}
|
||||
if data
|
||||
result[:entreprise_bilans_bdf] = data
|
||||
result[:entreprise_bilans_bdf_monnaie] = 'euros'
|
||||
end
|
||||
result
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,51 +1,75 @@
|
|||
{
|
||||
"monnaie": "kEuros",
|
||||
"bilans": [
|
||||
"data": [
|
||||
{
|
||||
"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"
|
||||
]
|
||||
"data": {
|
||||
"annee": "2020",
|
||||
"date_arrete_exercice": "202012",
|
||||
"valeurs_calculees": [
|
||||
{
|
||||
"disponibilites": {
|
||||
"valeur": "9001",
|
||||
"evolution": 12.34
|
||||
},
|
||||
"total_dettes_stables": {
|
||||
"valeur": "9001",
|
||||
"evolution": 12.34
|
||||
},
|
||||
"valeur_ajoutee_bdf": {
|
||||
"valeur": "9001",
|
||||
"evolution": 12.34
|
||||
},
|
||||
"besoin_en_fonds_de_roulement": {
|
||||
"valeur": "9001",
|
||||
"evolution": 12.34
|
||||
},
|
||||
"excedent_brut_exploitation": {
|
||||
"valeur": "9001",
|
||||
"evolution": 12.34
|
||||
},
|
||||
"capacite_autofinancement": {
|
||||
"valeur": "9001",
|
||||
"evolution": 12.34
|
||||
},
|
||||
"fonds_roulement_net_global": {
|
||||
"valeur": "9001",
|
||||
"evolution": 12.34
|
||||
},
|
||||
"ratio_fonds_roulement_net_global_sur_besoin_en_fonds_de_roulement": {
|
||||
"valeur": 23.45,
|
||||
"evolution": 12.34
|
||||
},
|
||||
"dettes4_maturite_a_un_an_au_plus": {
|
||||
"valeur": "9001",
|
||||
"evolution": 12.34
|
||||
}
|
||||
}
|
||||
],
|
||||
"declarations": [
|
||||
{
|
||||
"numero_imprime": "2051",
|
||||
"donnees": [
|
||||
{
|
||||
"code": "GR",
|
||||
"code_EDI": "GR:C889:7111:1:TBX",
|
||||
"evolution": 4.56,
|
||||
"code_absolu": "2006744",
|
||||
"code_type_donnee": "CCI",
|
||||
"intitule": "Déposé néant",
|
||||
"code_nref": "304651",
|
||||
"valeurs": [
|
||||
"dummy"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"links": {},
|
||||
"meta": {}
|
||||
}
|
||||
],
|
||||
"meta": {
|
||||
"count": 1
|
||||
},
|
||||
"links": {}
|
||||
}
|
||||
|
|
|
@ -6,10 +6,10 @@ RSpec.describe APIEntreprise::BilansBdfJob, type: :job do
|
|||
let(:procedure_id) { procedure.id }
|
||||
let(:body) { File.read('spec/fixtures/files/api_entreprise/bilans_entreprise_bdf.json') }
|
||||
let(:status) { 200 }
|
||||
let(:bilans_bdf) { JSON.parse(body)["bilans"] }
|
||||
let(:bilans_bdf) { JSON.parse(body)["data"] }
|
||||
|
||||
before do
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/bilans_entreprises_bdf\/#{siren}/)
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v3\/banque_de_france\/unites_legales\/#{siren}\/bilans/)
|
||||
.to_return(body: body, status: status)
|
||||
allow_any_instance_of(APIEntrepriseToken).to receive(:roles).and_return(["bilans_entreprise_bdf"])
|
||||
allow_any_instance_of(APIEntrepriseToken).to receive(:expired?).and_return(false)
|
||||
|
|
|
@ -7,7 +7,7 @@ describe APIEntreprise::BilansBdfAdapter do
|
|||
subject { adapter.to_params }
|
||||
|
||||
before do
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/bilans_entreprises_bdf\/#{siren}/)
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v3\/banque_de_france\/unites_legales\/#{siren}\/bilans/)
|
||||
.to_return(body: body, status: status)
|
||||
allow_any_instance_of(APIEntrepriseToken).to receive(:roles).and_return(["bilans_entreprise_bdf"])
|
||||
allow_any_instance_of(APIEntrepriseToken).to receive(:expired?).and_return(false)
|
||||
|
@ -22,7 +22,7 @@ describe APIEntreprise::BilansBdfAdapter do
|
|||
end
|
||||
|
||||
it "returns bilans bdf" do
|
||||
expect(subject[:entreprise_bilans_bdf][0][:valeur_ajoutee_bdf]).to eq("7848792")
|
||||
expect(subject[:entreprise_bilans_bdf][0][:data][:valeurs_calculees][0][:excedent_brut_exploitation][:valeur]).to eq "9001"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue