Skip to content

Commit

Permalink
Merge pull request #315 from icefoganalytics/test
Browse files Browse the repository at this point in the history
NARS fixes
  • Loading branch information
datajohnson authored Nov 13, 2024
2 parents f804341 + 245886f commit 904f892
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
3 changes: 2 additions & 1 deletion src/api/routes/portal/application-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ portalApplicationRouter.get("/:sub/application/:applicationId/documents", async
res.status(404).send();
});

// returns the documents associated with a draft
portalApplicationRouter.get("/:sub/:draftId/required-documents", async (req: Request, res: Response) => {
const { sub, draftId } = req.params;
let student = await studentService.getBySub(sub);
Expand All @@ -100,7 +101,7 @@ portalApplicationRouter.get("/:sub/:draftId/required-documents", async (req: Req
res.status(404).send();
});

//uploads a document
//uploads a document to a draft
portalApplicationRouter.post("/:sub/:draftId/upload", async (req: Request, res: Response) => {
const { sub, draftId } = req.params;
const { requirement_type_id, disability_requirement_id, person_id, dependent_id, mimetype, replace, replace_id } =
Expand Down
8 changes: 5 additions & 3 deletions src/api/services/admin/nars-dis-reporting-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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));
Expand Down
16 changes: 12 additions & 4 deletions src/api/services/admin/nars-pt-reporting-service.ts
Original file line number Diff line number Diff line change
@@ -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);
Expand Down Expand Up @@ -87,7 +88,7 @@ export class NarsPTReportingService {
async makeRows(app: any): Promise<Row[]> {
let result = new Array<Row>();

console.log("APPP", app);
//console.log("APPP", app);

let num_dep_child_pse = 0;
let depchild_to_11_and_dis_12over = 0;
Expand Down Expand Up @@ -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));
Expand All @@ -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));

Expand Down Expand Up @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions src/api/services/admin/nars-v17-2-reporting-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -462,7 +462,7 @@ export class Column {
}
}

async function calculateFamilySize(
export async function calculateFamilySize(
classification: number,
applicationId: number,
hasParent1: boolean,
Expand Down

0 comments on commit 904f892

Please sign in to comment.