Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
guru-aot committed Dec 20, 2024
1 parent e803fd6 commit 1e0b821
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ import {
AssessmentSequentialProcessingService,
AwardTotal,
FTProgramYearContributionTotal,
ProgramYearTotal,
SystemUsersService,
WorkflowClientService,
} from "@sims/services";
Expand Down Expand Up @@ -423,21 +422,20 @@ export class AssessmentController {
this.studentAssessmentService.saveAssessmentCalculationStartDate(
assessmentId,
);
const programYearTotals = await this.getProgramYearTotals(
assessmentId,
{
alternativeReferenceDate: new Date(),
offeringIntensity: offeringIntensity,
},
);
const programYearTotals =
await this.assessmentSequentialProcessingService.getProgramYearTotals(
assessmentId,
{
alternativeReferenceDate: new Date(),
offeringIntensity: offeringIntensity,
},
);
// Updates the calculation start date and get the program year totals and for
// full-time the contribution program year totals in parallel.
const [, programYearTotalAwards, ftProgramYearContributionTotal] =
await Promise.all([
saveAssessmentCalculationStartDate,
programYearTotals.awardTotal,
programYearTotals.ftProgramYearContributionTotal,
]);
const [programYearAwardsContributionTotal] = await Promise.all([
programYearTotals,
saveAssessmentCalculationStartDate,
]);
if (
assessment.offering.offeringIntensity === OfferingIntensity.partTime
) {
Expand All @@ -451,8 +449,8 @@ export class AssessmentController {
`The assessment calculation order has been verified and the assessment id ${assessmentId} is ready to be processed.`,
);
this.createOutputForProgramYearTotals(
programYearTotalAwards,
ftProgramYearContributionTotal,
programYearAwardsContributionTotal.awardTotal,
programYearAwardsContributionTotal.ftProgramYearContributionTotal,
result,
);
result.isReadyForCalculation = true;
Expand Down Expand Up @@ -503,59 +501,6 @@ export class AssessmentController {
});
}

/**
* Get the promises of the program year awards totals for part-time and
* full-time and contribution totals for full-time for the assessment.
* @param assessmentId assessment id.
* @param options method options.
* - `offeringIntensity` the offering intensity to be used.
* - `alternativeReferenceDate` the reference date to be used.
* @returns the promise to get the program year totals.
*/
private async getProgramYearTotals(
assessmentId: number,
options?: {
offeringIntensity?: OfferingIntensity;
alternativeReferenceDate?: Date;
},
): Promise<ProgramYearTotal> {
// Get the current assessment from the assessment id.
const currentAssessment =
await this.assessmentSequentialProcessingService.getCurrentAssessment(
assessmentId,
);
// The chronology of the applications is defined by the method {@link getSequencedApplications}.
// Only the current assessment awards are considered since it must reflect the most updated
// workflow calculated values.
const sequencedApplications =
await this.assessmentSequentialProcessingService.getSequencedApplications(
currentAssessment.application.applicationNumber,
currentAssessment.application.student.id,
currentAssessment.application.programYear.id,
{ alternativeReferenceDate: options?.alternativeReferenceDate },
);
// Get the application numbers of the previous applications.
const applicationNumbers = sequencedApplications.previous.map(
(application) => application.applicationNumber,
);
return {
// Get the program year awards totals for part-time and full-time.
awardTotal:
this.assessmentSequentialProcessingService.getProgramYearPreviousAwardsTotals(
sequencedApplications,
currentAssessment,
options,
),
// Only get the full-time contribution totals if the offering intensity is full-time.
ftProgramYearContributionTotal:
OfferingIntensity.fullTime === options.offeringIntensity
? this.assessmentSequentialProcessingService.getFTProgramYearContributionTotals(
applicationNumbers,
)
: null,
};
}

