Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#3258 - Supplier Errors Part 3 #4031

Merged
merged 9 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,23 @@ describe("CASSupplierAESTController(e2e)-getCASSuppliers", () => {
db = createE2EDataSources(dataSource);
});

it("Should get all the CAS suppliers for a student when CAS suppliers info is requested for a student.", async () => {
it("Should get all the CAS suppliers with and without error for a student when CAS suppliers info is requested for a student.", async () => {
// Arrange
const savedCASSupplier1 = await saveFakeCASSupplier(db);
const student = savedCASSupplier1.student;
const savedCASSupplier2 = await saveFakeCASSupplier(
db,
{ student },
{ initialValues: { supplierStatus: SupplierStatus.VerifiedManually } },
{
initialValues: {
supplierStatus: SupplierStatus.ManualIntervention,
status: "ACTIVE",
errors: [
"[0034] SIN is already in use.",
"[9999] Duplicate Supplier , Reason: [0065]- Possible duplicate exists, please use online form",
andrewsignori-aot marked this conversation as resolved.
Show resolved Hide resolved
],
},
},
);

const endpoint = `/aest/cas-supplier/student/${student.id}`;
Expand All @@ -44,16 +53,24 @@ describe("CASSupplierAESTController(e2e)-getCASSuppliers", () => {
.expect({
items: [
{
id: savedCASSupplier2.id,
dateCreated: savedCASSupplier2.createdAt.toISOString(),
status: savedCASSupplier2.status,
supplierNumber: savedCASSupplier2.supplierNumber,
supplierProtected: null,
supplierProtected: true,
supplierStatus: savedCASSupplier2.supplierStatus,
isValid: savedCASSupplier2.isValid,
supplierSiteCode:
savedCASSupplier2.supplierAddress.supplierSiteCode,
siteStatus: savedCASSupplier2.supplierAddress.status,
addressLine1: savedCASSupplier2.supplierAddress.addressLine1,
siteProtected: savedCASSupplier2.supplierAddress.siteProtected,
errors: savedCASSupplier2.errors,
},
{
id: savedCASSupplier1.id,
dateCreated: savedCASSupplier1.createdAt.toISOString(),
status: savedCASSupplier1.status,
supplierNumber: savedCASSupplier1.supplierNumber,
supplierProtected: savedCASSupplier1.supplierProtected,
supplierStatus: savedCASSupplier1.supplierStatus,
Expand All @@ -63,6 +80,7 @@ describe("CASSupplierAESTController(e2e)-getCASSuppliers", () => {
siteStatus: savedCASSupplier1.supplierAddress.status,
addressLine1: savedCASSupplier1.supplierAddress.addressLine1,
siteProtected: savedCASSupplier1.supplierAddress.siteProtected,
errors: null,
},
],
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ export class CASSupplierAESTController extends BaseController {
studentId,
);
const casSupplierInfoDTOList = casSuppliers.map((casSupplier) => ({
id: casSupplier.id,
dateCreated: casSupplier.createdAt,
status: casSupplier.status,
supplierNumber: casSupplier.supplierNumber,
supplierProtected: casSupplier.supplierProtected,
supplierStatus: casSupplier.supplierStatus,
Expand All @@ -70,6 +72,7 @@ export class CASSupplierAESTController extends BaseController {
addressLine1: casSupplier.supplierAddress?.addressLine1,
siteStatus: casSupplier.supplierAddress?.status,
siteProtected: casSupplier.supplierAddress?.siteProtected,
errors: casSupplier?.errors,
}));
return { items: casSupplierInfoDTOList };
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ export class CASSupplierInfoAPIOutDTO {
}

export class CASSupplierInfoItemAPIOutDTO {
id: number;
dateCreated: Date;
status: string;
supplierNumber?: string;
supplierProtected?: boolean;
supplierStatus: SupplierStatus;
Expand All @@ -15,6 +17,7 @@ export class CASSupplierInfoItemAPIOutDTO {
addressLine1?: string;
siteStatus?: CASSupplierSiteStatus;
siteProtected?: string;
errors?: string[];
}

export class AddCASSupplierAPIInDTO {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,15 @@ export class CASSupplierService {
async getCASSuppliers(studentId: number): Promise<CASSupplier[]> {
return this.casSupplierRepo.find({
select: {
id: true,
createdAt: true,
status: true,
supplierNumber: true,
supplierProtected: true,
supplierStatus: true,
isValid: true,
supplierAddress: true as unknown,
errors: true,
},
where: {
student: { id: studentId },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ export function createFakeCASSupplier(
casSupplier.supplierStatus =
options?.initialValues?.supplierStatus ??
SupplierStatus.PendingSupplierVerification;
casSupplier.status = options?.initialValues?.status;
casSupplier.errors = options?.initialValues?.errors;

// Verified manually has a minimum of values populated.
if (
Expand Down
3 changes: 3 additions & 0 deletions sources/packages/web/src/services/http/dto/CASSupplier.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ export interface CASSupplierInfoAPIOutDTO {
}

export interface CASSupplierInfoItemAPIOutDTO {
id: number;
dateCreated: Date;
status: string;
supplierNumber?: string;
supplierProtected?: boolean;
supplierStatus: SupplierStatus;
Expand All @@ -12,6 +14,7 @@ export interface CASSupplierInfoItemAPIOutDTO {
addressLine1?: string;
siteStatus?: CASSupplierSiteStatus;
siteProtected?: string;
errors?: string[];
}

export type CASSupplierSiteStatus = "ACTIVE" | "INACTIVE";
Expand Down
36 changes: 23 additions & 13 deletions sources/packages/web/src/types/contracts/DataTableContract.ts
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The table labels vary between starting the second-word uppercase/lowercase.
We should not have it inside the same table. Please check with biz which one should be.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
image
Confirmed with @CarlyCotton

Original file line number Diff line number Diff line change
Expand Up @@ -320,45 +320,55 @@ export const CASSupplierInformationHeaders = [
key: "dateCreated",
},
{
title: "Supplier number",
title: "Status",
sortable: false,
key: "supplierNumber",
key: "supplierStatus",
},
{
title: "Supplier protected",
title: "Supplier valid",
sortable: false,
key: "supplierProtected",
key: "isValid",
},
{
title: "Supplier status",
title: "Supplier",
sortable: false,
key: "supplierStatus",
key: "supplierNumber",
},
{
title: "Supplier valid",
title: "Supplier active?",
sortable: false,
key: "isValid",
key: "status",
},
{
title: "Site code",
title: "Site",
sortable: false,
key: "supplierSiteCode",
},
{
title: "Address line 1",
title: "Site active?",
sortable: false,
key: "addressLine1",
key: "siteStatus",
},
{
title: "Site status",
title: "Supplier protected",
sortable: false,
key: "siteStatus",
key: "supplierProtected",
},
{
title: "Site protected",
sortable: false,
key: "siteProtected",
},
{
title: "Address line",
sortable: false,
key: "addressLine1",
},
{
title: "Details",
sortable: false,
key: "data-table-expand",
},
];

/**
Expand Down
andrewsignori-aot marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,14 @@
:items="casSupplierInfo.items"
:items-per-page="DEFAULT_PAGE_LIMIT"
:items-per-page-options="ITEMS_PER_PAGE"
show-expand
>
<template #[`item.dateCreated`]="{ item }">
{{ dateOnlyLongString(item.dateCreated) }}
</template>
<template #[`item.status`]="{ item }">
{{ item.status }}
</template>
<template #[`item.supplierNumber`]="{ item }">
{{ item.supplierNumber }}
</template>
Expand All @@ -58,6 +62,36 @@
<template #[`item.siteProtected`]="{ item }">
{{ emptyStringFiller(item.siteProtected) }}
</template>
<template v-slot:expanded-row="{ item, columns }">
<tr>
<td :colspan="columns.length">
<ul>
<li v-for="(error, index) in item.errors" :key="index">
{{ error }}
</li>
</ul>
</td>
</tr>
</template>
<template
v-slot:[`item.data-table-expand`]="{
item,
internalItem,
isExpanded,
toggleExpand,
}"
>
<v-btn
v-if="item.errors && item.errors.length > 0"
:icon="
isExpanded(internalItem)
? '$expanderExpandIcon'
: '$expanderCollapseIcon'
"
variant="text"
@click="toggleExpand(internalItem)"
></v-btn>
</template>
</v-data-table>
</toggle-content>
</content-group>
Expand Down Expand Up @@ -100,8 +134,8 @@ export default defineComponent({
},
},
setup(props) {
const { dateOnlyLongString, emptyStringFiller } = useFormatters();
const { booleanToYesNo } = useFormatters();
const { dateOnlyLongString, emptyStringFiller, booleanToYesNo } =
useFormatters();
const showModal = ref(false);
const casSupplierInfo = ref({} as CASSupplierInfoAPIOutDTO);
const addCASSupplierModal = ref(
Expand Down
Loading