From 42abc61494152af5acaad20a06e9b2c61b094953 Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 15 Jul 2025 18:26:48 +1000 Subject: [PATCH] Improve RenderStockItem (#10028) - Display "available" quantity if some has been allocted --- src/frontend/src/components/render/Stock.tsx | 7 +++++++ src/frontend/src/tables/build/BuildLineTable.tsx | 1 - 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/frontend/src/components/render/Stock.tsx b/src/frontend/src/components/render/Stock.tsx index 30aec4db01..5dd2af05b6 100644 --- a/src/frontend/src/components/render/Stock.tsx +++ b/src/frontend/src/components/render/Stock.tsx @@ -57,12 +57,19 @@ export function RenderStockItem( const { instance } = props; let quantity_string = ''; + const allocated: number = Math.max(0, instance?.allocated ?? 0); + if (instance?.serial !== null && instance?.serial !== undefined) { quantity_string += `${t`Serial Number`}: ${instance.serial}`; + } else if (allocated > 0) { + const available: number = Math.max(0, instance.quantity - allocated); + quantity_string = `${t`Available`}: ${available} / ${instance.quantity}`; } else if (instance?.quantity) { quantity_string = `${t`Quantity`}: ${instance.quantity}`; } + console.log('item:', instance); + let batch_string = ''; if (!!instance.batch) { diff --git a/src/frontend/src/tables/build/BuildLineTable.tsx b/src/frontend/src/tables/build/BuildLineTable.tsx index 2bc691c935..c80dbfd73f 100644 --- a/src/frontend/src/tables/build/BuildLineTable.tsx +++ b/src/frontend/src/tables/build/BuildLineTable.tsx @@ -560,7 +560,6 @@ export default function BuildLineTable({ in_production && !consumable && user.hasChangeRole(UserRoles.build) && - record.allocated < record.quantity && record.trackable == hasOutput; // Can de-allocate