Skip to content
Snippets Groups Projects
Select Git revision
  • 1de4fa3531534cb1f6eab3b2953af6b9a7cd5e83
  • master default protected
  • ajout_ppa_rsa_budgetaire
  • 365-ouvrir-l-onglet-employeur-ou-taxes-carburant-quand-c-est-le-cas-pour-un-dispositif
  • 381-pb-affichage-labels-des-parametres-sur-plus-de-3-lignes
  • ajoute-duplicate-aide-logement
  • poc_castype_ia
  • parametres-editables-budget
  • ui-parametres
  • 366-signe-a-cote-du-droit-en-vigueur-sur-l-ui-pour-indiquer-que-la-reforme-a-eu-lieu-mais-qu-elle-n
  • 355-les-dispositifs-prestations-sociales-du-graphique-se-cachent-montrent-en-meme-temps-2
  • 358-les-variables-dont-le-montant-est-nul-apparaissent-en-bleu-et-non-cliquables
  • 356-ajuster-la-largeur-sur-les-graphiques-budgetaires
  • incoherence_cas_type_0
  • fix-ui-suppression-tranches-baremes
  • ajout-agregat-cehr-version-plf
  • impact_carbone
  • xlsx
  • header_revamp
  • 270-concevoir-la-page-d-accueil-leximpact
  • 219-conversion-des-montants-min-et-max-de-l-axe-des-x-en-smic
  • 0.0.1123
  • 0.0.1122
  • 0.0.1121
  • 0.0.1120
  • 0.0.1119
  • 0.0.1118
  • 0.0.1117
  • 0.0.1116
  • 0.0.1115
  • 0.0.1114
  • 0.0.1113
  • 0.0.1112
  • 0.0.1111
  • 0.0.1110
  • 0.0.1109
  • 0.0.1108
  • 0.0.1107
  • 0.0.1106
  • 0.0.1105
  • 0.0.1104
41 results

shared.svelte.ts

Blame
  • shared.svelte.ts 3.75 KiB
    import "intro.js/introjs.css"
    
    import { type Waterfall } from "@openfisca/json-model"
    import "iconify-icon"
    
    import type { BudgetSimulation } from "$lib/budgets"
    import {
      buildDecompositionByNameFromCore,
      decompositionCoreByName,
      decompositionCoreByNameByReformName,
      waterfalls,
      type EvaluationByName,
      type DecompositionByName,
    } from "$lib/decompositions"
    import type { DisplayMode } from "$lib/displays"
    import { trackTestCaseShowAllVariables } from "$lib/matomo"
    import { getNavbarConfig, type NavbarConfig } from "$lib/navbar"
    import publicConfig from "$lib/public_config"
    import { type ParametricReform, reformMetadataByName } from "$lib/reforms"
    import {
      extractInputInstantsFromTestCases,
      testCasesCore,
      type Axis,
      type CalculationByName,
      type Situation,
    } from "$lib/situations"
    import { type ValuesByCalculationNameByVariableName } from "$lib/variables"
    
    export interface Shared {
      axes: Axis[][]
      displayMode?: DisplayMode
      budgetSimulation?: BudgetSimulation
      calculationByName: CalculationByName
      decompositionByName: DecompositionByName
      evaluationByNameArray: EvaluationByName[]
      inputInstantsByVariableNameArray: Array<{
        [name: string]: Set<string>
      }>
      navbarConfig: NavbarConfig
      parametricReform: ParametricReform
      requestedSimulationEmail?: string // Budget simulation requests
      requestedSimulationSent: boolean // Budget simulation requests
      requestedVariablesNameToCalculate?: Set<string> // Budget simulation requests
      searchActive: boolean // Search
      searchVariableName?: string // Search
      showNulls: boolean
      showTutorial: boolean
      testCases: Situation[]
      testCasesIndex: number[]
      valuesByCalculationNameByVariableNameArray: ValuesByCalculationNameByVariableName[]
      variableModalOpen: boolean
      vectorLength: number
      waterfall: Waterfall
    }
    
    const { reformName: reformBillName, revaluationName: reformRevaluationName } =
      publicConfig
    
    /**
     * Bill (PLF) and revaluation (contrefactuel)
     */
    
    export const billName: string | undefined =
      reformBillName === undefined
        ? undefined
        : reformMetadataByName[reformBillName] === undefined
          ? undefined
          : reformBillName
    export const billActive: boolean = billName !== undefined
    
    export const revaluationName: string | undefined =
      reformRevaluationName === undefined
        ? undefined
        : reformMetadataByName[reformRevaluationName] === undefined
          ? undefined
          : reformRevaluationName
    
    const today = new Date()
    export const year =
      today.getFullYear() + (today.getMonth() > 1 /* => After February */ ? 1 : 0)
    export const yearPLF =
      today.getFullYear() +
      (revaluationName !== undefined && today.getMonth() > 1 /* => After February */
        ? 1
        : 0)
    export const date = `${year}-01-01`
    export const budgetDate = `${yearPLF}-01-01`
    
    export const shared: Shared = $state({
      axes: [],
      calculationByName: {},
      // Note: We always use the reform decomposition, because it is more
      // complete than decomposition before reform.
      decompositionByName: buildDecompositionByNameFromCore(
        billName === undefined
          ? decompositionCoreByName
          : (decompositionCoreByNameByReformName[billName] ??
              decompositionCoreByName),
      ),
      evaluationByNameArray: new Array(testCasesCore.length).fill(
        {},
      ) as EvaluationByName[],
      inputInstantsByVariableNameArray:
        extractInputInstantsFromTestCases(testCasesCore),
      navbarConfig: getNavbarConfig("/"),
      parametricReform: {},
      requestedSimulationSent: false,
      searchActive: false,
      showNulls: false,
      showTutorial: false,
      testCases: structuredClone(testCasesCore),
      testCasesIndex: [],
      valuesByCalculationNameByVariableNameArray: new Array(
        testCasesCore.length,
      ).fill({}),
      variableModalOpen: false,
      vectorLength: 1,
      waterfall: waterfalls[0],
    })
    
    if (shared.showNulls) {
      trackTestCaseShowAllVariables()
    }