Skip to content

Commit

Permalink
feat: implements rne and insee source lastModified dates (#1398)
Browse files Browse the repository at this point in the history
* feat: implements rne and insee source lastModified dates

* feat: add sources

* feat: implements rne and insee source lastModified dates

* feat: add sources

* refactor: data sources last modified - only for rne and idcc

* chore: re merge with main
  • Loading branch information
XavierJp authored Dec 16, 2024
1 parent 1f693ec commit 22513b8
Show file tree
Hide file tree
Showing 18 changed files with 216 additions and 147 deletions.
12 changes: 10 additions & 2 deletions app/(header-default)/divers/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import ConventionsCollectivesSection from '#components/conventions-collectives-s
import Title from '#components/title-section';
import { FICHE } from '#components/title-section/tabs';
import { getAllIdccWithMetadata } from '#models/conventions-collectives';
import { getRechercheEntrepriseSourcesLastModified } from '#models/recherche-entreprise-modified';
import {
uniteLegalePageDescription,
uniteLegalePageTitle,
Expand Down Expand Up @@ -33,7 +34,11 @@ export const generateMetadata = async (
export default async function ConventionCollectivePage(props: AppRouterProps) {
const session = await getSession();
const { slug, page, isBot } = await extractParamsAppRouter(props);
const uniteLegale = await cachedGetUniteLegale(slug, isBot, page);

const [uniteLegale, sourcesLastModified] = await Promise.all([
cachedGetUniteLegale(slug, isBot, page),
getRechercheEntrepriseSourcesLastModified(),
]);

const ccWithMetadata = await getAllIdccWithMetadata(uniteLegale.siren);

Expand All @@ -44,7 +49,10 @@ export default async function ConventionCollectivePage(props: AppRouterProps) {
uniteLegale={uniteLegale}
session={session}
/>
<ConventionsCollectivesSection ccWithMetadata={ccWithMetadata} />
<ConventionsCollectivesSection
ccWithMetadata={ccWithMetadata}
ccLastModified={sourcesLastModified.idcc}
/>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import FAQLink from '#components-ui/faq-link';
import { INPI } from '#components/administrations';
import { DataInpiLinkWithExplanations } from '#components/justificatifs/data-inpi-link';
import { DataSection } from '#components/section/data-section';
import { Section } from '#components/section';
import { TwoColumnTable } from '#components/table/simple';
import { EAdministration } from '#models/administrations/EAdministration';
import { IUniteLegale } from '#models/core/types';
Expand All @@ -17,114 +17,113 @@ const formatDateCloture = (DDMM: string) => {

export const UniteLegaleImmatriculationSection = ({
uniteLegale,
rneLastModified,
session,
}: {
uniteLegale: IUniteLegale;
rneLastModified: string | null;
session: ISession | null;
}) => {
const immatriculation = uniteLegale.immatriculation;

if (!immatriculation) {
return null;
}

return (
<DataSection
<Section
title="Immatriculation au RNE"
id="immatriculation-rne"
sources={[EAdministration.INPI]}
data={immatriculation}
notFoundInfo={null}
lastModified={rneLastModified}
>
{(immatriculation) => (
<>
<p>
Cette structure est une entreprise immatriculée au{' '}
<strong>Registre National des Entreprises (RNE)</strong>. Ce
registre liste les entreprises de France. Il est tenu par l’
<INPI />.
</p>
<TwoColumnTable
body={[
...(immatriculation
? [
[
'Date d’immatriculation',
formatDate(immatriculation?.dateImmatriculation),
],
[
'Date de début d’activité',
formatDate(immatriculation?.dateDebutActivite),
],
[
'Nature de l’entreprise',
(immatriculation?.natureEntreprise || []).join(', '),
],
...(immatriculation?.isPersonneMorale
? [
[
<FAQLink tooltipLabel="Capital social">
Le capital social d’une société est constitué des
apports (en argent ou en nature) de ses
actionnaires.
<br />
Il peut être fixe ou variable. La modification
d’un capital fixe nécessite une modification des
statuts tandis que le capital variable peut varier
dans certaines limites sans modification des
statuts.
</FAQLink>,
immatriculation?.capital,
],
[
'Clôture de l’exercice comptable',
formatDateCloture(immatriculation?.dateCloture),
],
]
: []),
...(immatriculation?.duree
? [
[
'Durée de la personne morale',
`${immatriculation?.duree} ans${
immatriculation?.dateFin
? `, jusqu’au ${immatriculation?.dateFin}`
: ''
}`,
],
]
: []),
...(immatriculation?.dateRadiation
? [
[
'Date de radiation',
formatDate(immatriculation?.dateRadiation),
],
]
: []),
[
'Dirigeants',
<a href={`/dirigeants/${uniteLegale.siren}`}>
→ Consulter la liste des dirigeants
</a>,
],
[
<FAQLink tooltipLabel="Annonces et observations">
Les annonces BODACC et les observations au RNE assurent
la publicité des actes enregistrés pour une entreprise
(procédures collectives, ventes, créations,
modification, radiation et dépôt des comptes)
</FAQLink>,
<a href={`/dirigeants/${uniteLegale.siren}`}>
→ Consulter les annonces
</a>,
],
]
: []),
]}
/>
<DataInpiLinkWithExplanations
uniteLegale={uniteLegale}
session={session}
/>
</>
)}
</DataSection>
<p>
Cette structure est une entreprise immatriculée au{' '}
<strong>Registre National des Entreprises (RNE)</strong>. Ce registre
liste les entreprises de France. Il est tenu par l’
<INPI />.
</p>
<TwoColumnTable
body={[
...(immatriculation
? [
[
'Date d’immatriculation',
formatDate(immatriculation?.dateImmatriculation),
],
[
'Date de début d’activité',
formatDate(immatriculation?.dateDebutActivite),
],
[
'Nature de l’entreprise',
(immatriculation?.natureEntreprise || []).join(', '),
],
...(immatriculation?.isPersonneMorale
? [
[
<FAQLink tooltipLabel="Capital social">
Le capital social d’une société est constitué des
apports (en argent ou en nature) de ses actionnaires.
<br />
Il peut être fixe ou variable. La modification d’un
capital fixe nécessite une modification des statuts
tandis que le capital variable peut varier dans
certaines limites sans modification des statuts.
</FAQLink>,
immatriculation?.capital,
],
[
'Clôture de l’exercice comptable',
formatDateCloture(immatriculation?.dateCloture),
],
]
: []),
...(immatriculation?.duree
? [
[
'Durée de la personne morale',
`${immatriculation?.duree} ans${
immatriculation?.dateFin
? `, jusqu’au ${immatriculation?.dateFin}`
: ''
}`,
],
]
: []),
...(immatriculation?.dateRadiation
? [
[
'Date de radiation',
formatDate(immatriculation?.dateRadiation),
],
]
: []),
[
'Dirigeants',
<a href={`/dirigeants/${uniteLegale.siren}`}>
→ Consulter la liste des dirigeants
</a>,
],
[
<FAQLink tooltipLabel="Annonces et observations">
Les annonces BODACC et les observations au RNE assurent la
publicité des actes enregistrés pour une entreprise
(procédures collectives, ventes, créations, modification,
radiation et dépôt des comptes)
</FAQLink>,
<a href={`/dirigeants/${uniteLegale.siren}`}>
→ Consulter les annonces
</a>,
],
]
: []),
]}
/>
<DataInpiLinkWithExplanations
uniteLegale={uniteLegale}
session={session}
/>
</Section>
);
};
7 changes: 6 additions & 1 deletion app/(header-default)/entreprise/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
isCollectiviteTerritoriale,
isServicePublic,
} from '#models/core/types';
import { getRechercheEntrepriseSourcesLastModified } from '#models/recherche-entreprise-modified';
import { ApplicationRights, hasRights } from '#models/user/rights';
import {
shouldNotIndex,
Expand Down Expand Up @@ -54,7 +55,10 @@ export default async function UniteLegalePage(props: AppRouterProps) {
props
);
const session = await getSession();
const uniteLegale = await cachedGetUniteLegale(slug, isBot, page);
const [uniteLegale, sourcesLastModified] = await Promise.all([
cachedGetUniteLegale(slug, isBot, page),
getRechercheEntrepriseSourcesLastModified(),
]);

return (
<>
Expand Down Expand Up @@ -84,6 +88,7 @@ export default async function UniteLegalePage(props: AppRouterProps) {
{uniteLegale.dateMiseAJourInpi && (
<UniteLegaleImmatriculationSection
uniteLegale={uniteLegale}
rneLastModified={sourcesLastModified.rne}
session={session}
/>
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import routes from '#clients/routes';
import { MetadataStore } from '.';
import { DataStore } from '../store';

type InclusionMetadata = { id: string; name: string; parent: string };

Expand All @@ -10,7 +10,7 @@ function mapToDomainObject(response: { results: InclusionMetadata[] }) {
}, {} as { [kind: string]: InclusionMetadata });
}

const store = new MetadataStore<InclusionMetadata>(
const store = new DataStore<InclusionMetadata>(
routes.certifications.entrepriseInclusive.api.metadata,
'inclusion-metadata',
mapToDomainObject
Expand Down
31 changes: 0 additions & 31 deletions clients/metadata-store/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import routes from '#clients/routes';
import { ICCWithMetadata } from '#models/conventions-collectives';
import { MetadataStore } from '.';
import { DataStore } from '../store';

type IIdccMetadata = {
[idcc: string]: {
Expand Down Expand Up @@ -33,7 +33,7 @@ function mapToDomainObject(response: IIdccMetadata) {
}, {} as { [idcc: string]: ICCWithMetadata });
}

const store = new MetadataStore<ICCWithMetadata>(
const store = new DataStore<ICCWithMetadata>(
routes.rechercheEntreprise.idcc.metadata,
'idcc-metadata',
mapToDomainObject
Expand Down
21 changes: 21 additions & 0 deletions clients/recherche-entreprise/last-modified.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import routes from '#clients/routes';
import { DataStore } from '../store';

const store = new DataStore<string>(
routes.rechercheEntreprise.lastModified,
'recherche-entreprise-last-modified',
(response) => response
);

/**
* Returns the dates of last modification of the data sources used in recherche entreprise
*
* For instance :
* IDCC was published on 29/11, we indexed it on 12/12, then last modified date is 29/11
*/
export const clientRechercheEntrepriseLastModified = async () => {
return {
rne: (await store.get('rne')) ?? null,
idcc: (await store.get('convention_collective')) ?? null,
};
};
2 changes: 2 additions & 0 deletions clients/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ const routes = {
metadata: 'https://recherche-entreprises.api.gouv.fr/idcc/metadata',
siren: 'https://recherche-entreprises.api.gouv.fr/idcc',
},
lastModified:
'https://recherche-entreprises.api.gouv.fr/sources/last_modified',
},
tooling: {
grist: 'https://grist.numerique.gouv.fr/api/docs/',
Expand Down
Loading

0 comments on commit 22513b8

Please sign in to comment.