Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1852 - Enable Overawards Tab For Public Institution User #1906

Merged
merged 16 commits into from
May 2, 2023
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ import {
EducationProgramOfferingControllerService,
ConfirmationOfEnrollmentControllerService,
StudentInstitutionsController,
OverawardInstitutionsController,
StudentControllerService,
OverawardControllerService,
} from "./route-controllers";
import { AuthModule } from "./auth/auth.module";
import {
Expand Down Expand Up @@ -77,6 +79,7 @@ import { UserControllerService } from "./route-controllers/user/user.controller.
EducationProgramOfferingInstitutionsController,
UserInstitutionsController,
StudentInstitutionsController,
OverawardInstitutionsController,
],
providers: [
WorkflowClientService,
Expand Down Expand Up @@ -123,6 +126,7 @@ import { UserControllerService } from "./route-controllers/user/user.controller.
NoteSharedService,
StudentControllerService,
RestrictionSharedService,
OverawardControllerService,
],
})
export class AppInstitutionsModule {}
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@ export * from "./confirmation-of-enrollment/confirmation-of-enrollment.controlle
export * from "./confirmation-of-enrollment/confirmation-of-enrollment.aest.controller";
export * from "./overaward/overaward.controller.service";
export * from "./overaward/overaward.aest.controller";
export * from "./overaward/overaward.institutions.controller";
export * from "./overaward/overaward.students.controller";
export * from "./student/student.institutions.controller";
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { HttpStatus, INestApplication } from "@nestjs/common";
import * as request from "supertest";
import {
createFakeDisbursementOveraward,
saveFakeStudent,
} from "@sims/test-utils";
import { DataSource, Repository } from "typeorm";
import {
DisbursementOveraward,
DisbursementOverawardOriginType,
} from "@sims/sims-db";

import {
BEARER_AUTH_TYPE,
createTestingAppModule,
getInstitutionToken,
InstitutionTokenTypes,
} from "../../../../testHelpers";

