🐛 répare le changement de période mois/année

pull/439/head
Johan Girod 2019-01-31 16:18:14 +01:00
parent af7f05d858
commit aac32399d5
5 changed files with 69 additions and 85 deletions

View File

@ -7,18 +7,18 @@ import type {
SetSimulationConfigAction,
SetSituationBranchAction
} from 'Types/ActionsTypes'
import { reset } from 'redux-form'
import { deletePersistedSimulation } from '../storage/persistSimulation'
import { reset } from 'redux-form';
import { deletePersistedSimulation } from '../storage/persistSimulation';
import type { RouterHistory } from 'react-router-dom'
export const resetSimulation = () => (dispatch: any => void): void => {
dispatch(reset('conversation'))
dispatch(
({
type: 'RESET_SIMULATION'
}: ResetSimulationAction)
)
dispatch(reset('conversation'))
}
export const setSituationBranch = (id: number): SetSituationBranchAction => ({

View File

@ -1,13 +1,9 @@
import React from 'react'
import { Trans } from 'react-i18next'
import { evaluateNode, makeJsx, rewriteNode } from './evaluation'
import { Leaf, Node } from './mecanismViews/common'
import {
disambiguateRuleReference,
findParentDependency,
findRuleByDottedName
} from './rules'
import { getSituationValue } from './variables'
import React from 'react';
import { Trans } from 'react-i18next';
import { evaluateNode, makeJsx, rewriteNode } from './evaluation';
import { Leaf, Node } from './mecanismViews/common';
import { disambiguateRuleReference, findParentDependency, findRuleByDottedName } from './rules';
import { getSituationValue } from './variables';
export let treatVariable = (rules, rule, filter) => parseResult => {
let evaluate = (cache, situation, parsedRules, node) => {
@ -147,22 +143,23 @@ export let treatVariableTransforms = (rules, rule) => parseResult => {
rule.dottedName
}, qui appelle une variable à période flexible, ${
ruleToTransform.dottedName
}, c'est suspect !
}, c'est suspect !
`
)
return filteredNode
}
if (!ruleToTransform.période) return filteredNode
let environmentPeriod = situation('période') || 'mois'
console.log(rule.dottedName, environmentPeriod)
let callingPeriod =
inlinePeriodTransform ||
(rule.période == 'flexible' ? environmentPeriod : rule.période)
inlinePeriodTransform ||
(rule.période === 'flexible' ? environmentPeriod : rule.période)
let calledPeriod =
ruleToTransform.période == 'flexible'
? environmentPeriod
: ruleToTransform.période
ruleToTransform.période === 'flexible'
? environmentPeriod
: ruleToTransform.période
let transformedNodeValue =
callingPeriod === 'mois' && calledPeriod === 'année'

View File

@ -1,31 +1,10 @@
import {
collectMissingVariablesByTarget,
getNextSteps
} from 'Engine/generateQuestions'
import {
collectDefaults,
disambiguateExampleSituation,
findRuleByDottedName,
formatInputs,
nestedSituationToPathMap,
rules as baseRulesEn,
rulesFr as baseRulesFr
} from 'Engine/rules'
import { analyse, analyseMany, parseAll } from 'Engine/traverse'
import {
add,
contains,
difference,
equals,
head,
intersection,
isNil,
mergeDeepWith,
pick
} from 'ramda'
import { getFormValues } from 'redux-form'
import { createSelector, createSelectorCreator, defaultMemoize } from 'reselect'
import { softCatch } from '../utils'
import { collectMissingVariablesByTarget, getNextSteps } from 'Engine/generateQuestions';
import { collectDefaults, disambiguateExampleSituation, findRuleByDottedName, formatInputs, nestedSituationToPathMap, rules as baseRulesEn, rulesFr as baseRulesFr } from 'Engine/rules';
import { analyse, analyseMany, parseAll } from 'Engine/traverse';
import { add, contains, difference, equals, head, intersection, isNil, mergeDeepWith, pick } from 'ramda';
import { getFormValues } from 'redux-form';
import { createSelector, createSelectorCreator, defaultMemoize } from 'reselect';
import { softCatch } from '../utils';
// create a "selector creator" that uses deep equal instead of ===
const createDeepEqualSelector = createSelectorCreator(defaultMemoize, equals)
@ -103,13 +82,13 @@ const createSituationBrancheSelector = situationSelector =>
(situation, branches, configSituation) => {
if (branches) {
return branches.map(({ situation: branchSituation }) => ({
...situation,
...configSituation,
...branchSituation
...branchSituation,
...situation,
}))
}
if (configSituation) {
return { ...situation, ...configSituation }
return { ...configSituation, ...situation }
}
return situation
}

View File

@ -1,16 +1,16 @@
/* @flow */
import { React, T } from 'Components'
import withSitePaths from 'Components/utils/withSitePaths'
import { compose } from 'ramda'
import { withNamespaces } from 'react-i18next'
import { connect } from 'react-redux'
import { NavLink, withRouter } from 'react-router-dom'
import companySvg from '../../images/company.svg'
import estimateSvg from '../../images/estimate.svg'
import hiringSvg from '../../images/hiring.svg'
import './Navigation.css'
import NavOpener from './NavOpener'
import SideBar from './SideBar'
import { React, T } from 'Components';
import withSitePaths from 'Components/utils/withSitePaths';
import { compose } from 'ramda';
import { withNamespaces } from 'react-i18next';
import { connect } from 'react-redux';
import { NavLink, withRouter } from 'react-router-dom';
import companySvg from '../../images/company.svg';
import estimateSvg from '../../images/estimate.svg';
import hiringSvg from '../../images/hiring.svg';
import './Navigation.css';
import NavOpener from './NavOpener';
import SideBar from './SideBar';
import type { TFunction } from 'react-i18next'
@ -199,6 +199,7 @@ const StepsHeader = ({ t, sitePaths, companyStatusChoice }: Props) => (
</>
}>
<ul>
{!['mycompanyinfrance.fr', 'mon-entreprise.fr'].includes(window.location.hostname) &&
<li>
<NavOpener title={<T>Statut du dirigeant</T>}>
<ul>
@ -232,7 +233,7 @@ const StepsHeader = ({ t, sitePaths, companyStatusChoice }: Props) => (
</li>
</ul>
</NavOpener>
</li>
</li>}
<li>
<NavLink exact to={sitePaths.sécuritéSociale.salarié}>
<T>Simulateur de coût d'embauche</T>

View File

@ -1,18 +1,18 @@
/* @flow */
import { Component, React, T } from 'Components'
import { ScrollToTop } from 'Components/utils/Scroll'
import withLanguage from 'Components/utils/withLanguage'
import withSitePaths from 'Components/utils/withSitePaths'
import { compose } from 'ramda'
import emoji from 'react-easy-emoji'
import Helmet from 'react-helmet'
import { withNamespaces } from 'react-i18next'
import { connect } from 'react-redux'
import { Link } from 'react-router-dom'
import { régimeSelector } from 'Selectors/companyStatusSelectors'
import * as Animate from 'Ui/animate'
import Video from './Video'
import { Component, React, T } from 'Components';
import { ScrollToTop } from 'Components/utils/Scroll';
import withLanguage from 'Components/utils/withLanguage';
import withSitePaths from 'Components/utils/withSitePaths';
import { compose } from 'ramda';
import emoji from 'react-easy-emoji';
import Helmet from 'react-helmet';
import { withNamespaces } from 'react-i18next';
import { connect } from 'react-redux';
import { Link } from 'react-router-dom';
import { régimeSelector } from 'Selectors/companyStatusSelectors';
import * as Animate from 'Ui/animate';
import Video from './Video';
import type { Match, Location } from 'react-router'
import type { TFunction } from 'react-i18next'
@ -60,25 +60,32 @@ class SocialSecurity extends Component<Props, {}> {
</Link>
</p>
)}
{!['mycompanyinfrance.fr', 'mon-entreprise.fr'].includes(window.location.hostname) ? <>
<br />
<h2 style={{ textAlign: 'center', marginBottom: '2rem' }}>
Que souhaitez vous estimer ?
</h2>
<Link
className="landing__choice "
to={
régime
? sitePaths.sécuritéSociale[régime]
: sitePaths.sécuritéSociale.comparaison
}>
className="landing__choice "
to={
régime
? sitePaths.sécuritéSociale[régime]
: sitePaths.sécuritéSociale.comparaison
}>
{emoji('👔')} La rémunération du dirigeant
</Link>
<Link
className="landing__choice "
to={sitePaths.sécuritéSociale.salarié}>
className="landing__choice "
to={sitePaths.sécuritéSociale.salarié}>
{emoji('👥')} Le salaire d'un employé
</Link>
<br />
</> : <Link
className="landing__choice "
to={sitePaths.sécuritéSociale.salarié}>
{emoji('👥')} Estimer les cotisations sociales pour une embauche
</Link>}
<Video />
</Animate.fromBottom>
)}