Skip to content

Commit

Permalink
Merge pull request #311 from icefoganalytics/test
Browse files Browse the repository at this point in the history
NARS stub and STA fix
  • Loading branch information
datajohnson authored Oct 31, 2024
2 parents dfb6506 + bd85364 commit 689766c
Show file tree
Hide file tree
Showing 11 changed files with 1,481 additions and 507 deletions.
90 changes: 90 additions & 0 deletions src/api/controllers/admin/reporting-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,96 @@ export default class ReportingController extends BaseController {
);
}

async runNars2023FTReport() {
return ReportingService.runNars2023FTReport({ format: this.format }).then((reportData) => {
if (this.format == "html") {
this.response.send(reportData);
} else if (this.format == "csv") {
this.response.setHeader("Content-disposition", `attachment; filename="PPYT.CSLS.NARS_2324.001.csv"`);
this.response.setHeader("Content-type", "text/csv");
this.response.send(reportData);
} else if (this.format == "json") {
this.response.json(reportData);
} else {
this.response.setHeader("Content-disposition", `attachment; filename="PPYT.CSLS.NARS_2324.001.txt"`);
this.response.setHeader("Content-type", "text/plain");
this.response.send(reportData);
}
});
}

async runNars2023PTReport() {
return ReportingService.runNars2023PTReport({ format: this.format }).then((reportData) => {
if (this.format == "html") {
this.response.send(reportData);
} else if (this.format == "csv") {
this.response.setHeader("Content-disposition", `attachment; filename="PPYT.CSLS.PT_NARS_2324.001.csv"`);
this.response.setHeader("Content-type", "text/csv");
this.response.send(reportData);
} else if (this.format == "json") {
this.response.json(reportData);
} else {
this.response.setHeader("Content-disposition", `attachment; filename="PPYT.CSLS.PT_NARS_2324.001.txt"`);
this.response.setHeader("Content-type", "text/plain");
this.response.send(reportData);
}
});
}

async runNars2023DisabilityReport() {
let academic_year_id = parseInt(this.request.params.academic_year_id ?? moment().format("YYYY"));
return ReportingService.runNars2023DisabilityReport({ format: this.format, academic_year_id }).then(
(reportData) => {
if (this.format == "html") {
this.response.send(reportData);
} else if (this.format == "csv") {
this.response.setHeader(
"Content-disposition",
`attachment; filename="PPYT.CSLS.PDEXPAND_2324.${moment().format("YYYY-MM-DD")}.csv"`
);
this.response.setHeader("Content-type", "text/csv");
this.response.send(reportData);
} else if (this.format == "json") {
this.response.json(reportData);
} else {
this.response.setHeader(
"Content-disposition",
`attachment; filename="PPYT.CSLS.PDEXPAND_2324.${moment().format("YYYY-MM-DD")}.txt"`
);
this.response.setHeader("Content-type", "text/plain");
this.response.send(reportData);
}
}
);
}

async runNars2023DisabilityRCLReport() {
let academic_year_id = parseInt(this.request.params.academic_year_id ?? moment().format("YYYY"));
return ReportingService.runNars2023DisabilityRCLReport({ format: this.format, academic_year_id }).then(
(reportData) => {
if (this.format == "html") {
this.response.send(reportData);
} else if (this.format == "csv") {
this.response.setHeader(
"Content-disposition",
`attachment; filename="PPYT.CSLS.PDReducedCourseLoad_2324.${moment().format("YYYY-MM-DD")}.csv"`
);
this.response.setHeader("Content-type", "text/csv");
this.response.send(reportData);
} else if (this.format == "json") {
this.response.json(reportData);
} else {
this.response.setHeader(
"Content-disposition",
`attachment; filename="PPYT.CSLS.PDReducedCourseLoad_2324.${moment().format("YYYY-MM-DD")}.txt"`
);
this.response.setHeader("Content-type", "text/plain");
this.response.send(reportData);
}
}
);
}

async runStepReport() {
let academic_year_id = parseInt(this.request.params.academic_year_id ?? moment().format("YYYY"));

Expand Down
22 changes: 20 additions & 2 deletions src/api/repositories/assessment/assessment-sta-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,22 @@ export class AssessmentSTA extends AssessmentBaseRepository {

initValues.funding_request_id = funding_request_id;
initValues.assessed_date = moment().toDate();
initValues.effective_rate_date = this.application.classes_start_date;
initValues.classes_start_date = this.application.classes_start_date;
initValues.classes_end_date = this.application.classes_end_date;

const lastAssessment = await this.mainDb("assessment")
.withSchema("sfa")
.where({ funding_request_id: funding_request_id })
.orderBy("assessed_date", "desc")
.first();

if (lastAssessment) {
console.log("LAST ONE: ", lastAssessment);
initValues.effective_rate_date = lastAssessment.effective_rate_date; // don't override this
}

if (!initValues.effective_rate_date) initValues.effective_rate_date = this.application.classes_start_date;

initValues.home_city_id = await this.getScalarValue<number>("fn_get_home_city", [this.application.student_id || 0]);
initValues.destination_city_id = await this.getScalarValue<number>("fn_get_institution_city", [application_id]);
initValues.dependent_count = await this.getScalarValue<number>("fn_get_dependent_count_sta_fct", [application_id]);
Expand Down Expand Up @@ -85,9 +98,14 @@ export class AssessmentSTA extends AssessmentBaseRepository {
application_id,
]);

const allowedWeeksBasedOnEffectiveDate = weeksBetween(
initValues.effective_rate_date,
this.application.classes_end_date
);

initValues.weeks_allowed = await this.getScalarValue<number>("fn_get_weeks_allowed_sta", [
initValues.previous_weeks || 0,
initValues.assessed_weeks || 0,
allowedWeeksBasedOnEffectiveDate || 0,
prev_weeks_curr_yr || 0, // prev_weeks_curr_yr nvl(GET_PREV_WEEKS_CURR_YR('Normal'),0)
]);
initValues.previous_upgrade_weeks = await this.getScalarValue<number>("fn_get_previous_weeks_sfa", [
Expand Down
6 changes: 6 additions & 0 deletions src/api/routes/admin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ adminRouter.use("/reporting/nars2022", routedTo(ReportingController, "runNars202
adminRouter.use("/reporting/nars2022pt", routedTo(ReportingController, "runNars2022PTReport"));
adminRouter.use("/reporting/nars2022dis/:academic_year_id", routedTo(ReportingController, "runNars2022DisabilityReport"));
adminRouter.use("/reporting/nars2022disrcl/:academic_year_id", routedTo(ReportingController, "runNars2022DisabilityRCLReport"));

adminRouter.use("/reporting/nars2023", routedTo(ReportingController, "runNars2023FTReport"));
adminRouter.use("/reporting/nars2023pt", routedTo(ReportingController, "runNars2023PTReport"));
adminRouter.use("/reporting/nars2023dis/:academic_year_id", routedTo(ReportingController, "runNars2023DisabilityReport"));
adminRouter.use("/reporting/nars2023disrcl/:academic_year_id", routedTo(ReportingController, "runNars2023DisabilityRCLReport"));

adminRouter.use("/reporting/step/:academic_year_id", routedTo(ReportingController, "runStepReport"));
adminRouter.use("/reporting/approvedFunding/:academic_year_id", routedTo(ReportingController, "runApprovedFundingReport"));
adminRouter.use("/reporting/t4a/:tax_year", routedTo(ReportingController, "runT4AReport"));
Expand Down
Loading

0 comments on commit 689766c

Please sign in to comment.