Skip to content

Commit

Permalink
Mtfi afs (#614)
Browse files Browse the repository at this point in the history
* wip document filter works across facilties, delete works well

* wip - navbar status checking works properly now

* lock and doc status update works on submission

* updates to lock

* enable afs works in the store - and cleanup

* Fixed button layout.

* comments from Wes

---------

Co-authored-by: weskubo-cgi <[email protected]>
  • Loading branch information
jenbeckett and weskubo-cgi authored Jan 21, 2025
1 parent a4c6746 commit da48bf6
Show file tree
Hide file tree
Showing 21 changed files with 406 additions and 188 deletions.
95 changes: 34 additions & 61 deletions backend/src/components/changeRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,11 @@ 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 { getLabelFromValue, getOperation, postOperation, patchOperationWithObjectId, deleteOperationWithObjectId, getChangeActionDocument, postChangeActionDocument } = require('./utils');
const { getFileExtension, convertHeicDocumentToJpg } = require('../util/uploadFileUtils');

function mapChangeRequestForBack(data, changeType) {
let changeRequestForBack = new MappableObjectForBack(data, ChangeRequestMappings).toJSON();
const changeRequestForBack = new MappableObjectForBack(data, ChangeRequestMappings).toJSON();
changeRequestForBack['[email protected]'] = `/ccof_program_years(${data.programYearId})`;
delete changeRequestForBack._ccof_program_year_value;

Expand All @@ -45,20 +36,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(
const 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 = [];
const changeActionDetails = await getOperation(operation);
const details = changeActionDetails?.value;
const retVal = [];
details?.forEach((el) => {
let data = new MappableObjectForFront(el, NewFacilityMappings).toJSON();
const 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);
});
Expand All @@ -84,11 +71,11 @@ async function getChangeActionDetails(changeActionId, changeDetailEntity, change
operation = `${changeDetailEntity}?$select=${getMappingString(changeDetailMapper)}&$filter=_ccof_change_action_value eq '${changeActionId}'`;
}

let changeActionDetails = await getOperation(operation);
let details = changeActionDetails?.value;
let retVal = [];
const changeActionDetails = await getOperation(operation);
const details = changeActionDetails?.value;
const retVal = [];
details?.forEach((el) => {
let data = new MappableObjectForFront(el, changeDetailMapper).toJSON();
const data = new MappableObjectForFront(el, changeDetailMapper).toJSON();
let joinData = undefined;
if (joiningTable) {
joinData = new MappableObjectForFront(el[joiningTable], joiningTableMapping).toJSON();
Expand All @@ -105,14 +92,14 @@ async function getChangeActionDetails(changeActionId, changeDetailEntity, change
}

async function mapChangeRequestObjectForFront(data) {
let retVal = new MappableObjectForFront(data, ChangeRequestMappings).toJSON();
const retVal = new MappableObjectForFront(data, ChangeRequestMappings).toJSON();

let changeList = [];
const 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);
const 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');
});
Expand All @@ -121,21 +108,19 @@ async function mapChangeRequestObjectForFront(data) {
const newFacilities = await getChangeActionNewFacilitityDetails(changeAction.changeActionId);
changeAction.newFacilities = newFacilities;
}
let unlockVals = new MappableObjectForFront(el, ChangeRequestUnlockMapping).toJSON();
const 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)`;
const 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);
Expand All @@ -149,17 +134,14 @@ async function getChangeRequest(req, res) {

async function updateChangeRequest(req, res) {
let changeRequest = req.body;
//changeRequest.externalStatus = CHANGE_REQUEST_EXTERNAL_STATUS_CODES.externalStatus;
changeRequest = new MappableObjectForBack(changeRequest, ChangeRequestMappings);
changeRequest = changeRequest.toJSON();

try {
log.verbose('update change Request: payload', changeRequest);
let response = await patchOperationWithObjectId('ccof_change_requests', req.params.changeRequestId, changeRequest);

//is change req complete ? (status 2 i think )
const response = await patchOperationWithObjectId('ccof_change_requests', req.params.changeRequestId, changeRequest);

if (changeRequest.ccof_externalstatus == 2) {
if (changeRequest.ccof_externalstatus === CHANGE_REQUEST_EXTERNAL_STATUS_CODES.SUBMITTED) {
printPdf(req).then();
}

Expand All @@ -171,12 +153,9 @@ async function updateChangeRequest(req, res) {

// create Change Request
async function createChangeRequest(req, res) {
log.info('createChangeRequest called');

try {
let changeRequest = req.body;
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') {
changeType = CHANGE_REQUEST_TYPES.PARENT_FEE_CHANGE;
Expand All @@ -185,10 +164,9 @@ async function createChangeRequest(req, res) {
} else if (changeType === 'PDF_CHANGE') {
changeType = CHANGE_REQUEST_TYPES.PDF_CHANGE;
}
//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)`;
const operation = `ccof_change_requests(${changeRequestId})?$select=ccof_change_requestid&$expand=ccof_change_action_change_request($select=ccof_change_actionid,statuscode)`;
const payload = await getOperation(operation);
let changeActionId = undefined;
if (payload && payload.ccof_change_action_change_request?.length > 0) {
Expand All @@ -205,7 +183,6 @@ async function createChangeRequest(req, res) {
}

async function createChangeAction(req, res, changeType) {
log.info('createChangeAction called');
try {
const payload = {
ccof_changetype: changeType,
Expand All @@ -224,7 +201,6 @@ async function createChangeAction(req, res, changeType) {
}

async function deleteChangeAction(req, res) {
log.info('deleteChangeAction called - changeActionId = ' + req.params.changeActionId);
try {
await deleteOperationWithObjectId('ccof_change_actions', req.params.changeActionId);
return res.status(HttpStatus.OK).end();
Expand Down Expand Up @@ -256,7 +232,7 @@ function buildNewFacilityPayload(req) {

async function updateChangeRequestNewFacility(changeRequestNewFacilityId, payload) {
try {
let response = await patchOperationWithObjectId('ccof_change_request_new_facilities', changeRequestNewFacilityId, payload);
const response = await patchOperationWithObjectId('ccof_change_request_new_facilities', changeRequestNewFacilityId, payload);
return response;
} catch (e) {
log.error('error', e);
Expand All @@ -265,16 +241,15 @@ async function updateChangeRequestNewFacility(changeRequestNewFacilityId, payloa
}

async function createChangeRequestFacility(req, res) {
let facility = buildNewFacilityPayload(req);
const facility = buildNewFacilityPayload(req);
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 payload = await getOperation(operation);
console.log(payload);
const payload = await getOperation(operation);
let changeRequestNewFacilityId = undefined;
let ccofBaseFundingId = undefined;
let ccofBaseFundingStatus = undefined;
Expand All @@ -300,7 +275,7 @@ async function createChangeRequestFacility(req, res) {
}

async function deleteChangeRequest(req, res) {
let { changeRequestId } = req.params;
const { changeRequestId } = req.params;
log.verbose(changeRequestId);

try {
Expand All @@ -312,13 +287,12 @@ async function deleteChangeRequest(req, res) {
}
}

//TODO: need some mapping here prob but lets figure out Sukanyas component first
async function getChangeRequestDocs(req, res) {
let { changeRequestId } = req.params;
const { changeRequestId } = req.params;
log.verbose(changeRequestId);

try {
let response = await getChangeActionDocument(changeRequestId);
const response = await getChangeActionDocument(changeRequestId);

log.verbose(response.value);
return res.status(HttpStatus.OK).json(response.value);
Expand All @@ -330,8 +304,8 @@ async function getChangeRequestDocs(req, res) {

async function saveChangeRequestDocs(req, res) {
try {
let documents = req.body;
for (let document of documents) {
const documents = req.body;
for (const document of documents) {
let documentClone = document;
if (getFileExtension(documentClone.filename) === 'heic') {
log.verbose(`saveChangeRequestDocs :: heic detected for file name ${documentClone.filename} starting conversion`);
Expand All @@ -348,11 +322,10 @@ async function saveChangeRequestDocs(req, res) {

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();
const operation = `ccof_applicationccfris(${req.params.ccfriId})?$expand=ccof_change_request_mtfi_application_ccfri`;
const response = await getOperation(operation);
const mtfiDetails = [];
const 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 });
Expand All @@ -366,8 +339,7 @@ async function getChangeRequestMTFIByCcfriId(req, res) {

async function deleteChangeRequestMTFI(req, res) {
try {
log.info('deleteChangeRequestMTFI - mtfiId = ', req.params.mtfiId);
let response = await deleteOperationWithObjectId('ccof_change_request_mtfis', req.params.mtfiId);
const response = await deleteOperationWithObjectId('ccof_change_request_mtfis', req.params.mtfiId);
return res.status(HttpStatus.OK).json(response);
} catch (e) {
log.error(e);
Expand All @@ -377,7 +349,8 @@ async function deleteChangeRequestMTFI(req, res) {

async function updateChangeRequestMTFI(req, res) {
try {
let response = await patchOperationWithObjectId('ccof_change_request_mtfis', req.params.mtfiId, req.body);
const payload = new MappableObjectForBack(req?.body, MtfiMappings);
await patchOperationWithObjectId('ccof_change_request_mtfis', req.params.mtfiId, payload);
return res.status(HttpStatus.OK).json();
} catch (e) {
log.error('error', e);
Expand Down
2 changes: 1 addition & 1 deletion backend/src/components/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async function createApplicationDocuments(req, res) {
async function createChangeActionDocuments(req, res) {
try {
const documents = req.body;
for (let document of documents) {
for (const document of documents) {
let documentClone = cloneDeep(document);
if (getFileExtension(documentClone.filename) === 'heic') {
log.verbose(`createChangeActionDocuments :: heic detected for file name ${documentClone.filename} starting conversion`);
Expand Down
5 changes: 3 additions & 2 deletions backend/src/components/supportingDocumentUpload.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ const { getFileExtension, convertHeicDocumentToJpg } = require('../util/uploadFi
async function saveDocument(req, res) {
try {
let documents = req.body;
for (let document of documents) {
for (const document of documents) {
let documentClone = document;
let changeRequestNewFacilityId = documentClone.changeRequestNewFacilityId;
//ccfri-3755 saved document can now be for MTFI AFS - so it may not have a NewFacilityId
const changeRequestNewFacilityId = documentClone.changeRequestNewFacilityId ?? null;
delete documentClone.changeRequestNewFacilityId;
if (getFileExtension(documentClone.filename) === 'heic') {
log.verbose(`saveDocument :: heic detected for file name ${documentClone.filename} starting conversion`);
Expand Down
39 changes: 17 additions & 22 deletions backend/src/util/mapping/ChangeRequestMappings.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
const UserProfileChangeRequestMappings = [
{ back: 'ccof_name', front: 'name' }, // "807",
{ back: 'statuscode', front: 'status' }, // 6,
{ back: 'ccof_name', front: 'name' },
{ back: 'statuscode', front: 'status' },
{ back: 'ccof_unlock_declaration', front: 'unlockDeclaration' },
{ back: 'ccof_change_requestid', front: 'changeRequestId' }, // "36866904-44d9-ed11-a7c6-000d3a09d132",
{ back: 'ccof_change_requestid', front: 'changeRequestId' },
{ back: 'ccof_licensecomplete', front: 'isLicenseUploadComplete' },
{ back: 'ccof_ecewe_eligibility_complete', front: 'isEceweComplete' },
{ back: 'ccof_externalstatus', front: 'externalStatus' }, // 2,
];

const ChangeRequestMappings = [
{ back: '_ccof_program_year_value', front: 'programYearId' }, // "cd63f67b-bd39-ed11-9db0-002248d53d53",
{ back: 'ccof_provider_type', front: 'providerType' }, // 100000001, - family
{ back: '_ccof_application_value', front: 'applicationId' }, // "d11fbf2c-e1c5-ed11-b597-000d3a09d699",
{ back: 'ccof_change_action_change_request ', front: 'ccof_change_action_change_request' }, // "d11fbf2c-e1c5-ed11-b597-000d3a09d699",
{ back: '_ccof_program_year_value', front: 'programYearId' },
{ back: 'ccof_provider_type', front: 'providerType' },
{ back: '_ccof_application_value', front: 'applicationId' },
{ back: 'ccof_change_action_change_request ', front: 'ccof_change_action_change_request' },
{ back: 'createdon', front: 'createdOnDate' },
{ back: 'ccof_firstsubmissiondate', front: 'firstSubmissionDate' },
{ back: 'ccof_latestsubmissiondate', front: 'latestSubmissionDate' },
Expand All @@ -27,20 +27,18 @@ const ChangeRequestMappings = [
{ back: 'ccof_declaration', front: 'enabledDeclarationB' },
{ back: 'ccof_indicator_unlock', front: 'isChangeRequestUnlocked' },
{ back: 'ccof_public_sector_employer', front: 'publicSector' },
{ back: 'ccof_union_agreement_reached', front: 'isUnionAgreementReached' }, //null,
{ back: 'ccof_describe_your_org', front: 'describeOrgCSSEA' }, //null,
{ back: 'ccof_union_agreement_reached', front: 'isUnionAgreementReached' },
{ back: 'ccof_describe_your_org', front: 'describeOrgCSSEA' },

...UserProfileChangeRequestMappings,
// { back: 'ccof_change_request_new_facilityid', front: 'changeFacilityID'},
];

const ChangeActionRequestMappings = [
{ back: 'statuscode', front: 'status' }, // 6,
{ back: 'ccof_change_actionid', front: 'changeActionId' }, // 6,
{ back: 'ccof_changetype', front: 'changeType' }, // 100000013,
{ back: '_ccof_change_request_value', front: 'changeRequestId' }, // 6,
{ back: 'statuscode', front: 'status' },
{ back: 'ccof_change_actionid', front: 'changeActionId' },
{ back: 'ccof_changetype', front: 'changeType' },
{ back: '_ccof_change_request_value', front: 'changeRequestId' },
{ back: 'createdon', front: 'createdOn' },
// { back: '_ccof_facility_value', front: 'facilityId'},
];

const NewFacilityMappings = [
Expand All @@ -58,12 +56,15 @@ const MtfiMappings = [
{ back: 'ccof_unlock_nmf_rfi', front: 'unlockNmf' },
{ back: 'ccof_unlock_rfi', front: 'unlockRfi' },
{ back: 'ccof_unlock_ccfri', front: 'unlockCcfri' },
{ back: 'ccof_unlock_afs', front: 'unlockAfs' },
{ back: 'ccof_unlock_afs_enable', front: 'enableAfs' },
{ back: 'ccof_facilityid_mapped', front: 'facilityAccountNumber' },
];

const ChangeRequestUnlockMapping = [
{ back: 'ccof_applicationid', front: 'applicationId' },
{ back: 'statuscode', front: 'applicationStatus' },
{ back: 'ccof_providertype', front: 'organizationProviderType' }, // group or family
{ back: 'ccof_providertype', front: 'organizationProviderType' },
{ back: 'ccof_applicationtype', front: 'applicationType' },
{ back: 'ccof_licensecomplete', front: 'isLicenseUploadComplete' },
{ back: 'ccof_ecewe_eligibility_complete', front: 'isEceweComplete' },
Expand All @@ -85,9 +86,3 @@ module.exports = {
UserProfileChangeRequestMappings,
ChangeRequestUnlockMapping,
};

// const ChangeRequestMappings = [
// { back: 'ccof_change_requestid', front: 'changeRequestId'},

// //{ back: '', front: ''}, // null,
// ];
1 change: 1 addition & 0 deletions backend/src/util/mapping/Mappings.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const CCFRIFacilityMappings = [
{ back: 'ccof_unlock_afs', front: 'unlockAfs' },
{ back: 'ccof_unlock_afsenable', front: 'enableAfs' },
{ back: 'ccof_afs_status', front: 'afsStatus' },
{ back: 'ccof_afs_status_mtfi', front: 'afsStatusMtfi' },
];

const RFIApplicationMappings = [
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/components/SummaryDeclaration.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@
<p>You will be unable to submit a change request until the Program Confirmation Form is updated.</p>
<br />
<br />

<!-- <v-btn theme="dark" class="blueButton mb-10" @click="goToChangeRequestHistory()" :loading="processing">View My Changes</v-btn> -->
</v-card>
</v-row>

Expand Down
Loading

0 comments on commit da48bf6

Please sign in to comment.