/**
* Creates a well-known object that represents the universe of possible
* information that can be later filtered.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ export interface AwardTotal {
* and for full-time program year contribution (e.g. ScholarshipsBursaries, SpouseContributionWeeks, FederalFSC, ProvincialFSC) and its totals promise.
*/
export interface ProgramYearTotal {
awardTotal: Promise<AwardTotal[]>;
ftProgramYearContributionTotal?: Promise<FTProgramYearContributionTotal[]>;
awardTotal: AwardTotal[];
ftProgramYearContributionTotal?: FTProgramYearContributionTotal[];
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
import {
AwardTotal,
FTProgramYearContributionTotal,
ProgramYearTotal,
SequencedApplications,
SequentialApplication,
} from "..";
Expand Down Expand Up @@ -133,6 +134,58 @@ export class AssessmentSequentialProcessingService {
return applicationRepo.save(impactedApplication);
}

/**
* Get the program year awards totals for part-time and
* full-time and contribution totals for full-time for the assessment.
* @param assessmentId assessment id.
* @param options method options.
* - `offeringIntensity` the offering intensity to be used.
* - `alternativeReferenceDate` the reference date to be used.
* @returns the promise to get the program year totals.
*/
async getProgramYearTotals(
assessmentId: number,
options?: {
offeringIntensity?: OfferingIntensity;
alternativeReferenceDate?: Date;
},
): Promise<ProgramYearTotal> {
// Get the current assessment from the assessment id.
const currentAssessment = await this.getCurrentAssessment(assessmentId);
// The chronology of the applications is defined by the method {@link getSequencedApplications}.
// Only the current assessment awards are considered since it must reflect the most updated
// workflow calculated values.
const sequencedApplications = await this.getSequencedApplications(
currentAssessment.application.applicationNumber,
currentAssessment.application.student.id,
currentAssessment.application.programYear.id,
{ alternativeReferenceDate: options?.alternativeReferenceDate },
);
// Get the application numbers of the previous applications.
const applicationNumbers = sequencedApplications.previous.map(
(application) => application.applicationNumber,
);

const [programYearTotalAwards, ftProgramYearContributionTotal] =
await Promise.all([
// Get the program year awards totals for part-time and full-time.
await this.getProgramYearPreviousAwardsTotals(
sequencedApplications,
currentAssessment,
options,
),
// Only get the full-time contribution totals if the offering intensity is full-time.
OfferingIntensity.fullTime === options.offeringIntensity &&
applicationNumbers?.length > 0
? await this.getFTProgramYearContributionTotals(applicationNumbers)
: null,
]);
return {
awardTotal: programYearTotalAwards,
ftProgramYearContributionTotal: ftProgramYearContributionTotal,
};
}

/**
* Returns the sum of all awards associated with non-overwritten applications.
* Only pending awards or already sent awards will be considered.
Expand All @@ -148,7 +201,7 @@ export class AssessmentSequentialProcessingService {
* for instance, if the application is the first application or the only application for the
* program year.
*/
async getProgramYearPreviousAwardsTotals(
private async getProgramYearPreviousAwardsTotals(
sequencedApplications: SequencedApplications,
assessment: StudentAssessment,
options?: { alternativeReferenceDate?: Date },
Expand Down Expand Up @@ -264,7 +317,7 @@ export class AssessmentSequentialProcessingService {
* @param applicationNumbers application numbers.
* @returns full-time program year contribution totals.
*/
async getFTProgramYearContributionTotals(
private async getFTProgramYearContributionTotals(
applicationNumbers: string[],
): Promise<FTProgramYearContributionTotal[]> {
const totals = await this.applicationRepo
Expand Down Expand Up @@ -317,7 +370,9 @@ export class AssessmentSequentialProcessingService {
* @param assessmentId assessment id.
* @returns current assessment.
*/
async getCurrentAssessment(assessmentId: number): Promise<StudentAssessment> {
private async getCurrentAssessment(
assessmentId: number,
): Promise<StudentAssessment> {
const currentAssessment = await this.studentAssessmentRepo.findOne({
select: {
id: true,
Expand Down Expand Up @@ -372,7 +427,7 @@ export class AssessmentSequentialProcessingService {
* {@link applicationNumber} used as reference does not have a calculated date yet.
* @returns sequenced applications.
*/
async getSequencedApplications(
private async getSequencedApplications(
applicationNumber: string,
studentId: number,
programYearId: number,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@
<bpmn:intermediateThrowEvent id="Event_0w0bgro" name="Configure workflow data">
<bpmn:extensionElements>
<zeebe:ioMapping>
<zeebe:output source="={ &#10; studentData: {&#10; dependantStatus: studentDataDependantstatus,&#10; relationshipStatus: studentDataRelationshipStatus,&#10; livingWithParents: studentDataLivingWithParents,&#10; numberOfParents: if is defined(studentDataNumberOfParents) then studentDataNumberOfParents&#10; else null&#10; },&#10; dmnValues:{&#10; lifetimeMaximumCSLP: if(dmnPartTimeAwardAllowableLimits!=null) then dmnPartTimeAwardAllowableLimits.limitAwardCSLPAmount else null&#10; },&#10; calculatedData: {&#10; pdppdStatus: calculatedDataPDPPDStatus,&#10; parentalAssets: if is defined(calculatedDataParentalAssets)&#10; then calculatedDataParentalAssets else null,&#10; studentMaritalStatusCode: if is defined(calculatedDataStudentMaritalStatusCode) &#10; then calculatedDataStudentMaritalStatusCode else null,&#10; totalEligibleDependents: calculatedDataTotalEligibleDependants,&#10; familySize: calculatedDataFamilySize,&#10; parentalAssetContribution: if is defined(calculatedDataParentalAssetContribution) &#10; then calculatedDataParentalAssetContribution else null,&#10; parentalContribution: if is defined(calculatedDataParentalContribution) &#10; then calculatedDataParentalContribution else null,&#10; parentDiscretionaryIncome: if is defined(calculatedDataTotalDiscretionaryIncome) &#10; then calculatedDataTotalDiscretionaryIncome else null ,&#10; dependantTotalMSOLAllowance: if is defined(calculatedDataDependantTotalMSOLAllowance) &#10; then calculatedDataDependantTotalMSOLAllowance else null,&#10; studentMSOLAllowance: if is defined(calculatedDataStudentMSOLAllowance) &#10; then calculatedDataStudentMSOLAllowance else null,&#10; totalChildCareCost: if is defined(calculatedDataTotalChildCareCost) &#10; then calculatedDataTotalChildCareCost else null,&#10; totalNonEducationalCost: if is defined(calaulatedDataTotalNonEducationalCost) &#10; then calaulatedDataTotalNonEducationalCost else null,&#10; dependantChildQuantity: if is defined(calculatedDataDependantChildQuantity) &#10; then calculatedDataDependantChildQuantity else null,&#10; dependantChildInDaycareQuantity: if is defined(calculatedDataDependantChildInDaycareQuantity)&#10; then calculatedDataDependantChildInDaycareQuantity else null,&#10; dependantInfantQuantity: if is defined(calculatedDataDependantInfantQuantity)&#10; then calculatedDataDependantInfantQuantity else null,&#10; dependantDeclaredOnTaxesQuantity: if is defined(calculatedDataDependantDeclaredOnTaxesQuantity)&#10; then calculatedDataDependantDeclaredOnTaxesQuantity else null,&#10; dependantPostSecondaryQuantity: if is defined(calculatedDataDependantPostSecondaryQuantity)&#10; then calculatedDataDependantPostSecondaryQuantity else null,&#10; partnerStudentStudyWeeks: if is defined(calculatedDataPartnerStudentStudyWeeks)&#10; then calculatedDataPartnerStudentStudyWeeks else null,&#10; dependants11YearsOrUnder: if is defined(calculatedDataDependants11YearsOrUnder)&#10; then calculatedDataDependants11YearsOrUnder else null,&#10; dependants12YearsOverOnTaxes: if is defined(calculatedDataDependants12YearsOverOnTaxes)&#10; then calculatedDataDependants12YearsOverOnTaxes else null,&#10; partner1TotalIncome: if is defined(calculatedDataPartner1TotalIncome)&#10; then calculatedDataPartner1TotalIncome else null,&#10; studentTotalIncome: if is defined(calculatedDataStudentTotalIncome)&#10; then calculatedDataStudentTotalIncome else null, &#10; totalDaycareCosts11YearsOrUnder: if is defined(calculatedDataTotalDaycareCosts11YearsOrUnder)&#10; then calculatedDataTotalDaycareCosts11YearsOrUnder else null,&#10; totalDaycareCosts12YearsOrOver: if is defined(calculatedDataTotalDaycareCosts12YearsOrOver)&#10; then calculatedDataTotalDaycareCosts12YearsOrOver else null,&#10; totalFederalFSC: if is defined(calculatedDataTotalFederalFSC) then calculatedDataTotalFederalFSC else null,&#10; totalProvincialFSC: if is defined(calculatedDataTotalProvincialFSC) then calculatedDataTotalProvincialFSC else null,&#10; studentScholarshipsBursaries: if is defined(calculatedDataTotalScholarshipsBursaries) then calculatedDataTotalScholarshipsBursaries else null,&#10; studentSpouseContribution: if is defined(calculatedDataTotalSpouseContribution) then calculatedDataTotalSpouseContribution else null&#10; }&#10;}" target="workflowData" />
<zeebe:output source="={ &#10; studentData: {&#10; dependantStatus: studentDataDependantstatus,&#10; relationshipStatus: studentDataRelationshipStatus,&#10; livingWithParents: studentDataLivingWithParents,&#10; numberOfParents: if is defined(studentDataNumberOfParents) then studentDataNumberOfParents&#10; else null&#10; },&#10; dmnValues:{&#10; lifetimeMaximumCSLP: if(dmnPartTimeAwardAllowableLimits!=null) then dmnPartTimeAwardAllowableLimits.limitAwardCSLPAmount else null&#10; },&#10; calculatedData: {&#10; pdppdStatus: calculatedDataPDPPDStatus,&#10; parentalAssets: if is defined(calculatedDataParentalAssets)&#10; then calculatedDataParentalAssets else null,&#10; studentMaritalStatusCode: if is defined(calculatedDataStudentMaritalStatusCode) &#10; then calculatedDataStudentMaritalStatusCode else null,&#10; totalEligibleDependents: calculatedDataTotalEligibleDependants,&#10; familySize: calculatedDataFamilySize,&#10; parentalAssetContribution: if is defined(calculatedDataParentalAssetContribution) &#10; then calculatedDataParentalAssetContribution else null,&#10; parentalContribution: if is defined(calculatedDataParentalContribution) &#10; then calculatedDataParentalContribution else null,&#10; parentDiscretionaryIncome: if is defined(calculatedDataTotalDiscretionaryIncome) &#10; then calculatedDataTotalDiscretionaryIncome else null ,&#10; dependantTotalMSOLAllowance: if is defined(calculatedDataDependantTotalMSOLAllowance) &#10; then calculatedDataDependantTotalMSOLAllowance else null,&#10; studentMSOLAllowance: if is defined(calculatedDataStudentMSOLAllowance) &#10; then calculatedDataStudentMSOLAllowance else null,&#10; totalChildCareCost: if is defined(calculatedDataTotalChildCareCost) &#10; then calculatedDataTotalChildCareCost else null,&#10; totalNonEducationalCost: if is defined(calaulatedDataTotalNonEducationalCost) &#10; then calaulatedDataTotalNonEducationalCost else null,&#10; dependantChildQuantity: if is defined(calculatedDataDependantChildQuantity) &#10; then calculatedDataDependantChildQuantity else null,&#10; dependantChildInDaycareQuantity: if is defined(calculatedDataDependantChildInDaycareQuantity)&#10; then calculatedDataDependantChildInDaycareQuantity else null,&#10; dependantInfantQuantity: if is defined(calculatedDataDependantInfantQuantity)&#10; then calculatedDataDependantInfantQuantity else null,&#10; dependantDeclaredOnTaxesQuantity: if is defined(calculatedDataDependantDeclaredOnTaxesQuantity)&#10; then calculatedDataDependantDeclaredOnTaxesQuantity else null,&#10; dependantPostSecondaryQuantity: if is defined(calculatedDataDependantPostSecondaryQuantity)&#10; then calculatedDataDependantPostSecondaryQuantity else null,&#10; partnerStudentStudyWeeks: if is defined(calculatedDataPartnerStudentStudyWeeks)&#10; then calculatedDataPartnerStudentStudyWeeks else null,&#10; dependants11YearsOrUnder: if is defined(calculatedDataDependants11YearsOrUnder)&#10; then calculatedDataDependants11YearsOrUnder else null,&#10; dependants12YearsOverOnTaxes: if is defined(calculatedDataDependants12YearsOverOnTaxes)&#10; then calculatedDataDependants12YearsOverOnTaxes else null,&#10; partner1TotalIncome: if is defined(calculatedDataPartner1TotalIncome)&#10; then calculatedDataPartner1TotalIncome else null,&#10; studentTotalIncome: if is defined(calculatedDataStudentTotalIncome)&#10; then calculatedDataStudentTotalIncome else null, &#10; totalDaycareCosts11YearsOrUnder: if is defined(calculatedDataTotalDaycareCosts11YearsOrUnder)&#10; then calculatedDataTotalDaycareCosts11YearsOrUnder else null,&#10; totalDaycareCosts12YearsOrOver: if is defined(calculatedDataTotalDaycareCosts12YearsOrOver)&#10; then calculatedDataTotalDaycareCosts12YearsOrOver else null,&#10; totalFederalFSC: if is defined(calculatedDataTotalFederalFSC) then calculatedDataTotalFederalFSC else null,&#10; totalProvincialFSC: if is defined(calculatedDataTotalProvincialFSC) then calculatedDataTotalProvincialFSC else null,&#10; exemptScholarshipsBursaries: if is defined(calculatedDataExemptScholarshipsBursaries) then calculatedDataExemptScholarshipsBursaries else null,&#10; studentSpouseContributionWeeks: if is defined(calculatedDataSpouseContributionWeeks) then calculatedDataSpouseContributionWeeks else null&#10; }&#10;}" target="workflowData" />
</zeebe:ioMapping>
</bpmn:extensionElements>
<bpmn:incoming>Flow_1txrz77</bpmn:incoming>
Expand Down

0 comments on commit 1e0b821

Please sign in to comment.