-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dgfip liasses fiscales): add dgfip liasses fiscales data
- Loading branch information
Showing
8 changed files
with
153 additions
and
0 deletions.
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
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; | ||
}; |
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,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; | ||
}; | ||
}>; |
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,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" | ||
} | ||
} |
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,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', | ||
}) | ||
); | ||
}; |