@eeplatform/basic-edu 1.10.36 → 1.10.38

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,17 @@
1
1
  # @eeplatform/basic-edu
2
2
 
3
+ ## 1.10.38
4
+
5
+ ### Patch Changes
6
+
7
+ - 14c385d: Fix enrollment service, remove special program to reclassified application
8
+
9
+ ## 1.10.37
10
+
11
+ ### Patch Changes
12
+
13
+ - 84cc4a1: Fix enrollent and screening program
14
+
3
15
  ## 1.10.36
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1695,6 +1695,7 @@ type TProgramScreening = {
1695
1695
  declare const statusesProgramScreening: string[];
1696
1696
  declare const schemaProgramScreening: Joi.ObjectSchema<any>;
1697
1697
  declare const schemaProgramScreeningUpdate: Joi.ObjectSchema<any>;
1698
+ declare const schemaProgramScreeningUpdateStatus: Joi.ObjectSchema<any>;
1698
1699
  declare function modelProgramScreening(value: TProgramScreening): TProgramScreening;
1699
1700
 
1700
1701
  declare function useProgramScreeningRepo(): {
@@ -1964,4 +1965,4 @@ declare function useStrandController(): {
1964
1965
  deleteById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
1965
1966
  };
1966
1967
 
1967
- export { MAsset, MBuilding, MBuildingUnit, MCurriculum, MGradeLevel, MLearner, MPersonnel, MPlantilla, MStockCard, TAddress, TAddressInformation, TAsset, TBasicEduCount, TBlockTime, TBuilding, TBuildingUnit, TCurriculum, TDivision, TEnrollment, TGradeLevel, TKindergartenDomain, TKindergartenRoutine, TLearner, TLearnerInfo, TLearningModality, TParentGuardianInfo, TPersonContact, TPersonnel, TPlantilla, TProgram, TProgramScreening, TRegion, TReturningLearnerInfo, TSchool, TSection, TSectionPreset, TSectionStudent, TSectionSubject, TSeniorHighInformation, TStockCard, TStrand, TSubject, TTeachingLoad, TTeachingLoadSlot, TTrack, allowedSectionStudentStatuses, modelBasicEduCount, modelDivision, modelKindergartenDomain, modelKindergartenRoutine, modelProgram, modelProgramScreening, modelRegion, modelSchool, modelSection, modelSectionPreset, modelSectionStudent, modelSectionSubject, modelStrand, modelSubject, modelTeachingLoad, modelTeachingLoadSlot, modelTrack, schemaAsset, schemaAssetUpdateOption, schemaBasicEduCount, schemaBuilding, schemaBuildingUnit, schemaCurriculum, schemaDivision, schemaDivisionUpdate, schemaEnrollment, schemaGenerateSections, schemaGradeLevel, schemaKindergartenDomain, schemaKindergartenRoutine, schemaKindergartenRoutineUpdate, schemaPersonnel, schemaPlantilla, schemaProgram, schemaProgramScreening, schemaProgramScreeningUpdate, schemaProgramUpdate, schemaRegion, schemaSchool, schemaSchoolUpdate, schemaSection, schemaSectionPreset, schemaSectionStudent, schemaSectionSubject, schemaSectionSubjectSetup, schemaStockCard, schemaStrand, schemaSubject, schemaSubjectAdd, schemaTeachingLoad, schemaTeachingLoadSlot, schemaTrack, schemaUpdateOptions, schemaUpdateStatus, statusesProgramScreening, useAssetController, useAssetRepo, useBasicEduCountRepo, useBuildingController, useBuildingRepo, useBuildingService, useBuildingUnitController, useBuildingUnitRepo, useBuildingUnitService, useCurriculumController, useCurriculumRepo, useDivisionController, useDivisionRepo, useDivisionService, useEnrollmentController, useEnrollmentRepo, useEnrollmentService, useGradeLevelController, useGradeLevelRepo, useKindergartenDomainController, useKindergartenDomainRepo, useKindergartenDomainService, useKindergartenRoutineController, useKindergartenRoutineRepo, useLearnerController, useLearnerRepo, usePersonnelController, usePersonnelRepo, usePlantillaController, usePlantillaRepo, usePlantillaService, useProgramController, useProgramRepo, useProgramScreeningController, useProgramScreeningRepo, useRegionController, useRegionRepo, useSchoolController, useSchoolRepo, useSchoolService, useSectionController, useSectionPresetController, useSectionPresetRepo, useSectionRepo, useSectionStudentController, useSectionStudentRepo, useSectionSubjectController, useSectionSubjectRepo, useSectionSubjectService, useStockCardController, useStockCardRepository, useStockCardService, useStrandController, useStrandRepo, useSubjectController, useSubjectRepo, useSubjectService, useTeachingLoadController, useTeachingLoadRepo, useTeachingLoadSlotController, useTeachingLoadSlotRepo, useTrackController, useTrackRepo, useTrackService };
1968
+ export { MAsset, MBuilding, MBuildingUnit, MCurriculum, MGradeLevel, MLearner, MPersonnel, MPlantilla, MStockCard, TAddress, TAddressInformation, TAsset, TBasicEduCount, TBlockTime, TBuilding, TBuildingUnit, TCurriculum, TDivision, TEnrollment, TGradeLevel, TKindergartenDomain, TKindergartenRoutine, TLearner, TLearnerInfo, TLearningModality, TParentGuardianInfo, TPersonContact, TPersonnel, TPlantilla, TProgram, TProgramScreening, TRegion, TReturningLearnerInfo, TSchool, TSection, TSectionPreset, TSectionStudent, TSectionSubject, TSeniorHighInformation, TStockCard, TStrand, TSubject, TTeachingLoad, TTeachingLoadSlot, TTrack, allowedSectionStudentStatuses, modelBasicEduCount, modelDivision, modelKindergartenDomain, modelKindergartenRoutine, modelProgram, modelProgramScreening, modelRegion, modelSchool, modelSection, modelSectionPreset, modelSectionStudent, modelSectionSubject, modelStrand, modelSubject, modelTeachingLoad, modelTeachingLoadSlot, modelTrack, schemaAsset, schemaAssetUpdateOption, schemaBasicEduCount, schemaBuilding, schemaBuildingUnit, schemaCurriculum, schemaDivision, schemaDivisionUpdate, schemaEnrollment, schemaGenerateSections, schemaGradeLevel, schemaKindergartenDomain, schemaKindergartenRoutine, schemaKindergartenRoutineUpdate, schemaPersonnel, schemaPlantilla, schemaProgram, schemaProgramScreening, schemaProgramScreeningUpdate, schemaProgramScreeningUpdateStatus, schemaProgramUpdate, schemaRegion, schemaSchool, schemaSchoolUpdate, schemaSection, schemaSectionPreset, schemaSectionStudent, schemaSectionSubject, schemaSectionSubjectSetup, schemaStockCard, schemaStrand, schemaSubject, schemaSubjectAdd, schemaTeachingLoad, schemaTeachingLoadSlot, schemaTrack, schemaUpdateOptions, schemaUpdateStatus, statusesProgramScreening, useAssetController, useAssetRepo, useBasicEduCountRepo, useBuildingController, useBuildingRepo, useBuildingService, useBuildingUnitController, useBuildingUnitRepo, useBuildingUnitService, useCurriculumController, useCurriculumRepo, useDivisionController, useDivisionRepo, useDivisionService, useEnrollmentController, useEnrollmentRepo, useEnrollmentService, useGradeLevelController, useGradeLevelRepo, useKindergartenDomainController, useKindergartenDomainRepo, useKindergartenDomainService, useKindergartenRoutineController, useKindergartenRoutineRepo, useLearnerController, useLearnerRepo, usePersonnelController, usePersonnelRepo, usePlantillaController, usePlantillaRepo, usePlantillaService, useProgramController, useProgramRepo, useProgramScreeningController, useProgramScreeningRepo, useRegionController, useRegionRepo, useSchoolController, useSchoolRepo, useSchoolService, useSectionController, useSectionPresetController, useSectionPresetRepo, useSectionRepo, useSectionStudentController, useSectionStudentRepo, useSectionSubjectController, useSectionSubjectRepo, useSectionSubjectService, useStockCardController, useStockCardRepository, useStockCardService, useStrandController, useStrandRepo, useSubjectController, useSubjectRepo, useSubjectService, useTeachingLoadController, useTeachingLoadRepo, useTeachingLoadSlotController, useTeachingLoadSlotRepo, useTrackController, useTrackRepo, useTrackService };
package/dist/index.js CHANGED
@@ -1389,6 +1389,7 @@ __export(src_exports, {
1389
1389
  schemaProgram: () => schemaProgram,
1390
1390
  schemaProgramScreening: () => schemaProgramScreening,
1391
1391
  schemaProgramScreeningUpdate: () => schemaProgramScreeningUpdate,
1392
+ schemaProgramScreeningUpdateStatus: () => schemaProgramScreeningUpdateStatus,
1392
1393
  schemaProgramUpdate: () => schemaProgramUpdate,
1393
1394
  schemaRegion: () => schemaRegion,
1394
1395
  schemaSchool: () => schemaSchool,
@@ -3106,7 +3107,7 @@ var learnerInfoSchema = import_joi5.default.object({
3106
3107
  });
3107
3108
  var schemaUpdateStatus = import_joi5.default.object({
3108
3109
  _id: import_joi5.default.string().hex().length(24).required(),
3109
- status: import_joi5.default.string().valid("pending", "accepted", "rejected", "cancelled", "withdrawn").required()
3110
+ status: import_joi5.default.string().valid("screening", "pending", "accepted", "rejected", "cancelled").required()
3110
3111
  });
3111
3112
  var gradeLevels = [
3112
3113
  "kindergarten",
@@ -3150,7 +3151,7 @@ var schemaEnrollment = import_joi5.default.object({
3150
3151
  // Added to match frontend
3151
3152
  specialProgramMajor: import_joi5.default.string().optional().allow("", null),
3152
3153
  // Added to match frontend
3153
- gwa: import_joi5.default.number().optional().allow(null, 0),
3154
+ gwa: import_joi5.default.number().max(100).optional().allow(null, 0),
3154
3155
  subjects: import_joi5.default.array().items(
3155
3156
  import_joi5.default.object({
3156
3157
  title: import_joi5.default.string().max(100).required(),
@@ -4102,7 +4103,7 @@ var statusesProgramScreening = [
4102
4103
  "passed",
4103
4104
  "failed",
4104
4105
  "reclassified",
4105
- "withdrawn"
4106
+ "cancelled"
4106
4107
  ];
4107
4108
  var schemaProgramScreening = import_joi9.default.object({
4108
4109
  _id: import_joi9.default.string().hex().optional().allow(null, ""),
@@ -4133,6 +4134,10 @@ var schemaProgramScreeningUpdate = import_joi9.default.object({
4133
4134
  specialProgramName: import_joi9.default.string().optional().allow("", null),
4134
4135
  status: import_joi9.default.string().valid("pending", "pass", "failed").optional().allow("", null)
4135
4136
  });
4137
+ var schemaProgramScreeningUpdateStatus = import_joi9.default.object({
4138
+ _id: import_joi9.default.string().hex().length(24).required(),
4139
+ status: import_joi9.default.string().valid("passed", "failed", "reclassified").required()
4140
+ });
4136
4141
  function modelProgramScreening(value) {
4137
4142
  const { error } = schemaProgramScreening.validate(value);
4138
4143
  if (error) {
@@ -4589,19 +4594,26 @@ function useProgramScreeningService() {
4589
4594
  const { updateStatusById: updateEnrollmentStatusById, removeProgramById } = useEnrollmentRepo();
4590
4595
  const { updateFieldById, getById: getProgramScreeningById } = useProgramScreeningRepo();
4591
4596
  async function updateStatusById(id, status) {
4597
+ const { error } = schemaProgramScreeningUpdateStatus.validate({
4598
+ _id: id,
4599
+ status
4600
+ });
4601
+ if (error) {
4602
+ throw new import_nodejs_utils14.BadRequestError(`Invalid data: ${error.message}`);
4603
+ }
4592
4604
  const session = import_nodejs_utils14.useAtlas.getClient()?.startSession();
4593
4605
  try {
4594
4606
  await session?.startTransaction();
4595
4607
  const application = await getProgramScreeningById(id);
4596
4608
  if (!application) {
4597
- throw new import_nodejs_utils14.AppError("Application not found", 404);
4609
+ throw new import_nodejs_utils14.NotFoundError("Application not found");
4598
4610
  }
4599
4611
  await updateFieldById(
4600
4612
  { _id: id, field: "status", value: status },
4601
4613
  session
4602
4614
  );
4603
4615
  let enrollmentStatus = "pending";
4604
- const ReclassifyCond = status === "reclassified" && application.status && ["failed", "withdrawn"].includes(application.status);
4616
+ const ReclassifyCond = status === "reclassified" && application.status === "failed";
4605
4617
  if (ReclassifyCond) {
4606
4618
  await removeProgramById(String(application.applicant), session);
4607
4619
  }
@@ -4611,9 +4623,6 @@ function useProgramScreeningService() {
4611
4623
  if (status === "failed" && application.status === "pending") {
4612
4624
  enrollmentStatus = "failed-screening";
4613
4625
  }
4614
- if (status === "withdrawn" && application.status === "pending") {
4615
- enrollmentStatus = "withdrawn-screening";
4616
- }
4617
4626
  await updateEnrollmentStatusById(
4618
4627
  application.applicant,
4619
4628
  enrollmentStatus,
@@ -4621,10 +4630,10 @@ function useProgramScreeningService() {
4621
4630
  );
4622
4631
  await session?.commitTransaction();
4623
4632
  return "Status updated successfully";
4624
- } catch (error) {
4633
+ } catch (error2) {
4625
4634
  await session?.abortTransaction();
4626
- if (error instanceof import_nodejs_utils14.AppError) {
4627
- throw error;
4635
+ if (error2 instanceof import_nodejs_utils14.AppError) {
4636
+ throw error2;
4628
4637
  } else {
4629
4638
  throw new import_nodejs_utils14.AppError("Failed to update status", 500);
4630
4639
  }
@@ -4833,22 +4842,17 @@ function useProgramScreeningController() {
4833
4842
  }
4834
4843
  async function updateStatusById(req, res, next) {
4835
4844
  const id = req.params.id;
4836
- const validation = import_joi10.default.string().hex().required();
4837
- const { error } = validation.validate(id);
4845
+ const status = req.body.status ?? "";
4846
+ const { error } = schemaProgramScreeningUpdateStatus.validate({
4847
+ _id: id,
4848
+ status
4849
+ });
4838
4850
  if (error) {
4839
4851
  next(new import_nodejs_utils15.BadRequestError(error.message));
4840
4852
  return;
4841
4853
  }
4842
- const value = req.body;
4843
- const { error: updatePayloadError } = import_joi10.default.object({
4844
- status: import_joi10.default.string().valid(...statusesProgramScreening).required()
4845
- }).validate(value);
4846
- if (updatePayloadError) {
4847
- next(new import_nodejs_utils15.BadRequestError(updatePayloadError.message));
4848
- return;
4849
- }
4850
4854
  try {
4851
- const message = await _updateStatusById(id, value.status);
4855
+ const message = await _updateStatusById(id, status);
4852
4856
  res.json({ message });
4853
4857
  return;
4854
4858
  } catch (error2) {
@@ -5485,7 +5489,8 @@ function useEnrollmentService() {
5485
5489
  getAll: _getAll,
5486
5490
  getByApplicantInfo: _getByApplicantInfo,
5487
5491
  getById: _getById,
5488
- updateStatusById: _updateStatusById
5492
+ updateStatusById: _updateStatusById,
5493
+ removeProgramById
5489
5494
  } = useEnrollmentRepo();
5490
5495
  const {
5491
5496
  add: addProgramScreening,
@@ -5646,6 +5651,11 @@ function useEnrollmentService() {
5646
5651
  "Only enrollments in screening status can be withdrawn."
5647
5652
  );
5648
5653
  }
5654
+ if (enrollment.status === "cancelled" && !enrollment.specialProgram && status === "pending") {
5655
+ throw new import_nodejs_utils19.BadRequestError(
5656
+ "Cancelled enrollment without special program cannot be updated to pending."
5657
+ );
5658
+ }
5649
5659
  const result = await _updateStatusById(_id, status, session);
5650
5660
  if (result.modifiedCount === 0) {
5651
5661
  throw new import_nodejs_utils19.InternalServerError("Failed to accept enrollment");
@@ -5670,10 +5680,12 @@ function useEnrollmentService() {
5670
5680
  await addLearner(enrollment, session);
5671
5681
  }
5672
5682
  const programScreening = await getByApplicantId(_id);
5673
- if (programScreening) {
5674
- if (["cancelled", "withdrawn"].includes(status)) {
5675
- await updateStatusByApplicantId(_id, "cancelled", session);
5676
- }
5683
+ if (programScreening && status === "cancelled") {
5684
+ await updateStatusByApplicantId(_id, "cancelled", session);
5685
+ }
5686
+ if (programScreening && programScreening.status === "cancelled" && enrollment.status === "cancelled" && enrollment.specialProgram && status === "pending") {
5687
+ await updateStatusByApplicantId(_id, "reclassified", session);
5688
+ await removeProgramById(_id, session);
5677
5689
  }
5678
5690
  await session.commitTransaction();
5679
5691
  return "Enrollment accepted successfully";
@@ -47446,6 +47458,7 @@ dotenv.config();
47446
47458
  schemaProgram,
47447
47459
  schemaProgramScreening,
47448
47460
  schemaProgramScreeningUpdate,
47461
+ schemaProgramScreeningUpdateStatus,
47449
47462
  schemaProgramUpdate,
47450
47463
  schemaRegion,
47451
47464
  schemaSchool,