describe("OverawardInstitutionsController(e2e)-getOverawardBalance", () => {
let app: INestApplication;
let appDataSource: DataSource;
let disbursementOverawardRepo: Repository<DisbursementOveraward>;

beforeAll(async () => {
const { nestApplication, dataSource } = await createTestingAppModule();
app = nestApplication;
appDataSource = dataSource;
disbursementOverawardRepo = dataSource.getRepository(DisbursementOveraward);
});

it("Should return correct value for overaward balance when student has some overawards.", async () => {
// Arrange
const student = await saveFakeStudent(appDataSource);
// Create an overaward.
const legacyOveraward = createFakeDisbursementOveraward({ student });
legacyOveraward.disbursementValueCode = "BCSL";
legacyOveraward.overawardValue = 500;
legacyOveraward.originType =
DisbursementOverawardOriginType.LegacyOveraward;
// Create a manual overaward deduction.
const manualOveraward = createFakeDisbursementOveraward({ student });
manualOveraward.disbursementValueCode = "BCSL";
manualOveraward.overawardValue = -200;
manualOveraward.originType = DisbursementOverawardOriginType.ManualRecord;
// Persist the overawards.
await disbursementOverawardRepo.save([legacyOveraward, manualOveraward]);
const institutionUserToken = await getInstitutionToken(
InstitutionTokenTypes.CollegeFUser,
);
const endpoint = `/institutions/overaward/student/${student.id}/balance`;

// Act/Assert.
await request(app.getHttpServer())
.get(endpoint)
.auth(institutionUserToken, BEARER_AUTH_TYPE)
.expect(HttpStatus.OK)
.expect({ overawardBalanceValues: { BCSL: "300.00" } });
});

afterAll(async () => {
await app?.close();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import { HttpStatus, INestApplication } from "@nestjs/common";
import * as request from "supertest";
import {
createFakeDisbursementOveraward,
createFakeStudentAssessment,
saveFakeApplication,
} from "@sims/test-utils";
import { Repository, DataSource } from "typeorm";
import {
Application,
DisbursementOveraward,
DisbursementOverawardOriginType,
StudentAssessment,
} from "@sims/sims-db";

import {
BEARER_AUTH_TYPE,
createTestingAppModule,
getInstitutionToken,
InstitutionTokenTypes,
} from "../../../../testHelpers";

describe("OverawardInstitutionsController(e2e)-getOverawardsByStudent", () => {
let app: INestApplication;
let appDataSource: DataSource;
let assessmentRepo: Repository<StudentAssessment>;
let applicationRepo: Repository<Application>;
let disbursementOverawardRepo: Repository<DisbursementOveraward>;

beforeAll(async () => {
const { nestApplication, dataSource } = await createTestingAppModule();
app = nestApplication;
appDataSource = dataSource;
assessmentRepo = dataSource.getRepository(StudentAssessment);
applicationRepo = dataSource.getRepository(Application);
disbursementOverawardRepo = dataSource.getRepository(DisbursementOveraward);
});

it("Should return student overawards when student has some overawards.", async () => {
// Arrange
// Prepare the student assessment to create overaward.
const application = await saveFakeApplication(appDataSource);
const student = application.student;
ann-aot marked this conversation as resolved.
Show resolved Hide resolved
const user = application.student.user;
const studentAssessment = await assessmentRepo.save(
createFakeStudentAssessment({
auditUser: user,
application,
}),
);
application.currentAssessment = studentAssessment;
await applicationRepo.save(application);
// Create an overaward.
const reassessmentOveraward = createFakeDisbursementOveraward({ student });
reassessmentOveraward.studentAssessment = studentAssessment;
reassessmentOveraward.creator = user;
reassessmentOveraward.disbursementValueCode = "CSLP";
reassessmentOveraward.overawardValue = 100;
reassessmentOveraward.originType =
DisbursementOverawardOriginType.ReassessmentOveraward;
reassessmentOveraward.addedBy = user;
reassessmentOveraward.addedDate = new Date();
await disbursementOverawardRepo.save(reassessmentOveraward);
const institutionUserToken = await getInstitutionToken(
InstitutionTokenTypes.CollegeFUser,
);
const endpoint = `/institutions/overaward/student/${student.id}`;

// Act/Assert.
await request(app.getHttpServer())
.get(endpoint)
.auth(institutionUserToken, BEARER_AUTH_TYPE)
.expect(HttpStatus.OK)
.expect([
{
dateAdded: reassessmentOveraward.addedDate.toISOString(),
createdAt: reassessmentOveraward.createdAt.toISOString(),
overawardOrigin: reassessmentOveraward.originType,
awardValueCode: reassessmentOveraward.disbursementValueCode,
overawardValue: reassessmentOveraward.overawardValue,
applicationNumber: application.applicationNumber,
assessmentTriggerType: studentAssessment.triggerType,
},
]);
});

afterAll(async () => {
await app?.close();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { Controller, Param, ParseIntPipe, Get } from "@nestjs/common";
import { ApiTags } from "@nestjs/swagger";
import { AuthorizedParties } from "../../auth/authorized-parties.enum";
import { AllowAuthorizedParty } from "../../auth/decorators";
import { ClientTypeBaseRoute } from "../../types";
import BaseController from "../BaseController";
import {
OverawardBalanceAPIOutDTO,
StudentsOverawardAPIOutDTO,
} from "./models/overaward.dto";
import { OverawardControllerService } from "..";

@AllowAuthorizedParty(AuthorizedParties.institution)
@Controller("overaward")
@ApiTags(`${ClientTypeBaseRoute.Institution}-overaward`)
export class OverawardInstitutionsController extends BaseController {
constructor(
private readonly overawardControllerService: OverawardControllerService,
) {
super();
}

/**
* Get the overaward balance of a student.
* @param studentId student.
* @returns overaward balance for student.
*/
@Get("student/:studentId/balance")
async getOverawardBalance(
@Param("studentId", ParseIntPipe) studentId: number,
): Promise<OverawardBalanceAPIOutDTO> {
return this.overawardControllerService.getOverawardBalance(studentId);
}

/**
* Get all overawards which belong to a student.
* @param studentId student.
* @returns overaward details of a student.
*/
@Get("student/:studentId")
async getOverawardsByStudent(
@Param("studentId", ParseIntPipe) studentId: number,
): Promise<StudentsOverawardAPIOutDTO[]> {
return this.overawardControllerService.getOverawardsByStudent(studentId);
}
}
5 changes: 3 additions & 2 deletions sources/packages/web/src/constants/routes/RouteConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const StudentRoutesConst = {
STUDENT_APPLICATION_DETAILS: Symbol(),
STUDENT_REQUEST_CHANGE: Symbol(),
STUDENT_ACCOUNT_ACTIVITY: Symbol(),
STUDENT_OVERAWARDS_BALANCE: Symbol(),
STUDENT_OVERAWARDS: Symbol(),
STUDENT_ACCOUNT_APPLICATION_IN_PROGRESS: Symbol(),
STUDENT_APPEAL_REQUESTS: Symbol(),
};
Expand Down Expand Up @@ -74,6 +74,7 @@ export const InstitutionRoutesConst = {
STUDENT_APPLICATIONS: Symbol(),
STUDENT_RESTRICTIONS: Symbol(),
STUDENT_FILE_UPLOADS: Symbol(),
STUDENT_OVERAWARDS: Symbol(),
STUDENT_NOTES: Symbol(),
};

Expand All @@ -91,7 +92,7 @@ export const AESTRoutesConst = {
STUDENT_FILE_UPLOADS: Symbol(),
STUDENT_NOTES: Symbol(),
SIN_MANAGEMENT: Symbol(),
OVERAWARDS: Symbol(),
STUDENT_OVERAWARDS: Symbol(),
andrewsignori-aot marked this conversation as resolved.
Show resolved Hide resolved
PROGRAM_DETAILS: Symbol(),
SEARCH_INSTITUTIONS: Symbol(),
INSTITUTION_PROFILE: Symbol(),
Expand Down
2 changes: 1 addition & 1 deletion sources/packages/web/src/router/AESTRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export const aestRoutes: Array<RouteRecordRaw> = [
},
{
path: AppRoutes.Overawards,
name: AESTRoutesConst.OVERAWARDS,
name: AESTRoutesConst.STUDENT_OVERAWARDS,
props: true,
component: Overawards,
meta: {
Expand Down
14 changes: 14 additions & 0 deletions sources/packages/web/src/router/InstitutionRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import InstitutionStudentProfile from "@/views/institution/student/InstitutionSt
import InstitutionStudentApplications from "@/views/institution/student/InstitutionStudentApplications.vue";
import InstitutionStudentRestrictions from "@/views/institution/student/InstitutionStudentRestrictions.vue";
import InstitutionStudentFileUploads from "@/views/institution/student/InstitutionStudentFileUploads.vue";
import InstitutionStudentOverawards from "@/views/institution/student/InstitutionStudentOverawards.vue";
import InstitutionStudentNotes from "@/views/institution/student/InstitutionStudentNotes.vue";

export const institutionRoutes: Array<RouteRecordRaw> = [
Expand Down Expand Up @@ -515,6 +516,19 @@ export const institutionRoutes: Array<RouteRecordRaw> = [
],
},
},
{
path: AppRoutes.Overawards,
name: InstitutionRoutesConst.STUDENT_OVERAWARDS,
props: true,
component: InstitutionStudentOverawards,
meta: {
clientType: ClientIdType.Institution,
institutionUserTypes: [
InstitutionUserTypes.admin,
InstitutionUserTypes.user,
],
},
},
{
path: AppRoutes.Notes,
name: InstitutionRoutesConst.STUDENT_NOTES,
Expand Down
2 changes: 1 addition & 1 deletion sources/packages/web/src/router/StudentRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export const studentRoutes: Array<RouteRecordRaw> = [
},
{
path: AppRoutes.StudentOverawardsBalance,
name: StudentRoutesConst.STUDENT_OVERAWARDS_BALANCE,
name: StudentRoutesConst.STUDENT_OVERAWARDS,
component: StudentOverawardsBalance,
meta: {
clientType: ClientIdType.Student,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export default defineComponent({
label: "Overawards",
icon: "fa:fa fa-circle-dollar-to-slot",
command: () => ({
name: AESTRoutesConst.OVERAWARDS,
name: AESTRoutesConst.STUDENT_OVERAWARDS,
params: { studentId: props.studentId },
}),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ export default defineComponent({
params: { studentId: props.studentId },
}),
},
{
label: "Overawards",
icon: "fa:fa fa-circle-dollar-to-slot",
command: () => ({
name: InstitutionRoutesConst.STUDENT_OVERAWARDS,
params: { studentId: props.studentId },
}),
},
{
label: "Notes",
icon: "fa:fa fa-sticky-note",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<template>
<tab-container :enableCardView="false">
<student-overaward-details :studentId="studentId"
/></tab-container>
</template>
<script lang="ts">
import { defineComponent } from "vue";
import StudentOverawardDetails from "@/components/common/StudentOverawardDetails.vue";

export default defineComponent({
components: { StudentOverawardDetails },
props: {
studentId: {
type: Number,
required: true,
},
},
});
</script>
2 changes: 1 addition & 1 deletion sources/packages/web/src/views/student/AppStudent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export default defineComponent({
title: "Overawards Balance",
props: {
to: {
name: StudentRoutesConst.STUDENT_OVERAWARDS_BALANCE,
name: StudentRoutesConst.STUDENT_OVERAWARDS,
},
},
},
Expand Down