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

#1715 COE and Tuition Remittance - e-Cert Adjustments #1840

Merged
merged 6 commits into from
Mar 30, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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
@@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be not a part of the PR or may be. The effective_amount and the awards(which are money values) are NUMERIC(8 , 2) but the tuition_remittance and tuition_remittance_effective_value are INT. Don't we eventually have one data type for the the amounts? @ann-aot @andrewsignori-aot @guru-aot @andrepestana-aot @sh16011993

image

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had some back and forth about the money values actually having decimals or not. I would say that we can ensure that every money amount on DB has the ability to receive the decimals.
We also have different NUMERIC precisions (e.g. NUMERIC(8, 2) and NUMERIC(7, 2)).
I would say that we should normalize them all as NUMERIC(8, 2) which should allow 999,999.99.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I can create a ticket to have this tracked.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing the fix 😉

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

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(
andrewsignori-aot marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -159,4 +159,12 @@ 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;
}