diff --git a/src/api/routes/admin/csg-threshold-router.ts b/src/api/routes/admin/csg-threshold-router.ts index 1d1b2987..0ec2b829 100644 --- a/src/api/routes/admin/csg-threshold-router.ts +++ b/src/api/routes/admin/csg-threshold-router.ts @@ -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(), diff --git a/src/web/src/components/application/assessments/store/csl-full-time.js b/src/web/src/components/application/assessments/store/csl-full-time.js index 8a162477..4e642d36 100644 --- a/src/web/src/components/application/assessments/store/csl-full-time.js +++ b/src/web/src/components/application/assessments/store/csl-full-time.js @@ -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) => { diff --git a/src/web/src/components/application/assessments/views/CSLFT.vue b/src/web/src/components/application/assessments/views/CSLFT.vue index e46b0946..ca2daace 100644 --- a/src/web/src/components/application/assessments/views/CSLFT.vue +++ b/src/web/src/components/application/assessments/views/CSLFT.vue @@ -51,9 +51,13 @@ mdi-pin-outline Record Overaward + + mdi-pin-outline + Remove Applied Overaward + mdi-eraser - Apply Student Overaward + Apply Existing Overaward mdi-trash-can-outline @@ -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; }, @@ -267,6 +274,7 @@ export default { "clearOveraward", "recordOveraward", "deleteAssessment", + "unApplyOveraward", ]), ...mapActions([ "setCslClassifications", @@ -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) => {