Skip to content

Commit

Permalink
Merge pull request #177 from icefoganalytics/test
Browse files Browse the repository at this point in the history
CSLPT
  • Loading branch information
datajohnson authored Oct 13, 2023
2 parents 24a1fdd + 8b84638 commit 78a3653
Show file tree
Hide file tree
Showing 24 changed files with 3,883 additions and 1,920 deletions.
626 changes: 296 additions & 330 deletions src/api/repositories/cheque_req_list/cheque-req-list-repository.ts

Large diffs are not rendered by default.

364 changes: 193 additions & 171 deletions src/api/routes/admin/application-router.ts

Large diffs are not rendered by default.

56 changes: 23 additions & 33 deletions src/api/routes/admin/cheque-req-list-router.ts
Original file line number Diff line number Diff line change
@@ -1,44 +1,34 @@
import knex from "knex";
import express, { Request, Response } from "express";
import { body, param } from "express-validator";
import { ReturnValidationErrors } from "../../middleware";
import { DB_CONFIG } from "../../config";
import { ChequeReqList } from '../../repositories/cheque_req_list';
import { ChequeReqList } from "../../repositories/cheque_req_list";

const db = knex(DB_CONFIG)
const db = knex(DB_CONFIG);
export const chequeReqRouter = express.Router();

chequeReqRouter.get("/",
async (req: Request, res: Response) => {
try {
const { issueDate = "", reRunBatch = null } = req.query;

let start_p = 0;
chequeReqRouter.get("/", async (req: Request, res: Response) => {
const { issueDate = "", reRunBatch = null } = req.query;

if (
reRunBatch !== null &&
reRunBatch !== "" &&
Number(reRunBatch)
) {
start_p = Number(reRunBatch);
}
try {
let start_p = 0;

if (issueDate?.length !== 10) {
return res.status(200).json({
success: false,
text: 'Select a valid date'
});
}
if (reRunBatch !== null && reRunBatch !== "" && Number(reRunBatch)) {
start_p = Number(reRunBatch);
}

const chequeRequest = new ChequeReqList(db);
if (issueDate?.length !== 10) {
return res.status(200).json({
success: false,
text: "Select a valid date",
});
}

const records: any = await chequeRequest.validate(issueDate.toString(), start_p);

return res.status(200).json({ ...records });
const chequeRequest = new ChequeReqList(db);
const records: any = await chequeRequest.validate(issueDate.toString(), start_p);

} catch (error) {
console.log(error);
return res.status(404).send();
}
}
);
return res.status(200).json({ ...records });
} catch (error) {
console.log(error);
return res.status(404).send();
}
});
191 changes: 185 additions & 6 deletions src/api/routes/admin/csg-threshold-router.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import express, { Request, Response } from "express";
import knex from "knex";
import { DB_CONFIG } from "../../config";
import { isArray } from "lodash";
import { isArray, sortBy } from "lodash";
import { param } from "express-validator";
import { ReturnValidationErrors } from "@/middleware";
import { cleanNumber } from "@/models";
import moment from "moment";

const db = knex(DB_CONFIG);

const CSGDEP_REQUEST_TYPE_ID = 32;
const CSGD_REQUEST_TYPE_ID = 29;
const CSGTU_REQUEST_TYPE_ID = 28;
const CSGFT_REQUEST_TYPE_ID = 35;
const CSGD_REQUEST_TYPE_ID = 29;
const CSGDSE_REQUEST_TYPE_ID = 30;
const CSGDEP_REQUEST_TYPE_ID = 32;
const CSGFT_REQUEST_TYPE_ID = 35;
const CSLPT_REQUEST_TYPE_ID = 5;

export const csgThresholdRouter = express.Router();

