diff --git a/backend/src/components/application.js b/backend/src/components/application.js index 7e53318b..c0a3aa11 100644 --- a/backend/src/components/application.js +++ b/backend/src/components/application.js @@ -290,7 +290,7 @@ async function getECEWEApplication(req, res) { const operation = 'ccof_applications(' + req.params.applicationId + - ')?$select=ccof_ecewe_optin,ccof_ecewe_employeeunion,ccof_ecewe_selecttheapplicablefundingmodel,ccof_ecewe_selecttheapplicablesector,ccof_public_sector_employer,ccof_ecewe_confirmation&$expand=ccof_ccof_application_ccof_applicationecewe_application($select=ccof_name,_ccof_facility_value,ccof_optintoecewe,statuscode)'; + ')?$select=ccof_ecewe_optin,ccof_ecewe_employeeunion,ccof_ecewe_selecttheapplicablefundingmodel,ccof_describe_your_org,ccof_ecewe_selecttheapplicablesector,ccof_public_sector_employer,ccof_union_agreement_reached,ccof_ecewe_confirmation&$expand=ccof_ccof_application_ccof_applicationecewe_application($select=ccof_name,_ccof_facility_value,ccof_optintoecewe,ccof_facilityunionstatus,statuscode)'; let eceweApp = await getOperation(operation); eceweApp = new MappableObjectForFront(eceweApp, ECEWEApplicationMappings); const forFrontFacilities = []; @@ -425,7 +425,7 @@ async function postPdf(req, buffer) { } async function printPdf(req, numOfRetries = 0) { - let url = `${req.headers.referer}/printable`; + const url = `${req.headers.referer}/printable`; log.info('printPdf :: user is', req.session?.passport?.user?.displayName); log.verbose('printPdf :: correlationId is', req.session.correlationID); @@ -511,7 +511,7 @@ function getFacilityInMap(map, facilityId) { async function updateStatusForApplicationComponents(req, res) { const promises = []; - let request = req.body; + const request = req.body; try { if (request.organizationId && request.isOrganizationComplete !== null && request.isOrganizationComplete !== undefined) { let organizationReq = { @@ -538,7 +538,7 @@ async function updateStatusForApplicationComponents(req, res) { } } if (request.facilities) { - for (let facility of request.facilities) { + for (const facility of request.facilities) { if (facility.facilityId && facility.isFacilityComplete !== null && facility.isFacilityComplete !== undefined) { let facilityReq = { isFacilityComplete: facility.isFacilityComplete, @@ -549,7 +549,7 @@ async function updateStatusForApplicationComponents(req, res) { } } if (request.fundings) { - for (let funding of request.fundings) { + for (const funding of request.fundings) { if (funding.basefundingId && funding.isCCOFComplete !== null && funding.isCCOFComplete !== undefined) { let ccofBaseFundingReq = { isCCOFComplete: funding.isCCOFComplete, @@ -560,7 +560,7 @@ async function updateStatusForApplicationComponents(req, res) { } } if (request.ccfris) { - for (let ccfri of request.ccfris) { + for (const ccfri of request.ccfris) { if ( ccfri.ccfriId && ((ccfri.isCCFRIComplete !== null && ccfri.isCCFRIComplete !== undefined) || @@ -589,12 +589,12 @@ async function updateStatusForApplicationComponents(req, res) { async function getApplicationSummary(req, res) { try { - let operation = `ccof_applications(${req.params.applicationId})?$expand=ccof_applicationccfri_Application_ccof_ap($select=${getMappingString( + const operation = `ccof_applications(${req.params.applicationId})?$expand=ccof_applicationccfri_Application_ccof_ap($select=${getMappingString( ApplicationSummaryCcfriMappings, - )}),ccof_ccof_application_ccof_applicationecewe_application($select=ccof_name,_ccof_facility_value,ccof_optintoecewe,statuscode),ccof_application_basefunding_Application`; - let results = await getOperation(operation); + )}),ccof_ccof_application_ccof_applicationecewe_application($select=ccof_name,_ccof_facility_value,ccof_optintoecewe,statuscode,ccof_facilityunionstatus),ccof_application_basefunding_Application`; + const results = await getOperation(operation); - let applicationSummary = new MappableObjectForFront(results, ApplicationSummaryMappings).data; + const applicationSummary = new MappableObjectForFront(results, ApplicationSummaryMappings).data; applicationSummary.organizationProviderType = getLabelFromValue(applicationSummary.organizationProviderType, ORGANIZATION_PROVIDER_TYPES); applicationSummary.applicationType = getLabelFromValue(applicationSummary.applicationType, CCOF_APPLICATION_TYPES); applicationSummary.ccofStatus = getLabelFromValue(applicationSummary.ccofStatus, CCOF_STATUS_CODES, 'NEW'); @@ -621,7 +621,7 @@ async function getApplicationSummary(req, res) { }); //add the change request ID to the facility so we can filter by it on the front end - let allChangeRequests = await getChangeRequestsFromApplicationId(req.params.applicationId); + const allChangeRequests = await getChangeRequestsFromApplicationId(req.params.applicationId); if (allChangeRequests.length > 0) { allChangeRequests.forEach((changeRequest) => { changeRequest.changeActions.forEach((changeAction) => { @@ -646,7 +646,7 @@ async function getApplicationSummary(req, res) { /* Checks if object attrubte name exists in payload */ function checkKey(key, obj) { - for (let name in obj) { + for (const name in obj) { if (name === key) { return true; } @@ -660,27 +660,24 @@ function checkKey(key, obj) { } async function getFacilityChangeData(changeActionId) { - let mappedData = []; + const mappedData = []; //also grab some facility data so we can use the CCOF page.We might also be able to grab CCFRI ID from here? - let newFacOperation = `ccof_change_request_new_facilities?$select=_ccof_facility_value,ccof_change_request_new_facilityid&$expand=ccof_facility($select=name,ccof_facilitystatus)&$filter=_ccof_change_action_value eq ${changeActionId}`; - let newFacData = await getOperation(newFacOperation); - log.info(newFacData, 'new fac data before mapping'); - + const newFacOperation = `ccof_change_request_new_facilities?$select=_ccof_facility_value,ccof_change_request_new_facilityid&$expand=ccof_facility($select=name,ccof_facilitystatus)&$filter=_ccof_change_action_value eq ${changeActionId}`; + const newFacData = await getOperation(newFacOperation); newFacData.value.forEach((fac) => { if (fac.ccof_facility) { - let mappedFacility = new MappableObjectForFront(fac, NewFacilityMappings).toJSON(); + const mappedFacility = new MappableObjectForFront(fac, NewFacilityMappings).toJSON(); mappedFacility.facilityName = fac.ccof_facility['name']; mappedFacility.facilityStatus = fac.ccof_facility['ccof_facilitystatus@OData.Community.Display.V1.FormattedValue']; mappedData.push(mappedFacility); } }); - log.info('faccccc data post mapping', mappedData); return mappedData; } async function getMTFIChangeData(changeActionId) { - let mtfi = await getChangeActionDetails(changeActionId, 'ccof_change_request_mtfis', MtfiMappings, 'ccof_CCFRI', UserProfileBaseCCFRIMappings); + const mtfi = await getChangeActionDetails(changeActionId, 'ccof_change_request_mtfis', MtfiMappings, 'ccof_CCFRI', UserProfileBaseCCFRIMappings); mtfi?.forEach((item) => { item.ccfriStatus = getLabelFromValue(item.ccfriStatus, CCFRI_STATUS_CODES, 'NOT STARTED'); }); @@ -701,25 +698,17 @@ async function getChangeRequestsFromApplicationId(applicationIds) { } }); - log.info(str); - try { - let operation = `ccof_change_requests?$expand=ccof_change_action_change_request&$select=${getMappingString( + const operation = `ccof_change_requests?$expand=ccof_change_action_change_request&$select=${getMappingString( ChangeRequestMappings, )}&$filter=(Microsoft.Dynamics.CRM.In(PropertyName='ccof_application',PropertyValues=${str}))`; - //let operation = `ccof_change_requests?$expand=ccof_change_action_change_request&$select=${getMappingString(ChangeRequestMappings)}&$filter=_ccof_application_value eq ${applicationId}`; let changeRequests = await getOperation(operation); changeRequests = changeRequests.value; - // log.info('ALL CHANGE REQZ'); - // log.info(changeRequests); - - let payload = []; - - //log.verbose(changeRequests); + const payload = []; await Promise.all( changeRequests.map(async (request) => { - let req = new MappableObjectForFront(request, ChangeRequestMappings).toJSON(); + const req = new MappableObjectForFront(request, ChangeRequestMappings).toJSON(); //go through the array of change ACTIONS and map them. Depending on the type of change action - we might need to load more data. req.changeActions = await Promise.all( @@ -738,8 +727,6 @@ async function getChangeRequestsFromApplicationId(applicationIds) { payload.push(req); }), ); - - //log.info('final payload', payload); return payload; } catch (e) { log.error('An error occurred while getting change request', e); @@ -751,8 +738,6 @@ async function getChangeRequest(req, res) { try { //pulled the logic out into a seperate function so it can be called from somewhere else const payload = await getChangeRequestsFromApplicationId(req.params.applicationId); - - //log.info('final payload', payload); return res.status(HttpStatus.OK).json(payload); } catch (e) { log.error('An error occurred while getting change request', e); @@ -762,14 +747,13 @@ async function getChangeRequest(req, res) { async function deletePcfApplication(req, res) { try { - let operation = `ccof_applications(${req.params.applicationId})?$expand=ccof_application_basefunding_Application($select=_ccof_facility_value)`; - let application = await getOperation(operation); + const operation = `ccof_applications(${req.params.applicationId})?$expand=ccof_application_basefunding_Application($select=_ccof_facility_value)`; + const application = await getOperation(operation); //loop thru to grab facility ID's and delete all of them await Promise.all( application['ccof_application_basefunding_Application'].map(async (facility) => { await deleteOperationWithObjectId('accounts', facility['_ccof_facility_value']); - //log.info(response); }), ); diff --git a/backend/src/components/changeRequest.js b/backend/src/components/changeRequest.js index 9c35de8d..e5c3c5be 100644 --- a/backend/src/components/changeRequest.js +++ b/backend/src/components/changeRequest.js @@ -3,7 +3,7 @@ const log = require('./logger'); const { MappableObjectForFront, MappableObjectForBack, getMappingString } = require('../util/mapping/MappableObject'); const { ChangeRequestMappings, ChangeActionRequestMappings, MtfiMappings, NewFacilityMappings } = require('../util/mapping/ChangeRequestMappings'); -const { UserProfileBaseCCFRIMappings, UserProfileBaseFundingMappings, UserProfileECEWEMappings, UserProfileApplicationMappings} = require('../util/mapping/Mappings'); +const { UserProfileBaseCCFRIMappings, UserProfileBaseFundingMappings, UserProfileECEWEMappings } = require('../util/mapping/Mappings'); const { ChangeRequestUnlockMapping } = require('../util/mapping/ChangeRequestMappings'); const { mapFacilityObjectForBack } = require('./facility'); @@ -12,8 +12,17 @@ const { ACCOUNT_TYPE, CCOF_STATUS_CODES, CHANGE_REQUEST_TYPES, CHANGE_REQUEST_EX const HttpStatus = require('http-status-codes'); -const { getLabelFromValue, getOperation, postOperation, patchOperationWithObjectId, deleteOperationWithObjectId, getChangeActionDocument, postChangeActionDocument, postChangeRequestSummaryDocument} = require('./utils'); -const {getFileExtension, convertHeicDocumentToJpg} = require('../util/uploadFileUtils'); +const { + getLabelFromValue, + getOperation, + postOperation, + patchOperationWithObjectId, + deleteOperationWithObjectId, + getChangeActionDocument, + postChangeActionDocument, + postChangeRequestSummaryDocument, +} = require('./utils'); +const { getFileExtension, convertHeicDocumentToJpg } = require('../util/uploadFileUtils'); function mapChangeRequestForBack(data, changeType) { let changeRequestForBack = new MappableObjectForBack(data, ChangeRequestMappings).toJSON(); @@ -24,8 +33,8 @@ function mapChangeRequestForBack(data, changeType) { delete changeRequestForBack._ccof_application_value; changeRequestForBack['ccof_change_action_change_request'] = [ { - ccof_changetype: changeType - } + ccof_changetype: changeType, + }, ]; if (changeType === CHANGE_REQUEST_TYPES.NEW_FACILITY) { changeRequestForBack.ccof_provider_type = 100000000; //New facilities are only available for GROUP provider types @@ -36,14 +45,16 @@ function mapChangeRequestForBack(data, changeType) { async function getChangeActionNewFacilitityDetails(changeActionId) { if (changeActionId) { try { - let operation = `ccof_change_request_new_facilities?$filter=_ccof_change_action_value eq '${changeActionId}'&$expand=ccof_ccfri($select=${getMappingString(UserProfileBaseCCFRIMappings)}),ccof_ecewe($select=${getMappingString(UserProfileECEWEMappings)}),ccof_CCOF($select=${getMappingString(UserProfileBaseFundingMappings)})`; + let operation = `ccof_change_request_new_facilities?$filter=_ccof_change_action_value eq '${changeActionId}'&$expand=ccof_ccfri($select=${getMappingString( + UserProfileBaseCCFRIMappings, + )}),ccof_ecewe($select=${getMappingString(UserProfileECEWEMappings)}),ccof_CCOF($select=${getMappingString(UserProfileBaseFundingMappings)})`; let changeActionDetails = await getOperation(operation); let details = changeActionDetails?.value; log.info('!!!!!!!!!!'); log.info(details); let retVal = []; - details?.forEach(el => { + details?.forEach((el) => { let data = new MappableObjectForFront(el, NewFacilityMappings).toJSON(); data.ccfri = new MappableObjectForFront(el.ccof_ccfri, UserProfileBaseCCFRIMappings).toJSON(); data.ecewe = new MappableObjectForFront(el.ccof_ecewe, UserProfileECEWEMappings).toJSON(); @@ -53,21 +64,22 @@ async function getChangeActionNewFacilitityDetails(changeActionId) { }); return retVal; } catch (e) { - log.error('Unable to get change action details',e); + log.error('Unable to get change action details', e); } } else { return undefined; } } - // get Change Action details. depending on the entity, we may want to get details 2 level below change action async function getChangeActionDetails(changeActionId, changeDetailEntity, changeDetailMapper, joiningTable, joiningTableMapping) { if (changeActionId && changeDetailEntity && changeDetailMapper) { try { let operation; if (joiningTable) { - operation = `${changeDetailEntity}?$select=${getMappingString(changeDetailMapper)}&$filter=_ccof_change_action_value eq '${changeActionId}'&$expand=${joiningTable}($select=${getMappingString(joiningTableMapping)})`; + operation = `${changeDetailEntity}?$select=${getMappingString(changeDetailMapper)}&$filter=_ccof_change_action_value eq '${changeActionId}'&$expand=${joiningTable}($select=${getMappingString( + joiningTableMapping, + )})`; } else { operation = `${changeDetailEntity}?$select=${getMappingString(changeDetailMapper)}&$filter=_ccof_change_action_value eq '${changeActionId}'`; } @@ -75,17 +87,17 @@ async function getChangeActionDetails(changeActionId, changeDetailEntity, change let changeActionDetails = await getOperation(operation); let details = changeActionDetails?.value; let retVal = []; - details?.forEach(el => { + details?.forEach((el) => { let data = new MappableObjectForFront(el, changeDetailMapper).toJSON(); let joinData = undefined; if (joiningTable) { joinData = new MappableObjectForFront(el[joiningTable], joiningTableMapping).toJSON(); } - retVal.push({...data, ...joinData}); + retVal.push({ ...data, ...joinData }); }); return retVal; } catch (e) { - log.error('Unable to get change action details',e); + log.error('Unable to get change action details', e); } } else { return undefined; @@ -96,38 +108,38 @@ async function mapChangeRequestObjectForFront(data) { let retVal = new MappableObjectForFront(data, ChangeRequestMappings).toJSON(); let changeList = []; - await Promise.all( retVal.changeActions?.map(async (el) => { - let changeAction = new MappableObjectForFront(el, ChangeActionRequestMappings).toJSON(); - if (changeAction.changeType == CHANGE_REQUEST_TYPES.PARENT_FEE_CHANGE) { - let mtfi = await getChangeActionDetails(changeAction.changeActionId, 'ccof_change_request_mtfis', MtfiMappings, 'ccof_CCFRI', UserProfileBaseCCFRIMappings ); - mtfi?.forEach(item => { - item.ccfriStatus = getLabelFromValue(item.ccfriStatus, CCFRI_STATUS_CODES, 'NOT STARTED'); - }); - changeAction.mtfi = mtfi; - } - else if (changeAction.changeType == CHANGE_REQUEST_TYPES.NEW_FACILITY) { - const newFacilities = await getChangeActionNewFacilitityDetails(changeAction.changeActionId); - changeAction.newFacilities = newFacilities; - } - let unlockVals = new MappableObjectForFront(el, ChangeRequestUnlockMapping).toJSON(); - changeAction = {...changeAction, ...unlockVals}; - changeList.push(changeAction); - })); + await Promise.all( + retVal.changeActions?.map(async (el) => { + let changeAction = new MappableObjectForFront(el, ChangeActionRequestMappings).toJSON(); + if (changeAction.changeType == CHANGE_REQUEST_TYPES.PARENT_FEE_CHANGE) { + let mtfi = await getChangeActionDetails(changeAction.changeActionId, 'ccof_change_request_mtfis', MtfiMappings, 'ccof_CCFRI', UserProfileBaseCCFRIMappings); + mtfi?.forEach((item) => { + item.ccfriStatus = getLabelFromValue(item.ccfriStatus, CCFRI_STATUS_CODES, 'NOT STARTED'); + }); + changeAction.mtfi = mtfi; + } else if (changeAction.changeType == CHANGE_REQUEST_TYPES.NEW_FACILITY) { + const newFacilities = await getChangeActionNewFacilitityDetails(changeAction.changeActionId); + changeAction.newFacilities = newFacilities; + } + let unlockVals = new MappableObjectForFront(el, ChangeRequestUnlockMapping).toJSON(); + changeAction = { ...changeAction, ...unlockVals }; + changeList.push(changeAction); + }), + ); retVal.changeActions = changeList; log.info('change actions: ', retVal); return retVal; } - // get Change Request async function getChangeRequest(req, res) { try { let operation = `ccof_change_requests(${req.params.changeRequestId})?$expand=ccof_change_action_change_request($select=ccof_change_actionid,statuscode,ccof_changetype,createdon,ccof_unlock_ecewe,ccof_unlock_ccof,ccof_unlock_supporting_document,ccof_unlock_other_changes_document,ccof_unlock_change_request,ccof_unlock_licence_upload)`; let changeRequest = await getOperation(operation); changeRequest = await mapChangeRequestObjectForFront(changeRequest); - changeRequest.providerType = getLabelFromValue(changeRequest.providerType , ORGANIZATION_PROVIDER_TYPES); - changeRequest.externalStatus = getLabelFromValue(changeRequest.externalStatus , CHANGE_REQUEST_EXTERNAL_STATUS_CODES); + changeRequest.providerType = getLabelFromValue(changeRequest.providerType, ORGANIZATION_PROVIDER_TYPES); + changeRequest.externalStatus = getLabelFromValue(changeRequest.externalStatus, CHANGE_REQUEST_EXTERNAL_STATUS_CODES); return res.status(HttpStatus.OK).json(changeRequest); } catch (e) { console.log('e', e); @@ -135,7 +147,7 @@ async function getChangeRequest(req, res) { } } -async function updateChangeRequest(req, res){ +async function updateChangeRequest(req, res) { let changeRequest = req.body; //changeRequest.externalStatus = CHANGE_REQUEST_EXTERNAL_STATUS_CODES.externalStatus; changeRequest = new MappableObjectForBack(changeRequest, ChangeRequestMappings); @@ -147,7 +159,7 @@ async function updateChangeRequest(req, res){ //is change req complete ? (status 2 i think ) - if (changeRequest.ccof_externalstatus == 2){ + if (changeRequest.ccof_externalstatus == 2) { printPdf(req).then(); } @@ -166,13 +178,11 @@ async function createChangeRequest(req, res) { let changeType = changeRequest.changeType; //log.info('change type', changeType); //this is kind of ugly, replace with a better mapping function - if (changeType === 'PARENT_FEE_CHANGE'){ + if (changeType === 'PARENT_FEE_CHANGE') { changeType = CHANGE_REQUEST_TYPES.PARENT_FEE_CHANGE; - } - else if(changeType === 'NEW_FACILITY'){ + } else if (changeType === 'NEW_FACILITY') { changeType = CHANGE_REQUEST_TYPES.NEW_FACILITY; - } - else if(changeType === 'PDF_CHANGE'){ + } else if (changeType === 'PDF_CHANGE') { changeType = CHANGE_REQUEST_TYPES.PDF_CHANGE; } //log.info('change type', changeType); @@ -199,13 +209,13 @@ async function createChangeAction(req, res, changeType) { try { const payload = { ccof_changetype: changeType, - 'ccof_change_request@odata.bind': `ccof_change_requests(${req.params.changeRequestId})` + 'ccof_change_request@odata.bind': `ccof_change_requests(${req.params.changeRequestId})`, }; const changeActionId = await postOperation('ccof_change_actions', payload); return res.status(HttpStatus.CREATED).json({ changeRequestId: req.params.changeRequestId, changeActionId: changeActionId, - changeType: changeType + changeType: changeType, }); } catch (e) { log.error('error', e); @@ -229,27 +239,26 @@ function buildNewFacilityPayload(req) { facility = mapFacilityObjectForBack(facility); facility['ccof_accounttype'] = ACCOUNT_TYPE.FACILITY; - facility['parentaccountid@odata.bind'] = `/accounts(${req.body.organizationId})`, - facility['ccof_ccof_change_request_new_facility_facility'] = [ - { - 'ccof_change_action@odata.bind': `/ccof_change_actions(${req.params.changeActionId})`, - }, - ]; + (facility['parentaccountid@odata.bind'] = `/accounts(${req.body.organizationId})`), + (facility['ccof_ccof_change_request_new_facility_facility'] = [ + { + 'ccof_change_action@odata.bind': `/ccof_change_actions(${req.params.changeActionId})`, + }, + ]); facility['ccof_application_basefunding_Facility'] = [ { 'ccof_Application@odata.bind': `/ccof_applications(${req.body.applicationId})`, - } + }, ]; return facility; } -async function updateChangeRequestNewFacility(changeRequestNewFacilityId, payload){ - try{ +async function updateChangeRequestNewFacility(changeRequestNewFacilityId, payload) { + try { let response = await patchOperationWithObjectId('ccof_change_request_new_facilities', changeRequestNewFacilityId, payload); return response; - } - catch(e){ + } catch (e) { log.error('error', e); return e.data ? e.data : e?.status; } @@ -260,61 +269,62 @@ async function createChangeRequestFacility(req, res) { try { const facilityGuid = await postOperation('accounts', facility); //After the 'ChangeActionNewFacility' entity is created, grab the guid - let operation = 'accounts(' + facilityGuid + ')?$select=accountid&$expand=ccof_ccof_change_request_new_facility_facility($select=ccof_change_request_new_facilityid,statuscode),ccof_application_basefunding_Facility($select=ccof_application_basefundingid,statuscode)'; + let operation = + 'accounts(' + + facilityGuid + + ')?$select=accountid&$expand=ccof_ccof_change_request_new_facility_facility($select=ccof_change_request_new_facilityid,statuscode),ccof_application_basefunding_Facility($select=ccof_application_basefundingid,statuscode)'; let payload = await getOperation(operation); console.log(payload); let changeRequestNewFacilityId = undefined; let ccofBaseFundingId = undefined; let ccofBaseFundingStatus = undefined; - if ( payload?.ccof_application_basefunding_Facility?.length > 0) { + if (payload?.ccof_application_basefunding_Facility?.length > 0) { ccofBaseFundingId = payload.ccof_application_basefunding_Facility[0].ccof_application_basefundingid; ccofBaseFundingStatus = getLabelFromValue(payload.ccof_application_basefunding_Facility[0].statuscode, CCOF_STATUS_CODES); } - if ( payload?.ccof_ccof_change_request_new_facility_facility?.length > 0) { + if (payload?.ccof_ccof_change_request_new_facility_facility?.length > 0) { changeRequestNewFacilityId = payload.ccof_ccof_change_request_new_facility_facility[0].ccof_change_request_new_facilityid; } if (ccofBaseFundingId && changeRequestNewFacilityId) { - await updateChangeRequestNewFacility(changeRequestNewFacilityId, - { - 'ccof_CCOF@odata.bind': `/ccof_application_basefundings(${ccofBaseFundingId})` - } - ); + await updateChangeRequestNewFacility(changeRequestNewFacilityId, { + 'ccof_CCOF@odata.bind': `/ccof_application_basefundings(${ccofBaseFundingId})`, + }); } - return res.status(HttpStatus.CREATED).json({facilityId: facilityGuid, changeRequestNewFacilityId: changeRequestNewFacilityId, ccofBaseFundingId: ccofBaseFundingId, ccofBaseFundingStatus: ccofBaseFundingStatus}); + return res + .status(HttpStatus.CREATED) + .json({ facilityId: facilityGuid, changeRequestNewFacilityId: changeRequestNewFacilityId, ccofBaseFundingId: ccofBaseFundingId, ccofBaseFundingStatus: ccofBaseFundingStatus }); } catch (e) { console.log(e); - return res.status(HttpStatus.INTERNAL_SERVER_ERROR).json(e.data? e.data : e?.status ); + return res.status(HttpStatus.INTERNAL_SERVER_ERROR).json(e.data ? e.data : e?.status); } } -async function deleteChangeRequest(req, res){ - +async function deleteChangeRequest(req, res) { let { changeRequestId } = req.params; log.verbose(changeRequestId); - try{ + try { await deleteOperationWithObjectId('ccof_change_requests', changeRequestId); return res.status(HttpStatus.OK).end(); - }catch(e){ + } catch (e) { log.info(e); - return res.status(HttpStatus.INTERNAL_SERVER_ERROR).json(e.data? e.data : e?.status ); + return res.status(HttpStatus.INTERNAL_SERVER_ERROR).json(e.data ? e.data : e?.status); } } //TODO: need some mapping here prob but lets figure out Sukanyas component first -async function getChangeRequestDocs(req, res){ - +async function getChangeRequestDocs(req, res) { let { changeRequestId } = req.params; log.verbose(changeRequestId); - try{ + try { let response = await getChangeActionDocument(changeRequestId); log.verbose(response.value); return res.status(HttpStatus.OK).json(response.value); - }catch(e){ + } catch (e) { log.info(e); - return res.status(HttpStatus.INTERNAL_SERVER_ERROR).json(e.data? e.data : e?.status ); + return res.status(HttpStatus.INTERNAL_SERVER_ERROR).json(e.data ? e.data : e?.status); } } @@ -323,7 +333,7 @@ async function saveChangeRequestDocs(req, res) { let documents = req.body; for (let document of documents) { let documentClone = document; - if (getFileExtension(documentClone.filename) === 'heic' ) { + if (getFileExtension(documentClone.filename) === 'heic') { log.verbose(`saveChangeRequestDocs :: heic detected for file name ${documentClone.filename} starting conversion`); documentClone = await convertHeicDocumentToJpg(documentClone); } @@ -336,46 +346,42 @@ async function saveChangeRequestDocs(req, res) { } } -async function getChangeRequestMTFIByCcfriId(req, res){ - try{ +async function getChangeRequestMTFIByCcfriId(req, res) { + try { log.info('getChangeRequestMTFIByCcfriId - ccfriId = ', req.params.ccfriId); let operation = `ccof_applicationccfris(${req.params.ccfriId})?$expand=ccof_change_request_mtfi_application_ccfri`; let response = await getOperation(operation); let mtfiDetails = []; let rfiDetails = new MappableObjectForFront(response, UserProfileBaseCCFRIMappings).toJSON(); //Add in the rfi details mapping so on the front when we update hasRFI for the first time, we have the value needed to update it - response?.ccof_change_request_mtfi_application_ccfri?.forEach(mtfiFacility => { - mtfiDetails.push({...new MappableObjectForFront(mtfiFacility, MtfiMappings).toJSON(), ...rfiDetails}); + response?.ccof_change_request_mtfi_application_ccfri?.forEach((mtfiFacility) => { + mtfiDetails.push({ ...new MappableObjectForFront(mtfiFacility, MtfiMappings).toJSON(), ...rfiDetails }); }); return res.status(HttpStatus.OK).json(mtfiDetails); - } - catch (e){ + } catch (e) { log.error(e); return res.status(HttpStatus.INTERNAL_SERVER_ERROR).json(e.data ? e.data : e?.status); } } -async function deleteChangeRequestMTFI(req, res){ - try{ +async function deleteChangeRequestMTFI(req, res) { + try { log.info('deleteChangeRequestMTFI - mtfiId = ', req.params.mtfiId); let response = await deleteOperationWithObjectId('ccof_change_request_mtfis', req.params.mtfiId); return res.status(HttpStatus.OK).json(response); - } - catch (e){ + } catch (e) { log.error(e); return res.status(HttpStatus.INTERNAL_SERVER_ERROR).json(e.data ? e.data : e?.status); } } -async function updateChangeRequestMTFI(req, res){ - try{ +async function updateChangeRequestMTFI(req, res) { + try { let response = await patchOperationWithObjectId('ccof_change_request_mtfis', req.params.mtfiId, req.body); return res.status(HttpStatus.OK).json(); - } - catch(e){ + } catch (e) { log.error('error', e); return res.status(HttpStatus.INTERNAL_SERVER_ERROR).json(e.data ? e.data : e?.status); - } } @@ -391,5 +397,5 @@ module.exports = { updateChangeRequestMTFI, deleteChangeAction, getChangeRequestMTFIByCcfriId, - deleteChangeRequestMTFI + deleteChangeRequestMTFI, }; diff --git a/backend/src/components/lookup.js b/backend/src/components/lookup.js index 5b88e831..668f8e80 100644 --- a/backend/src/components/lookup.js +++ b/backend/src/components/lookup.js @@ -1,69 +1,72 @@ 'use strict'; -const {getOperation, getLabelFromValue, } = require('./utils'); +const { getOperation, getLabelFromValue } = require('./utils'); const HttpStatus = require('http-status-codes'); -const _ = require ('lodash'); +const _ = require('lodash'); const cache = require('memory-cache'); const { PROGRAM_YEAR_STATUS_CODES, ORGANIZATION_PROVIDER_TYPES, CHANGE_REQUEST_TYPES } = require('../util/constants'); const { ProgramYearMappings, SystemMessagesMappings } = require('../util/mapping/Mappings'); const { MappableObjectForFront } = require('../util/mapping/MappableObject'); - const lookupCache = new cache.Cache(); const organizationType = [ { name: 'Non-Profit Society', - id: 100000000 + id: 100000000, }, { name: 'Public Institution (college/university)', - id: 100000001 + id: 100000001, }, { name: 'Registered Company', - id: 100000002 + id: 100000002, }, { name: 'Local Government', - id: 100000003 + id: 100000003, }, { name: 'First Nations Government', - id: 100000004 + id: 100000004, }, { name: 'Sole Proprietorship or Partnership', - id: 100000005 - } + id: 100000005, + }, ]; const fundingModelType = [ { id: 100000000, - description: 'All of our facilities have provincially funded ECEs and receive Low-Wage Redress Funding', + description: 'All of our facilities have provincially funded ECEs and receive Low-Wage Redress Funding.', }, { id: 100000001, - description: 'All of our facilities have only non-provincially funded ECEs and do not receive Low-Wage Redress Funding', + description: 'All of our facilities have only non-provincially funded ECEs and do not receive Low-Wage Redress Funding.', }, { id: 100000002, - description: 'Some of our facilities have both non-provincially funded ECEs that do not receive Low-Wage Redress Funding AND provincially funded ECEs receiving Low-Wage Redress Funding', + description: 'Some of our facilities have both non-provincially funded ECEs that do not receive Low-Wage Redress Funding AND provincially funded ECEs receiving Low-Wage Redress Funding.', + }, + { + id: 100000003, + description: 'Our facilities have both provincially funded ECEs receiving Low -Wage Redress Funding and non -provincially funded ECEs that do not receive Low - Wage Redress Funding.', }, ]; function parseProgramYear(value) { - let programYears = { + const programYears = { current: undefined, future: undefined, previous: undefined, renewal: undefined, newApp: undefined, - list: [] + list: [], }; - value.forEach(item => { - let p = new MappableObjectForFront(item, ProgramYearMappings).data; - let currentStatus = p.status; + value.forEach((item) => { + const p = new MappableObjectForFront(item, ProgramYearMappings).data; + const currentStatus = p.status; p.status = getLabelFromValue(p.status, PROGRAM_YEAR_STATUS_CODES); if (currentStatus == PROGRAM_YEAR_STATUS_CODES.CURRENT) { programYears.current = p; @@ -72,9 +75,11 @@ function parseProgramYear(value) { } programYears.list.push(p); }); - programYears.previous = programYears.list.find(p => p.programYearId == programYears.current.previousYearId); - programYears.list.sort((a,b) => { return b.order - a.order; } ); - programYears.renewal = programYears.future ? programYears.future: programYears.list[0]; + programYears.previous = programYears.list.find((p) => p.programYearId == programYears.current.previousYearId); + programYears.list.sort((a, b) => { + return b.order - a.order; + }); + programYears.renewal = programYears.future ? programYears.future : programYears.list[0]; // Set the program year for a new application if (programYears.current?.intakeEnd) { @@ -84,9 +89,6 @@ function parseProgramYear(value) { programYears.newApp = programYears.current; } - - - return programYears; } @@ -95,9 +97,21 @@ async function getLicenseCategory() { if (!resData) { resData = {}; let licenseCategory = await getOperation('ccof_license_categories'); - licenseCategory = licenseCategory.value.filter(item => item.statuscode ==1).map(item => { return _.pick(item, ['ccof_license_categoryid', 'ccof_providertype', 'ccof_name', 'ccof_categorynumber']); }); - resData.groupLicenseCategory = licenseCategory.filter( item => item.ccof_providertype == ORGANIZATION_PROVIDER_TYPES.GROUP).sort((a,b) => { return a.ccof_categorynumber - b.ccof_categorynumber; } ); - resData.familyLicenseCategory = licenseCategory.filter( item => item.ccof_providertype == ORGANIZATION_PROVIDER_TYPES.FAMILY).sort((a,b) => { return a.ccof_categorynumber - b.ccof_categorynumber; } ); + licenseCategory = licenseCategory.value + .filter((item) => item.statuscode == 1) + .map((item) => { + return _.pick(item, ['ccof_license_categoryid', 'ccof_providertype', 'ccof_name', 'ccof_categorynumber']); + }); + resData.groupLicenseCategory = licenseCategory + .filter((item) => item.ccof_providertype == ORGANIZATION_PROVIDER_TYPES.GROUP) + .sort((a, b) => { + return a.ccof_categorynumber - b.ccof_categorynumber; + }); + resData.familyLicenseCategory = licenseCategory + .filter((item) => item.ccof_providertype == ORGANIZATION_PROVIDER_TYPES.FAMILY) + .sort((a, b) => { + return a.ccof_categorynumber - b.ccof_categorynumber; + }); lookupCache.put('licenseCategory', resData, 60 * 60 * 1000); } return resData; @@ -118,17 +132,21 @@ async function getLookupInfo(req, res) { programYear = parseProgramYear(programYear.value); let childCareCategory = await getOperation('ccof_childcare_categories'); - childCareCategory = childCareCategory.value.filter(item => item.statuscode ==1).map(item => { return _.pick(item, ['ccof_childcarecategorynumber', 'ccof_name', 'ccof_description', 'ccof_childcare_categoryid']); }); + childCareCategory = childCareCategory.value + .filter((item) => item.statuscode == 1) + .map((item) => { + return _.pick(item, ['ccof_childcarecategorynumber', 'ccof_name', 'ccof_description', 'ccof_childcare_categoryid']); + }); - let licenseCategory = await getLicenseCategory(); + const licenseCategory = await getLicenseCategory(); resData = { - 'programYear': programYear, - 'childCareCategory': childCareCategory, - 'organizationType': organizationType, - 'fundingModelType': fundingModelType, - 'groupLicenseCategory': licenseCategory.groupLicenseCategory, - 'familyLicenseCategory': licenseCategory.familyLicenseCategory, - 'changeRequestTypes:' : CHANGE_REQUEST_TYPES + programYear: programYear, + childCareCategory: childCareCategory, + organizationType: organizationType, + fundingModelType: fundingModelType, + groupLicenseCategory: licenseCategory.groupLicenseCategory, + familyLicenseCategory: licenseCategory.familyLicenseCategory, + 'changeRequestTypes:': CHANGE_REQUEST_TYPES, }; lookupCache.put('lookups', resData, 60 * 60 * 1000); } @@ -139,10 +157,10 @@ async function getLookupInfo(req, res) { async function getSystemMessages(req, res) { let systemMessages = lookupCache.get('systemMessages'); if (!systemMessages) { - let currentTime = (new Date()).toISOString(); + const currentTime = new Date().toISOString(); systemMessages = []; - let resData = await getOperation(`ccof_systemmessages?$filter=(ccof_startdate le ${currentTime} and ccof_enddate ge ${currentTime})`); - resData?.value.forEach(message => systemMessages.push(new MappableObjectForFront(message, SystemMessagesMappings).data)); + const resData = await getOperation(`ccof_systemmessages?$filter=(ccof_startdate le ${currentTime} and ccof_enddate ge ${currentTime})`); + resData?.value.forEach((message) => systemMessages.push(new MappableObjectForFront(message, SystemMessagesMappings).data)); lookupCache.put('systemMessages', systemMessages, 60 * 60 * 1000); } return res.status(HttpStatus.OK).json(systemMessages); @@ -151,5 +169,5 @@ async function getSystemMessages(req, res) { module.exports = { getLookupInfo, getLicenseCategory, - getSystemMessages + getSystemMessages, }; diff --git a/backend/src/util/mapping/Mappings.js b/backend/src/util/mapping/Mappings.js index 3ab05966..a73b4f14 100644 --- a/backend/src/util/mapping/Mappings.js +++ b/backend/src/util/mapping/Mappings.js @@ -244,12 +244,15 @@ const ECEWEApplicationMappings = [ { back: 'ccof_ecewe_eligibility_complete', front: 'isEceweComplete' }, { back: 'ccof_ecewe_selecttheapplicablesector', front: 'applicableSector' }, { back: 'ccof_public_sector_employer', front: 'publicSector' }, //null, + { back: 'ccof_union_agreement_reached', front: 'isUnionAgreementReached' }, //null, + { back: 'ccof_describe_your_org', front: 'describeOrgCSSEA' }, //null, ]; const ECEWEFacilityMappings = [ { back: 'ccof_applicationeceweid', front: 'eceweApplicationId' }, { back: '_ccof_facility_value', front: 'facilityId' }, { back: 'ccof_optintoecewe', front: 'optInOrOut' }, + { back: 'ccof_facilityunionstatus', front: 'facilityUnionStatus' }, { back: 'ccof_change_request_new_facilityid', front: 'changeRequestNewFacilityId' }, ]; diff --git a/frontend/src/components/SummaryDeclaration.vue b/frontend/src/components/SummaryDeclaration.vue index be5deaf4..8415baa4 100644 --- a/frontend/src/components/SummaryDeclaration.vue +++ b/frontend/src/components/SummaryDeclaration.vue @@ -209,6 +209,27 @@ @is-summary-valid="isFormComplete" /> + + + + + + + + { const keys = Object.keys(this.payload); - console.log('calling after 1 second'); //If this is a change request, we'll have 2 items in the payload. if ((!this.isChangeRequest && keys.length > 1) || (this.isChangeRequest && keys.length > 2)) { - console.log('sending updates to server'); this.updateApplicationStatus(this.payload); this.forceNavBarRefresh(); } diff --git a/frontend/src/components/eceweApplication/EceweEligibility.vue b/frontend/src/components/eceweApplication/EceweEligibility.vue index 7774c4ec..41838ad3 100644 --- a/frontend/src/components/eceweApplication/EceweEligibility.vue +++ b/frontend/src/components/eceweApplication/EceweEligibility.vue @@ -1,7 +1,7 @@