-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip: modularisation du modele-social
- Loading branch information
1 parent
ee6753e
commit 0667290
Showing
17 changed files
with
726 additions
and
7 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,70 @@ | ||
|
||
|
||
|
||
### Documentation et apprentissage | ||
|
||
La documentation de publicodes est disponible sur https://publi.codes. | ||
|
||
Un wiki contenant des informations intéressantes sur publicodes et le | ||
raisonnement ayant abouti à ce langage sont dispos sur le repository | ||
[betagouv/publicodes](https://github.com/betagouv/publicodes/wiki) | ||
|
||
Pour se familiariser avec les règles, vous pouvez jeter un œil aux fichiers | ||
contenant les règles elles-mêmes (dans le dossier `modele-social`) mais cela | ||
peut s'avérer assez abrupt. | ||
|
||
Essayez plutôt de jeter un œil [aux tests](https://github.com/betagouv/publicodes/tree/master/core/test/m%C3%A9canismes) | ||
dans un premier temps, et pourquoi pas à [à l'implémentation des mécanismes](https://github.com/betagouv/publicodes/tree/master/core/source/mecanisms). | ||
|
||
### Traduction des normes (lois) en règles Publicodes | ||
|
||
Checklist : | ||
|
||
- [ ] Lire les articles de vulgarisation (sur le site de l'URSSAF, des impôts, etc.). | ||
- [ ] Utiliser un moteur de recherche spécialisé, comme [RFPaye](https://rfpaye.grouperf.com/). | ||
- [ ] Lire les normes et noter leurs références dans les règles Publicodes. | ||
|
||
### Développement de modele-social et de mon-entreprise | ||
|
||
Pour développer les règles de `modele-social` et tester en temps réel sur les simulateurs de mon-entreprise, il vous faut lancer la commande suivantes : | ||
|
||
```sh | ||
yarn start | ||
``` | ||
|
||
Les règles s'actualiseront automatiquement et le site se rechargera à chaque modification. | ||
|
||
|
||
### Tests | ||
|
||
Pour tester les règles, il est recommandé de : | ||
|
||
- faire tourner un simulateur et vérifier à la main l'adéquation des règles avec les normes | ||
traduites ; | ||
- créer des cas de tests de non-régression sous la forme de nouveaux snapshots (cf. | ||
`site/test/regressions`). | ||
|
||
### Développement simultané de Publicodes et de mon-entreprise | ||
|
||
Il est parfois utile de tester des évolutions de publicodes sur mon-entreprise. C'est possible de la manière suivante : | ||
|
||
- cloner les deux dépôts | ||
- sur le dépôt `publicodes` lancer un `yarn build --watch` pour avoir du rechargement à chaud | ||
- sur le dépôt `mon-entreprise` lancer un `yarn link ../publicodes --all` pour lier dynamiquement les paquets `publicodes` et `@publicodes/react-ui` | ||
|
||
La commande yarn link prend en paramètre un chemin relatif au dépôt courant, et fonctionne uniquement en local. | ||
|
||
Pour revenir au paquet publié sur NPM il faut utiliser : | ||
|
||
```sh | ||
yarn unlink --all | ||
``` | ||
|
||
Pour déployer une version preview de mon-entreprise utilisant une version de publicodes non publiée sur NPM il est possible de référencer un commit ou une branche dans l'attribut résolution du `package.json` : | ||
|
||
```json | ||
{ | ||
"publicodes": "betagouv/publicodes#head=refacto&workspace=publicodes", | ||
"@publicodes/react-ui": "betagouv/publicodes#head=refacto&workspace=@publicodes/react-ui" | ||
} | ||
``` |
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,31 @@ | ||
# Modèle social français en publicodes | ||
|
||
Ce paquet contient les règles [publicodes](https://publi.codes) utilisées sur https://mon-entreprise.urssaf.fr | ||
pour le calcul des cotisations sociales, des impôts et des droits sociaux. | ||
|
||
### Installation | ||
|
||
``` | ||
npm install publicodes modele-social | ||
``` | ||
|
||
### Exemple d'utilisation | ||
|
||
```js | ||
import Engine, { formatValue } from 'publicodes' | ||
import rules from 'modele-social' | ||
|
||
const engine = new Engine(rules) | ||
|
||
const net = engine | ||
.setSituation({ | ||
'salarié . contrat . salaire brut': '3000 €/mois', | ||
}) | ||
.evaluate('salarié . rémunération . net . à payer avant impôt') | ||
|
||
console.log(formatValue(net)) | ||
``` | ||
|
||
👉 **[Voir le tutoriel complet](https://mon-entreprise.urssaf.fr/d%C3%A9veloppeur/biblioth%C3%A8que-de-calcul)** | ||
|
||
👉 **[Voir toutes les règles de mon-entreprise](https://mon-entreprise.urssaf.fr/documentation)** |
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,11 @@ | ||
import path from 'path' | ||
import { fileURLToPath } from 'url' | ||
|
||
import { buildRules } from '../scripts/build-rules.js' | ||
|
||
const __dirname = path.dirname(fileURLToPath(import.meta.url)) | ||
|
||
buildRules( | ||
path.resolve(__dirname, './règles'), | ||
path.resolve(__dirname, './dist') | ||
) |
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,35 @@ | ||
{ | ||
"name": "@modele-social/economie-collaborative", | ||
"version": "0.0.1", | ||
"description": "Les règles sociales pour les activités d’économie collaborative", | ||
"type": "module", | ||
"main": "./dist/index.js", | ||
"module": "dist/index.js", | ||
"types": "./index.d.ts", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/betagouv/mon-entreprise.git" | ||
}, | ||
"bugs": "https://github.com/betagouv/mon-entreprise/issues", | ||
"homepage": "https://mon-entreprise.urssaf.fr", | ||
"license": "MIT", | ||
"files": [ | ||
"dist", | ||
"index.d.ts" | ||
], | ||
"devDependencies": { | ||
"js-yaml": "^4.1.0", | ||
"onchange": "^7.1.0" | ||
}, | ||
"peerDependencies": { | ||
"publicodes": "^1.0.4" | ||
}, | ||
"scripts": { | ||
"build": "node ./build-rules.js && echo 'ℹ️ @modele-social/economie-collaborative compilé'", | ||
"start": "yarn run build && onchange 'règles/**/*.publicodes' -- yarn run build && echo 'ℹ️ @modele-social/economie-collaborative compilé'", | ||
"clean": "rimraf dist node_modules", | ||
"prepack": "yarn run build", | ||
"up": "yarn version --minor && echo \"ℹ N'oubliez pas de poussez le tag git\"", | ||
"test": "node ../scripts/check-changelog.js" | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
@modele-social/economie-collaborative/règles/index.publicodes
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,8 @@ | ||
importer!: | ||
depuis: | ||
nom: '@modele-social/legacy' | ||
source: "../../legacy/règles" | ||
dans: legacy | ||
|
||
tata: | ||
valeur: 2 |
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,7 @@ | ||
{ | ||
"compilerOptions": { | ||
"allowJs": true, | ||
"noEmit": true, | ||
"strict": true | ||
} | ||
} |
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,11 @@ | ||
import path from 'path' | ||
import { fileURLToPath } from 'url' | ||
|
||
import { buildRules } from '../scripts/build-rules.js' | ||
|
||
const __dirname = path.dirname(fileURLToPath(import.meta.url)) | ||
|
||
buildRules( | ||
path.resolve(__dirname, './règles'), | ||
path.resolve(__dirname, './dist') | ||
) |
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,35 @@ | ||
{ | ||
"name": "@modele-social/legacy", | ||
"version": "0.0.1", | ||
"description": "Paquet de règles sociales à découper…", | ||
"type": "module", | ||
"main": "./dist/index.js", | ||
"module": "dist/index.js", | ||
"types": "./index.d.ts", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/betagouv/mon-entreprise.git" | ||
}, | ||
"bugs": "https://github.com/betagouv/mon-entreprise/issues", | ||
"homepage": "https://mon-entreprise.urssaf.fr", | ||
"license": "MIT", | ||
"files": [ | ||
"dist", | ||
"index.d.ts" | ||
], | ||
"devDependencies": { | ||
"js-yaml": "^4.1.0", | ||
"onchange": "^7.1.0" | ||
}, | ||
"peerDependencies": { | ||
"publicodes": "^1.6.1" | ||
}, | ||
"scripts": { | ||
"build": "node ./build-rules.js && echo 'ℹ️ @modele-social/legacy compilé'", | ||
"start": "yarn run build && onchange 'règles/**/*.publicodes' -- yarn run build && echo 'ℹ️ @modele-social/legacy compilé'", | ||
"clean": "rimraf dist node_modules", | ||
"prepack": "yarn run build", | ||
"up": "yarn version --minor && echo \"ℹ N'oubliez pas de poussez le tag git\"", | ||
"test": "node ../scripts/check-changelog.js" | ||
} | ||
} |
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 @@ | ||
toto: 1 |
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,7 @@ | ||
{ | ||
"compilerOptions": { | ||
"allowJs": true, | ||
"noEmit": true, | ||
"strict": true | ||
} | ||
} |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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