mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-07 12:49:00 +00:00
Show the requested NTE total on work-order uplift cards
A request raised from the work order stores the increase, so the vendor card read a +90 request on a 600 NTE as "Requested $90.00 (was $600.00)". The card now shows the new total, $690.00, for those requests; vendor requests are unchanged.
This commit is contained in:
parent
33f7172598
commit
43dd95e7fd
2 changed files with 32 additions and 2 deletions
|
|
@ -32,6 +32,12 @@ function availableActions(request: VendorPortalUpliftRequest, locked: boolean, c
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A vendor request stores the requested new NTE total; a work-order request stores the increase.
|
||||||
|
function requestedTotal(request: VendorPortalUpliftRequest): number {
|
||||||
|
const requested = Number(request.requestedNTE);
|
||||||
|
return request.raisedByVendor === false ? Number(request.currentNTE ?? 0) + requested : requested;
|
||||||
|
}
|
||||||
|
|
||||||
export function UpliftRequestCard({
|
export function UpliftRequestCard({
|
||||||
request,
|
request,
|
||||||
locked,
|
locked,
|
||||||
|
|
@ -51,8 +57,7 @@ export function UpliftRequestCard({
|
||||||
<div className="vp-row">
|
<div className="vp-row">
|
||||||
<strong>Requested</strong>
|
<strong>Requested</strong>
|
||||||
<span>
|
<span>
|
||||||
${Number(request.requestedNTE).toFixed(2)} (was $
|
${requestedTotal(request).toFixed(2)} (was ${Number(request.currentNTE ?? 0).toFixed(2)})
|
||||||
{Number(request.currentNTE ?? 0).toFixed(2)})
|
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="vp-row">
|
<div className="vp-row">
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,31 @@ describe("UpliftRequestCard actions", () => {
|
||||||
expect(screen.getByRole("button", { name: /revise/i })).toBeInTheDocument();
|
expect(screen.getByRole("button", { name: /revise/i })).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("shows a work-order increase as the new NTE total", () => {
|
||||||
|
renderCard(request({ raisedByVendor: false, requestedNTE: 90, currentNTE: 600 }));
|
||||||
|
|
||||||
|
expect(screen.getByText("Requested").nextElementSibling).toHaveTextContent(
|
||||||
|
"$690.00 (was $600.00)",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("shows a vendor request's requested total unchanged", () => {
|
||||||
|
renderCard(request({ raisedByVendor: true, requestedNTE: 900, currentNTE: 600 }));
|
||||||
|
|
||||||
|
expect(screen.getByText("Requested").nextElementSibling).toHaveTextContent(
|
||||||
|
"$900.00 (was $600.00)",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("treats a request without the raised-by flag as vendor-raised", () => {
|
||||||
|
renderCard(request({ raisedByVendor: undefined, requestedNTE: 900, currentNTE: 600 }));
|
||||||
|
|
||||||
|
expect(screen.getByText("Requested").nextElementSibling).toHaveTextContent(
|
||||||
|
"$900.00 (was $600.00)",
|
||||||
|
);
|
||||||
|
expect(screen.getByRole("button", { name: /withdraw request/i })).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
it.each(["Pending", "ChangesRequested"])(
|
it.each(["Pending", "ChangesRequested"])(
|
||||||
"shows a %s request raised from the work order read-only",
|
"shows a %s request raised from the work order read-only",
|
||||||
(status) => {
|
(status) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue