diff --git a/backend/src/components/application.js b/backend/src/components/application.js
index 2dbe87196..c91a16f4e 100644
--- a/backend/src/components/application.js
+++ b/backend/src/components/application.js
@@ -321,7 +321,7 @@ async function postClosureDates(dates, ccfriApplicationGuid, res) {
async function getECEWEApplication(req, res) {
try {
- let operation = 'ccof_applications(' + req.params.applicationId + ')?$select=ccof_ecewe_optin,ccof_ecewe_employeeunion,ccof_ecewe_selecttheapplicablefundingmodel,ccof_ecewe_selecttheapplicablesector,ccof_ecewe_confirmation&$expand=ccof_ccof_application_ccof_applicationecewe_application($select=ccof_name,_ccof_facility_value,ccof_optintoecewe,statuscode)';
+ let 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)';
let eceweApp = await getOperation(operation);
eceweApp = new MappableObjectForFront(eceweApp, ECEWEApplicationMappings);
let forFrontFacilities = [];
@@ -705,16 +705,37 @@ async function getMTFIChangeData(changeActionId) {
});
return mtfi;
}
+//and Microsoft.Dynamics.CRM.In(PropertyName='_ccof_application_value',PropertyValues=[${applicationId}]));
+async function getChangeRequestsFromApplicationId(applicationIds){
+
+ let str = '[';
+
+ const regex = new RegExp('([^,]+)' , 'g');
+ const found = applicationIds.match(regex);
+ found.forEach((app, index) => {
+ str = str + `'${app}'`;
+ if (index != found.length -1 ){
+ str = str + ',';
+ }
+ else{
+ str = str + ']';
+ }
+ });
+
+ log.info(str);
-async function getChangeRequestsFromApplicationId(applicationId){
try {
- let operation = `ccof_change_requests?$expand=ccof_change_action_change_request&$select=${getMappingString(ChangeRequestMappings)}&$filter=_ccof_application_value eq ${applicationId}`;
+ let 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);
+ //log.verbose(changeRequests);
await Promise.all(changeRequests.map(async (request) => {
let req = new MappableObjectForFront(request, ChangeRequestMappings).toJSON();
@@ -735,11 +756,11 @@ async function getChangeRequestsFromApplicationId(applicationId){
payload.push(req);
}));
- log.info('final payload', payload);
+ //log.info('final payload', payload);
return payload;
} catch (e) {
log.error('An error occurred while getting change request', e);
- return res.status(HttpStatus.INTERNAL_SERVER_ERROR).json(e.data ? e.data : e?.status);
+ throw e;
}
}
@@ -758,6 +779,30 @@ 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);
+
+ //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);
+ }));
+
+ //delete the application
+ await deleteOperationWithObjectId('ccof_applications', req.params.applicationId);
+
+ //and delete the org. We must delete the org otherwise the user will be linked to multiple orgs in dynamics
+ await deleteOperationWithObjectId('accounts', application['_ccof_organization_value']);
+
+ return res.status(HttpStatus.OK).json();
+ } catch (e) {
+ log.error('An error occurred while deleting PCF', e);
+ return res.status(HttpStatus.INTERNAL_SERVER_ERROR).json(e.data ? e.data : e?.status);
+ }
+}
+
module.exports = {
updateCCFRIApplication,
upsertParentFees,
@@ -772,5 +817,6 @@ module.exports = {
getChangeRequest,
patchCCFRIApplication,
deleteCCFRIApplication,
- printPdf
+ printPdf,
+ deletePcfApplication
};
diff --git a/backend/src/components/changeRequest.js b/backend/src/components/changeRequest.js
index ab69e662a..9c35de8de 100644
--- a/backend/src/components/changeRequest.js
+++ b/backend/src/components/changeRequest.js
@@ -3,7 +3,8 @@
const log = require('./logger');
const { MappableObjectForFront, MappableObjectForBack, getMappingString } = require('../util/mapping/MappableObject');
const { ChangeRequestMappings, ChangeActionRequestMappings, MtfiMappings, NewFacilityMappings } = require('../util/mapping/ChangeRequestMappings');
-const { UserProfileBaseCCFRIMappings } = require('../util/mapping/Mappings');
+const { UserProfileBaseCCFRIMappings, UserProfileBaseFundingMappings, UserProfileECEWEMappings, UserProfileApplicationMappings} = require('../util/mapping/Mappings');
+const { ChangeRequestUnlockMapping } = require('../util/mapping/ChangeRequestMappings');
const { mapFacilityObjectForBack } = require('./facility');
const { printPdf } = require('./application');
@@ -32,6 +33,34 @@ function mapChangeRequestForBack(data, changeType) {
return changeRequestForBack;
}
+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 changeActionDetails = await getOperation(operation);
+ let details = changeActionDetails?.value;
+
+ log.info('!!!!!!!!!!');
+ log.info(details);
+ let retVal = [];
+ 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();
+ log.info(data.ecewe);
+ data.baseFunding = new MappableObjectForFront(el.ccof_CCOF, UserProfileBaseFundingMappings).toJSON();
+ retVal.push(data);
+ });
+ return retVal;
+ } catch (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) {
@@ -65,6 +94,7 @@ async function getChangeActionDetails(changeActionId, changeDetailEntity, change
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();
@@ -74,10 +104,13 @@ async function mapChangeRequestObjectForFront(data) {
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 getChangeActionDetails(changeAction.changeActionId, 'ccof_change_request_new_facilities', NewFacilityMappings);
+ }
+ 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;
@@ -89,16 +122,12 @@ async function mapChangeRequestObjectForFront(data) {
// get Change Request
async function getChangeRequest(req, res) {
- log.info('get changeRequest called');
-
try {
- let operation = `ccof_change_requests(${req.params.changeRequestId})?$expand=ccof_change_action_change_request($select=ccof_change_actionid,statuscode,ccof_changetype,createdon)`;
+ 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);
- log.info(changeRequest);
- log.info(CHANGE_REQUEST_EXTERNAL_STATUS_CODES);
return res.status(HttpStatus.OK).json(changeRequest);
} catch (e) {
console.log('e', e);
@@ -146,7 +175,7 @@ async function createChangeRequest(req, res) {
else if(changeType === 'PDF_CHANGE'){
changeType = CHANGE_REQUEST_TYPES.PDF_CHANGE;
}
- log.info('change type', changeType);
+ //log.info('change type', changeType);
changeRequest = mapChangeRequestForBack(changeRequest, changeType);
const changeRequestId = await postOperation('ccof_change_requests', changeRequest);
let operation = `ccof_change_requests(${changeRequestId})?$select=ccof_change_requestid&$expand=ccof_change_action_change_request($select=ccof_change_actionid,statuscode)`;
@@ -313,8 +342,10 @@ async function getChangeRequestMTFIByCcfriId(req, res){
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());
+ mtfiDetails.push({...new MappableObjectForFront(mtfiFacility, MtfiMappings).toJSON(), ...rfiDetails});
});
return res.status(HttpStatus.OK).json(mtfiDetails);
}
diff --git a/backend/src/components/facility.js b/backend/src/components/facility.js
index 2a75f0021..46844ba8c 100644
--- a/backend/src/components/facility.js
+++ b/backend/src/components/facility.js
@@ -33,11 +33,13 @@ function mapFacilityObjectForBack(data) {
if (facilityForBack.ccof_facilitystartdate) {
facilityForBack.ccof_facilitystartdate = `${facilityForBack.ccof_facilitystartdate}-01-01`;
}
-
+ if (facilityForBack.ccof_licensestartdate) {
+ facilityForBack.ccof_licensestartdate = facilityForBack.ccof_licensestartdate + 'T12:00:00-07:00';
+ }
if (data.hasReceivedFunding === 'no') {
- facilityForBack.ccof_everreceivedfundingundertheccofprogram = 100000000;
- } else if (data.hasReceivedFunding === 'yes') {
facilityForBack.ccof_everreceivedfundingundertheccofprogram = 100000001;
+ } else if (data.hasReceivedFunding === 'yes') {
+ facilityForBack.ccof_everreceivedfundingundertheccofprogram = 100000000;
} else if (data.hasReceivedFunding === 'yesFacility') {
facilityForBack.ccof_everreceivedfundingundertheccofprogram = 100000002;
} else if (data.hasReceivedFunding) {
@@ -60,9 +62,9 @@ function mapFacilityObjectForFront(data) {
let obj = new MappableObjectForFront(data, FacilityMappings).toJSON();
//TODO: map this if it is returned from dynamics
- if (data.ccof_everreceivedfundingundertheccofprogram === 100000000) {
+ if (data.ccof_everreceivedfundingundertheccofprogram === 100000001) {
obj.hasReceivedFunding = 'no';
- } else if (data.ccof_everreceivedfundingundertheccofprogram === 100000001) {
+ } else if (data.ccof_everreceivedfundingundertheccofprogram === 100000000) {
obj.hasReceivedFunding = 'yes';
} else if (data.ccof_everreceivedfundingundertheccofprogram === 100000002) {
obj.hasReceivedFunding = 'yesFacility';
@@ -169,6 +171,17 @@ async function getFacilityChildCareTypes(req, res){
return res.status(HttpStatus.INTERNAL_SERVER_ERROR).json(e.data? e.data : e?.status );
}
}
+//a wrapper fn as getCCFRIClosureDates does not take in a req/res
+async function returnCCFRIClosureDates(req, res){
+ try {
+ const dateData = {dates: await getCCFRIClosureDates(req.params.ccfriId)};
+ return res.status(HttpStatus.OK).json(dateData);
+
+ } catch (e) {
+ log.error('failed with error', e);
+ return res.status(HttpStatus.INTERNAL_SERVER_ERROR).json(e.data? e.data : e?.status );
+ }
+}
async function getCCFRIClosureDates(ccfriId){
const url = `ccof_applicationccfris(${ccfriId})?$select=ccof_name,&$expand=ccof_ccfri_closure_application_ccfri`;
@@ -379,9 +392,10 @@ async function getApprovedParentFees(req, res) {
}
);
}); //end for each
+
const retVal = {
facilityId: facilityId,
- childCareTypes: childCareTypes
+ childCareTypes: childCareTypes,
};
return res.status(200).json(retVal);
} catch (e) {
@@ -402,6 +416,7 @@ module.exports = {
updateFacilityLicenseType,
getCCFRIClosureDates,
mapFacilityObjectForBack,
- getApprovedParentFees
+ getApprovedParentFees,
+ returnCCFRIClosureDates
};
diff --git a/backend/src/components/message.js b/backend/src/components/message.js
index d4afb3a66..b9c9ddfd0 100644
--- a/backend/src/components/message.js
+++ b/backend/src/components/message.js
@@ -25,17 +25,15 @@ function sortByPropertyDesc(property){
async function getAllMessages(req, res) {
try {
- let operation = 'emails?$select=activityid,createdon,description,lastopenedtime ,_regardingobjectid_value,subject&$expand=regardingobjectid_account_email($select=accountid,accountnumber,name)&$filter=(regardingobjectid_account_email/accountid eq ' + req.params.organizationId + ' and statecode eq 1)';
+ let operation = 'emails?$select=activityid,createdon,description,lastopenedtime,ccof_program_year,_regardingobjectid_value,subject&$expand=regardingobjectid_account_email($select=accountid,accountnumber,name)&$filter=(regardingobjectid_account_email/accountid eq ' + req.params.organizationId + ' and statecode eq 1)';
log.info('operation: ', operation);
let operationResponse = await getOperation(operation);
operationResponse.value.sort(sortByPropertyDesc('createdon'));
let allMessages = [];
operationResponse.value.forEach(item => {
let message = mapMessageObjectForFront(item);
- if (message.lastOpenedTime)
- message['isRead'] = true;
- else
- message['isRead'] = false;
+ message.isRead = message.lastOpenedTime ? true : false;
+ message.programYearValue = message.programYearValue?.replace(/[^\d/]/g, '');
allMessages.push(message);
});
return res.status(HttpStatus.OK).json(allMessages);
diff --git a/backend/src/components/rfiApplication.js b/backend/src/components/rfiApplication.js
index 3cf9c272f..60c65730f 100644
--- a/backend/src/components/rfiApplication.js
+++ b/backend/src/components/rfiApplication.js
@@ -57,6 +57,25 @@ function formatDate(data, columnName) {
return data;
}
+async function deleteRfiApplication(req, res){
+ let query = `ccof_rfipfis?$filter=(_ccof_applicationccfri_value eq ${req.params.ccfriId} and statuscode eq 1)`;
+
+ try {
+ const response = await getOperation(query);
+
+ //there should only every be one RFI application per ccfri app.
+ //if array empty - don't try to delete anything.
+ if (response?.value?.length > 0) {
+ log.info(response.value[0]);
+ await deleteOperationWithObjectId('ccof_rfipfis', response.value[0].ccof_rfipfiid);
+ }
+
+ return res.status(HttpStatus.OK).json({});
+ } catch (e) {
+ log.error(e);
+ return res.status(HttpStatus.INTERNAL_SERVER_ERROR).json(e.data? e.data : e?.status );
+ }
+}
async function getRFIApplication(req, res) {
let query = `ccof_rfipfis?$filter=(_ccof_applicationccfri_value eq ${req.params.ccfriId} and statuscode eq 1)&$expand=ccof_ccof_rfipfi_ccof_rfi_pfi_fee_history_deta($select=ccof_feeafterincrease),ccof_ccof_rfipfi_ccof_rfipfiserviceexpansiondetail_rfipfi,ccof_rfi_pfi_other_funding_RFI_PFI, ccof_rfi_pfi_dcs_wi_detail_RFI_PFI_Detail,ccof_ccof_rfipfi_ccof_rfipfiexpenseinfo_rfipfi,ccof_rfipfi_ccof_rfipfi_IndegenousService`;
@@ -71,7 +90,7 @@ async function getRFIApplication(req, res) {
rfiApplication.data['expenseList'] = response.value[0].ccof_ccof_rfipfi_ccof_rfipfiexpenseinfo_rfipfi?.map(el=> formatDate(new MappableObjectForFront(el,ExpenseInformationMappings).data, 'date'));
rfiApplication.data['fundingList'] = response.value[0].ccof_rfi_pfi_other_funding_RFI_PFI?.map(el=> formatDate(new MappableObjectForFront(el,OtherFundingProgramMappings).data, 'date'));
rfiApplication.data['indigenousExpenseList'] = response.value[0].ccof_rfipfi_ccof_rfipfi_IndegenousService?.map(el=> formatDate(new MappableObjectForFront(el,IndigenousExpenseMappings).data, 'date'));
-
+
return res.status(HttpStatus.OK).json(rfiApplication);
} else {
return res.status(HttpStatus.OK).json({});
@@ -158,7 +177,7 @@ async function updateRFIApplication(req, res) {
payload['ccof_rfipfi@odata.bind'] = `/ccof_rfipfis(${rfipfiid})`;
await postOperation('ccof_rfipfiexpenseinfos', payload);
await sleep(100);
- });
+ });
}
//rfipfiid, entityName, selectorName, filterName) {
@@ -172,7 +191,7 @@ async function updateRFIApplication(req, res) {
payload['ccof_rfipfi_IndegenousServiceExpansion@odata.bind'] = `/ccof_rfipfis(${rfipfiid})`;
await postOperation('ccof_rfipfiserviceexpansionindigenouscommunities', payload);
await sleep(100);
- });
+ });
}
return res.status(HttpStatus.OK).json(friApplicationResponse);
@@ -218,4 +237,5 @@ module.exports = {
createRFIApplication,
updateRFIApplication,
getRFIMedian,
+ deleteRfiApplication
};
diff --git a/backend/src/components/user.js b/backend/src/components/user.js
index fb72100cf..d6a2b02bf 100644
--- a/backend/src/components/user.js
+++ b/backend/src/components/user.js
@@ -5,7 +5,7 @@ const ApiError = require('./error');
const axios = require('axios');
const HttpStatus = require('http-status-codes');
const log = require('../components/logger');
-const { APPLICATION_STATUS_CODES, CCFRI_STATUS_CODES, ECEWE_STATUS_CODES, CCOF_STATUS_CODES, CCOF_APPLICATION_TYPES, ORGANIZATION_PROVIDER_TYPES, CHANGE_REQUEST_TYPES, CHANGE_REQUEST_STATUS_CODES, CHANGE_REQUEST_EXTERNAL_STATUS_CODES} = require('../util/constants');
+const { APPLICATION_STATUS_CODES, CCFRI_STATUS_CODES, ECEWE_STATUS_CODES, CCOF_STATUS_CODES, CCOF_APPLICATION_TYPES, ORGANIZATION_PROVIDER_TYPES, CHANGE_REQUEST_TYPES, PROGRAM_YEAR_STATUS_CODES, CHANGE_REQUEST_STATUS_CODES, CHANGE_REQUEST_EXTERNAL_STATUS_CODES} = require('../util/constants');
const { UserProfileFacilityMappings, UserProfileOrganizationMappings, UserProfileBaseFundingMappings, UserProfileApplicationMappings, UserProfileCCFRIMappings, UserProfileECEWEMappings, UserProfileChangeRequestNewFacilityMappings } = require('../util/mapping/Mappings');
const { UserProfileChangeRequestMappings } = require('../util/mapping/ChangeRequestMappings');
@@ -80,22 +80,30 @@ async function getUserInfo(req, res) {
creatUser(req);
return res.status(HttpStatus.OK).json(resData);
}
- if (userResponse === {}){
+ if (userResponse == {}){
// If no data back, then no associated Organization/Facilities, return empty orgination data
return res.status(HttpStatus.OK).json(resData);
}
let organization = new MappableObjectForFront(userResponse, UserProfileOrganizationMappings).data;
+ let applicationList = [];
+ if (userResponse.application && userResponse.application.length > 0 ) {
+ userResponse.application.forEach( ap => {
+ let application = new MappableObjectForFront(ap, UserProfileApplicationMappings).data;
+ application.organizationProviderType = getLabelFromValue(application.organizationProviderType, ORGANIZATION_PROVIDER_TYPES);
+ application.applicationStatus = getLabelFromValue(application.applicationStatus, APPLICATION_STATUS_CODES, 'NEW');
+ application.applicationType = getLabelFromValue(application.applicationType, CCOF_APPLICATION_TYPES);
+ application.ccofProgramYearId = ap.ccof_ProgramYear?.ccof_program_yearid;
+ application.ccofProgramYearName = ap.ccof_ProgramYear?.ccof_name;
+ application.ccofProgramYearStatus = getLabelFromValue(ap.ccof_ProgramYear?.statuscode, PROGRAM_YEAR_STATUS_CODES);
+ application.ccofApplicationStatus = getLabelFromValue(application.ccofStatus, CCOF_STATUS_CODES, 'NEW');
+ applicationList.push(application);
- let application = new MappableObjectForFront(userResponse.application, UserProfileApplicationMappings).data;
- application.organizationProviderType = getLabelFromValue(application.organizationProviderType, ORGANIZATION_PROVIDER_TYPES);
- application.applicationStatus = getLabelFromValue(application.applicationStatus, APPLICATION_STATUS_CODES, 'NEW');
- application.applicationType = getLabelFromValue(application.applicationType, CCOF_APPLICATION_TYPES);
- application.ccofProgramYearId = userResponse.application?.ccof_ProgramYear?.ccof_program_yearid;
- application.ccofProgramYearName = userResponse.application?.ccof_ProgramYear?.ccof_name;
- application.ccofApplicationStatus = getLabelFromValue(application.ccofStatus, CCOF_STATUS_CODES, 'NEW');
-
+ application.facilityList = parseFacilityData(ap, userResponse.facilities);
+ });
+ }
+ /*
const changeRequests = [];
userResponse.application?.ccof_ccof_change_request_Application_ccof_appl?.forEach(el => {
const item = new MappableObjectForFront(el, UserProfileChangeRequestMappings).data;
@@ -120,13 +128,13 @@ async function getUserInfo(req, res) {
changeRequests.push(item);
});
-
- resData.facilityList = parseFacilityData(userResponse);
+*/
+ //resData.facilityList = parseFacilityData(userResponse.facilities);
let results = {
...resData,
...organization,
- ...application,
- changeRequests: changeRequests
+ applications: applicationList
+ // changeRequests: changeRequests
};
return res.status(HttpStatus.OK).json(results);
}
@@ -135,9 +143,9 @@ async function getUserProfile(userGuid, userName) {
try {
let url = undefined;
if (userGuid) {
- url = config.get('dynamicsApi:apiEndpoint') + `/api/ProviderProfile?userId=${userGuid}&userName=${userName}`;
+ url = config.get('dynamicsApi:apiEndpoint') + `/api/ProviderFiscalProfile?userId=${userGuid}&userName=${userName}`;
} else {
- url = config.get('dynamicsApi:apiEndpoint') + `/api/ProviderProfile?userName=${userName}`;
+ url = config.get('dynamicsApi:apiEndpoint') + `/api/ProviderFiscalProfile?userName=${userName}`;
}
log.verbose('UserProfile Url is', url);
@@ -172,31 +180,36 @@ function updateFacilityWithChangeRequestDetails(changeRequestList, returnValue,
}
}
-function parseFacilityData(userResponse) {
- let facilityMap = new Map(userResponse.facilities?.map((m) => [m['accountid'], new MappableObjectForFront(m, UserProfileFacilityMappings).data]));
+function parseFacilityData(application, facilities) {
+
+ //all the facilites
+ let facilityMap = new Map(facilities?.map((m) => [m['accountid'], new MappableObjectForFront(m, UserProfileFacilityMappings).data]));
- if (userResponse.application) {
+ if (application) {
facilityMap.forEach((value, key, map) => {
- let ccfriInfo = userResponse.application.ccof_applicationccfri_Application_ccof_ap?.find(item => item['_ccof_facility_value'] === key);
+ let ccfriInfo = application.ccof_applicationccfri_Application_ccof_ap?.find(item => item['_ccof_facility_value'] === key);
ccfriInfo = new MappableObjectForFront(ccfriInfo, UserProfileCCFRIMappings).data;
- let eceweInfo = userResponse.application.ccof_ccof_application_ccof_applicationecewe_application?.find(item => item['_ccof_facility_value'] === key);
+ let eceweInfo = application.ccof_ccof_application_ccof_applicationecewe_application?.find(item => item['_ccof_facility_value'] === key);
eceweInfo = new MappableObjectForFront(eceweInfo, UserProfileECEWEMappings).data;
- let baseFunding = userResponse.application.ccof_application_basefunding_Application?.find(item => item['_ccof_facility_value'] === key);
+ let baseFunding = application.ccof_application_basefunding_Application?.find(item => item['_ccof_facility_value'] === key);
baseFunding = new MappableObjectForFront(baseFunding, UserProfileBaseFundingMappings).data;
- let changeRequestList = userResponse.application.ccof_ccof_change_request_Application_ccof_appl;
+ // let changeRequestList = userResponse.application.ccof_ccof_change_request_Application_ccof_appl;
let returnValue = {
...value,
...ccfriInfo,
...eceweInfo,
...baseFunding,
};
- updateFacilityWithChangeRequestDetails(changeRequestList, returnValue, key);
+ // updateFacilityWithChangeRequestDetails(changeRequestList, returnValue, key);
map.set(key, returnValue);
});
}
let facilityList = [];
facilityMap.forEach((facility) => {
- if (!_.isEmpty(facility)) {
+ // //only add a facility to the application Facility List if they have an application id shown below.
+ // //otherwise that facility does not exist in this application year.
+ //if application status is incomplete, show all available facilties so CR fac's will also appear for the draft application
+ if (facility.ccofBaseFundingId || facility.ccfriApplicationId || facility.eceweApplicationId || application.statuscode_formatted == 'Incomplete') {
facility.ccofBaseFundingStatus = getLabelFromValue(facility.ccofBaseFundingStatus, CCOF_STATUS_CODES);
facility.ccfriStatus = getLabelFromValue(facility.ccfriStatus, CCFRI_STATUS_CODES, 'NOT STARTED');
facility.eceweStatus = getLabelFromValue(facility.eceweStatus, ECEWE_STATUS_CODES, 'NOT STARTED');
diff --git a/backend/src/routes/application.js b/backend/src/routes/application.js
index f7d839c33..2494df63b 100644
--- a/backend/src/routes/application.js
+++ b/backend/src/routes/application.js
@@ -3,8 +3,8 @@ const passport = require('passport');
const router = express.Router();
const auth = require('../components/auth');
const isValidBackendToken= auth.isValidBackendToken();
-const { getRFIMedian, getRFIApplication, createRFIApplication, updateRFIApplication} = require('../components/rfiApplication');
-const { upsertParentFees, updateCCFRIApplication, deleteCCFRIApplication, renewCCOFApplication, getApplicationSummary, getChangeRequest } = require('../components/application');
+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 { getNMFApplication, updateNMFApplication, createNMFApplication } = require('../components/nmfApplication');
const { param, validationResult } = require('express-validator');
@@ -46,6 +46,12 @@ router.get('/ccfri/:ccfriId/median', passport.authenticate('jwt', {session: fals
return getRFIMedian(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.patch('/ccfri', passport.authenticate('jwt', {session: false}),isValidBackendToken, [], (req, res) => {
//validationResult(req).throw();
//console.log(req.bpdy);
@@ -57,9 +63,9 @@ router.patch('/ccfri/:ccfriId/', passport.authenticate('jwt', {session: false}),
return patchCCFRIApplication(req, res);
});
-router.delete('/ccfri/:ccfriId/', passport.authenticate('jwt', {session: false}),isValidBackendToken,
+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);
+ return deleteCCFRIApplication(req, res);
});
router.get('/ccfri/:ccfriId/nmf', passport.authenticate('jwt', {session: false}),isValidBackendToken,
@@ -138,5 +144,13 @@ router.get('/changeRequest/:applicationId', passport.authenticate('jwt', {sessio
});
+/* 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) => {
+ return deletePcfApplication(req, res);
+ });
+
+
module.exports = router;
diff --git a/backend/src/routes/facility.js b/backend/src/routes/facility.js
index a20f170af..c0f29200f 100644
--- a/backend/src/routes/facility.js
+++ b/backend/src/routes/facility.js
@@ -3,7 +3,7 @@ const passport = require('passport');
const router = express.Router();
const auth = require('../components/auth');
const isValidBackendToken= auth.isValidBackendToken();
-const { getFacility, getFacilityChildCareTypes, createFacility, updateFacility, deleteFacility, getLicenseCategories, getApprovedParentFees } = require('../components/facility');
+const { getFacility, getFacilityChildCareTypes, createFacility, updateFacility, deleteFacility, getLicenseCategories, getApprovedParentFees, returnCCFRIClosureDates } = require('../components/facility');
const { param, validationResult, checkSchema} = require('express-validator');
@@ -56,6 +56,16 @@ router.get('/fees/:facilityId/year/:programYearId', passport.authenticate('jwt',
return getApprovedParentFees(req, res);
});
+/**
+ * Get closure dates for a facility
+ *
+ */
+router.get('/dates/:ccfriId', passport.authenticate('jwt', {session: false}),isValidBackendToken,
+ [param('ccfriId', 'URL param: [ccfriId] is required').not().isEmpty()], (req, res) => {
+ validationResult(req).throw();
+ return returnCCFRIClosureDates(req, res);
+ });
+
/**
* Create a new Facility
diff --git a/backend/src/util/mapping/ChangeRequestMappings.js b/backend/src/util/mapping/ChangeRequestMappings.js
index 780d3c070..ae7b08552 100644
--- a/backend/src/util/mapping/ChangeRequestMappings.js
+++ b/backend/src/util/mapping/ChangeRequestMappings.js
@@ -25,6 +25,9 @@ const ChangeRequestMappings = [
{ back: 'ccof_ecewe_selecttheapplicablefundingmode', front: 'fundingModel' },
{ back: 'ccof_ecewe_confirmation', front: 'confirmation' },
{ back: 'ccof_declaration', front: 'enabledDeclarationB' },
+ { back: 'ccof_indicator_unlock', front: 'isChangeRequestUnlocked' },
+ { back: 'ccof_public_sector_employer', front: 'publicSector' },
+
...UserProfileChangeRequestMappings
// { back: 'ccof_change_request_new_facilityid', front: 'changeFacilityID'},
];
@@ -42,6 +45,9 @@ const ChangeActionRequestMappings = [
const NewFacilityMappings = [
{ back: '_ccof_facility_value', front: 'facilityId'},
{ back: 'ccof_change_request_new_facilityid', front: 'changeRequestNewFacilityId'},
+ { back: 'ccof_unlock_ccfri', front: 'unlockCcfri' },
+ { back: 'ccof_unlock_nmf_rfi', front: 'unlockNmf' },
+ { back: 'ccof_unlock_rfi', front: 'unlockRfi' },
];
const MtfiMappings = [
@@ -53,6 +59,22 @@ const MtfiMappings = [
{ back: 'ccof_unlock_ccfri', front: 'unlockCcfri'},
];
+const ChangeRequestUnlockMapping = [
+ { back: 'ccof_applicationid', front: 'applicationId' },
+ { back: 'statuscode', front: 'applicationStatus' },
+ { back: 'ccof_providertype', front: 'organizationProviderType' }, // group or family
+ { back: 'ccof_applicationtype', front: 'applicationType' },
+ { back: 'ccof_licensecomplete', front: 'isLicenseUploadComplete' },
+ { back: 'ccof_ecewe_eligibility_complete', front: 'isEceweComplete' },
+ { back: 'ccof_unlock_declaration', front: 'unlockDeclaration' },
+ { back: 'ccof_unlock_licence_upload', front: 'isLicenseUploadUnlocked' },
+ { back: 'ccof_unlock_supporting_document', front: 'isSupportingDocumentsUnlocked' },
+ { back: 'ccof_unlock_ccof', front: 'isCCOFUnlocked' },
+ { back: 'ccof_unlock_ecewe', front: 'isEceweUnlocked' },
+ { back: 'ccof_ccofstatus', front: 'ccofStatus' },
+ { back: 'ccof_unlock_other_changes_document', front: 'isOtherDocumentsUnlocked' },
+ { back: 'ccof_unlock_change_request', front: 'isChangeRequestUnlocked' },
+];
module.exports = {
ChangeRequestMappings,
@@ -60,6 +82,7 @@ module.exports = {
NewFacilityMappings,
MtfiMappings,
UserProfileChangeRequestMappings,
+ ChangeRequestUnlockMapping,
};
// const ChangeRequestMappings = [
diff --git a/backend/src/util/mapping/Mappings.js b/backend/src/util/mapping/Mappings.js
index 7b4ac8ddb..c13fcbc06 100644
--- a/backend/src/util/mapping/Mappings.js
+++ b/backend/src/util/mapping/Mappings.js
@@ -242,6 +242,7 @@ const ECEWEApplicationMappings = [
{ back: 'ccof_licensecomplete', front: 'isLicenseUploadComplete' },
{ back: 'ccof_ecewe_eligibility_complete', front: 'isEceweComplete' },
{ back: 'ccof_ecewe_selecttheapplicablesector', front: 'applicableSector' },
+ { back: 'ccof_public_sector_employer', front: 'publicSector' }, //null,
];
const ECEWEFacilityMappings = [
@@ -342,11 +343,13 @@ const ProgramYearMappings = [
{ back: 'ccof_intakeperiodstart', front: 'intakeStart' },
{ back: 'ccof_intakeperiodend', front: 'intakeEnd' },
{ back: 'ccof_declarationbstart', front: 'declarationbStart' },
+ { back: 'ccof_ccfri_funding_guidelines', front: 'fundingGuidelinesUrl' },
];
const MessageMappings = [
{ back: 'activityid', front: 'messageId' },
{ back: 'createdon', front: 'dateReceived' },
+ { back: 'ccof_program_year', front: 'programYearValue'},
{ back: 'description', front: 'messageContent' },
{ back: 'lastopenedtime', front: 'lastOpenedTime' },
{ back: 'subject', front: 'subject' },
@@ -398,6 +401,7 @@ const ApplicationSummaryMappings = [
{ back: 'ccof_ecewe_confirmation', front: 'confirmation' }, //null,
{ back: 'ccof_ecewe_employeeunion', front: 'belongsToUnion' }, //0,
{ back: 'ccof_ecewe_selecttheapplicablefundingmodel', front: 'fundingModel' }, //null,
+ { back: 'ccof_public_sector_employer', front: 'publicSector' }, //null,
// Unlock Details
{ back: 'ccof_unlock_ccof', front: 'unlockBaseFunding' }, //null,
{ back: 'ccof_unlock_ecewe', front: 'unlockEcewe' }, //null,
diff --git a/frontend/public/index.html b/frontend/public/index.html
index 5cbc90445..02950e442 100644
--- a/frontend/public/index.html
+++ b/frontend/public/index.html
@@ -11,7 +11,7 @@
-
Child Care Operating Fund
+ My ChildCareBC Services