Skip to content

Commit ea8eb65

Browse files
authored
Merge pull request #346 from icefoganalytics/test
Update nars-v17-2-reporting-service.ts
2 parents d2dccae + 6cdf899 commit ea8eb65

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/api/services/admin/nars-v17-2-reporting-service.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,10 @@ export class NarsV17_2ReportingService {
262262
let parent_cont = a2?.parent_contribution_override ?? a2?.parent_contribution ?? 0;
263263
let tot_ass_res = a2?.total_contribution ?? 0;
264264

265-
if (Number.isNaN(tot_ass_res)) console.log("STUDENT", tot_ass_res, appId);
265+
if (Number.isNaN(tot_ass_res)) {
266+
console.log("STUDENT", tot_ass_res, appId);
267+
tot_ass_res = 0;
268+
}
266269

267270
let row = new Row();
268271
row.push(new Column("loanyear", `${this.year}${this.year + 1}`, " ", 8));
@@ -381,7 +384,7 @@ export class NarsV17_2ReportingService {
381384
row.push(new Column("tot_ass_cost", cleanMoney(totalCosts), "0", 6));
382385

383386
row.push(new Column("req_need", cleanMoney(req_need), "0", 6)); // if maximum, costs minus resources, or 0 if grants only (multiples of 300/week)
384-
row.push(new Column("tot_calc_need", cleanMoney(totalCosts - tot_ass_res), "+", 7)); // calculated need in award tab
387+
row.push(new Column("tot_calc_need", cleanMoney(parseInt(`${totalCosts}`) - parseInt(`${tot_ass_res}`)), "+", 7)); // calculated need in award tab
385388
row.push(new Column("ass_csl_bef_overa", cleanMoney(csl_ft || 0), "0", 6)); // sum of loan disbursements for this assessment (* should have overawards ignored)
386389
row.push(new Column("ass_psl_bef_overa", "0", "0", 6)); // always 0
387390
row.push(new Column("csl_over_award_recovered", "0", "0", 6)); // this is complicated by the over award change reason, 0 for now
@@ -468,8 +471,15 @@ export class Column {
468471
this.length = length;
469472
//this.output = `${value}`;
470473

471-
if (fill == "+") this.output = "+" + this.rawValue.padStart(length - 1, "0").substring(0, length);
472-
else if (fill == "0")
474+
if (fill == "+") {
475+
if (`${this.rawValue}`.startsWith("-")) {
476+
this.output = this.rawValue.padEnd(length, " ").substring(0, length);
477+
} else if (`${this.rawValue}` == "0") {
478+
this.output = " 0".padEnd(length, " ").substring(0, length);
479+
} else {
480+
this.output = "+" + this.rawValue.padEnd(length, " ").substring(0, length);
481+
}
482+
} else if (fill == "0")
473483
this.output =
474484
this.rawValue.length == 0
475485
? ".".padEnd(length, " ").substring(0, length)

0 commit comments

Comments
 (0)