Skip to content

Commit

Permalink
Merge pull request #564 from bcgov/ccfri-3752-add-afs
Browse files Browse the repository at this point in the history
ccfri-3752, ccfri-3754, ccfri-3813 - add AFS page to Application
  • Loading branch information
vietle-cgi authored Nov 14, 2024
2 parents 1b20ed7 + 5649c7c commit 710fb49
Show file tree
Hide file tree
Showing 14 changed files with 707 additions and 230 deletions.
14 changes: 14 additions & 0 deletions backend/src/components/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const {
OrganizationFacilityMappings,
CCOFApplicationFundingMapping,
OrganizationMappings,
CCFRIApprovableFeeSchedulesMappings,
CCFRIFacilityMappings,
//ChangeRequestMappings
} = require('../util/mapping/Mappings');
Expand Down Expand Up @@ -150,6 +151,18 @@ async function updateCCFRIApplication(req, res) {
return res.status(HttpStatus.OK).json(retVal);
}

async function getApprovableFeeSchedules(req, res) {
try {
const response = await getOperation(`ccof_applicationccfris(${req.params.ccfriId})?$select=ccof_afs_status&$expand=ccof_afs_applicationccfri`);
const afs = new MappableObjectForFront(response, ApplicationSummaryCcfriMappings).toJSON();
afs.approvableFeeSchedules = response?.ccof_afs_applicationccfri?.map((item) => new MappableObjectForFront(item, CCFRIApprovableFeeSchedulesMappings).toJSON());
return res.status(HttpStatus.OK).json(afs);
} catch (e) {
log.error('An error occurred while getting CCFRI AFS', e);
return res.status(HttpStatus.INTERNAL_SERVER_ERROR).json(e.data ? e.data : e?.status);
}
}

/* child care and program year GUIDs are looked up in AddNewFees.vue */

