Skip to content

Commit

Permalink
Merge pull request #490 from bcgov/bf-revert-5.5-2
Browse files Browse the repository at this point in the history
Reverting to pre-5.5
  • Loading branch information
barrfalk authored Dec 4, 2024
2 parents 3ab5d9c + 2b02d30 commit d28dd6b
Show file tree
Hide file tree
Showing 13 changed files with 3 additions and 435 deletions.
2 changes: 1 addition & 1 deletion app/client/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<title>Agriculture Licencing System</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this application.</noscript>
<noscript>You need to enable JavaScript to run this application</noscript>
<div id="root"></div>
</body>
</html>
83 changes: 0 additions & 83 deletions app/client/src/features/reports/ReportLicenceComments.jsx

This file was deleted.

16 changes: 0 additions & 16 deletions app/client/src/features/reports/Reports.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import ReportLicenceExpiry from "./ReportLicenceExpiry";
import { clearReportsJob } from "./reportsSlice";
import RenderOnRole from "../../components/RenderOnRole";
import ReportDairyTrailerInspection from "./ReportDairyTrailerInspection";
import ReportLicenceComments from "./ReportLicenceComments";

export default function Reports() {
const dispatch = useDispatch();
Expand Down Expand Up @@ -71,9 +70,6 @@ export default function Reports() {
case REPORTS.DAIRY_TEST_THRESHOLD:
control = <ReportDairyThreshold />;
break;
case REPORTS.LICENCE_COMMENTS:
control = <ReportLicenceComments />;
break;
case REPORTS.LICENCE_LOCATION:
control = <ReportLicenceTypeLocation />;
break;
Expand Down Expand Up @@ -197,18 +193,6 @@ export default function Reports() {
</option>
</RenderOnRole>

<RenderOnRole
roles={[
SYSTEM_ROLES.READ_ONLY,
SYSTEM_ROLES.USER,
SYSTEM_ROLES.SYSTEM_ADMIN,
]}
>
<option value={REPORTS.LICENCE_COMMENTS}>
Licence Comments
</option>
</RenderOnRole>

<RenderOnRole
roles={[
SYSTEM_ROLES.READ_ONLY,
Expand Down
21 changes: 0 additions & 21 deletions app/client/src/features/reports/reportsSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,24 +234,6 @@ export const startLicenceTypeLocationJob = createAsyncThunk(
}
);

export const startLicenceCommentsJob = createAsyncThunk(
"reports/startLicenceCommentsJob",
async (payload, thunkApi) => {
try {
const response = await Api.post(
`documents/reports/startJob/licenceComments`,
payload
);
return response.data;
} catch (error) {
if (error instanceof ApiError) {
return thunkApi.rejectWithValue(error.serialize());
}
return thunkApi.rejectWithValue({ code: -1, description: error.message });
}
}
);

export const startLicenceExpiryJob = createAsyncThunk(
"reports/startLicenceExpiryJob",
async (payload, thunkApi) => {
Expand Down Expand Up @@ -397,9 +379,6 @@ export const reportsSlice = createSlice({
[startLicenceExpiryJob.pending]: pendingStartJobReducer,
[startLicenceExpiryJob.fulfilled]: fulfilledStartJobReducer,
[startLicenceExpiryJob.rejected]: rejectionStartJobReducer,
[startLicenceCommentsJob.pending]: pendingStartJobReducer,
[startLicenceCommentsJob.fulfilled]: fulfilledStartJobReducer,
[startLicenceCommentsJob.rejected]: rejectionStartJobReducer,

[fetchReportJob.pending]: (state) => {
state.job.status = REQUEST_STATUS.PENDING;
Expand Down
1 change: 0 additions & 1 deletion app/client/src/utilities/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ export const REPORTS = {
DAIRY_FARM_QUALITY: "DAIRY_FARM_QUALITY",
DAIRY_FARM_TANK: "DAIRY_FARM_TANK",
DAIRY_TEST_THRESHOLD: "DAIRY_TEST_THRESHOLD",
LICENCE_COMMENTS: "LICENCE_COMMENTS",
LICENCE_LOCATION: "LICENCE_LOCATION",
LICENCE_EXPIRY: "LICENCE_EXPIRY",
DAIRY_TRAILER_INSPECTION: "TRAILER INSPECTION",
Expand Down
39 changes: 2 additions & 37 deletions app/server/routes/v1/documents.js
Original file line number Diff line number Diff line change
Expand Up @@ -955,21 +955,6 @@ async function startLicenceTypeLocationJob(licenceTypeId) {
return { jobId, documents };
}

async function startLicenceCommentsJob(licenceNumber) {
const [procedureResult] = await prisma.$transaction([
prisma.$queryRawUnsafe(
`CALL mals_app.pr_generate_print_json_licence_comments('${licenceNumber}', NULL)`,
licenceNumber
),
]);

const jobId = procedureResult[0].iop_print_job_id;

const documents = await getPendingDocuments(jobId);

return { jobId, documents };
}

async function startLicenceExpiryJob(startDate, endDate) {
const [procedureResult] = await prisma.$transaction([
prisma.$queryRawUnsafe(
Expand Down Expand Up @@ -1477,17 +1462,6 @@ router.post("/reports/startJob/licenceTypeLocation", async (req, res, next) => {
.finally(async () => prisma.$disconnect());
});

router.post("/reports/startJob/licenceComments", async (req, res, next) => {
const licenceNumber = req.body.licenceNumber;

await startLicenceCommentsJob(licenceNumber)
.then(({ jobId, documents }) => {
return res.send({ jobId, documents, type: REPORTS.LICENCE_COMMENTS });
})
.catch(next)
.finally(async () => prisma.$disconnect());
});

router.post("/reports/startJob/licenceExpiry", async (req, res, next) => {
const startDate = formatDate(new Date(req.body.startDate));
const endDate = formatDate(new Date(req.body.endDate));
Expand Down Expand Up @@ -1569,17 +1543,7 @@ router.post("/download/:jobId(\\d+)", async (req, res, next) => {
const zip = new AdmZip();
let fileName = null;
documents.forEach((document) => {
if (
job.printCategory === constants.DOCUMENT_TYPE_REPORT &&
document.document_type === constants.REPORTS.LICENCE_COMMENTS
) {
fileName = `${document.document_json.Licence_Number}-${document.document_type}.xlsx`;
} else if (
job.printCategory === constants.DOCUMENT_TYPE_REPORT &&
document.document_type === constants.REPORTS.DAIRY_TRAILER_INSPECTION
) {
fileName = `${document.document_json.LicenceNumber}-${document.document_type}.xlsx`;
} else if (job.printCategory === constants.DOCUMENT_TYPE_REPORT) {
if (job.printCategory === constants.DOCUMENT_TYPE_REPORT) {
fileName = `${document.document_json.Licence_Type}-${document.document_type}.xlsx`;
} else if (
document.document_type === constants.DOCUMENT_TYPE_DAIRY_INFRACTION
Expand All @@ -1588,6 +1552,7 @@ router.post("/download/:jobId(\\d+)", async (req, res, next) => {
} else {
fileName = `${document.licence_number}-${document.document_type}.docx`;
}

zip.addFile(fileName, document.document_binary);
});

Expand Down
Binary file modified app/server/static/templates/certificates/Dairy-Farm.docx
Binary file not shown.
Binary file modified app/server/static/templates/certificates/Purchase-Live-Poultry.docx
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 0 additions & 1 deletion app/server/utilities/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,5 @@ module.exports = Object.freeze({
DAIRY_TRAILER_INSPECTION: "TRAILER INSPECTION",
LICENCE_LOCATION: "LICENCE_LOCATION",
LICENCE_EXPIRY: "LICENCE_EXPIRY",
LICENCE_COMMENTS: "LICENCE_COMMENTS",
},
});
2 changes: 0 additions & 2 deletions app/server/utilities/documents.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,6 @@ function getReportsTemplateName(documentType) {
return "Licence_Expiry_Species_NoSpecies_Template";
case constants.REPORTS.DAIRY_TRAILER_INSPECTION:
return "Dairy_Trailer_Inspection_Template";
case constants.REPORTS.LICENCE_COMMENTS:
return "Licence_Comments_Template";
default:
return null;
}
Expand Down
Loading

0 comments on commit d28dd6b

Please sign in to comment.