From 245886fea59ad5f3b96650399edd25bdb4095363 Mon Sep 17 00:00:00 2001 From: Michael Johnson Date: Wed, 13 Nov 2024 15:50:10 -0700 Subject: [PATCH] Minor NARS fixes --- .../services/admin/nars-dis-reporting-service.ts | 8 +++++--- .../services/admin/nars-pt-reporting-service.ts | 16 ++++++++++++---- .../admin/nars-v17-2-reporting-service.ts | 4 ++-- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/api/services/admin/nars-dis-reporting-service.ts b/src/api/services/admin/nars-dis-reporting-service.ts index fcaf421d..af45cd72 100644 --- a/src/api/services/admin/nars-dis-reporting-service.ts +++ b/src/api/services/admin/nars-dis-reporting-service.ts @@ -91,7 +91,7 @@ export class NarsDisabilityReportingService { .select("request_type_id") .groupBy("request_type_id") .sum("disbursed_amount as disbursed_amount") - .min("due_date as disbursed_date") + .min("due_date as disbursed_date") .min("issue_date as issue_date"); let disGrant = otherFunds.find((f) => f.request_type_id == 29); @@ -144,12 +144,14 @@ export class NarsDisabilityReportingService { row.push(new Column("csg_pd_auth", csg_d, "0", 5)); row.push(new Column("csg_pd_disb", csg_d, "0", 5)); - row.push(new Column("csg_pd_authdate", moment.utc(csg_di_date).format("YYYYMMDD"), " ", 8)); + row.push(new Column("csg_pd_authdate", csg_di_date ? moment.utc(csg_di_date).format("YYYYMMDD") : "", " ", 8)); row.push(new Column("csg_pd_disbdate", csg_d_date ? moment.utc(csg_d_date).format("YYYYMMDD") : "", " ", 8)); row.push(new Column("csg_pdse_auth", csg_dse, "0", 5)); row.push(new Column("csg_pdse_disb", csg_dse, "0", 5)); - row.push(new Column("csg_pdse_authdate", moment.utc(csg_dsei_date).format("YYYYMMDD"), " ", 8)); + row.push( + new Column("csg_pdse_authdate", csg_dsei_date ? moment.utc(csg_dsei_date).format("YYYYMMDD") : "", " ", 8) + ); row.push(new Column("csg_pdse_disbdate", csg_dse_date ? moment.utc(csg_dse_date).format("YYYYMMDD") : "", " ", 8)); row.push(new Column("disab_code1", code1, ".", 1)); diff --git a/src/api/services/admin/nars-pt-reporting-service.ts b/src/api/services/admin/nars-pt-reporting-service.ts index e5e2c012..93687d45 100644 --- a/src/api/services/admin/nars-pt-reporting-service.ts +++ b/src/api/services/admin/nars-pt-reporting-service.ts @@ -1,7 +1,8 @@ import { DB_CONFIG } from "@/config"; +import { calculateFamilySize } from "./nars-v17-2-reporting-service"; import { weeksBetween } from "@/utils/date-utils"; import knex from "knex"; -import { isUndefined } from "lodash"; +import { isEmpty, isUndefined } from "lodash"; import moment from "moment"; const db = knex(DB_CONFIG); @@ -87,7 +88,7 @@ export class NarsPTReportingService { async makeRows(app: any): Promise { let result = new Array(); - console.log("APPP", app); + //console.log("APPP", app); let num_dep_child_pse = 0; let depchild_to_11_and_dis_12over = 0; @@ -191,6 +192,13 @@ export class NarsPTReportingService { console.log("NO APP"); } + let family = await calculateFamilySize( + app.csl_classification, + appId?.application_id ?? 0, + !isEmpty(app.parent1_sin), + !isEmpty(app.parent2_sin) + ); + let row = new Row(); row.push(new Column("loanyear", `${this.year}${this.year + 1}`, " ", 8)); row.push(new Column("prov_issue", "YT", " ", 2)); @@ -209,7 +217,7 @@ export class NarsPTReportingService { row.push(new Column("disab_flag", app.is_perm_disabled ? "1" : app.is_disabled ? "2" : "0", " ", 1)); row.push(new Column("disab_sr_status", app.is_disabled && !app.is_perm_disabled ? "Y" : "N", " ", 1)); - row.push(new Column("family_size", app.family_size, " ", 2)); + row.push(new Column("family_size", app.family_size ?? family.family_size, " ", 2)); row.push(new Column("dep_under12_or_disabled", depchild_to_11_and_dis_12over, " ", 1)); row.push(new Column("depchild_12over_ndis_andOthDep", depchild_12over_ndis_andothdep, " ", 1)); @@ -239,7 +247,7 @@ export class NarsPTReportingService { row.push(new Column("csl_pt_amt", csl_pt || 0, "0", 5)); // sum of loan disbursements for this assessment row.push(new Column("psl_pt_amt", "", "0", 5)); // always 0 - row.push(new Column("principal_outstanding", app.outstanding_cslpt_amount, "0", 5)); + row.push(new Column("principal_outstanding", app.outstanding_cslpt_amount ?? "", "0", 5)); row.push(new Column("csg_pt_studies", csg_pt, "0", 5)); row.push(new Column("csg_ptdep", csg_ptdep, "0", 5)); diff --git a/src/api/services/admin/nars-v17-2-reporting-service.ts b/src/api/services/admin/nars-v17-2-reporting-service.ts index 8e8d02ab..f80d02cb 100644 --- a/src/api/services/admin/nars-v17-2-reporting-service.ts +++ b/src/api/services/admin/nars-v17-2-reporting-service.ts @@ -232,7 +232,7 @@ export class NarsV17_2ReportingService { stud_sp_cost_other -= stud_sp_cost_computers; let req_need = app.csl_request_amount; - let tot_ass_res = app.student_expected_contribution; + let tot_ass_res = app.student_expected_contribution ?? 0; if (app.is_csg_only) req_need = 0; else if (app.is_csl_full_amount) req_need = app.study_weeks * 210; @@ -462,7 +462,7 @@ export class Column { } } -async function calculateFamilySize( +export async function calculateFamilySize( classification: number, applicationId: number, hasParent1: boolean,