Skip to content

Commit

Permalink
Merge pull request #3477 from bcgov/NDT-447-Update-GCPE-reports-for-n…
Browse files Browse the repository at this point in the history
…ew-fields

feat: add ccbc connected coast and announced to gcpe report
  • Loading branch information
rafasdc authored Aug 22, 2024
2 parents ba1f24a + ef4e3ff commit 3e4d015
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# [1.183.0](https://github.com/bcgov/CONN-CCBC-portal/compare/v1.182.2...v1.183.0) (2024-08-22)

### Features

- add ccbc connected coast and announced to gcpe report ([86bfd62](https://github.com/bcgov/CONN-CCBC-portal/commit/86bfd62f15af5901c63d0df1b6e4af116214dbfe))

## [1.182.2](https://github.com/bcgov/CONN-CCBC-portal/compare/v1.182.1...v1.182.2) (2024-08-22)

### Bug Fixes
Expand Down
23 changes: 18 additions & 5 deletions app/backend/lib/reporting/gcpe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
findPrimaryAnnouncement,
findPrimaryAnnouncementDate,
findSecondaryAnnouncement,
getConnectedCoastDependent,
getHouseholdCount,
getTotalProjectBudget,
handleProjectType,
Expand Down Expand Up @@ -101,6 +102,17 @@ const getCcbcQuery = `
}
totalCount
}
applicationAnnouncedsByApplicationId(last: 1, condition: {archivedAt: null}) {
nodes {
announced
}
}
assessmentDataByApplicationId(condition: {archivedAt: null}) {
nodes {
assessmentDataType
jsonData
}
}
ccbcNumber
externalStatus
internalDescription
Expand Down Expand Up @@ -295,10 +307,9 @@ const generateExcelData = async (
{ value: 'CCBC' },
// announced by province
{
value:
node?.applicationAnnouncementsByApplicationId.totalCount > 0
? 'YES'
: 'NO',
value: node?.applicationAnnouncedsByApplicationId?.nodes[0]?.announced
? 'YES'
: 'NO',
},
// change request pending
{
Expand Down Expand Up @@ -418,7 +429,9 @@ const generateExcelData = async (
// rest areas
{ value: null },
// connected coast network dependent
{ value: null },
{
value: getConnectedCoastDependent(node?.assessmentDataByApplicationId),
},
// proposed start date
{ value: node?.formData?.jsonData?.projectPlan?.projectStartDate },
// date conditionally approved
Expand Down
9 changes: 9 additions & 0 deletions app/backend/lib/reporting/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@ export const getTotalProjectBudget = (
return applicationTotalProjectBudget;
};

export const getConnectedCoastDependent = (assessments) => {
const screeningAssessment = assessments?.nodes.find(
(assessment) => assessment?.assessmentDataType === 'screening'
);
return screeningAssessment?.jsonData?.connectedCoastNetworkDependent
? 'YES'
: null;
};

export const convertBoolean = (value): string => {
if (value === null || value === undefined) return null;
return value ? 'YES' : 'NO';
Expand Down
24 changes: 24 additions & 0 deletions app/tests/backend/lib/reporting/gcpe.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,30 @@ describe('Gcpe reporting functions', () => {
expect(blob).toBeDefined();
});

it('should generate a gcpe report with ccbc data without announced by province', async () => {
const modifiedCcbcDataQueryResult = {
...ccbcDataQueryResult,
data: {
...ccbcDataQueryResult.data,
allApplications: {
...ccbcDataQueryResult.data.allApplications,
edges: ccbcDataQueryResult.data.allApplications.edges.map((edge) => ({
...edge,
node: {
...edge.node,
applicationAnnouncedsByApplicationId: null,
},
})),
},
},
};
mocked(performQuery).mockImplementation(async () => {
return modifiedCcbcDataQueryResult;
});
const blob = await generateGcpeReport(null);
expect(blob).toBeDefined();
});

it('should compare and generate a report', async () => {
mocked(performQuery).mockImplementation(async () => {
return generateAndCompareQueryResult;
Expand Down
23 changes: 23 additions & 0 deletions app/tests/backend/lib/reporting/testData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22009,6 +22009,29 @@ export const ccbcDataQueryResult = {
status: 'conditionally_approved',
intakeNumber: 1,
organizationName: 'Joint Ops',
assessmentDataByApplicationId: {
nodes: [
{
assessmentDataType: 'screening',
jsonData: {
decision: 'No decision',
nextStep: 'Assessment complete',
assignedTo: 'Test',
targetDate: '2023-04-01',
contestingMap: [],
assessmentTemplate: [],
connectedCoastNetworkDependent: true,
},
},
],
},
applicationAnnouncedsByApplicationId: {
nodes: [
{
announced: true,
},
],
},
applicationPendingChangeRequestsByApplicationId: {
edges: [],
},
Expand Down
1 change: 1 addition & 0 deletions db/sqitch.plan
Original file line number Diff line number Diff line change
Expand Up @@ -641,3 +641,4 @@ tables/cbc_add_fk_update_constraint 2024-07-11T20:32:11Z Rafael Solorzano <61289
@1.182.0 2024-08-22T16:48:01Z CCBC Service Account <ccbc@button.is> # release v1.182.0
@1.182.1 2024-08-22T17:30:53Z CCBC Service Account <ccbc@button.is> # release v1.182.1
@1.182.2 2024-08-22T17:54:31Z CCBC Service Account <ccbc@button.is> # release v1.182.2
@1.183.0 2024-08-22T18:35:35Z CCBC Service Account <ccbc@button.is> # release v1.183.0
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "CONN-CCBC-portal",
"version": "1.182.2",
"version": "1.183.0",
"main": "index.js",
"repository": "https://github.com/bcgov/CONN-CCBC-portal.git",
"author": "Romer, Meherzad CITZ:EX <Meherzad.Romer@gov.bc.ca>",
Expand Down

0 comments on commit 3e4d015

Please sign in to comment.