Expand Down Expand Up @@ -72,7 +74,7 @@ csgThresholdRouter.get(
const { application_id } = req.params;

let funding_request = await db("sfa.funding_request")
.where({ application_id, request_type_id: 5 })
.where({ application_id, request_type_id: CSLPT_REQUEST_TYPE_ID })
.orderBy("id", "desc")
.first();

Expand All @@ -91,7 +93,9 @@ csgThresholdRouter.get(
.orderBy("issue_date")
.orderBy("id");

return res.json({ data: { funding_request, assessment, disbursements } });
let msfaa = await db("sfa.msfaa").where({ application_id }).first();

return res.json({ data: { funding_request, assessment, disbursements, msfaa } });
}

res.status(404).send("Funding Request not found");
Expand Down Expand Up @@ -268,6 +272,108 @@ csgThresholdRouter.get(
}
);

csgThresholdRouter.get(
"/csgpt/:application_id",
param("application_id").isInt(),
ReturnValidationErrors,
async (req: Request, res: Response) => {
const { application_id } = req.params;

let funding_request = await db("sfa.funding_request")
.where({ application_id, request_type_id: 31 })
.orderBy("id", "desc")
.first();

if (funding_request) {
let assessment = await db("sfa.assessment")
.where({
funding_request_id: funding_request.id,
})
.orderBy("id", "desc")
.first();

let disbursements = await db("sfa.disbursement")
.where({
funding_request_id: funding_request.id,
})
.orderBy("issue_date")
.orderBy("id");

return res.json({ data: { funding_request, assessment, disbursements } });
}

res.status(404).send("Funding Request not found");
}
);

csgThresholdRouter.get(
"/csgdpt/:application_id",
param("application_id").isInt(),
ReturnValidationErrors,
async (req: Request, res: Response) => {
const { application_id } = req.params;

let funding_request = await db("sfa.funding_request")
.where({ application_id, request_type_id: 34 })
.orderBy("id", "desc")
.first();

if (funding_request) {
let assessment = await db("sfa.assessment")
.where({
funding_request_id: funding_request.id,
})
.orderBy("id", "desc")
.first();

let disbursements = await db("sfa.disbursement")
.where({
funding_request_id: funding_request.id,
})
.orderBy("issue_date")
.orderBy("id");

return res.json({ data: { funding_request, assessment, disbursements } });
}

res.status(404).send("Funding Request not found");
}
);

csgThresholdRouter.get(
"/csgptdep/:application_id",
param("application_id").isInt(),
ReturnValidationErrors,
async (req: Request, res: Response) => {
const { application_id } = req.params;

let funding_request = await db("sfa.funding_request")
.where({ application_id, request_type_id: 33 })
.orderBy("id", "desc")
.first();

if (funding_request) {
let assessment = await db("sfa.assessment")
.where({
funding_request_id: funding_request.id,
})
.orderBy("id", "desc")
.first();

let disbursements = await db("sfa.disbursement")
.where({
funding_request_id: funding_request.id,
})
.orderBy("issue_date")
.orderBy("id");

return res.json({ data: { funding_request, assessment, disbursements } });
}

res.status(404).send("Funding Request not found");
}
);

csgThresholdRouter.post(
"/csgftdep/:application_id/funding-request/:funding_request_id/assessment",
param("application_id").isInt(),
Expand Down Expand Up @@ -301,6 +407,79 @@ csgThresholdRouter.post(
await db("sfa.disbursement").insert(disb);
}
}

let fundingRequest = await db("sfa.funding_request").where({ id: funding_request_id }).first();

