@eeplatform/basic-edu 1.8.5 → 1.8.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @eeplatform/basic-edu
2
2
 
3
+ ## 1.8.6
4
+
5
+ ### Patch Changes
6
+
7
+ - 41403d6: Enrollment management - fix enrollment status update
8
+
3
9
  ## 1.8.5
4
10
 
5
11
  ### Patch Changes
package/dist/index.js CHANGED
@@ -5523,9 +5523,21 @@ function useEnrollmentService() {
5523
5523
  const session = client.startSession();
5524
5524
  try {
5525
5525
  session.startTransaction();
5526
- const enrollment = await _getById(_id, "pending");
5526
+ const enrollment = await _getById(_id);
5527
5527
  if (!enrollment) {
5528
- throw new import_nodejs_utils21.NotFoundError("Enrollment not found or not pending");
5528
+ throw new import_nodejs_utils21.NotFoundError("Enrollment not found.");
5529
+ }
5530
+ if (status === "accepted" && enrollment.status == "rejected") {
5531
+ throw new import_nodejs_utils21.BadRequestError("Rejected enrollments cannot be accepted.");
5532
+ }
5533
+ if (status === "accepted" && enrollment.status == "accepted") {
5534
+ throw new import_nodejs_utils21.BadRequestError("Enrollment is already accepted.");
5535
+ }
5536
+ if (status === "rejected" && enrollment.status == "rejected") {
5537
+ throw new import_nodejs_utils21.BadRequestError("Enrollment is already rejected.");
5538
+ }
5539
+ if (status === "rejected" && enrollment.status == "accepted") {
5540
+ throw new import_nodejs_utils21.BadRequestError("Accepted enrollments cannot be rejected.");
5529
5541
  }
5530
5542
  const result = await _updateStatusById(_id, status, session);
5531
5543
  if (result.modifiedCount === 0) {
@@ -5563,6 +5575,7 @@ function useEnrollmentService() {
5563
5575
  await incrementById(counterId, session);
5564
5576
  }
5565
5577
  enrollment.specialProgram = enrollment.specialProgram?.toString();
5578
+ enrollment.createdBy = enrollment.createdBy?.toString();
5566
5579
  await addLearner(enrollment, session);
5567
5580
  }
5568
5581
  await session.commitTransaction();