Skip to content

Commit e95d3a7

Browse files
authored
ORV2-4031 BE: Interim GARMS/TPS Show Credit Account Information (#1966)
1 parent 10fdbb2 commit e95d3a7

File tree

13 files changed

+342
-44
lines changed

13 files changed

+342
-44
lines changed

frontend/src/common/authentication/PermissionMatrix.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,13 @@ const MANAGE_PROFILE = {
230230
VIEW_CREDIT_ACCOUNT_DETAILS_ACCOUNT_HOLDER: {
231231
allowedBCeIDRoles: [CA],
232232
},
233+
234+
/**
235+
* View Credit Account info banner - Account holder
236+
*/
237+
VIEW_CREDIT_ACCOUNT_INFO_BANNER_ACCOUNT_HOLDER: {
238+
allowedBCeIDRoles: [CA],
239+
},
233240
} as const;
234241

235242
const MANAGE_SETTINGS = {

frontend/src/common/constants/bannerMessages.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ export const BANNER_MESSAGES = {
4949
"This tool only calculates Bridge Formula, which is a mathematical equation that is used to calculate the maximum allowable weight allowed by permit for various axle groups in a combination. This tool is not confirming compliance with the CTR or CTPM.\n\nThe image on the right is for illustration purposes only.",
5050
NON_FINANCE_USER:
5151
"For Credit Accounts, please contact CVSE Revenue. ",
52+
CREDIT_ACCOUNT_CVSE_INFO:
53+
"Please contact CVSE Revenue. ",
5254
CLIENT_NAME_MUST_BE_REGISTERED_OWNER:
5355
"Client name must be the registered owner (company or individual) of the vehicles being permitted.",
5456
};

frontend/src/features/settings/components/creditAccount/ActivityTable.tsx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,10 @@ import {
1212
} from "../../../../common/helpers/tableHelper";
1313
import { getDefaultRequiredVal } from "../../../../common/helpers/util";
1414
import { CompanyProfile } from "../../../manageProfile/types/manageProfile.d";
15-
import {
16-
useGetCreditAccountHistoryQuery
17-
} from "../../hooks/creditAccount";
15+
import { useGetCreditAccountHistoryQuery } from "../../hooks/creditAccount";
1816
import {
1917
CREDIT_ACCOUNT_ACTIVITY_TYPE,
20-
CreditAccountActivity
18+
CreditAccountActivity,
2119
} from "../../types/creditAccount";
2220
import { CreditAccountActivityColumnsDefinition } from "../../types/CreditAccountActivityColumns";
2321
import "./ActivityTable.scss";
@@ -38,10 +36,7 @@ export const ActivityTable = ({
3836
isError: fetchCreditAccountError,
3937
} = useGetCreditAccountHistoryQuery({ companyId, creditAccountId });
4038

41-
const dataToBeShown = getDefaultRequiredVal(
42-
[],
43-
creditAccountActivities,
44-
)
39+
const dataToBeShown = getDefaultRequiredVal([], creditAccountActivities)
4540
.filter(
4641
(activity: CreditAccountActivity) =>
4742
activity.creditAccountActivityType !==
@@ -83,7 +78,7 @@ export const ActivityTable = ({
8378
() => (
8479
<Box className="toolbar__inner">
8580
<Typography variant="h3" className="activity-table__heading">
86-
Hold / Close History
81+
Account History
8782
</Typography>
8883
</Box>
8984
),

frontend/src/features/settings/components/creditAccount/StatusChip.scss

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
@import "../../../../themes/orbcStyles";
22

33
.status-chip {
4-
border-radius: .25rem;
4+
border-radius: 0.25rem;
55
font-size: 0.9rem;
6-
padding: .25rem .75rem;
6+
padding: 0.25rem 0.75rem;
77
text-transform: capitalize;
88

99
&--on-hold {
@@ -20,4 +20,9 @@
2020
background-color: $bc-messages-red-text;
2121
color: $white;
2222
}
23-
}
23+
24+
&--unverified {
25+
background-color: $bc-messages-red-text;
26+
color: $white;
27+
}
28+
}

frontend/src/features/settings/components/creditAccount/StatusChip.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ import {
66
import "./StatusChip.scss";
77

88
interface StatusChipProps {
9-
status: CreditAccountStatusType | "SUSPENDED";
9+
status: CreditAccountStatusType | "SUSPENDED" | "UNVERIFIED";
1010
}
1111

1212
export const StatusChip = ({ status }: StatusChipProps) => {
1313
const classModifier =
1414
status !== "SUSPENDED" &&
15+
status !== "UNVERIFIED" &&
1516
CreditAccountStatusDisplayValues[status].toLowerCase().replace(" ", "-");
1617

1718
if (status === CREDIT_ACCOUNT_STATUS_TYPE.ACTIVE) {
@@ -24,6 +25,14 @@ export const StatusChip = ({ status }: StatusChipProps) => {
2425
</span>
2526
);
2627
}
28+
if (status === "UNVERIFIED") {
29+
return (
30+
<span role="status" className="status-chip status-chip--unverified">
31+
Unverified
32+
</span>
33+
);
34+
}
35+
2736
return (
2837
<span role="status" className={`status-chip status-chip--${classModifier}`}>
2938
{CreditAccountStatusDisplayValues[status]}

frontend/src/features/settings/pages/CreditAccount.scss

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,19 @@
3737
&__user-designation {
3838
text-transform: capitalize;
3939
}
40+
41+
&__info-banner {
42+
padding-top: 1.5rem;
43+
padding-bottom: .75rem;
44+
&__banner {
45+
font-weight: normal;
46+
}
47+
48+
&__contact {
49+
font-weight: bold;
50+
margin-left: 0.25rem;
51+
}
52+
}
4053
}
4154
}
4255
}

frontend/src/features/settings/pages/ViewCreditAccount.tsx

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ import {
1313
CreditAccountMetadata,
1414
} from "../types/creditAccount";
1515
import "./CreditAccount.scss";
16+
import { InfoBcGovBanner } from "../../../common/components/banners/InfoBcGovBanner";
17+
import { BANNER_MESSAGES } from "../../../common/constants/bannerMessages";
18+
import {
19+
CVSE_REVENUE_EMAIL,
20+
CVSE_REVENUE_PHONE,
21+
} from "../../../common/constants/constants";
1622

1723
export const ViewCreditAccount = ({
1824
companyId,
@@ -43,12 +49,41 @@ export const ViewCreditAccount = ({
4349
<Typography variant="h3" className="overview__title">
4450
Credit Account No: {creditAccount.creditAccountNumber}
4551
</Typography>
46-
52+
{!creditAccount?.isVerified && (
53+
<StatusChip status="UNVERIFIED" />
54+
)}
4755
<StatusChip status={creditAccount.creditAccountStatusType} />
4856
</Box>
4957
<Typography className="overview__user-designation">
5058
{isAccountHolder ? "Account Holder" : "Account User"}
5159
</Typography>
60+
<RenderIf
61+
component={
62+
<Box className="overview__info-banner">
63+
<InfoBcGovBanner
64+
msg={
65+
<div className="overview__info-banner__banner">
66+
{BANNER_MESSAGES.CREDIT_ACCOUNT_CVSE_INFO}
67+
Phone:
68+
<span className="overview__info-banner__contact">
69+
{CVSE_REVENUE_PHONE}{" "}
70+
</span>
71+
Email:
72+
<span className="overview__info-banner__contact">
73+
{CVSE_REVENUE_EMAIL}
74+
</span>
75+
</div>
76+
}
77+
/>
78+
</Box>
79+
}
80+
permissionMatrixKeys={{
81+
permissionMatrixFeatureKey: "MANAGE_PROFILE",
82+
permissionMatrixFunctionKey:
83+
"VIEW_CREDIT_ACCOUNT_INFO_BANNER_ACCOUNT_HOLDER",
84+
}}
85+
additionalConditionToCheck={() => isAccountHolder}
86+
/>
5287
</Box>
5388
<RenderIf
5489
component={
@@ -105,9 +140,8 @@ export const ViewCreditAccount = ({
105140
additionalConditionToCheck={() =>
106141
fromTab === "MANAGE_SETTINGS" ||
107142
(fromTab === "MANAGE_PROFILE" &&
108-
creditAccount?.creditAccountStatusType !==
109-
CREDIT_ACCOUNT_STATUS_TYPE.CLOSED &&
110-
isAccountHolder)
143+
isAccountHolder &&
144+
creditAccount?.isVerified)
111145
}
112146
/>
113147
</Box>
@@ -139,7 +173,8 @@ export const ViewCreditAccount = ({
139173
fromTab === "MANAGE_SETTINGS" ||
140174
(fromTab === "MANAGE_PROFILE" &&
141175
creditAccount.creditAccountStatusType ===
142-
CREDIT_ACCOUNT_STATUS_TYPE.ACTIVE)
176+
CREDIT_ACCOUNT_STATUS_TYPE.ACTIVE &&
177+
creditAccount?.isVerified)
143178
}
144179
/>
145180
</Box>

frontend/src/features/settings/types/creditAccount.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export interface CreditAccountData {
1717
availableCredit: string;
1818
creditLimit: CreditAccountLimitType;
1919
creditBalance: number;
20+
isVerified: boolean;
2021
}
2122

2223
export interface CreditAccountUser

vehicles/src/modules/credit-account/credit-account.controller.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import {
3030
} from '../../common/enum/user-role.enum';
3131
import { ReadCreditAccountMetadataDto } from './dto/response/read-credit-account-metadata.dto';
3232
import { ReadCreditAccountLimitDto } from './dto/response/read-credit-account-limit.dto';
33+
import { UpdateCreditAccountVerificationDto } from './dto/request/update-credit-account-verification.dto';
3334

3435
@ApiBearerAuth()
3536
@ApiTags('Credit Accounts')
@@ -192,6 +193,8 @@ export class CreditAccountController {
192193
IDIRUserRole.FINANCE,
193194
IDIRUserRole.HQ_ADMINISTRATOR,
194195
IDIRUserRole.SYSTEM_ADMINISTRATOR,
196+
IDIRUserRole.PPC_CLERK,
197+
IDIRUserRole.CTPO,
195198
],
196199
})
197200
async getCreditAccountLimit(
@@ -277,4 +280,36 @@ export class CreditAccountController {
277280
},
278281
);
279282
}
283+
284+
/**
285+
* Verifies a credit account.
286+
*
287+
* @param {string} companyId - The companyId path parameter.
288+
* @param {string} creditAccountId - The creditAccountId path parameter.
289+
* @param {string} comment - The comment to update during verification.
290+
* @returns {Promise<ReadCreditAccountDto>} The result of the verification operation.
291+
*/
292+
@ApiOperation({
293+
summary: 'Verifies a credit account.',
294+
description:
295+
'Verifies the status of a credit account user, enforcing authentication.',
296+
})
297+
@ApiOkResponse({
298+
description: 'The verified credit account status details.',
299+
type: ReadCreditAccountDto,
300+
})
301+
@Put(':creditAccountId/verification')
302+
@Permissions({ allowedIdirRoles: [IDIRUserRole.FINANCE] })
303+
async verifyCreditAccount(
304+
@Req() request: Request,
305+
@Param() { companyId, creditAccountId }: CreditAccountIdPathParamDto,
306+
@Body() { comment }: UpdateCreditAccountVerificationDto,
307+
): Promise<ReadCreditAccountDto> {
308+
const currentUser = request.user as IUserJWT;
309+
return await this.creditAccountService.verifyCreditAccount(currentUser, {
310+
creditAccountHolderId: companyId,
311+
creditAccountId,
312+
comment: comment,
313+
});
314+
}
280315
}

0 commit comments

Comments
 (0)