Skip to content

Commit

Permalink
Required quantity display (#7938)
Browse files Browse the repository at this point in the history
* Add "required" badge to PUI part detail page

* Add "required for orders" to CUI
  • Loading branch information
SchrodingersGat authored Aug 21, 2024
1 parent 8c6275b commit 9239c82
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/backend/InvenTree/part/templates/part/part_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,13 @@ <h5>
<td>{% decimal on_order %} {% include "part/part_units.html" %}</td>
</tr>
{% endif %}
{% if required > 0 %}
<tr>
<td><span class='fas fa-clipboard-check'></span></td>
<td>{% trans "Required for Orders" %}</td>
<td>{% decimal required %}</td>
</tr>
{% endif %}
{% if part.component %}
{% if required_build_order_quantity > 0 or allocated_build_order_quantity > 0 %}
<tr>
Expand Down
2 changes: 2 additions & 0 deletions src/frontend/src/functions/icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
IconCircleMinus,
IconCirclePlus,
IconCircleX,
IconClipboardCheck,
IconClipboardList,
IconClipboardText,
IconCopy,
Expand Down Expand Up @@ -212,6 +213,7 @@ const icons = {
barLine: IconMinusVertical,
batch: IconClipboardText,
batch_code: IconClipboardText,
tick_off: IconClipboardCheck,
destination: IconFlag,
repeat_destination: IconFlagShare,
unlink: IconUnlink,
Expand Down
22 changes: 21 additions & 1 deletion src/frontend/src/pages/part/PartDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ export default function PartDetail() {
refetchOnMount: true
});

part.required =
(part?.required_for_build_orders ?? 0) +
(part?.required_for_sales_orders ?? 0);

const detailsPanel = useMemo(() => {
if (instanceQuery.isFetching) {
return <Skeleton />;
Expand Down Expand Up @@ -258,6 +262,13 @@ export default function PartDetail() {
unit: true,
hidden: !part.purchaseable || part.ordering <= 0
},
{
type: 'string',
name: 'required',
label: t`Required for Orders`,
hidden: part.required <= 0,
icon: 'tick_off'
},
{
type: 'progressbar',
name: 'allocated_to_build_orders',
Expand Down Expand Up @@ -285,7 +296,7 @@ export default function PartDetail() {
type: 'string',
name: 'building',
unit: true,
label: t`Building`,
label: t`In Production`,
hidden: !part.assembly || !part.building
}
];
Expand Down Expand Up @@ -838,6 +849,9 @@ export default function PartDetail() {
return [];
}

const required =
part.required_for_build_orders + part.required_for_sales_orders;

return [
<DetailsBadge
label={t`In Stock` + `: ${part.total_in_stock}`}
Expand All @@ -857,6 +871,12 @@ export default function PartDetail() {
visible={part.total_in_stock == 0}
key="no_stock"
/>,
<DetailsBadge
label={t`Required` + `: ${required}`}
color="grape"
visible={required > 0}
key="required"
/>,
<DetailsBadge
label={t`On Order` + `: ${part.ordering}`}
color="blue"
Expand Down

0 comments on commit 9239c82

Please sign in to comment.