Skip to content

Commit

Permalink
Merge pull request #501 from bcgov/release-196
Browse files Browse the repository at this point in the history
ccfri 2939 add functionality for Funding Agreement Number to be Dynam…
  • Loading branch information
roblo-cgi authored Feb 1, 2024
2 parents eb9a8ef + a1296f9 commit 4b9fb32
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 54 deletions.
52 changes: 21 additions & 31 deletions backend/src/components/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ 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, 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 { UserProfileFacilityMappings, UserProfileOrganizationMappings, UserProfileBaseFundingMappings, UserProfileApplicationMappings, UserProfileCCFRIMappings, UserProfileECEWEMappings, UserProfileChangeRequestNewFacilityMappings, fundingAgreementMappings} = require('../util/mapping/Mappings');
const { UserProfileChangeRequestMappings } = require('../util/mapping/ChangeRequestMappings');

const { MappableObjectForFront } = require('../util/mapping/MappableObject');
Expand Down Expand Up @@ -87,7 +87,13 @@ async function getUserInfo(req, res) {

let organization = new MappableObjectForFront(userResponse, UserProfileOrganizationMappings).data;
let applicationList = [];

if (userResponse.application && userResponse.application.length > 0 ) {
//call the funding agreement table and load that to the application
let operation = `ccof_funding_agreements?$filter=_ccof_organization_value eq '${organization.organizationId}'`;
let fundingAgreementDetails = (await getOperation(operation)).value;
//log.info(fundingAgreementDetails);

userResponse.application.forEach( ap => {
let application = new MappableObjectForFront(ap, UserProfileApplicationMappings).data;
application.organizationProviderType = getLabelFromValue(application.organizationProviderType, ORGANIZATION_PROVIDER_TYPES);
Expand All @@ -97,44 +103,28 @@ async function getUserInfo(req, res) {
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);

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;
item.status = getLabelFromValue(item.status, CHANGE_REQUEST_STATUS_CODES);
item.externalStatus = getLabelFromValue(item.externalStatus , CHANGE_REQUEST_EXTERNAL_STATUS_CODES);
let changeActionNewFacilityList = el?.ccof_change_action_change_request?.filter(item => item.ccof_changetype === CHANGE_REQUEST_TYPES.NEW_FACILITY);
for (const changeActionNewFacility of changeActionNewFacilityList) {
item.unlockEcewe = changeActionNewFacility?.ccof_unlock_ecewe;
item.unlockCCOF = changeActionNewFacility?.ccof_unlock_ccof;
item.unlockSupportingDocuments = changeActionNewFacility?.ccof_unlock_supporting_document;
item.unlockLicenseUpload = changeActionNewFacility?.ccof_unlock_licence_upload;
}
let changeActionOtherChanges = el?.ccof_change_action_change_request?.filter(item => item.ccof_changetype !== CHANGE_REQUEST_TYPES.NEW_FACILITY);
for (const changeActionOthers of changeActionOtherChanges){
item.unlockChangeRequest = changeActionOthers?.ccof_unlock_change_request;
item.unlockOtherChangesDocuments = changeActionOthers?.ccof_unlock_other_changes_document;
if (changeActionOthers.ccof_changetype === CHANGE_REQUEST_TYPES.PDF_CHANGE) {
item.changeNotificationActionId = changeActionOthers.ccof_change_actionid;
//add in funding agreement details based on the fiscal year
let fundingAgreementForFront = null;
for (const fundingAgreementObj of fundingAgreementDetails){
if (fundingAgreementObj._ccof_programyear_value != application.ccofProgramYearId){
continue;
}
else if (!fundingAgreementForFront ||fundingAgreementObj.ccof_version > fundingAgreementForFront.ccof_version ){
fundingAgreementForFront = fundingAgreementObj;
}
}
}
changeRequests.push(item);
fundingAgreementForFront = new MappableObjectForFront(fundingAgreementForFront, fundingAgreementMappings).data;
application = {...application, ...fundingAgreementForFront};

});
*/
//resData.facilityList = parseFacilityData(userResponse.facilities);
applicationList.push(application);
});
}
let results = {
...resData,
...organization,
applications: applicationList
// changeRequests: changeRequests
};
return res.status(HttpStatus.OK).json(results);
}
Expand Down
10 changes: 9 additions & 1 deletion backend/src/util/mapping/Mappings.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,13 @@ const PdfDocumentMappings = [
{back: 'filesize', front: 'fileSize'},
];

const fundingAgreementMappings = [
{ back: 'ccof_version', front: 'fundingAgreementOrderNumber'}, // null,
{ back: 'ccof_name', front: 'fundingAgreementNumber'}, // null,
{ back: 'ccof_contractstatus', front: 'fundingAgreementStatusCode'}, // false,
{ back: 'ccof_contractstatus@OData.Community.Display.V1.FormattedValue', front: 'fundingAgreementStatusLabel'}, // null,
];

