Skip to content

Commit

Permalink
Merge pull request #3 from bcgov/dev
Browse files Browse the repository at this point in the history
Updating Test with latest changes
  • Loading branch information
npham49 authored Nov 28, 2024
2 parents 136853f + dee722b commit a89d177
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 13 deletions.
25 changes: 19 additions & 6 deletions client/src/components/Form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ import FileSaver from "file-saver";
import apiService from "../services/apiService";
import { periods } from "../utils/enums/application";
import { RLS } from "../utils/types/rls";
import { InitiativeTypes } from "../utils/types";
import { HA, haMapping, InitiativeTypes } from "../utils/types";
import { useAuthStore } from "../stores/authStore";
import { getCurrentFiscalAndPeriod } from "../utils/helper";
Expand All @@ -233,7 +233,7 @@ const fiscalYears = ref<string[]>([]);
// Reactive selected values
const selectedRLSEntries = ref<RLS[]>([]);
const selectedHealthAuthority = ref();
const selectedHealthAuthority = ref<HA | undefined>();
const selectedPCNCommunity = ref();
const selectedInitiativeName = ref();
const selectedFiscalYear = ref();
Expand Down Expand Up @@ -278,9 +278,22 @@ const mutation = useMutation({
reportingPeriod: String(selectedPeriod.value),
})
.then((data) => {
const fileName = `${initiative.value}${selectedHealthAuthority.value}${
selectedPeriod.value
}${String(selectedFiscalYear.value)}`.replace(/[^a-z0-9_-]/gi, "_");
const today = new Date();
const fileName = `HLTH.FinRpt.${
haMapping[selectedHealthAuthority.value || "NotAvailable"]
}.${initiative.value?.toUpperCase()}.FY${String(selectedFiscalYear.value)
.substring(2)
.replace("/", "")}.${selectedPeriod.value}.${today.getFullYear()}${(
today.getMonth() + 1
)
.toString()
.padStart(2, "0")}${today
.getDate()
.toString()
.padStart(2, "0")}.${today
.getHours()
.toString()
.padStart(2, "0")}${today.getMinutes().toString().padStart(2, "0")}`;
FileSaver.saveAs(data.data, `${fileName}.xlsm`);
toast.success("Template downloaded successfully", {
duration: 5000,
Expand Down Expand Up @@ -337,7 +350,7 @@ watch(
() => initiative.value,
(newInitiative) => {
if (!newInitiative) return;
selectedHealthAuthority.value = null;
selectedHealthAuthority.value = undefined;
selectedPCNCommunity.value = [];
selectedInitiativeName.value = [];
}
Expand Down
11 changes: 11 additions & 0 deletions client/src/utils/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,14 @@ export type OtherFinancialSubmission = {
export type FinancialSubmission =
| PCNFinancialSubmission
| OtherFinancialSubmission;

export const haMapping = {
Fraser: "FHA",
Interior: "IHA",
"Vancouver Island": "VIHA",
Northern: "NHA",
"Vancouver Coastal": "VCHA",
NotAvailable: "N-A",
};

export type HA = keyof typeof haMapping;
8 changes: 4 additions & 4 deletions server/api/components/chefsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export default function ChefsService() {
switch (data.typeOfInitiative) {
case "pcn":
const pcnFields =
"healthAuthority,communityName,fiscalYear,periodReported,financialData";
"healthAuthority,communityName,fiscalYear,periodReported,financialData,reasonForExceptionInPeriodReported";
const pcnUrl = `${env.CHEFS_API_URL}/forms/${env.CHEFS_PCN_FINANCIAL_FORM_ID}/submissions?deleted=false&draft=false&fields=${pcnFields}`;
const pcnResponse = await fetch(pcnUrl, {
headers: {
Expand Down Expand Up @@ -216,7 +216,7 @@ export default function ChefsService() {
return pcnReports;
case "upcc":
const upccFields =
"healthAuthority,communityName,upccName,fiscalYear,periodReported,financialData";
"healthAuthority,communityName,upccName,fiscalYear,periodReported,financialData,reasonForExceptionInPeriodReported";
const upccUrl = `${env.CHEFS_API_URL}/forms/${env.CHEFS_UPCC_FINANCIAL_FORM_ID}/submissions?deleted=false&draft=false&fields=${upccFields}`;
const upccResponse = await fetch(upccUrl, {
headers: {
Expand Down Expand Up @@ -264,7 +264,7 @@ export default function ChefsService() {
return upccReports;
case "nppcc":
const nppccFields =
"healthAuthority,communityName,nppccName,fiscalYear,periodReported,financialData";
"healthAuthority,communityName,nppccName,fiscalYear,periodReported,financialData,reasonForExceptionInPeriodReported";
const nppccUrl = `${env.CHEFS_API_URL}/forms/${env.CHEFS_NPPCC_FINANCIAL_FORM_ID}/submissions?deleted=false&draft=false&fields=${nppccFields}`;
const nppccResponse = await fetch(nppccUrl, {
headers: {
Expand Down Expand Up @@ -312,7 +312,7 @@ export default function ChefsService() {
return nppccReports;
case "chc":
const chcFields =
"healthAuthority,communityName,chcName,fiscalYear,periodReported,financialData";
"healthAuthority,communityName,chcName,fiscalYear,periodReported,financialData,reasonForExceptionInPeriodReported";
const chcUrl = `${env.CHEFS_API_URL}/forms/${env.CHEFS_CHC_FINANCIAL_FORM_ID}/submissions?deleted=false&draft=false&fields=${chcFields}`;
const chcResponse = await fetch(chcUrl, {
headers: {
Expand Down
2 changes: 2 additions & 0 deletions server/api/utils/mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ export default {
}
}

console.log(reportingSubmission);

return {
submissionInformation: {
healthAuthority: reportingSubmission.healthAuthority,
Expand Down
14 changes: 11 additions & 3 deletions server/api/utils/worksheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,10 @@ export default {
);
}
if (initiative === "pcn") {
// Needs clarification on the following fields
worksheet
.cell(constants.PCN.notes + String(index))
.value(formatValue(item.submissionInformation.notes));
} else {
// Needs clarification on the following fields
worksheet
.cell(
// @ts-expect-error - TS doesn't know that initiative is a valid key for constants
Expand All @@ -198,6 +196,17 @@ export default {
)
.value(formatValue(item.submissionInformation.notes));
}
worksheet
.cell(
constants[initiative.toUpperCase() as Initiative]
.reasonForExceptionInPeriodReported + String(index)
)
.value(
formatValue(
item.submissionInformation.reasonForExceptionInPeriodReported,
true
)
);
index = index + 1;
}
if (item.reporting.length > 0) {
Expand Down Expand Up @@ -464,7 +473,6 @@ export default {
.value(formatValue(item.budget.totalBudgetAllocation));
}

// Needs clarification on the following fields
worksheet
.cell(constants.PCN.otherItems + String(index))
.value(formatValue(report.otherItems));
Expand Down

0 comments on commit a89d177

Please sign in to comment.