generated from bcgov/vue-scaffold
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #586 from bcgov/ccfri-3818-ecewe-group-update
Ccfri 3818 ecewe group update
- Loading branch information
Showing
15 changed files
with
1,429 additions
and
722 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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['[email protected]']; | ||
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); | ||
}), | ||
); | ||
|
||
|
Oops, something went wrong.