async function upsertParentFees(req, res) {
Expand Down Expand Up @@ -817,6 +830,7 @@ module.exports = {
getApplicationSummary,
updateStatusForApplicationComponents,
getChangeRequest,
getApprovableFeeSchedules,
patchCCFRIApplication,
deleteCCFRIApplication,
printPdf,
Expand Down
234 changes: 140 additions & 94 deletions backend/src/routes/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,155 +2,201 @@ const express = require('express');
const passport = require('passport');
const router = express.Router();
const auth = require('../components/auth');
const isValidBackendToken= auth.isValidBackendToken();
const { deleteRfiApplication, getRFIMedian, getRFIApplication, createRFIApplication, updateRFIApplication} = require('../components/rfiApplication');
const isValidBackendToken = auth.isValidBackendToken();
const { deleteRfiApplication, getRFIMedian, getRFIApplication, createRFIApplication, updateRFIApplication } = require('../components/rfiApplication');
const { upsertParentFees, updateCCFRIApplication, deleteCCFRIApplication, renewCCOFApplication, getApplicationSummary, getChangeRequest, deletePcfApplication } = require('../components/application');
const { patchCCFRIApplication,getECEWEApplication, updateECEWEApplication, updateECEWEFacilityApplication, getCCFRIApplication, getDeclaration, submitApplication,updateStatusForApplicationComponents} = require('../components/application');
const {
patchCCFRIApplication,
getECEWEApplication,
updateECEWEApplication,
updateECEWEFacilityApplication,
getApprovableFeeSchedules,
getCCFRIApplication,
getDeclaration,
submitApplication,
updateStatusForApplicationComponents,
} = require('../components/application');
const { getNMFApplication, updateNMFApplication, createNMFApplication } = require('../components/nmfApplication');
const { param, validationResult } = require('express-validator');

router.post('/renew-ccof', passport.authenticate('jwt', {session: false}),isValidBackendToken, [], (req, res) => {
router.post('/renew-ccof', passport.authenticate('jwt', { session: false }), isValidBackendToken, [], (req, res) => {
return renewCCOFApplication(req, res);
});

/* CREATE or UPDATE an existing CCFRI application for opt-in and out
CCOF application guid and facility guid are defined in the payload
*/
router.get('/ccfri/:ccfriId', passport.authenticate('jwt', {session: false}),isValidBackendToken,
[param('ccfriId', 'URL param: [ccfriId] is required').not().isEmpty()], (req, res) => {
validationResult(req).throw();
return getCCFRIApplication(req, res);
});
router.get('/ccfri/:ccfriId', passport.authenticate('jwt', { session: false }), isValidBackendToken, [param('ccfriId', 'URL param: [ccfriId] is required').notEmpty().isUUID()], (req, res) => {
validationResult(req).throw();
return getCCFRIApplication(req, res);
});

router.get('/ccfri/:ccfriId/rfi', passport.authenticate('jwt', {session: false}),isValidBackendToken,
[param('ccfriId', 'URL param: [ccfriId] is required').not().isEmpty()], (req, res) => {
validationResult(req).throw();
return getRFIApplication(req, res);
});
router.get('/ccfri/:ccfriId/afs', passport.authenticate('jwt', { session: false }), isValidBackendToken, [param('ccfriId', 'URL param: [ccfriId] is required').notEmpty().isUUID()], (req, res) => {
validationResult(req).throw();
return getApprovableFeeSchedules(req, res);
});

router.post('/ccfri/:ccfriId/rfi', passport.authenticate('jwt', {session: false}),isValidBackendToken,
[param('ccfriId', 'URL param: [ccfriId] is required').not().isEmpty()], (req, res) => {
validationResult(req).throw();
return createRFIApplication(req, res);
});
router.get('/ccfri/:ccfriId/rfi', passport.authenticate('jwt', { session: false }), isValidBackendToken, [param('ccfriId', 'URL param: [ccfriId] is required').notEmpty().isUUID()], (req, res) => {
validationResult(req).throw();
return getRFIApplication(req, res);
});

router.put('/ccfri/rfi/:rfipfiid', passport.authenticate('jwt', {session: false}),isValidBackendToken,
[param('rfipfiid', 'URL param: [rfipfiid] is required').not().isEmpty()], (req, res) => {
validationResult(req).throw();
return updateRFIApplication(req, res);
});
router.post('/ccfri/:ccfriId/rfi', passport.authenticate('jwt', { session: false }), isValidBackendToken, [param('ccfriId', 'URL param: [ccfriId] is required').notEmpty().isUUID()], (req, res) => {
validationResult(req).throw();
return createRFIApplication(req, res);
});

router.get('/ccfri/:ccfriId/median', passport.authenticate('jwt', {session: false}),isValidBackendToken,
[param('ccfriId', 'URL param: [ccfriId] is required').not().isEmpty()], (req, res) => {
validationResult(req).throw();
return getRFIMedian(req, res);
});
router.put('/ccfri/rfi/:rfipfiid', passport.authenticate('jwt', { session: false }), isValidBackendToken, [param('rfipfiid', 'URL param: [rfipfiid] is required').notEmpty().isUUID()], (req, res) => {
validationResult(req).throw();
return updateRFIApplication(req, res);
});

router.delete('/ccfri/:ccfriId/rfi', passport.authenticate('jwt', {session: false}),isValidBackendToken,
[param('ccfriId', 'URL param: [ccfriId] is required').not().isEmpty()], (req, res) => {
validationResult(req).throw();
return deleteRfiApplication(req, res);
});
router.get('/ccfri/:ccfriId/median', passport.authenticate('jwt', { session: false }), isValidBackendToken, [param('ccfriId', 'URL param: [ccfriId] is required').notEmpty().isUUID()], (req, res) => {
validationResult(req).throw();
return getRFIMedian(req, res);
});

router.patch('/ccfri', passport.authenticate('jwt', {session: false}),isValidBackendToken, [], (req, res) => {
router.delete('/ccfri/:ccfriId/rfi', passport.authenticate('jwt', { session: false }), isValidBackendToken, [param('ccfriId', 'URL param: [ccfriId] is required').notEmpty().isUUID()], (req, res) => {
validationResult(req).throw();
return deleteRfiApplication(req, res);
});

router.patch('/ccfri', passport.authenticate('jwt', { session: false }), isValidBackendToken, [], (req, res) => {
//validationResult(req).throw();
//console.log(req.bpdy);
return updateCCFRIApplication(req, res);
});

router.patch('/ccfri/:ccfriId/', passport.authenticate('jwt', {session: false}),isValidBackendToken, [], (req, res) => {
router.patch('/ccfri/:ccfriId/', passport.authenticate('jwt', { session: false }), isValidBackendToken, [param('ccfriId', 'URL param: [ccfriId] is required').notEmpty().isUUID()], (req, res) => {
//validationResult(req).throw();
return patchCCFRIApplication(req, res);
});

router.delete('/ccfri/:ccfriId/', passport.authenticate('jwt', {session: false}),isValidBackendToken,
[param('ccfriId', 'URL param: [ccfriId] is required').not().isEmpty()], (req, res) => {
return deleteCCFRIApplication(req, res);
router.delete('/ccfri/:ccfriId/', passport.authenticate('jwt', { session: false }), isValidBackendToken, [param('ccfriId', 'URL param: [ccfriId] is required').notEmpty().isUUID()], (req, res) => {
return deleteCCFRIApplication(req, res);
});

router.get('/ccfri/:ccfriId/nmf', passport.authenticate('jwt', {session: false}),isValidBackendToken,
[param('ccfriId', 'URL param: [ccfriId] is required').not().isEmpty()], (req, res) => {
validationResult(req).throw();
return getNMFApplication(req, res);
});
router.get('/ccfri/:ccfriId/nmf', passport.authenticate('jwt', { session: false }), isValidBackendToken, [param('ccfriId', 'URL param: [ccfriId] is required').notEmpty().isUUID()], (req, res) => {
validationResult(req).throw();
return getNMFApplication(req, res);
});

router.post('/ccfri/:ccfriId/nmf', passport.authenticate('jwt', {session: false}),isValidBackendToken,
[param('ccfriId', 'URL param: [ccfriId] is required').not().isEmpty()], (req, res) => {
validationResult(req).throw();
return createNMFApplication(req, res);
});
router.post('/ccfri/:ccfriId/nmf', passport.authenticate('jwt', { session: false }), isValidBackendToken, [param('ccfriId', 'URL param: [ccfriId] is required').notEmpty().isUUID()], (req, res) => {
validationResult(req).throw();
return createNMFApplication(req, res);
});

router.put('/ccfri/nmf/:nmfpfiid', passport.authenticate('jwt', {session: false}),isValidBackendToken,
[param('nmfpfiid', 'URL param: [nmfpfiid] is required').not().isEmpty()], (req, res) => {
validationResult(req).throw();
return updateNMFApplication(req, res);
});
router.put('/ccfri/nmf/:nmfpfiid', passport.authenticate('jwt', { session: false }), isValidBackendToken, [param('nmfpfiid', 'URL param: [nmfpfiid] is required').notEmpty().isUUID()], (req, res) => {
validationResult(req).throw();
return updateNMFApplication(req, res);
});

/* CREATE or UPDATE parent fees for a specified age group and year.
age group and year are defined in the payload
*/
router.patch('/parentfee', passport.authenticate('jwt', {session: false}),isValidBackendToken, [], (req, res) => {
router.patch('/parentfee', passport.authenticate('jwt', { session: false }), isValidBackendToken, [], (req, res) => {
//validationResult(req).throw();
//console.log(req.bpdy);
return upsertParentFees(req, res);
});


/* Retrieve an ECEWE application for an application id. */
router.get('/ecewe/:applicationId', passport.authenticate('jwt', {session: false}),isValidBackendToken, (req, res) => {
return getECEWEApplication(req, res);
});
router.get(
'/ecewe/:applicationId',
passport.authenticate('jwt', { session: false }),
isValidBackendToken,
[param('applicationId', 'URL param: [applicationId] is required').notEmpty().isUUID()],
(req, res) => {
return getECEWEApplication(req, res);
},
);

/* Update an ECEWE applciation for an application id. */
router.patch('/ecewe/:applicationId', passport.authenticate('jwt', {session: false}),isValidBackendToken, [
param('applicationId', 'URL param: [applicationId] is required').not().isEmpty()], (req, res) => {
return updateECEWEApplication(req, res);
});
router.patch(
'/ecewe/:applicationId',
passport.authenticate('jwt', { session: false }),
isValidBackendToken,
[param('applicationId', 'URL param: [applicationId] is required').notEmpty().isUUID()],
(req, res) => {
return updateECEWEApplication(req, res);
},
);

/* Update an ECEWE facility applciation for an ecewe application id. */
router.post('/ecewe/facilities/:applicationId', passport.authenticate('jwt', {session: false}),isValidBackendToken, [
param('applicationId', 'URL param: [applicationId] is required').not().isEmpty()], (req, res) => {
return updateECEWEFacilityApplication(req, res);
});
router.post(
'/ecewe/facilities/:applicationId',
passport.authenticate('jwt', { session: false }),
isValidBackendToken,
[param('applicationId', 'URL param: [applicationId] is required').notEmpty().isUUID()],
(req, res) => {
return updateECEWEFacilityApplication(req, res);
},
);

/* Get the user declaration for a given application id. */
router.get('/declaration/:applicationId', passport.authenticate('jwt', {session: false}),isValidBackendToken, (req, res) => {
return getDeclaration(req, res);
});
router.get(
'/declaration/:applicationId',
passport.authenticate('jwt', { session: false }),
isValidBackendToken,
[param('applicationId', 'URL param: [applicationId] is required').notEmpty().isUUID()],
(req, res) => {
return getDeclaration(req, res);
},
);

/* Update Declaration for an CCOF/CCFRI/ECEWE application given an application id. */
router.patch('/declaration/submit/:applicationId', passport.authenticate('jwt', {session: false}),isValidBackendToken, [
param('applicationId', 'URL param: [applicationId] is required').not().isEmpty()], (req, res) => {
return submitApplication(req, res);
});
router.patch(
'/declaration/submit/:applicationId',
passport.authenticate('jwt', { session: false }),
isValidBackendToken,
[param('applicationId', 'URL param: [applicationId] is required').notEmpty().isUUID()],
(req, res) => {
return submitApplication(req, res);
},
);

/* Get the full summary of the application */
router.get('/summary/:applicationId', passport.authenticate('jwt', {session: false}),isValidBackendToken, [
param('applicationId', 'URL param: [applicationId] is required').not().isEmpty()], (req, res) => {
return getApplicationSummary(req, res);
});

router.put('/status/:applicationId', passport.authenticate('jwt', {session: false}),isValidBackendToken,
[param('applicationId', 'URL param: [applicationId] is required').not().isEmpty()], (req, res) => {
router.get(
'/summary/:applicationId',
passport.authenticate('jwt', { session: false }),
isValidBackendToken,
[param('applicationId', 'URL param: [applicationId] is required').notEmpty().isUUID()],
(req, res) => {
return getApplicationSummary(req, res);
},
);

router.put(
'/status/:applicationId',
passport.authenticate('jwt', { session: false }),
isValidBackendToken,
[param('applicationId', 'URL param: [applicationId] is required').notEmpty().isUUID()],
(req, res) => {
validationResult(req).throw();
return updateStatusForApplicationComponents(req, res);
});
},
);

/* Get existing change requests for an application */

router.get('/changeRequest/:applicationId', passport.authenticate('jwt', {session: false}),isValidBackendToken, [
param('applicationId', 'URL param: [applicationId] is required').not().isEmpty()], (req, res) => {
return getChangeRequest(req, res);
});

router.get(
'/changeRequest/:applicationId',
passport.authenticate('jwt', { session: false }),
isValidBackendToken,
[param('applicationId', 'URL param: [applicationId] is required').notEmpty().isUUID()],
(req, res) => {
return getChangeRequest(req, res);
},
);

/* DELETE an existing PCF -- new PCF ONLY */

router.delete('/:applicationId/', passport.authenticate('jwt', {session: false}),isValidBackendToken,
[param('applicationId', 'URL param: [applicationId] is required').not().isEmpty()], (req, res) => {
router.delete(
'/:applicationId/',
passport.authenticate('jwt', { session: false }),
isValidBackendToken,
[param('applicationId', 'URL param: [applicationId] is required').notEmpty().isUUID()],
(req, res) => {
return deletePcfApplication(req, res);
});

},
);

module.exports = router;

Loading

0 comments on commit 710fb49

Please sign in to comment.