2018-06-06 08:22:46 +00:00
|
|
|
/* @flow */
|
|
|
|
|
2019-05-20 15:01:47 +00:00
|
|
|
import { expect } from 'chai'
|
2019-02-01 12:31:57 +00:00
|
|
|
// $FlowFixMe
|
2019-05-20 15:01:47 +00:00
|
|
|
import salariéConfig from 'Components/simulationConfigs/salarié.yaml'
|
2019-09-17 18:10:27 +00:00
|
|
|
import { getRuleFromAnalysis, rules } from 'Engine/rules'
|
2019-08-26 15:37:05 +00:00
|
|
|
import { analysisWithDefaultsSelector } from 'Selectors/analyseSelectors'
|
2019-07-05 14:43:00 +00:00
|
|
|
import {
|
|
|
|
analysisToCotisationsSelector,
|
2019-05-20 15:01:47 +00:00
|
|
|
COTISATION_BRANCHE_ORDER
|
|
|
|
} from 'Selectors/ficheDePaieSelectors'
|
2018-06-06 08:22:46 +00:00
|
|
|
|
2018-06-18 09:28:47 +00:00
|
|
|
let state = {
|
2019-09-17 18:10:27 +00:00
|
|
|
rules,
|
2019-02-01 12:31:57 +00:00
|
|
|
simulation: {
|
2019-09-13 10:42:19 +00:00
|
|
|
config: salariéConfig,
|
|
|
|
situation: {
|
|
|
|
'contrat salarié . rémunération . brut de base': '2300',
|
|
|
|
'entreprise . effectif': '50'
|
|
|
|
}
|
2019-02-01 12:31:57 +00:00
|
|
|
},
|
2018-07-25 14:07:53 +00:00
|
|
|
conversationSteps: {
|
|
|
|
foldedSteps: []
|
|
|
|
}
|
2018-06-18 09:28:47 +00:00
|
|
|
}
|
2018-06-06 08:22:46 +00:00
|
|
|
|
2019-07-05 14:43:00 +00:00
|
|
|
let cotisations = null,
|
|
|
|
analysis
|
2018-06-18 09:28:47 +00:00
|
|
|
|
|
|
|
describe('pay slip selector', function() {
|
2018-08-28 12:16:57 +00:00
|
|
|
beforeEach(() => {
|
2019-02-03 17:05:55 +00:00
|
|
|
// $FlowFixMe
|
2019-07-05 14:43:00 +00:00
|
|
|
cotisations = analysisToCotisationsSelector(state)
|
|
|
|
analysis = analysisWithDefaultsSelector(state)
|
2019-02-01 12:31:57 +00:00
|
|
|
|
2019-07-05 14:43:00 +00:00
|
|
|
expect(cotisations).not.to.eq(null)
|
2018-08-28 12:16:57 +00:00
|
|
|
})
|
2018-06-06 08:22:46 +00:00
|
|
|
it('should have cotisations grouped by branches in the proper ordering', function() {
|
2018-08-28 12:16:57 +00:00
|
|
|
// $FlowFixMe
|
2019-07-05 14:43:00 +00:00
|
|
|
let branches = cotisations.map(([branche]) => branche)
|
|
|
|
expect(branches).to.eql(COTISATION_BRANCHE_ORDER)
|
2018-06-06 08:22:46 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
it('should collect all cotisations in a branche', function() {
|
2018-08-28 12:16:57 +00:00
|
|
|
// $FlowFixMe
|
2019-07-05 14:43:00 +00:00
|
|
|
let cotisationsSanté = (cotisations.find(([branche]) =>
|
|
|
|
branche.includes('santé')
|
2019-10-11 15:01:11 +00:00
|
|
|
) || [])[1].map(cotisation => cotisation.name)
|
2019-10-01 09:39:03 +00:00
|
|
|
expect(cotisationsSanté).to.have.lengthOf(2)
|
2018-06-06 08:22:46 +00:00
|
|
|
expect(cotisationsSanté).to.include('maladie')
|
|
|
|
expect(cotisationsSanté).to.include('complémentaire santé')
|
|
|
|
})
|
|
|
|
|
|
|
|
it('should sum all cotisations', function() {
|
2019-07-05 14:43:00 +00:00
|
|
|
let pat = getRuleFromAnalysis(analysis)(
|
2019-09-19 10:15:17 +00:00
|
|
|
'contrat salarié . cotisations . patronales'
|
2019-07-05 14:43:00 +00:00
|
|
|
),
|
|
|
|
sal = getRuleFromAnalysis(analysis)(
|
|
|
|
'contrat salarié . cotisations . salariales'
|
|
|
|
)
|
2019-10-01 09:39:03 +00:00
|
|
|
expect(pat.nodeValue).to.be.closeTo(824.7, 5)
|
2019-07-05 14:43:00 +00:00
|
|
|
expect(sal.nodeValue).to.be.closeTo(498, 5)
|
2018-06-06 08:22:46 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
it('should have value for "salarié" and "employeur" for a cotisation', function() {
|
2018-08-28 12:16:57 +00:00
|
|
|
// $FlowFixMe
|
2019-07-05 14:43:00 +00:00
|
|
|
let cotisationATMP = (cotisations.find(([branche]) =>
|
|
|
|
branche.includes('accidents du travail et maladies professionnelles')
|
2018-06-06 08:22:46 +00:00
|
|
|
) || [])[1][0]
|
|
|
|
expect(cotisationATMP.montant.partSalariale).to.be.closeTo(0, 0.1)
|
|
|
|
let defaultATMPRate = 2.22 / 100
|
|
|
|
expect(cotisationATMP.montant.partPatronale).to.be.closeTo(
|
|
|
|
2300 * defaultATMPRate,
|
|
|
|
1
|
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|