Skip to content

Commit

Permalink
Merge pull request #325 from icefoganalytics/test
Browse files Browse the repository at this point in the history
Unapply Overawards
  • Loading branch information
datajohnson authored Dec 18, 2024
2 parents 7b64374 + b07fb07 commit 4ffce20
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 2 deletions.
44 changes: 44 additions & 0 deletions src/api/routes/admin/csg-threshold-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,50 @@ csgThresholdRouter.post(
}
);

csgThresholdRouter.post(
"/funding-request/:funding_request_id/assessment/:assessment_id/unapply-overaward",
param("assessment_id").isInt(),
param("funding_request_id").isInt(),
ReturnValidationErrors,
async (req: Request, res: Response) => {
const { assessment_id, funding_request_id } = req.params;

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

let repo = new AssessmentCslftRepositoryV2(db);
let loaded = await repo.loadExisting(assessment, fundingRequest.application_id);
if (!loaded) return res.status(500).send("Error loading assessment");

await db("sfa.overaward")
.where({
assessment_id,
})
.delete();

await db("sfa.assessment").where({ id: assessment_id }).update({
over_award: null,
over_award_applied_flg: null,
});

let recalc = await repo.create(funding_request_id, assessment_id);

delete (recalc as any).id;
delete (recalc as any).assessment_type_id;
(recalc as any).student_contribution_override = null;
(recalc as any).spouse_contribution_override = null;
(recalc as any).parent_contribution_override = null;
(recalc as any).return_uncashable_cert = null;
(recalc as any).csl_non_reason_id = null;
(recalc as any).csl_over_reason_id = null;

await db("sfa.assessment").where({ id: assessment_id }).update(recalc);

return res.status(200).json({ data: "Assessment Saved" });
}
);

csgThresholdRouter.post(
"/cslft/:application_id/funding-request/:funding_request_id/assessment",
param("application_id").isInt(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,17 @@ const actions = {
});
},

async unApplyOveraward({ dispatch }) {
let url = `${CSG_THRESHOLD_URL}/funding-request/${state.fundingRequest.id}/assessment/${state.assessment.id}/unapply-overaward`;

return axios.post(url).then(async (resp) => {
dispatch("loadCSLFTAssessment", {
applicationId: state.fundingRequest.application_id,
assessmentId: state.assessment.id,
});
});
},
async clearOveraward({ dispatch }) {
console.log("CLEARING OVERAWRD");
let url = `${CSG_THRESHOLD_URL}/funding-request/${state.fundingRequest.id}/assessment/${state.assessment.id}/clear-overaward`;

return axios.post(url).then(async (resp) => {
Expand Down
15 changes: 14 additions & 1 deletion src/web/src/components/application/assessments/views/CSLFT.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,13 @@
<v-list-item-icon><v-icon>mdi-pin-outline</v-icon></v-list-item-icon>
<v-list-item-title>Record Overaward</v-list-item-title>
</v-list-item>
<v-list-item v-if="canUnapplyOveraward" @click="unapplyOverawardClick">
<v-list-item-icon><v-icon>mdi-pin-outline</v-icon></v-list-item-icon>
<v-list-item-title>Remove Applied Overaward</v-list-item-title>
</v-list-item>
<v-list-item v-if="canApplyOveraward" @click="applyOverawardClick">
<v-list-item-icon><v-icon>mdi-eraser</v-icon></v-list-item-icon>
<v-list-item-title>Apply Student Overaward</v-list-item-title>
<v-list-item-title>Apply Existing Overaward</v-list-item-title>
</v-list-item>
<v-list-item v-if="canDelete" @click="deleteClick">
<v-list-item-icon><v-icon>mdi-trash-can-outline</v-icon></v-list-item-icon>
Expand Down Expand Up @@ -254,6 +258,9 @@ export default {
!(this.assessment.has_overaward_applied || this.assessment.has_overaward_recorded)
);
},
canUnapplyOveraward() {
return this.assessment.id && this.canSave && this.assessment.has_overaward_applied;
},
canDelete() {
return this.disbursements.length == 0;
},
Expand All @@ -267,6 +274,7 @@ export default {
"clearOveraward",
"recordOveraward",
"deleteAssessment",
"unApplyOveraward",
]),
...mapActions([
"setCslClassifications",
Expand Down Expand Up @@ -323,6 +331,11 @@ export default {
this.showSuccess("Overaward recorded");
});
},
async unapplyOverawardClick() {
await this.unApplyOveraward().then(() => {
this.showSuccess("Overaward removed");
});
},
async deleteClick() {
await this.deleteAssessment()
.then((resp) => {
Expand Down

0 comments on commit 4ffce20

Please sign in to comment.