diff --git a/src/routes/calculations/index.svelte b/src/routes/calculations/index.svelte new file mode 100644 index 0000000000000000000000000000000000000000..e83992d8c8970889ea28e6e9a3113bfc31cde4db --- /dev/null +++ b/src/routes/calculations/index.svelte @@ -0,0 +1,71 @@ +<script context="module" lang="ts"> + export async function load({ page, fetch, session, context }) { + const url = "https://fr.openfisca.org/api/latest/calculate"; + const situation = { + individus: { + Claude: { + salaire_de_base: { + "2017": 20000, + }, + }, + Dominique: { + salaire_de_base: { + "2017": 30000, + }, + }, + Camille: {}, + }, + menages: { + menage_1: { + personne_de_reference: ["Claude"], + conjoint: ["Dominique"], + enfants: ["Camille"], + revenu_disponible: { + "2017": null, + }, + impots_directs: { + "2017": null, + }, + }, + }, + familles: { + famille_1: { + parents: ["Claude", "Dominique"], + enfants: ["Camille"], + }, + }, + foyers_fiscaux: { + foyer_fiscal_1: { + declarants: ["Claude", "Dominique"], + personnes_a_charge: ["Camille"], + }, + }, + }; + const res = await fetch(url, { + body: JSON.stringify(situation, null, 2), + headers: { + "Content-Type": "application/json", + }, + method: "POST", + }); + + if (res.ok) { + return { + props: { + simulation: await res.json(), + }, + }; + } + + return { + status: res.status, + error: new Error(`Could not load ${url}`), + }; + } +</script> + +<script lang="ts"> + export let simulation: any; +</script> + +<pre>{JSON.stringify(simulation, null, 2)}</pre> diff --git a/src/routes/entities/index.svelte b/src/routes/entities/index.svelte new file mode 100644 index 0000000000000000000000000000000000000000..f0e710b81bb5acd75e265977c781ced55aa1ad1c --- /dev/null +++ b/src/routes/entities/index.svelte @@ -0,0 +1,25 @@ +<script context="module" lang="ts"> + export async function load({ page, fetch, session, context }) { + const url = "https://fr.openfisca.org/api/latest/entities"; + const res = await fetch(url); + + if (res.ok) { + return { + props: { + entityById: await res.json() + } + }; + } + + return { + status: res.status, + error: new Error(`Could not load ${url}`) + }; + } +</script> + +<script lang="ts"> + export let entityById: any +</script> + +<pre>{JSON.stringify(entityById, null, 2)}</pre> \ No newline at end of file diff --git a/src/routes/index.svelte b/src/routes/index.svelte index d23ba33ce7ece95d12cd31196db459a670d5de45..88429daaa1e69b5d362750c9a83c1f589185b1c9 100644 --- a/src/routes/index.svelte +++ b/src/routes/index.svelte @@ -42,13 +42,20 @@ </style> <main> - <h1>Hello world!</h1> + <h1>Simulateur socio-fiscal Leximpact</h1> <Counter /> - <p> - Visit - <a class="text-blue-600 underline" href="https://svelte.dev">svelte.dev</a> - to learn how to build Svelte apps. - </p> + <h2>Usage</h2> + <ul> + <li><a href="calculations">Calculations</a></li> + <li><a href="entities">Entities</a></li> + <li><a href="parameters">Parameters</a></li> + <li><a href="variables">Variables</a></li> + </ul> + + <h2>Documentation</h2> + <ul> + <li><a href="spec">API documentation</a></li> + </ul> </main> diff --git a/src/routes/parameters/index.svelte b/src/routes/parameters/index.svelte new file mode 100644 index 0000000000000000000000000000000000000000..9d7000d01d8fa308fc430eb0f03d8335152dec5d --- /dev/null +++ b/src/routes/parameters/index.svelte @@ -0,0 +1,25 @@ +<script context="module" lang="ts"> + export async function load({ page, fetch, session, context }) { + const url = "https://fr.openfisca.org/api/latest/parameters"; + const res = await fetch(url); + + if (res.ok) { + return { + props: { + parameterById: await res.json() + } + }; + } + + return { + status: res.status, + error: new Error(`Could not load ${url}`) + }; + } +</script> + +<script lang="ts"> + export let parameterById: any +</script> + +<pre>{JSON.stringify(parameterById, null, 2)}</pre> \ No newline at end of file diff --git a/src/routes/spec.svelte b/src/routes/spec.svelte new file mode 100644 index 0000000000000000000000000000000000000000..3b6adba0c20e1546e05ed56d0c2a3a4d228f8009 --- /dev/null +++ b/src/routes/spec.svelte @@ -0,0 +1,25 @@ +<script context="module" lang="ts"> + export async function load({ page, fetch, session, context }) { + const url = "https://fr.openfisca.org/api/latest/spec"; + const res = await fetch(url); + + if (res.ok) { + return { + props: { + spec: await res.json() + } + }; + } + + return { + status: res.status, + error: new Error(`Could not load ${url}`) + }; + } +</script> + +<script lang="ts"> + export let spec: any +</script> + +<pre>{JSON.stringify(spec, null, 2)}</pre> \ No newline at end of file diff --git a/src/routes/variables/index.svelte b/src/routes/variables/index.svelte new file mode 100644 index 0000000000000000000000000000000000000000..a73655606e9f48ae42dfa62c37863fed53db16c0 --- /dev/null +++ b/src/routes/variables/index.svelte @@ -0,0 +1,25 @@ +<script context="module" lang="ts"> + export async function load({ page, fetch, session, context }) { + const url = "https://fr.openfisca.org/api/latest/variables"; + const res = await fetch(url); + + if (res.ok) { + return { + props: { + variableById: await res.json() + } + }; + } + + return { + status: res.status, + error: new Error(`Could not load ${url}`) + }; + } +</script> + +<script lang="ts"> + export let variableById: any +</script> + +<pre>{JSON.stringify(variableById, null, 2)}</pre> \ No newline at end of file