From 815ff255eee6e87255ba33bdae6923dd676342ce Mon Sep 17 00:00:00 2001 From: Johan Girod Date: Tue, 24 Mar 2020 11:10:47 +0100 Subject: [PATCH 1/4] =?UTF-8?q?:fountain=5Fpen:=20corrige=20la=20doc=20pou?= =?UTF-8?q?r=20la=20r=C3=A9gularisatio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- publicode/mecanism.md | 12 +++++++++--- source/engine/mecanisms/régularisation.ts | 7 ++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/publicode/mecanism.md b/publicode/mecanism.md index 4fd40f923..085f5521a 100644 --- a/publicode/mecanism.md +++ b/publicode/mecanism.md @@ -159,6 +159,8 @@ brut: somme: - 2000 €/mois | du 01/01/2020 | au 31/05/2020 - 4000 €/mois | du 01/06/2020 | au 31/12/2020 +plafond: + formule: 3000 €/mois cotisation: formule: @@ -166,13 +168,17 @@ cotisation: règle: produit: assiette: brut - plafond: 3000€/mois + plafond: plafond taux: 10% valeurs cumulées: - brut + - plafond -cotisation en 2020: - formule: cotisation | du 01/01/2020 | au 31/12/2020 +cotisation en mai: + formule: cotisation | du 01/05/2020 | au 30/05/2020 + +cotisation en juin: + formule: cotisation | du 01/05/2020 | au 30/05/2020 ``` [Lancer le calcul](https://publi.codes/studio?code=brut%3A%0A%20%20formule%3A%0A%20%20%20%20somme%3A%0A%20%20%20%20%20%20-%202000%20%E2%82%AC%2Fmois%20%7C%20du%2001%2F01%2F2020%20%7C%20au%2031%2F05%2F2020%0A%20%20%20%20%20%20-%204000%20%E2%82%AC%2Fmois%20%7C%20du%2001%2F06%2F2020%20%7C%20au%2031%2F12%2F2020%0A%0Acotisation%3A%0A%20%20formule%3A%20%0A%20%20%20%20r%C3%A9gularisation%3A%0A%20%20%20%20%20%20r%C3%A8gle%3A%0A%20%20%20%20%20%20%20%20produit%3A%0A%20%20%20%20%20%20%20%20%20%20assiette%3A%20brut%0A%20%20%20%20%20%20%20%20%20%20plafond%3A%203000%E2%82%AC%2Fmois%0A%20%20%20%20%20%20%20%20%20%20taux%3A%2010%25%0A%20%20%20%20%20%20valeurs%20cumul%C3%A9es%3A%0A%20%20%20%20%20%20%20%20-%20brut%0A%0Acotisation%20en%202020%3A%0A%20%20formule%3A%0A%20%20%20%20cotisation%20%7C%20du%2001%2F01%2F2020%20%7C%20au%2031%2F12%2F2020%0A) diff --git a/source/engine/mecanisms/régularisation.ts b/source/engine/mecanisms/régularisation.ts index 8d9e74b86..c1d78a295 100644 --- a/source/engine/mecanisms/régularisation.ts +++ b/source/engine/mecanisms/régularisation.ts @@ -6,6 +6,7 @@ import { Evaluation, groupByYear, liftTemporal2, + pureTemporal, Temporal, temporalAverage, temporalCumul @@ -95,17 +96,17 @@ function evaluate( const cumulatedVariables = node.explanation.variables.reduce( (acc, parsedVariable) => { const evaluation = evaluate(parsedVariable) - if (!evaluation.temporalValue) { + if (!evaluation.unit.denominators.some(unit => unit === 'mois')) { evaluationError( cache._meta.contextRule, - `Dans le mécanisme régularisation, la valeur annuelle ${parsedVariable.name} n'est pas une variables temporelle` + `Dans le mécanisme régularisation, la valeur cumulée '${parsedVariable.name}' n'est pas une variable numérique définie sur le mois` ) } return { ...acc, [parsedVariable.dottedName]: getMonthlyCumulatedValuesOverYear( currentYear, - evaluation.temporalValue, + evaluation.temporalValue ?? pureTemporal(evaluation.nodeValue), evaluation.unit ) } From 0f1ca13b7fcb365e72c24b293f481f1fc73f7f5a Mon Sep 17 00:00:00 2001 From: Johan Girod Date: Tue, 24 Mar 2020 17:50:18 +0100 Subject: [PATCH 2/4] =?UTF-8?q?:fountain=5Fpen:=20Am=C3=A9liore=20la=20pag?= =?UTF-8?q?e=20de=20documentation=20de=20publicode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Ajoute le tuto - Rend tous les exemples executables --- source/components/Mecanisms.tsx | 4 +- source/components/rule/ColoredYaml.tsx | 11 - source/components/rule/Rule.js | 4 +- source/components/rule/RuleSource.tsx | 4 +- source/components/ui/PublicodeHighlighter.tsx | 21 ++ source/components/ui/index.css | 9 +- source/components/utils/markdown.tsx | 17 +- {publicode => source/engine}/README.md | 93 ++++-- source/engine/known-mecanisms.yaml | 219 ------------- source/engine/mecanisms.js | 28 +- source/engine/mecanisms.yaml | 308 ++++++++++++++++++ source/engine/mecanisms/barème.ts | 2 +- source/engine/mecanisms/grille.ts | 2 +- source/engine/mecanisms/tauxProgressif.ts | 2 +- source/sites/publi.codes/Header.js | 2 +- source/sites/publi.codes/Landing.js | 67 +--- source/sites/publi.codes/Mécanismes.tsx | 0 source/webpack.common.js | 4 + 18 files changed, 436 insertions(+), 361 deletions(-) delete mode 100644 source/components/rule/ColoredYaml.tsx create mode 100644 source/components/ui/PublicodeHighlighter.tsx rename {publicode => source/engine}/README.md (72%) delete mode 100644 source/engine/known-mecanisms.yaml create mode 100644 source/engine/mecanisms.yaml create mode 100644 source/sites/publi.codes/Mécanismes.tsx diff --git a/source/components/Mecanisms.tsx b/source/components/Mecanisms.tsx index 62ad97a6f..6293fc3e1 100644 --- a/source/components/Mecanisms.tsx +++ b/source/components/Mecanisms.tsx @@ -1,5 +1,5 @@ // Page listing the engine's currently implemented mecanisms and their tests -import knownMecanims from 'Engine/known-mecanisms.yaml' +import mécanismes from 'Engine/mecanisms.yaml' import { fromPairs, has, toPairs } from 'ramda' import React from 'react' import './Mecanisms.css' @@ -24,7 +24,7 @@ export default function Mecanisms() { partageant le code de mecanisms.test.js