Skip to content

Commit

Permalink
fix: don't consider elapsed enrollBy in assignable course runs (#1313)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamstankiewicz authored Sep 18, 2024
1 parent 329fae8 commit 039039e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jest.mock('../../../../data/services/EnterpriseAccessApiService');

const futureStartDate = dayjs().add(5, 'days').toISOString();
const pastStartDate = dayjs().subtract(5, 'days').toISOString();
const enrollByTimestamp = dayjs().subtract(10, 'days').unix();
const enrollByTimestamp = dayjs().add(2, 'days').unix();
const enrollByDropdownText = `Enroll by ${dayjs.unix(enrollByTimestamp).format(SHORT_MONTH_DATE_FORMAT)}`;

const originalData = {
Expand Down
9 changes: 6 additions & 3 deletions src/components/learner-credit-management/data/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -660,13 +660,16 @@ export const getAssignableCourseRuns = ({ courseRuns, subsidyExpirationDatetime,
}) => {
let isEligibleForEnrollment = true;
if (hasEnrollBy) {
isEligibleForEnrollment = dayjs(enrollBy).isBefore(
minimumEnrollByDateFromToday({ subsidyExpirationDatetime }),
const enrollByDate = dayjs(enrollBy);
// Determine eligibility based on the provided enrollBy is and the subsidy expiration date - refund threshold
isEligibleForEnrollment = (
!isDateBeforeToday(enrollByDate)
&& enrollByDate.isBefore(minimumEnrollByDateFromToday({ subsidyExpirationDatetime }))
);
// Late redemption filter
if (isDateBeforeToday(enrollBy) && isLateRedemptionAllowed) {
const lateEnrollmentCutoff = dayjs().subtract(LATE_ENROLLMENTS_BUFFER_DAYS, 'days');
isEligibleForEnrollment = dayjs(enrollBy).isAfter(lateEnrollmentCutoff);
isEligibleForEnrollment = enrollByDate.isAfter(lateEnrollmentCutoff);
return isLateEnrollmentEligible && isEligibleForEnrollment;
}
}
Expand Down

0 comments on commit 039039e

Please sign in to comment.