diff --git a/site/cypress/integration/mon-entreprise/lodeom.ts b/site/cypress/integration/mon-entreprise/lodeom.ts index cf00f7150..ecd6e6095 100755 --- a/site/cypress/integration/mon-entreprise/lodeom.ts +++ b/site/cypress/integration/mon-entreprise/lodeom.ts @@ -282,7 +282,6 @@ describe('Simulateur lodeom', { testIsolation: false }, function () { }) it('should include a recap table', function () { - cy.contains('Régularisation progressive').click() cy.get('div[id="simulator-legend"]').should( 'include.text', 'Récapitulatif trimestriel' @@ -310,6 +309,7 @@ describe('Simulateur lodeom', { testIsolation: false }, function () { }) it('should display code in recap table based on scale', function () { + cy.contains('Régularisation progressive').click() cy.contains('Récapitulatif trimestriel').next().as('recapTable') cy.get('@recapTable').should('include.text', 'code 462') diff --git a/site/cypress/integration/mon-entreprise/reduction-generale.ts b/site/cypress/integration/mon-entreprise/reduction-generale.ts index 83b35f028..ebb13e8f6 100755 --- a/site/cypress/integration/mon-entreprise/reduction-generale.ts +++ b/site/cypress/integration/mon-entreprise/reduction-generale.ts @@ -201,7 +201,6 @@ describe( }) it('should handle incomplete months', function () { - cy.contains('Régularisation progressive').click() cy.get(inputSelector).first().type('{selectall}1500') cy.get('input[id="option-heures-sup-janvier"]').type('{selectall}5') cy.get('input[id="option-rémunération-etp-janvier"]') diff --git a/site/source/utils/réductionDeCotisations.ts b/site/source/utils/réductionDeCotisations.ts index b242576b2..c4c7ea07f 100644 --- a/site/source/utils/réductionDeCotisations.ts +++ b/site/source/utils/réductionDeCotisations.ts @@ -375,7 +375,8 @@ export const reevaluateRéductionMoisParMois = ( reevaluatedData.map((monthData) => monthData.réduction.value) ) régularisation.value = - réduction.value + (réductionTotale - currentRéductionGénéraleCumulée) + réduction.value + + (réductionTotale - currentRéductionGénéraleCumulée) if (régularisation.value > 0) { réduction.value = régularisation.value @@ -505,14 +506,19 @@ const getMonthlyRéduction = ( options: Options, engine: Engine ): number => { + const SMIC = getSMICMensuelAvecOptions( + date, + rémunérationBrute, + options, + engine + ) const réduction = engine.evaluate({ valeur: dottedName, unité: '€/mois', contexte: { date, [rémunérationBruteDottedName]: rémunérationBrute, - [heuresSupplémentairesDottedName]: options.heuresSupplémentaires, - [heuresComplémentairesDottedName]: options.heuresComplémentaires, + 'salarié . temps de travail . SMIC': SMIC, }, }) @@ -526,7 +532,7 @@ const getTotalRéduction = ( coefT: number, engine: Engine ): number => { - const réductionGénérale = engine.evaluate({ + const réduction = engine.evaluate({ valeur: dottedName, arrondi: 'non', contexte: { @@ -536,7 +542,7 @@ const getTotalRéduction = ( }, }) - return réductionGénérale.nodeValue as number + return réduction.nodeValue as number } const getRépartition = ( @@ -575,6 +581,51 @@ const getRépartition = ( } } +const getSMICMensuelAvecOptions = ( + date: string, + rémunérationBrute: number, + options: Options, + engine: Engine +): number => { + const contexte = { + date, + } as Situation + + if (!options.rémunérationETP) { + contexte[heuresSupplémentairesDottedName] = options.heuresSupplémentaires + contexte[heuresComplémentairesDottedName] = options.heuresComplémentaires + } + + const SMICMensuel = engine.evaluate({ + valeur: 'salarié . temps de travail . SMIC', + unité: '€/mois', + contexte, + }).nodeValue as number + + if (!options.rémunérationETP) { + return SMICMensuel + } + + const SMICHoraire = engine.evaluate({ + valeur: 'SMIC . horaire', + contexte, + }).nodeValue as number + // On retranche les primes et le paiements des heures supplémentaires à la rémunération versée + // et on la compare à la rémunération équivalente "mois complet" sans les primes + const prorata = + (rémunérationBrute - + options.rémunérationPrimes - + options.rémunérationHeuresSup) / + options.rémunérationETP + + // On applique ce prorata au SMIC mensuel et on y ajoute les heures supplémentaires et complémentaires + return ( + SMICMensuel * prorata + + SMICHoraire * + (options.heuresSupplémentaires + options.heuresComplémentaires) + ) +} + const getSMICCumulés = ( data: MonthState[], year: number, @@ -589,42 +640,13 @@ const getSMICCumulés = ( return SMICCumulés } - const contexte = { - date: getDateForContexte(monthIndex, year), - } as Situation - - if (!monthData.options.rémunérationETP) { - contexte[heuresSupplémentairesDottedName] = - monthData.options.heuresSupplémentaires - contexte[heuresComplémentairesDottedName] = - monthData.options.heuresComplémentaires - } - - let SMIC = engine.evaluate({ - valeur: 'salarié . temps de travail . SMIC', - unité: '€/mois', - contexte, - }).nodeValue as number - - if (monthData.options.rémunérationETP) { - const SMICHoraire = engine.evaluate({ - valeur: 'SMIC . horaire', - contexte, - }).nodeValue as number - // On retranche les primes et le paiements des heures supplémentaires à la rémunération versée - // et on la compare à la rémunération équivalente "mois complet" sans les primes - const prorata = - (monthData.rémunérationBrute - - monthData.options.rémunérationPrimes - - monthData.options.rémunérationHeuresSup) / - monthData.options.rémunérationETP - // On applique ce prorata au SMIC mensuel et on y ajoute les heures supplémentaires et complémentaires - SMIC = - SMIC * prorata + - SMICHoraire * - (monthData.options.heuresSupplémentaires + - monthData.options.heuresComplémentaires) - } + const date = getDateForContexte(monthIndex, year) + const SMIC = getSMICMensuelAvecOptions( + date, + monthData.rémunérationBrute, + monthData.options, + engine + ) let SMICCumulé = SMIC if (monthIndex > 0) {