Skip to content

Commit

Permalink
#1715 COE and Tuition Remittance - e-Cert Adjustments (#1840)
Browse files Browse the repository at this point in the history
#1715 COE and Tuition Remittance - e-Cert Adjustments (#1840)
  • Loading branch information
ann-aot authored Mar 30, 2023
1 parent bdbfc5f commit 2dcbe73
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { MigrationInterface, QueryRunner } from "typeorm";
import { getSQLFileData } from "../utilities/sqlLoader";

export class AddTuitionRemittanceEffectiveAmountCol1679688897417
implements MigrationInterface
{
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
getSQLFileData(
"Add-tuition-remittance-effective-amount-col.sql",
"DisbursementSchedules",
),
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
getSQLFileData(
"Remove-tuition-remittance-effective-amount-col.sql",
"DisbursementSchedules",
),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- Add tuition_remittance_effective_amount to disbursement_schedules table.
ALTER TABLE
sims.disbursement_schedules
ADD
COLUMN IF NOT EXISTS tuition_remittance_effective_amount NUMERIC(8, 2);

COMMENT ON COLUMN sims.disbursement_schedules.tuition_remittance_effective_amount IS 'Effective tuition remittance considered for the disbursement evaluated based on awards effective values.';
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- Drop tuition_remittance_effective_amount from sims.disbursement_schedules.
ALTER TABLE
sims.disbursement_schedules DROP COLUMN IF EXISTS tuition_remittance_effective_amount;
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,12 @@ export class CancelApplicationAssessmentProcessor {
}

if (
assessment.application.applicationStatus !== ApplicationStatus.Cancelled
![ApplicationStatus.Cancelled, ApplicationStatus.Overwritten].includes(
assessment.application.applicationStatus,
)
) {
await job.discard();
const errorMessage = `Application must be in the ${ApplicationStatus.Cancelled} state to have the assessment cancelled.`;
const errorMessage = `Application must be in the ${ApplicationStatus.Cancelled} or ${ApplicationStatus.Overwritten} state to have the assessment cancelled.`;
this.logger.error(errorMessage);
throw new Error(errorMessage);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ export class ECertFileHandler extends ESDCFileHandler {
disbursementDate: new Date(disbursement.disbursementDate),
documentProducedDate: now,
negotiatedExpiryDate: new Date(disbursement.negotiatedExpiryDate),
schoolAmount: disbursement.tuitionRemittanceRequestedAmount,
schoolAmount: disbursement.tuitionRemittanceEffectiveAmount,
educationalStartDate: new Date(offering.studyStartDate),
educationalEndDate: new Date(offering.studyEndDate),
federalInstitutionCode: offering.institutionLocation.institutionCode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
SequenceControlService,
StudentRestrictionSharedService,
NoteSharedService,
ConfirmationOfEnrollmentService,
} from "@sims/services";
import { ECertFileHandler } from "./e-cert-file-handler";
import { ECertFullTimeFileFooter } from "./e-cert-full-time-integration/e-cert-files/e-cert-file-footer";
Expand Down Expand Up @@ -42,6 +43,7 @@ import { SystemUsersService } from "@sims/services/system-users";
ECertGenerationService,
DisbursementOverawardService,
NoteSharedService,
ConfirmationOfEnrollmentService,
],
exports: [ECertFileHandler],
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { addDays, round } from "@sims/utilities";
import { EntityManager } from "typeorm";
import {
AwardValueWithRelatedSchedule,
ConfirmationOfEnrollmentService,
DisbursementOverawardService,
StudentRestrictionSharedService,
} from "@sims/services";
Expand All @@ -29,6 +30,7 @@ import {
LOAN_TYPES,
} from "@sims/services/constants";
import { SystemUsersService } from "@sims/services/system-users";
import { MaxTuitionRemittanceTypes } from "@sims/services/confirmation-of-enrollment/models/confirmation-of-enrollment.models";

/**
* While performing a possible huge amount of updates,
Expand All @@ -48,6 +50,7 @@ export class ECertGenerationService {
private readonly studentRestrictionService: StudentRestrictionSharedService,
private readonly disbursementOverawardService: DisbursementOverawardService,
private readonly systemUsersService: SystemUsersService,
private readonly confirmationOfEnrollmentService: ConfirmationOfEnrollmentService,
) {}

/**
Expand Down Expand Up @@ -77,10 +80,12 @@ export class ECertGenerationService {
await this.applyOverawardsDeductions(disbursements, entityManager);
// Step 2 - Execute the calculation to define the final value to be used for the e-Cert.
this.calculateEffectiveValue(disbursements);
// Step 3 - Calculate BC total grants after all others calculations are done.
// Step 3 - Calculate tuition remittance effective amount.
this.calculateTuitionRemittanceEffectiveAmount(disbursements);
// Step 4 - Calculate BC total grants after all others calculations are done.
//!This step relies on the effective value calculation (step 2).
await this.createBCTotalGrants(disbursements);
// Step 4 - Mark all disbursements as 'sent'.
// Step 5 - Mark all disbursements as 'sent'.
const now = new Date();
disbursements.forEach((disbursement) => {
disbursement.disbursementScheduleStatus = DisbursementScheduleStatus.Sent;
Expand Down Expand Up @@ -151,6 +156,8 @@ export class ECertGenerationService {
"offering.studyEndDate",
"offering.yearOfStudy",
"offering.offeringIntensity",
"offering.actualTuitionCosts",
"offering.programRelatedCosts",
"educationProgram.id",
"educationProgram.fieldOfStudyCode",
"educationProgram.completionYears",
Expand Down Expand Up @@ -497,4 +504,21 @@ export class ECertGenerationService {
}
}
}

/**
* Calculate tuition remittance effective amount.
* @param disbursements all disbursements that are part of one e-Cert.
*/
private calculateTuitionRemittanceEffectiveAmount(
disbursements: ECertDisbursementSchedule[],
) {
for (const disbursement of disbursements) {
disbursement.tuitionRemittanceEffectiveAmount =
this.confirmationOfEnrollmentService.getMaxTuitionRemittance(
disbursement.disbursementValues,
disbursement.studentAssessment.application.currentAssessment.offering,
MaxTuitionRemittanceTypes.Effective,
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,14 @@ export class DisbursementSchedule extends RecordDataModel {
nullable: false,
})
disbursementScheduleStatus: DisbursementScheduleStatus;
/**
* Tuition remittance effective amount of a disbursement.
*/
@Column({
name: "tuition_remittance_effective_amount",
nullable: true,
})
tuitionRemittanceEffectiveAmount?: number;

/**
* Id of the MSFAA (Master Student Financial Aid Agreement)
Expand Down

0 comments on commit 2dcbe73

Please sign in to comment.