2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-16 20:15:44 +00:00

[PUI] Supplier part badges (#8625)

* API fixes for SupplierPart

- Move API filtering into SupplierPartFilter class
- Correct field annotation for detail view

* Add "in stock" and "no stock" badges to SupplierPart detail

* Update details

* Annotate 'on_order' quantity for SupplierPart

* Add "has_stock" filter to SupplierPart API

* Improve API query efficiency

* Add 'has_stock' filter to table

* Update <SupplierPartDetail>

* Bump API version
This commit is contained in:
Oliver
2024-12-03 15:21:06 +11:00
committed by GitHub
parent 9ab18f1da7
commit 1a8b030819
7 changed files with 137 additions and 36 deletions

View File

@ -183,10 +183,25 @@ export default function SupplierPartDetail() {
];
const br: DetailsField[] = [
{
type: 'string',
name: 'in_stock',
label: t`In Stock`,
copy: true,
icon: 'stock'
},
{
type: 'string',
name: 'on_order',
label: t`On Order`,
copy: true,
icon: 'purchase_orders'
},
{
type: 'string',
name: 'available',
label: t`Supplier Availability`,
hidden: !data.availability_updated,
copy: true,
icon: 'packages'
},
@ -352,6 +367,28 @@ export default function SupplierPartDetail() {
label={t`Inactive`}
color='red'
visible={supplierPart.active == false}
/>,
<DetailsBadge
label={`${t`In Stock`}: ${supplierPart.in_stock}`}
color={'green'}
visible={
supplierPart?.active &&
supplierPart?.in_stock &&
supplierPart?.in_stock > 0
}
key='in_stock'
/>,
<DetailsBadge
label={t`No Stock`}
color={'red'}
visible={supplierPart.active && supplierPart.in_stock == 0}
key='no_stock'
/>,
<DetailsBadge
label={`${t`On Order`}: ${supplierPart.on_order}`}
color='blue'
visible={supplierPart.on_order > 0}
key='on_order'
/>
];
}, [supplierPart]);

View File

@ -199,6 +199,11 @@ export function SupplierPartTable({
name: 'supplier_active',
label: t`Active Supplier`,
description: t`Show active suppliers`
},
{
name: 'has_stock',
label: t`In Stock`,
description: t`Show supplier parts with stock`
}
];
}, []);