if (fundingRequest && fundingRequest.request_type_id == CSLPT_REQUEST_TYPE_ID) {
let msfaaForApplication = await db("sfa.msfaa").where({ application_id });

if (msfaaForApplication.length == 0) {
let app = await db("sfa.application").where({ id: application_id }).select("student_id").first();

if (app) {
let msfaaForStudent = await db("sfa.msfaa")
.where({ student_id: app.student_id, is_full_time: false })
.whereNull("cancel_date");

if (msfaaForStudent.length == 0) {
await db("sfa.msfaa").insert({
application_id,
student_id: app.student_id,
msfaa_status: "Pending",
is_full_time: false,
});
console.log("ADDING NEW MSFAA", {
application_id,
student_id: app.student_id,
msfaa_status: "Pending",
is_full_time: false,
});
} else {
let relevantIds = new Array<number>();

for (let msfaa of msfaaForStudent) {
let msfaaApp = await db("sfa.application").where({ id: msfaa.application_id }).first();

if (msfaaApp) {
if (moment(new Date()).diff(msfaaApp.classes_end_date, "year") > 2) {
await db("sfa.msfaa").where({ id: msfaa.id }).update({
cancel_date: new Date(),
cancel_reason: "> 2 yrs out of school",
msfaa_status: "Cancelled",
});
console.log("CANCELLEING EXPIRED MSFAA", msfaa.id);
} else {
relevantIds.push(msfaa.id);
}
}
}

if (relevantIds.length > 0) {
relevantIds = sortBy(relevantIds, "desc").reverse();
let first = true;

for (let relevantId of relevantIds) {
if (first) {
await db("sfa.msfaa").where({ id: relevantId }).update({
application_id,
});
console.log("MOVING MSFAA", relevantId, application_id);
} else {
await db("sfa.msfaa").where({ id: relevantId }).update({
cancel_date: new Date(),
cancel_reason: "Duplicate",
msfaa_status: "Cancelled",
});
console.log("CANCELLING DUP MSFAA", relevantId);
}

first = false;
}
}
}
}
}
}
}

res.status(201).send();
Expand Down
2 changes: 1 addition & 1 deletion src/web/src/components/ConfirmDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<v-card>
<v-card-title>{{ title }}</v-card-title>
<v-card-text>{{ message }}</v-card-text>
<v-card-actions>
<v-card-actions class="mb-3">
<v-btn color="primary" v-if="showConfirm" @click="doConfirm()">Confirm</v-btn>
<v-spacer></v-spacer>
<v-btn color="secondary" @click="doDeny()">{{messageButton}}</v-btn>
Expand Down
11 changes: 9 additions & 2 deletions src/web/src/components/application/Status.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,14 @@
</div>

<div class="row">
<div class="col-md-12" v-if="!assessmentComponent && showFundings">
<v-card class="default mb-5" v-for="(item, index) in application.funding_requests" :key="index">
<div class="col-md-12" v-if="!assessmentComponent && showFundings && application.funding_requests">
<v-card
class="default mb-5"
v-for="(item, index) in application.funding_requests?.filter(
(f) => !requestTypesToHide.includes(f.request_type_id)
)"
:key="index"
>
<v-card-title class="d-block mb-2">
<div class="float-right text-right">
<v-btn
Expand Down Expand Up @@ -199,6 +205,7 @@ export default {
received_date_menu: false,
assessmentsComponents: {},
},
requestTypesToHide: [31, 33, 34],
}),
async created() {
this.loadFundingTypes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Disbursements
<v-btn @click="addClick" color="primary" class="float-right" small>Add</v-btn>
</h3>
<v-simple-table class="text-left narrow">
<v-simple-table class="text-left narrow" v-if="disbursements.length > 0">
<template v-slot:default>
<thead>
<tr>
Expand Down Expand Up @@ -39,7 +39,7 @@ import { mapGetters } from "vuex";
import CsgDisbursementLine from "./csg-disbursement-line.vue";
export default {
name: "CSGDisbursemetns",
name: "CSGDisbursements",
props: ["store"],
components: { CsgDisbursementLine },
data: () => ({}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Disbursements
<v-btn @click="addClick" color="primary" class="float-right" small>Add</v-btn>
</h3>
<v-simple-table class="text-left narrow">
<v-simple-table class="text-left narrow" v-if="disbursements.length > 0">
<template v-slot:default>
<thead>
<tr>
Expand Down
Loading

0 comments on commit 78a3653

Please sign in to comment.