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:
Alexandre Brandizzi 2026-09-25 03:12:17 -03:00
parent 33f7172598
commit 43dd95e7fd
2 changed files with 32 additions and 2 deletions

View file

@ -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({
request,
locked,
@ -51,8 +57,7 @@ export function UpliftRequestCard({
<div className="vp-row">
<strong>Requested</strong>
<span>
${Number(request.requestedNTE).toFixed(2)} (was $
{Number(request.currentNTE ?? 0).toFixed(2)})
${requestedTotal(request).toFixed(2)} (was ${Number(request.currentNTE ?? 0).toFixed(2)})
</span>
</div>
<div className="vp-row">

View file

@ -46,6 +46,31 @@ describe("UpliftRequestCard actions", () => {
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"])(
"shows a %s request raised from the work order read-only",
(status) => {