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