diff --git a/src/api/repositories/assessment/assessment-cslft-repository-v2.ts b/src/api/repositories/assessment/assessment-cslft-repository-v2.ts index 70b6e75f..bfa54593 100644 --- a/src/api/repositories/assessment/assessment-cslft-repository-v2.ts +++ b/src/api/repositories/assessment/assessment-cslft-repository-v2.ts @@ -1099,7 +1099,7 @@ function cleanDollars(input: number | undefined) { return value; } -async function calculateFamilySize( +export async function calculateFamilySize( db: Knex, classification: number, applicationId: number @@ -1204,7 +1204,7 @@ async function calculateFamilySize( hasParent2 = true; } - logger.info(`PARENT INFO: ${hasParent1}, ${hasParent2}`); + //logger.info(`PARENT INFO: ${hasParent1}, ${hasParent2}`); family.total_dependants = 1 + parentDeps.length; @@ -1221,7 +1221,7 @@ async function calculateFamilySize( family.family_size = 1; } - logger.info(`FAMILY SIZE - ${family.family_size}`); + //logger.info(`FAMILY SIZE - ${family.family_size}`); return family; } diff --git a/src/api/repositories/assessment/assessment-yg-repository.ts b/src/api/repositories/assessment/assessment-yg-repository.ts index ba0facc4..8ec6ada2 100644 --- a/src/api/repositories/assessment/assessment-yg-repository.ts +++ b/src/api/repositories/assessment/assessment-yg-repository.ts @@ -57,6 +57,26 @@ export class AssessmentYukonGrant extends AssessmentBaseRepository { assess.destination_city_id || 0, ])) || 0; + const travel = await this.mainDb.raw( + `SELECT sfa.fn_get_post_leg_outside_travel(${this.application.student_id}) post_leg, sfa.fn_get_pre_leg_outside_travel(${this.application.student_id}) pre_leg` + ); + + let preLegTravel = 0; + let postLegTravel = 0; + let adjTravel = 0; + + if (travel && travel.length > 0) { + const row = travel[0]; + preLegTravel = row.pre_leg; + postLegTravel = row.post_leg; + } + + const travelTotal = preLegTravel + postLegTravel + adjTravel; + + if (travelTotal >= 6) { + assess.airfare_amount = 0; + } + if (this.application.is_correspondence) { assess.travel_allowance = 0; assess.airfare_amount = 0; diff --git a/src/api/services/admin/reporting-service.ts b/src/api/services/admin/reporting-service.ts index 2b228375..c94e438e 100644 --- a/src/api/services/admin/reporting-service.ts +++ b/src/api/services/admin/reporting-service.ts @@ -6,6 +6,7 @@ import { NarsV17ReportingService } from "./nars-v17-reporting-service"; import { NarsPTReportingService } from "./nars-pt-reporting-service"; import { NarsDisabilityReportingService } from "./nars-dis-reporting-service"; import { NarsDisabilityRCLReportingService } from "./nars-disft-reporting-service"; +import { calculateFamilySize } from "@/repositories/assessment/assessment-cslft-repository-v2"; export const STA_YUKON_UNIVERSITY_TEMPLATE = "./templates/admin/reports/student-training-allowance-yukon-university"; @@ -251,7 +252,7 @@ export default class ReportingService { , application.parent1_income, application.parent2_income, application.student_ln150_income, application.spouse_ln150_income , application.classes_start_date, application.classes_end_date , mail_address.address1 mail_address_line1, mail_address.address2 mail_address_line2, mail_address.city mail_address_city, mail_address.province mail_address_province, mail_address.country mail_address_country, mail_address.postal_code mail_address_postal_code - , application.school_email, application.school_telephone + , application.school_email, application.school_telephone, application.id as application_id FROM sfa.funding_request INNER JOIN sfa.application ON funding_request.application_id = application.id INNER JOIN sfa.student ON application.student_id = student.id @@ -288,7 +289,7 @@ export default class ReportingService { INNER JOIN sfa.assessment ON disbursement.assessment_id = assessment.id INNER JOIN sfa.funding_request ON disbursement.funding_request_id = funding_request.id and funding_request.status_id = 7 INNER JOIN sfa.application ON funding_request.application_id = application.id - WHERE application.academic_year_id = 2022 + WHERE application.academic_year_id = ${academic_year_id} GROUP BY student_id, request_type_id ORDER BY student_id`); @@ -298,13 +299,15 @@ export default class ReportingService { FROM sfa.dependent_eligibility INNER JOIN sfa.application on dependent_eligibility.application_id = application.id INNER JOIN sfa.dependent on dependent.id = dependent_eligibility.dependent_id - WHERE application.academic_year_id = 2022 + WHERE application.academic_year_id = ${academic_year_id} AND (dependent_eligibility.is_sta_eligible = 1 OR dependent_eligibility.is_csl_eligible = 1)`); for (let row of results) { let rowPays = payments.filter((p: any) => p.studentId == row.sfaId); let rowDepends = dependents.filter((p: any) => p.studentId == row.sfaId); + console.log("rowDepends", rowDepends); + row.yukon_grant_amount = rowPays.find((r: any) => r.requestTypeId == 2)?.disbursedAmount ?? 0; row.sta_amount = rowPays.find((r: any) => r.requestTypeId == 1)?.disbursedAmount ?? 0; row.yea_amount = rowPays.find((r: any) => r.requestTypeId == 3)?.disbursedAmount ?? 0; @@ -338,18 +341,20 @@ export default class ReportingService { row.sfa_art_amount + row.sfa_husky_amount; - let staCount = rowDepends.filter((r: any) => r.isStaEligible).length; - let csl0Count = rowDepends.filter((r: any) => r.isCslEligible && r.age < 12).length; - let csl12Count = rowDepends.filter((r: any) => r.isCslEligible && r.age > 11).length; + const family = await calculateFamilySize(db, row.csl_classification, row.application_id); + + let staCount = family.sta_dependants; + let csl0Count = family.under12_or_disabled; + let csl12Count = family.over11; row.sta_dependants = staCount; row.csl_dependants_0_11 = csl0Count; row.csl_dependants_12_up = csl12Count; row.csl_dependants_total = csl0Count + csl12Count; + row.csl_family_size = family.family_size; - let csl_family_size = 99; + //console.log("FAMILY", row) - row.csl_family_size = 99; } return results; diff --git a/src/web/src/modules/Administration/store/ReportsStore.js b/src/web/src/modules/Administration/store/ReportsStore.js index d088baf2..e5df5a49 100644 --- a/src/web/src/modules/Administration/store/ReportsStore.js +++ b/src/web/src/modules/Administration/store/ReportsStore.js @@ -402,12 +402,12 @@ const state = { { text: "study_field", value: "studyField" }, { text: "yukon_resident_since", value: "yukonResidentSince" }, { text: "left_high_school", value: "leftHighSchool" }, - { text: "sta_dependants", value: "staDependants" }, - { text: "csl_dependants_0_11", value: "cs_dependants_0_11" }, + { text: "sta_dependants", value: "sta_dependants" }, + { text: "csl_dependants_0_11", value: "csl_dependants_0_11" }, { text: "csl_dependants_12_up", value: "csl_dependants_12_up" }, { text: "csl_dependants_total", value: "csl_dependants_total" }, - { text: "family_size", value: "family_size" }, + { text: "csl_family_size", value: "csl_family_size" }, { text: "prestudy_csl_classification", value: "prestudyCslClassification" }, { text: "prestudy_accomodation", value: "prestudyAccomodation" }, @@ -416,26 +416,26 @@ const state = { { text: "student_prestudy_income", value: "student_prestudy_income" }, { text: "spouse_prestudy_income", value: "spouse_prestudy_income" }, - { text: "student_study_income", value: "student_study_income" }, - { text: "spouse_study_income", value: "spouse_study_income" }, + { text: "studentLn150Income", value: "studentLn150Income" }, + { text: "spouseLn150Income", value: "spouseLn150Income" }, - { text: "csl_parent1_income", value: "csl_parent1_income" }, - { text: "csl_parent2_income", value: "csl_parent2_income" }, + { text: "parent1Income", value: "parent1Income" }, + { text: "parent2Income", value: "parent2Income" }, { text: "csl_study_weeks", value: "csl_study_weeks" }, { text: "csl_assessed_resources", value: "csl_assessed_resources" }, { text: "csl_assessed_expenses", value: "csl_study_weeks" }, { text: "csl_assessed_need", value: "csl_assessed_need" }, { text: "csl_before_overaward", value: "csl_before_overaward" }, - { text: "mail_address1", value: "mail_address_line1" }, - { text: "mail_address2", value: "mail_address_line2" }, - { text: "mail_city", value: "mail_address_city" }, - { text: "mail_province", value: "mail_address_province" }, - { text: "mail_country", value: "mail_address_country" }, - { text: "mail_postal_code", value: "mail_address_postal_code" }, + { text: "mailAddressLine1", value: "mailAddressLine1" }, + { text: "mailAddressLine2", value: "mailAddressLine2" }, + { text: "mailAddressCity", value: "mailAddressCity" }, + { text: "mailAddressProvince", value: "mailAddressProvince" }, + { text: "mailAddressCountry", value: "mailAddressCountry" }, + { text: "mailAddressPostalCode", value: "mailAddressPostalCode" }, - { text: "school_email", value: "school_email" }, - { text: "school_telephone", value: "school_telephone" }, + { text: "schoolEmail", value: "schoolEmail" }, + { text: "schoolTelephone", value: "schoolTelephone" }, ], }, {