Skip to content

Commit

Permalink
feat(dgfip liasses fiscales): add dgfip liasses fiscales data
Browse files Browse the repository at this point in the history
  • Loading branch information
rmonnier9 committed Dec 29, 2024
1 parent d579b46 commit 1e4bb73
Show file tree
Hide file tree
Showing 8 changed files with 153 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/api/data-fetching/routes-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { getQualibat } from '#models/espace-agent/certificats/qualibat';
import { getQualifelec } from '#models/espace-agent/certificats/qualifelec';
import { getChiffreAffairesProtected } from '#models/espace-agent/chiffre-affaires';
import { getConformiteEntreprise } from '#models/espace-agent/conformite';
import { getLiassesFiscalesProtected } from '#models/espace-agent/dgfip/liasses-fiscales';
import { getDirigeantsProtected } from '#models/espace-agent/dirigeants-protected';
import { getEffectifsAnnuelsProtected } from '#models/espace-agent/effectifs/annuels';
import { getDocumentsRNEProtected } from '#models/espace-agent/rne-protected/documents';
Expand Down Expand Up @@ -38,6 +39,8 @@ export const APIRoutesHandlers = {
getEffectifsAnnuelsProtected,
[APIRoutesPaths.EspaceAgentChiffreAffairesProtected]:
getChiffreAffairesProtected,
[APIRoutesPaths.EspaceAgentLiassesFiscalesProtected]:
getLiassesFiscalesProtected,
[APIRoutesPaths.RneDirigeants]: getDirigeantsRNE,
[APIRoutesPaths.Observations]: getRNEObservations,
[APIRoutesPaths.Association]: getAssociationFromSlug,
Expand Down
1 change: 1 addition & 0 deletions app/api/data-fetching/routes-paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export enum APIRoutesPaths {
EspaceAgentAssociationProtected = 'espace-agent/association-protected',
EspaceAgentEffectifsAnnuelsProtected = 'espace-agent/effectifs-annuels-protected',
EspaceAgentChiffreAffairesProtected = 'espace-agent/chiffre-affaires-protected',
EspaceAgentLiassesFiscalesProtected = 'espace-agent/dgfip-liasses-fiscales-protected',
RneDirigeants = 'rne-dirigeants',
Observations = 'observations',
Association = 'association',
Expand Down
2 changes: 2 additions & 0 deletions app/api/data-fetching/routes-scopes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,6 @@ export const APIRoutesScopes: Record<APIRoutesPaths, ApplicationRights> = {
[APIRoutesPaths.EspaceAgentConformite]: ApplicationRights.conformite,
[APIRoutesPaths.EspaceAgentChiffreAffairesProtected]:
ApplicationRights.chiffreAffaires,
[APIRoutesPaths.EspaceAgentLiassesFiscalesProtected]:
ApplicationRights.protectedCertificats,
};
30 changes: 30 additions & 0 deletions clients/api-entreprise/dgfip/liasses-fiscales.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import routes from '#clients/routes';
import { ILiassesFiscalesProtected } from '#models/espace-agent/dgfip/liasses-fiscales';
import { Siren } from '#utils/helpers';
import clientAPIEntreprise from '../client';
import { IAPIEntrepriseLiassesFiscales } from './types';

/**
* GET association from API Entreprise
*/
export async function clientApiEntrepriseDgfipLiassesFiscales(siren: Siren) {
return await clientAPIEntreprise<
IAPIEntrepriseLiassesFiscales,
ILiassesFiscalesProtected
>(
`${
process.env.API_ENTREPRISE_URL
}${routes.apiEntreprise.dgfip.liassesFiscales(
siren,
//TEMP
2022
)}`,
mapToDomainObject
);
}

const mapToDomainObject = (
response: IAPIEntrepriseLiassesFiscales
): ILiassesFiscalesProtected => {
return response;
};
45 changes: 45 additions & 0 deletions clients/api-entreprise/dgfip/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { IAPIEntrepriseResponse } from '../client';

type Regime = {
code: string;
libelle: string;
};

type Donnee = {
code_nref: string;
valeurs: string[];
code_absolu: string;
intitule: string;
code_EDI: string;
code: string;
code_type_donnee: string;
};

type Declaration = {
numero_imprime: string;
regime: Regime;
date_declaration: string;
date_fin_exercice: string;
duree_exercice: number;
millesime: number;
donnees: Donnee[];
};

type ObligationFiscale = {
id: string;
code: string;
libelle: string | null;
reference: string | null;
regime: string;
};

export type IAPIEntrepriseLiassesFiscales = IAPIEntrepriseResponse<{
data: {
obligations_fiscales: ObligationFiscale[];
declarations: Declaration[];
};
links: Record<string, unknown>;
meta: {
internal_id_itip: string;
};
}>;
4 changes: 4 additions & 0 deletions clients/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ const routes = {
chiffreAffaires: (siret: string) =>
`/v3/dgfip/etablissements/${siret}/chiffres_affaires`,
},
dgfip: {

Check failure on line 40 in clients/routes.ts

View workflow job for this annotation

GitHub Actions / Install dependencies

An object literal cannot have multiple properties with the same name.
liassesFiscales: (siren: string, year: number) =>
`/v3/dgfip/unites_legales/${siren}/liasses_fiscales/${year}`,
},
mandatairesRCS: (siren: string) =>
`/v3/infogreffe/rcs/unites_legales/${siren}/mandataires_sociaux`,
effectifs: {
Expand Down
48 changes: 48 additions & 0 deletions cypress/fixtures/dgfip-liasses-fiscales.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"data": {
"obligations_fiscales": [
{
"id": "100209496193",
"code": "IS",
"libelle": "Impôt sur les sociétés",
"reference": null,
"regime": "RNMEMBRE"
},
{
"id": "101080892345",
"code": "ISGROUPE",
"libelle": null,
"reference": null,
"regime": "RNGROUPE"
}
],
"declarations": [
{
"numero_imprime": "2050",
"regime": {
"code": "RN",
"libelle": "Réel normal"
},
"date_declaration": "2023-07-24",
"date_fin_exercice": "2022-12-31",
"duree_exercice": 365,
"millesime": 201601,
"donnees": [
{
"code_nref": "300274",
"valeurs": ["222216704"],
"code_absolu": "2000321",
"intitule": "Concessions, brevets et droits similaires, brut",
"code_EDI": "AF:C516:5004:1",
"code": "AF",
"code_type_donnee": "MOA"
}
]
}
]
},
"links": {},
"meta": {
"internal_id_itip": "100008503160"
}
}
20 changes: 20 additions & 0 deletions models/espace-agent/dgfip/liasses-fiscales.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { clientApiEntrepriseDgfipLiassesFiscales } from '#clients/api-entreprise/dgfip/liasses-fiscales';
import { IAPIEntrepriseLiassesFiscales } from '#clients/api-entreprise/dgfip/types';
import { IAPINotRespondingError } from '#models/api-not-responding';
import { verifySiren } from '#utils/helpers';
import { handleApiEntrepriseError } from '../utils';

// TEMP
export type ILiassesFiscalesProtected = IAPIEntrepriseLiassesFiscales;

export const getLiassesFiscalesProtected = async (
maybeSiren: string
): Promise<ILiassesFiscalesProtected | IAPINotRespondingError> => {
const siren = verifySiren(maybeSiren);
return clientApiEntrepriseDgfipLiassesFiscales(siren).catch((error) =>
handleApiEntrepriseError(error, {
siren,
apiResource: 'getDgfipLiassesFiscalesProtected',
})
);
};

0 comments on commit 1e4bb73

Please sign in to comment.