Skip to content

Commit c46e520

Browse files
authored
Merge pull request #1269 from bcgov/bug/ecer-5119
ecer-5119 bug fix, 1 year edge case should display if 5 year certific…
2 parents d9b9bbb + 475f600 commit c46e520

File tree

4 files changed

+215
-1
lines changed

4 files changed

+215
-1
lines changed

src/ECER.Clients.RegistryPortal/ecer.clients.registryportal.client/src/components/ApplicationCardList.stories.ts

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,3 +665,193 @@ export const FullyCertified: Story = {
665665
],
666666
},
667667
};
668+
669+
export const RenewedOneYearTwiceWithExpiredFiveYearShouldAllowOneYearEdge: Story = {
670+
args: {
671+
certifications: [
672+
{
673+
id: "f403a278-8020-f011-998a-6045bdf9b81b",
674+
name: "KARISSA CAULKINS",
675+
number: "016359",
676+
expiryDate: getDatePlusYears(2),
677+
effectiveDate: getDateMinusYears(2),
678+
date: getTodayDate(),
679+
printDate: null,
680+
hasConditions: false,
681+
levelName: "Assistant",
682+
statusCode: "Active",
683+
certificatePDFGeneration: "Yes",
684+
levels: [{ id: "556b387e-8020-f011-998a-7c1e52871876", type: "Assistant" }],
685+
files: [
686+
{
687+
id: "3979ff88-f262-4747-b294-c289caa2402a",
688+
url: "ecer_certificate/f403a278-8020-f011-998a-6045bdf9b81b",
689+
extention: ".pdf",
690+
size: "322.00 KB",
691+
name: "Cover Letter-016359.pdf",
692+
},
693+
],
694+
certificateConditions: [],
695+
},
696+
{
697+
id: "f403a278-8020-f011-998a-6045bdf9b81b",
698+
name: "KARISSA CAULKINS",
699+
number: "016359",
700+
expiryDate: getDateMinusYears(4),
701+
effectiveDate: getDateMinusYears(4),
702+
date: getTodayDate(),
703+
printDate: null,
704+
hasConditions: false,
705+
levelName: "ECE One Year",
706+
statusCode: "Expired",
707+
certificatePDFGeneration: "Yes",
708+
levels: [{ id: "556b387e-8020-f011-998a-7c1e52871876", type: "ECE 1 YR" }],
709+
files: [
710+
{
711+
id: "3979ff88-f262-4747-b294-c289caa2402a",
712+
url: "ecer_certificate/f403a278-8020-f011-998a-6045bdf9b81b",
713+
extention: ".pdf",
714+
size: "322.00 KB",
715+
name: "Cover Letter-016359.pdf",
716+
},
717+
],
718+
certificateConditions: [],
719+
},
720+
{
721+
id: "f403a278-8020-f011-998a-6045bdf9b81b",
722+
name: "KARISSA CAULKINS",
723+
number: "016359",
724+
expiryDate: getDateMinusYears(3),
725+
effectiveDate: getDateMinusYears(3),
726+
date: getTodayDate(),
727+
printDate: null,
728+
hasConditions: false,
729+
levelName: "ECE One Year",
730+
statusCode: "Expired",
731+
certificatePDFGeneration: "Yes",
732+
levels: [{ id: "556b387e-8020-f011-998a-7c1e52871876", type: "ECE 1 YR" }],
733+
files: [
734+
{
735+
id: "3979ff88-f262-4747-b294-c289caa2402a",
736+
url: "ecer_certificate/f403a278-8020-f011-998a-6045bdf9b81b",
737+
extention: ".pdf",
738+
size: "322.00 KB",
739+
name: "Cover Letter-016359.pdf",
740+
},
741+
],
742+
certificateConditions: [],
743+
},
744+
{
745+
id: "f403a278-8020-f011-998a-6045bdf9b81b",
746+
name: "KARISSA CAULKINS",
747+
number: "016359",
748+
expiryDate: getDateMinusYears(1),
749+
effectiveDate: getDateMinusYears(1),
750+
date: getTodayDate(),
751+
printDate: null,
752+
hasConditions: false,
753+
levelName: "ECE Five Year + ITE + SNE",
754+
statusCode: "Expired",
755+
certificatePDFGeneration: "Yes",
756+
levels: [
757+
{ id: "556b387e-8020-f011-998a-7c1e52871876", type: "ECE 5 YR" },
758+
{ id: "656b387e-8020-f011-998a-7c1e52871876", type: "ITE" },
759+
{ id: "756b387e-8020-f011-998a-7c1e52871876", type: "SNE" },
760+
],
761+
files: [
762+
{
763+
id: "3979ff88-f262-4747-b294-c289caa2402a",
764+
url: "ecer_certificate/f403a278-8020-f011-998a-6045bdf9b81b",
765+
extention: ".pdf",
766+
size: "322.00 KB",
767+
name: "Cover Letter-016359.pdf",
768+
},
769+
],
770+
certificateConditions: [],
771+
},
772+
],
773+
},
774+
};
775+
776+
export const ExpiredOneYearWithExpiredFiveYearShouldAllowOneYearEdge: Story = {
777+
args: {
778+
certifications: [
779+
{
780+
id: "f403a278-8020-f011-998a-6045bdf9b81b",
781+
name: "KARISSA CAULKINS",
782+
number: "016359",
783+
expiryDate: getDatePlusYears(2),
784+
effectiveDate: getDateMinusYears(2),
785+
date: getTodayDate(),
786+
printDate: null,
787+
hasConditions: false,
788+
levelName: "Assistant",
789+
statusCode: "Active",
790+
certificatePDFGeneration: "Yes",
791+
levels: [{ id: "556b387e-8020-f011-998a-7c1e52871876", type: "Assistant" }],
792+
files: [
793+
{
794+
id: "3979ff88-f262-4747-b294-c289caa2402a",
795+
url: "ecer_certificate/f403a278-8020-f011-998a-6045bdf9b81b",
796+
extention: ".pdf",
797+
size: "322.00 KB",
798+
name: "Cover Letter-016359.pdf",
799+
},
800+
],
801+
certificateConditions: [],
802+
},
803+
{
804+
id: "f403a278-8020-f011-998a-6045bdf9b81b",
805+
name: "KARISSA CAULKINS",
806+
number: "016359",
807+
expiryDate: getDateMinusYears(3),
808+
effectiveDate: getDateMinusYears(3),
809+
date: getTodayDate(),
810+
printDate: null,
811+
hasConditions: false,
812+
levelName: "ECE One Year",
813+
statusCode: "Expired",
814+
certificatePDFGeneration: "Yes",
815+
levels: [{ id: "556b387e-8020-f011-998a-7c1e52871876", type: "ECE 1 YR" }],
816+
files: [
817+
{
818+
id: "3979ff88-f262-4747-b294-c289caa2402a",
819+
url: "ecer_certificate/f403a278-8020-f011-998a-6045bdf9b81b",
820+
extention: ".pdf",
821+
size: "322.00 KB",
822+
name: "Cover Letter-016359.pdf",
823+
},
824+
],
825+
certificateConditions: [],
826+
},
827+
{
828+
id: "f403a278-8020-f011-998a-6045bdf9b81b",
829+
name: "KARISSA CAULKINS",
830+
number: "016359",
831+
expiryDate: getDateMinusYears(1),
832+
effectiveDate: getDateMinusYears(1),
833+
date: getTodayDate(),
834+
printDate: null,
835+
hasConditions: false,
836+
levelName: "ECE Five Year + ITE + SNE",
837+
statusCode: "Expired",
838+
certificatePDFGeneration: "Yes",
839+
levels: [
840+
{ id: "556b387e-8020-f011-998a-7c1e52871876", type: "ECE 5 YR" },
841+
{ id: "656b387e-8020-f011-998a-7c1e52871876", type: "ITE" },
842+
{ id: "756b387e-8020-f011-998a-7c1e52871876", type: "SNE" },
843+
],
844+
files: [
845+
{
846+
id: "3979ff88-f262-4747-b294-c289caa2402a",
847+
url: "ecer_certificate/f403a278-8020-f011-998a-6045bdf9b81b",
848+
extention: ".pdf",
849+
size: "322.00 KB",
850+
name: "Cover Letter-016359.pdf",
851+
},
852+
],
853+
certificateConditions: [],
854+
},
855+
],
856+
},
857+
};

