Add new "available" badge to stock page (#7368)

This commit is contained in:
Oliver 2024-05-28 17:01:21 +10:00 committed by GitHub
parent f3223c6d7f
commit 4cf395c06f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -501,6 +501,9 @@ export default function StockDetail() {
);
const stockBadges: ReactNode[] = useMemo(() => {
let available = (stockitem?.quantity ?? 0) - (stockitem?.allocated ?? 0);
available = Math.max(0, available);
return instanceQuery.isLoading
? []
: [
@ -521,6 +524,12 @@ export default function StockDetail() {
visible={!stockitem.serial}
key="quantity"
/>,
<DetailsBadge
color="yellow"
label={t`Available` + `: ${available}`}
visible={!stockitem.serial && available != stockitem.quantity}
key="available"
/>,
<DetailsBadge
color="blue"
label={t`Batch Code` + `: ${stockitem.batch}`}