From fe2b247b7c97ab3e5d486a7dc7863a575bf9c290 Mon Sep 17 00:00:00 2001 From: ulysse Date: Thu, 19 Nov 2026 10:49:03 +0100 Subject: [PATCH] COM-4331: display billed duration --- src/helpers/hourlyPaymentPlans.js | 4 ++-- tests/unit/helpers/hourlyPaymentPlans.test.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/helpers/hourlyPaymentPlans.js b/src/helpers/hourlyPaymentPlans.js index af1551021b..063f38fe2a 100644 --- a/src/helpers/hourlyPaymentPlans.js +++ b/src/helpers/hourlyPaymentPlans.js @@ -29,8 +29,8 @@ exports.getPricesFromDurations = ( billableELearningDuration = remainingDuration.isShorterThan(PT0S) ? CompaniDuration(PT0S) : remainingDuration; } } - const eLearning = hourlyPaymentPlan.elearningPrice && { - duration: eLearningMonthDuration, + const eLearning = hourlyPaymentPlan.elearningPrice && !billableELearningDuration.isEquivalentTo(PT0S) && { + duration: billableELearningDuration, price: NumbersHelper.multiply(billableELearningDuration.asHours(), hourlyPaymentPlan.elearningPrice), }; diff --git a/tests/unit/helpers/hourlyPaymentPlans.test.js b/tests/unit/helpers/hourlyPaymentPlans.test.js index 4886a22480..38605b3e4d 100644 --- a/tests/unit/helpers/hourlyPaymentPlans.test.js +++ b/tests/unit/helpers/hourlyPaymentPlans.test.js @@ -64,16 +64,16 @@ describe('getPricesFromDurations', () => { .getPricesFromDurations(hourlyPaymentPlan, {}, eLearningDuration, [], CompaniDuration({ hours: 8 })); expect(limitReachedThisMonth.elearning.price).toBe('40'); - expect(limitReachedThisMonth.elearning.duration.asHours()).toBe(3); + expect(limitReachedThisMonth.elearning.duration.asHours()).toBe(2); }); - it('should not bill e-learning if limit already reached', () => { + it('should not return e-learning line if limit already reached', () => { const hourlyPaymentPlan = { prices: [], elearningPrice: 20, elearningLimit: 'PT36000S' }; const eLearningDuration = CompaniDuration({ hours: 3 }); const limitAlreadyReached = HourlyPaymentPlansHelper .getPricesFromDurations(hourlyPaymentPlan, {}, eLearningDuration, [], CompaniDuration({ hours: 12 })); - expect(limitAlreadyReached.elearning.price).toBe('0'); + expect(limitAlreadyReached.elearning).toBeUndefined(); }); it('should not return e-learning line if there is no e-learning price', () => {