-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(banque de france): add banque de france data #1486
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import routes from '#clients/routes'; | ||
import { IBilansProtected } from '#models/espace-agent/bilans'; | ||
import { Siren } from '#utils/helpers'; | ||
import clientAPIEntreprise from '../client'; | ||
import { IAPIEntrepriseBanqueDeFranceBilans } from './types'; | ||
|
||
/** | ||
* GET association from API Entreprise | ||
*/ | ||
export async function clientApiEntrepriseBilans(siren: Siren) { | ||
return await clientAPIEntreprise< | ||
IAPIEntrepriseBanqueDeFranceBilans, | ||
IBilansProtected | ||
>( | ||
`${ | ||
process.env.API_ENTREPRISE_URL | ||
}${routes.apiEntreprise.banqueDeFrance.bilans(siren)}`, | ||
mapToDomainObject | ||
); | ||
} | ||
const mapToDomainObject = ( | ||
response: IAPIEntrepriseBanqueDeFranceBilans | ||
): IBilansProtected => { | ||
return response.data.map((item) => { | ||
return { | ||
annee: item.data.annee, | ||
dateArreteExercice: item.data.date_arrete_exercice, | ||
besoinEnFondsDeRoulement: | ||
item.data.valeurs_calculees[0]?.besoin_en_fonds_de_roulement?.valeur ?? | ||
'', | ||
capaciteAutofinancement: | ||
item.data.valeurs_calculees[0]?.capacite_autofinancement?.valeur ?? '', | ||
dettes4MaturiteAUnAnAuPlus: | ||
item.data.valeurs_calculees[0]?.dettes4_maturite_a_un_an_au_plus | ||
?.valeur ?? '', | ||
disponibilites: | ||
item.data.valeurs_calculees[0]?.disponibilites?.valeur ?? '', | ||
excedentBrutExploitation: | ||
item.data.valeurs_calculees[0]?.excedent_brut_exploitation?.valeur ?? | ||
'', | ||
fondsRoulementNetGlobal: | ||
item.data.valeurs_calculees[0]?.fonds_roulement_net_global?.valeur ?? | ||
'', | ||
ratioFondsRoulementNetGlobalSurBesoinEnFondsDeRoulement: | ||
item.data.valeurs_calculees[0] | ||
?.ratio_fonds_roulement_net_global_sur_besoin_en_fonds_de_roulement | ||
?.valeur ?? '', | ||
totalDettesStables: | ||
item.data.valeurs_calculees[0]?.total_dettes_stables?.valeur ?? '', | ||
valeurAjouteeBdf: | ||
item.data.valeurs_calculees[0]?.valeur_ajoutee_bdf?.valeur ?? '', | ||
}; | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { IAPIEntrepriseResponse } from '../client'; | ||
|
||
export type IAPIEntrepriseBanqueDeFranceBilans = IAPIEntrepriseResponse< | ||
{ | ||
data: DataItem; | ||
links: Record<string, unknown>; | ||
meta: Record<string, unknown>; | ||
}[] | ||
>; | ||
|
||
type ValeursCalculees = { | ||
disponibilites: Valeur; | ||
total_dettes_stables: Valeur; | ||
valeur_ajoutee_bdf: Valeur; | ||
besoin_en_fonds_de_roulement: Valeur; | ||
excedent_brut_exploitation: Valeur; | ||
capacite_autofinancement: Valeur; | ||
fonds_roulement_net_global: Valeur; | ||
ratio_fonds_roulement_net_global_sur_besoin_en_fonds_de_roulement: Valeur; | ||
dettes4_maturite_a_un_an_au_plus: Valeur; | ||
}; | ||
|
||
type Valeur = { | ||
valeur: string; | ||
evolution: number | null; | ||
}; | ||
|
||
type Donnees = { | ||
code_nref: string; | ||
valeurs: string[]; | ||
evolution: number | null; | ||
code_absolu: string; | ||
intitule: string; | ||
code_EDI: string; | ||
code: string; | ||
code_type_donnee: string; | ||
}; | ||
|
||
type DataItem = { | ||
annee: string; | ||
date_arrete_exercice: string; | ||
declarations: { | ||
numero_imprime: string; | ||
donnees: Donnees[]; | ||
}[]; | ||
valeurs_calculees: ValeursCalculees[]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
'use client'; | ||
|
||
import FAQLink from '#components-ui/faq-link'; | ||
import { AsyncDataSectionClient } from '#components/section/data-section/client'; | ||
import { FullTable } from '#components/table/full'; | ||
import { EAdministration } from '#models/administrations/EAdministration'; | ||
import { IUniteLegale } from '#models/core/types'; | ||
import { ISession } from '#models/user/session'; | ||
import { formatCurrency, formatDate, getDateFromYYYYMM } from '#utils/helpers'; | ||
import { APIRoutesPaths } from 'app/api/data-fetching/routes-paths'; | ||
import { useAPIRouteData } from 'hooks/fetch/use-API-route-data'; | ||
|
||
export const FinancesSocieteBilansSection: React.FC<{ | ||
uniteLegale: IUniteLegale; | ||
session: ISession | null; | ||
}> = ({ uniteLegale, session }) => { | ||
const banqueDeFranceBilansProtected = useAPIRouteData( | ||
APIRoutesPaths.EspaceAgentBilansProtected, | ||
uniteLegale.siren, | ||
session | ||
); | ||
|
||
return ( | ||
<AsyncDataSectionClient | ||
title="Bilans Banque de France" | ||
id="bilans-banque-de-france" | ||
sources={[EAdministration.BANQUE_DE_FRANCE]} | ||
isProtected | ||
data={banqueDeFranceBilansProtected} | ||
notFoundInfo="Aucun bilan n’a été retrouvé pour cette structure." | ||
> | ||
{(bilans) => { | ||
const body = [ | ||
[ | ||
'Date de clôture', | ||
...bilans.map((item) => | ||
formatDate(getDateFromYYYYMM(item.dateArreteExercice || '')) | ||
), | ||
], | ||
[ | ||
'Besoin en Fonds de Roulement', | ||
...bilans.map((item) => | ||
formatCurrency(item.besoinEnFondsDeRoulement) | ||
), | ||
], | ||
[ | ||
'Capacité d’Autofinancement', | ||
...bilans.map((item) => | ||
formatCurrency(item.capaciteAutofinancement) | ||
), | ||
], | ||
[ | ||
'Dettes 4 maturité à un an au plus', | ||
...bilans.map((item) => | ||
formatCurrency(item.dettes4MaturiteAUnAnAuPlus) | ||
), | ||
], | ||
[ | ||
'Disponibilités', | ||
...bilans.map((item) => formatCurrency(item.disponibilites)), | ||
], | ||
|
||
[ | ||
'Excédent Brut d’Exploitation', | ||
...bilans.map((item) => | ||
formatCurrency(item.excedentBrutExploitation) | ||
), | ||
], | ||
[ | ||
'Fonds de Roulement Net Global', | ||
...bilans.map((item) => | ||
formatCurrency(item.fondsRoulementNetGlobal) | ||
), | ||
], | ||
[ | ||
'Ratio Fonds de Roulement Net Global sur Besoin en Fonds de Roulement', | ||
...bilans.map((item) => | ||
formatCurrency( | ||
item.ratioFondsRoulementNetGlobalSurBesoinEnFondsDeRoulement | ||
) | ||
), | ||
], | ||
[ | ||
'Total Dettes Stables', | ||
...bilans.map((item) => formatCurrency(item.totalDettesStables)), | ||
], | ||
[ | ||
'Valeur ajoutée BDF', | ||
...bilans.map((item) => formatCurrency(item.valeurAjouteeBdf)), | ||
], | ||
]; | ||
|
||
return ( | ||
<FullTable | ||
head={[ | ||
<FAQLink tooltipLabel="Indicateurs" to="/faq/donnees-financieres"> | ||
Définition des indicateurs | ||
</FAQLink>, | ||
...bilans.map((item) => item.annee), | ||
]} | ||
body={body} | ||
/> | ||
); | ||
}} | ||
</AsyncDataSectionClient> | ||
); | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@XavierJp
I've added a 3 years old condition.