module.exports = {
OrganizationMappings,
FacilityMappings,
Expand Down Expand Up @@ -476,5 +483,6 @@ module.exports = {
ApplicationSummaryCcfriMappings,
ChangeRequestMappings,
UserProfileChangeRequestNewFacilityMappings,
PdfDocumentMappings
PdfDocumentMappings,
fundingAgreementMappings
};
9 changes: 0 additions & 9 deletions frontend/src/components/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,6 @@
</v-row>
</v-row>
<v-spacer></v-spacer>
<v-row class="justify-right">
<v-toolbar-title fill-height >
<!--don't show funding agreement number on mobile... there is no space on the Header for it-->
<h6 v-if="this.$vuetify.breakpoint.xsOnly"></h6>
<h3 class="" v-else-if="fundingAgreementNumber">FA# {{ fundingAgreementNumber }}</h3>
<h3 class="" v-else></h3>
</v-toolbar-title>
</v-row>
<div v-if="isAuthenticated && dataReady" class="mt-6">
<v-btn
id="mail_box_button" @click="goToMessagePage()"
Expand Down Expand Up @@ -95,7 +87,6 @@ export default {
computed: {
...mapGetters('auth', ['isAuthenticated','userInfo', 'isMinistryUser']),
...mapGetters('message', ['unreadMessageCount']),
...mapState('organization', ['fundingAgreementNumber']),
dataReady: function () {
return this.userInfo;
},
Expand Down
13 changes: 11 additions & 2 deletions frontend/src/components/LandingPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@
<v-row no-gutters>
<v-col class="col-12 col-md-6 ml-4 mb-4">
<h2>Fiscal Year: {{ programYearNameForFacilityCards }}</h2>
<h2 v-if="getFundingAgreementNumberByYear">Funding Agreement Number: {{ getFundingAgreementNumberByYear }}</h2>
</v-col>
</v-row>
<v-row no-gutters justify="space-between">
Expand Down Expand Up @@ -310,7 +311,7 @@ export default {
...mapGetters('application', ['latestProgramYearId', 'applicationIds', 'getFacilityListForPCFByProgramYearId', 'formattedProgramYear']),
...mapState('app', ['programYearList']),
...mapState('navBar', ['navBarList']),
...mapState('organization', ['fundingAgreementNumber', 'organizationAccountNumber', 'organizationProviderType', 'organizationId', 'organizationName', 'organizationAccountNumber']),
...mapState('organization', ['organizationAccountNumber', 'organizationProviderType', 'organizationId', 'organizationName', 'organizationAccountNumber']),
...mapState('application', ['applicationType', 'programYearId', 'programYearLabel', 'ccofApplicationStatus', 'unlockBaseFunding', 'isRenewal',
'unlockDeclaration', 'unlockEcewe', 'unlockLicenseUpload', 'unlockSupportingDocuments', 'applicationStatus', 'applicationMap', 'applicationId']),
...mapState('reportChanges', ['changeRequestStore']),
Expand All @@ -333,6 +334,11 @@ export default {
//should not reach here- perhaps change-
return this.formattedProgramYear;
},
getFundingAgreementNumberByYear(){
if (this.selectedProgramYear)
return this.applicationMap?.get(this.selectedProgramYear.programYearId)?.fundingAgreementNumber;
return this.applicationMap?.get(this.programYearId)?.fundingAgreementNumber;
},
getActionRequiredApplicationsForCCOFCard() {
const applicationList = Array.from(this.applicationMap?.values());
return applicationList?.filter(application => {
Expand Down Expand Up @@ -454,7 +460,10 @@ export default {
return (this.applicationType === 'RENEW') || (this.ccofStatus === this.CCOF_STATUS_APPROVED);
},
isReportChangeButtonEnabled() {
return !!(this.organizationAccountNumber && this.fundingAgreementNumber);
if (this.applicationType === 'RENEW' && this.organizationAccountNumber){
return true;
}
return !!(this.organizationAccountNumber && this.applicationMap?.get(this.programYearId)?.fundingAgreementNumber);
},
isUpdateChangeRequestDisplayed() {
const index = this.changeRequestStore?.findIndex(changeRequest => changeRequest.externalStatus === CHANGE_REQUEST_EXTERNAL_STATUS.ACTION_REQUIRED);
Expand Down
9 changes: 6 additions & 3 deletions frontend/src/components/SummaryDeclaration.vue
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@
</div>
<!---Declaration Start--->
<v-row v-if="fundingAgreementNumber && languageYearLabel == programYearTypes.HISTORICAL" justify="center" class="pt-4 text-h5" style="color:#003466;">
Funding Agreement Number: {{ fundingAgreementNumber }}
<v-row v-if="getFundingAgreementNumber" justify="center" class="pt-4 text-h5" style="color:#003466;">
Funding Agreement Number: {{ getFundingAgreementNumber }}
</v-row>
<v-row justify="center">
<v-card class="py-0 px-3 mx-0 mt-10 rounded-lg col-11" elevation="4">
Expand Down Expand Up @@ -435,7 +435,7 @@ export default {
...mapGetters('app', ['getFundingUrl', 'getLanguageYearLabel']),
...mapGetters('navBar', ['previousPath', 'isChangeRequest']),
...mapState('navBar', ['canSubmit', 'navBarList', 'changeRequestId']),
...mapState('organization', ['fundingAgreementNumber', 'organizationAccountNumber', 'isOrganizationComplete']),
...mapState('organization', ['organizationAccountNumber', 'isOrganizationComplete']),
...mapState('summaryDeclaration', ['summaryModel', 'isSummaryLoading', 'isMainLoading', 'isLoadingComplete']),
...mapState('application', ['formattedProgramYear', 'isRenewal', 'programYearId', 'unlockBaseFunding', 'isLicenseUploadComplete',
'unlockDeclaration', 'unlockEcewe', 'unlockLicenseUpload', 'unlockSupportingDocuments', 'applicationStatus','isEceweComplete', 'applicationMap']),
Expand All @@ -447,6 +447,9 @@ export default {
programYearTypes(){
return PROGRAM_YEAR_LANGUAGE_TYPES;
},
getFundingAgreementNumber(){
return this.applicationMap?.get(this.programYearId)?.fundingAgreementNumber;
},
getChangeRequestYear(){
const currProgramYear = this.programYearList?.list?.find(el => el.programYearId == this.programYearId);
const prevProgramYear = this.programYearList?.list?.find(el => el.programYearId == currProgramYear.previousYearId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,6 @@
<!---Declaration Start--->
<v-row justify="center">
<v-row v-if="fundingAgreementNumber && languageYearLabel == programYearTypes.HISTORICAL" justify="center" class="pt-4 text-h5" style="color:#003466;">
Funding Agreement Number: {{ fundingAgreementNumber }}
</v-row>
<v-card class="py-0 px-3 mx-0 mt-10 rounded-lg col-11" elevation="4">
<v-row>
Expand Down Expand Up @@ -371,7 +367,7 @@ export default {
...mapGetters('navBar', ['previousPath']),
...mapGetters('reportChanges', ['getChangeNotificationActionId']),
...mapState('navBar', ['changeType']),
...mapState('organization', ['organizationAccountNumber', 'fundingAgreementNumber']),
...mapState('organization', ['organizationAccountNumber']),
...mapState('summaryDeclaration', ['isSummaryLoading', 'isMainLoading', 'isLoadingComplete']),
...mapState('summaryDeclaration', ['summaryModel', 'model']),
...mapState('application', ['isRenewal', 'applicationMap']),
Expand Down
1 change: 0 additions & 1 deletion frontend/src/store/modules/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ export default {
commit('organization/setOrganizationId', userInfoRes.data.organizationId, { root: true });
commit('organization/setOrganizationName', userInfoRes.data?.organizationName, { root: true });
commit('organization/setOrganizationAccountNumber', userInfoRes.data?.organizationAccountNumber, { root: true });
commit('organization/setFundingAgreementNumber', userInfoRes.data?.fundingAgreementNumber, { root: true });
commit('organization/setIsOrganizationComplete', userInfoRes.data.isOrganizationComplete, { root: true });
commit('setIsUserInfoLoaded', true);
commit('setIsMinistryUser', userInfoRes.data.isMinistryUser);
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/store/modules/ccof/organization.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export default {
organizationAccountNumber: null,
isOrganizationComplete: false,
isStarted: false,
fundingAgreementNumber: null,
organizationModel: {},
loadedModel: {},
},
Expand All @@ -22,7 +21,6 @@ export default {
setOrganizationName: (state, organizationName) => { state.organizationName = organizationName; },
setOrganizationAccountNumber: (state, organizationAccountNumber) => { state.organizationAccountNumber = organizationAccountNumber; },
setIsStarted: (state, isStarted) => { state.isStarted = isStarted; },
setFundingAgreementNumber: (state, fundingAgreementNumber) => { state.fundingAgreementNumber = fundingAgreementNumber; },
setOrganizationModel(state, model) { state.organizationModel = model; },
setLoadedModel(state, model) { state.loadedModel = model; },
setIsOrganizationComplete: (state, value) => { state.isOrganizationComplete = value; }
Expand Down

0 comments on commit 4b9fb32

Please sign in to comment.