Nettoyage des règles de la SASU
parent
12bba5fe9a
commit
b867c215c0
|
@ -17,7 +17,8 @@ let nestedSituationToStateSelector = nestedSituation => dottedName =>
|
|||
...nestedSituationToPathMap(nestedSituation)
|
||||
}[dottedName])
|
||||
|
||||
let enrichYaml = string => yaml.safeLoad(string).map(enrichRule)
|
||||
let enrichRules = input =>
|
||||
(typeof input === 'string' ? yaml.safeLoad(input) : input).map(enrichRule)
|
||||
|
||||
export default {
|
||||
evaluate: (targetNames, nestedSituation, rulesConfig) => {
|
||||
|
@ -25,8 +26,8 @@ export default {
|
|||
? do {
|
||||
let { base, extra } = rulesConfig
|
||||
parseAll([
|
||||
...(base ? enrichYaml(base) : rulesFr),
|
||||
...(extra ? enrichYaml(extra) : [])
|
||||
...(base ? enrichRules(base) : rulesFr),
|
||||
...(extra ? enrichRules(extra) : [])
|
||||
])
|
||||
}
|
||||
: defaultRules
|
||||
|
|
|
@ -41,31 +41,35 @@ import taux_versement_transport from 'Règles/taux-versement-transport.json'
|
|||
|
||||
// Enrichissement de la règle avec des informations évidentes pour un lecteur humain
|
||||
export let enrichRule = (rule, sharedData = {}) => {
|
||||
let type = possibleVariableTypes.find(t => has(t, rule) || rule.type === t),
|
||||
name = rule['nom'],
|
||||
title = capitalise0(rule['titre'] || name),
|
||||
ns = rule['espace'],
|
||||
data = rule['données'] ? sharedData[rule['données']] : null,
|
||||
dottedName = buildDottedName(rule),
|
||||
subquestionMarkdown = rule['sous-question'],
|
||||
subquestion = subquestionMarkdown && marked(subquestionMarkdown),
|
||||
defaultValue = rule['par défaut'],
|
||||
examples = rule['exemples'],
|
||||
icon = rule['icônes']
|
||||
try {
|
||||
let type = possibleVariableTypes.find(t => has(t, rule) || rule.type === t),
|
||||
name = rule['nom'],
|
||||
title = capitalise0(rule['titre'] || name),
|
||||
ns = rule['espace'],
|
||||
data = rule['données'] ? sharedData[rule['données']] : null,
|
||||
dottedName = buildDottedName(rule),
|
||||
subquestionMarkdown = rule['sous-question'],
|
||||
subquestion = subquestionMarkdown && marked(subquestionMarkdown),
|
||||
defaultValue = rule['par défaut'],
|
||||
examples = rule['exemples'],
|
||||
icon = rule['icônes']
|
||||
|
||||
return {
|
||||
...rule,
|
||||
type,
|
||||
name,
|
||||
title,
|
||||
ns,
|
||||
data,
|
||||
dottedName,
|
||||
subquestion,
|
||||
defaultValue,
|
||||
raw: rule,
|
||||
examples,
|
||||
icon
|
||||
return {
|
||||
...rule,
|
||||
type,
|
||||
name,
|
||||
title,
|
||||
ns,
|
||||
data,
|
||||
dottedName,
|
||||
subquestion,
|
||||
defaultValue,
|
||||
raw: rule,
|
||||
examples,
|
||||
icon
|
||||
}
|
||||
} catch (e) {
|
||||
throw new Error('Problem enriching ' + JSON.stringify(rule))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,49 +1,57 @@
|
|||
- nom: chiffre d'affaire
|
||||
|
||||
- nom: chiffre affaire
|
||||
format: euros
|
||||
|
||||
- nom: charges
|
||||
par defaut: 0
|
||||
format: euros
|
||||
|
||||
- nom: repartition salaire sur dividendes
|
||||
par defaut: 100%
|
||||
- nom: répartition salaire sur dividendes
|
||||
par defaut: 1
|
||||
|
||||
- nom: impot sur les societes
|
||||
|
||||
- nom: impôt sur les sociétés
|
||||
formule:
|
||||
bareme:
|
||||
assiette: benefices
|
||||
barème:
|
||||
assiette: dividendes . brut
|
||||
tranches:
|
||||
- en-dessous de: 38000
|
||||
taux: 15%
|
||||
- au-dessus de: 38000
|
||||
taux: 28%
|
||||
taux: 15%
|
||||
- au-dessus de: 38000
|
||||
taux: 28%
|
||||
|
||||
- nom: prelevement forfaitaire unique
|
||||
- espace: dividendes
|
||||
nom: brut
|
||||
formule: chiffre affaire - salaire total
|
||||
|
||||
- espace: dividendes
|
||||
nom: net
|
||||
formule: brut - prélèvement forfaitaire unique
|
||||
|
||||
- nom: prélèvement forfaitaire unique
|
||||
espace: dividendes
|
||||
formule:
|
||||
multiplication:
|
||||
assiette: dividendes
|
||||
assiette: brut
|
||||
composantes:
|
||||
- part: CSG
|
||||
taux: 17.2%
|
||||
- part: impot
|
||||
taux:
|
||||
variations:
|
||||
- si: exoneration impot X
|
||||
alors: 0%
|
||||
- sinon: 12.8%
|
||||
- taux: 17.2%
|
||||
- taux:
|
||||
variations:
|
||||
- si: exonération impôt X
|
||||
alors: 0%
|
||||
- sinon: 12.8%
|
||||
|
||||
- nom: exonération impôt X
|
||||
|
||||
|
||||
??
|
||||
- nom: salaire total
|
||||
formule: chiffre affaire * répartition salaire sur dividendes
|
||||
|
||||
salaire total = chiffre d'affaires * repartition
|
||||
|
||||
-> on en deduit le net car le total a une valeur
|
||||
|
||||
- nom: dividendes
|
||||
formule: chiffre d'affaires * repartition
|
||||
#-> on en deduit le net car le total a une valeur
|
||||
|
||||
|
||||
|
||||
revenu disponible: salaire apres impot + revenus des dividendes
|
||||
- nom: revenu disponible
|
||||
formule: contrat salarié . salaire . net après impôt + dividendes . net
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import { expect } from 'chai'
|
||||
import Syso from '../source/engine/index'
|
||||
import { propEq } from 'ramda'
|
||||
import dedent from 'dedent-js'
|
||||
import sasuYaml from 'yaml-loader!../source/règles/sasu.yaml'
|
||||
import sasuRules from '../source/règles/sasu.yaml'
|
||||
|
||||
describe('library', function() {
|
||||
it('should evaluate one target with no input data', function() {
|
||||
|
@ -52,7 +51,7 @@ describe('library', function() {
|
|||
{
|
||||
'contrat salarié . salaire . brut de base': 2300
|
||||
},
|
||||
{ extra: sasuYaml }
|
||||
{ extra: sasuRules }
|
||||
)
|
||||
|
||||
expect(evaluated.targets[0].nodeValue).to.be.closeTo(1780.41, 1)
|
||||
|
|
Loading…
Reference in New Issue