src/ECER.Clients.RegistryPortal/ecer.clients.registryportal.client/src/components/ApplicationCardList.vue

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@
126126

127127
<script lang="ts">
128128
import { defineComponent, type PropType } from "vue";
129+
import { DateTime } from "luxon";
129130
import Card from "@/components/Card.vue";
130131
import type { Components } from "@/types/openapi";
131132
import { useCertificationStore } from "@/store/certification";
@@ -193,11 +194,21 @@ export default defineComponent({
193194
const eceFiveYearCertifications = this.certifications.filter((certification) => certification.levels?.some((level) => level.type === "ECE 5 YR"));
194195
const eceOneYearCertifications = this.certifications.filter((certification) => certification.levels?.some((level) => level.type === "ECE 1 YR"));
195196
197+
const mostRecentFiveYearCertificate = this.certificationStore.getMostRecentCertificationByExpiryDate("ECE 5 YR");
198+
199+
//this will flag whether user has received an ECE 1 yr certification after their five year expired. If yes, we should not show the edge case pathway
200+
const oneYearCertificateIssuedAfterMostRecentFiveYear =
201+
eceOneYearCertifications.filter(
202+
(oneYearCert) => DateTime.fromISO(oneYearCert.effectiveDate || "") > DateTime.fromISO(mostRecentFiveYearCertificate?.expiryDate || ""),
203+
).length !== 0;
204+
196205
return (
197206
eceFiveYearCertifications.length > 0 &&
198207
eceFiveYearCertifications.every((certification) => certification.statusCode === "Expired") &&
208+
eceOneYearCertifications.every((certification) => certification.statusCode === "Expired") &&
199209
(eceOneYearCertifications.length === 0 ||
200-
eceOneYearCertifications.every((certification) => this.certificationStore.expiredMoreThan5Years(certification.id)))
210+
eceOneYearCertifications.every((certification) => this.certificationStore.expiredMoreThan5Years(certification.id)) ||
211+
!oneYearCertificateIssuedAfterMostRecentFiveYear)
201212
);
202213
},
203214
showEceFiveYearPathway() {

src/ECER.Clients.RegistryPortal/ecer.clients.registryportal.client/src/store/certification.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { orderBy } from "lodash";
44
import { getCertifications } from "@/api/certification";
55
import type { Components } from "@/types/openapi";
66
import { expiredMoreThan5Years } from "@/utils/functions";
7+
import type { CertificationLevelType } from "@/types/certificationLevelType";
78

89
export interface CertificationState {
910
certifications: Components.Schemas.Certification[] | null | undefined;
@@ -238,6 +239,15 @@ export const useCertificationStore = defineStore("certification", {
238239
}
239240
return certificationTypes;
240241
},
242+
getMostRecentCertificationByExpiryDate(certificateType: CertificationLevelType): Components.Schemas.Certification | undefined {
243+
const mostRecentCertification = orderBy(
244+
this.certifications?.filter((certification) => certification.levels?.some((level) => level.type === certificateType)),
245+
["expiryDate"],
246+
["desc"],
247+
)?.[0];
248+
249+
return mostRecentCertification;
250+
},
241251
async fetchCertifications() {
242252
// Drop any existing certifications
243253
this.$reset();
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
//these types refer to the levels contained with the certificate that are stored as strings.
2+
//It is slightly different from our certificationLevel withing Components.Schemas.CertificateLevel.
3+
export type CertificationLevelType = "Assistant" | "ECE 1 YR" | "ECE 5 YR" | "SNE" | "ITE";

0 commit comments

Comments
 (0)