Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

refactor: split leftover quantity

Brad Barbin07c80337ddab
diff --git a/apps/erp/app/modules/production/production.service.ts b/apps/erp/app/modules/production/production.service.ts
index 51adefaa70..4713254d15 100644
--- a/apps/erp/app/modules/production/production.service.ts
+++ b/apps/erp/app/modules/production/production.service.ts
@@ -2675,7 +2675,9 @@ export async function upsertMaintenanceDispatch(
if ("createdBy" in dispatch) {
return client
.from("maintenanceDispatch")
- .insert([dispatch])
+ .insert([
+ { ...dispatch, severity: dispatch.severity ?? "Support Required" }
+ ])
.select("id")
.single();
} else {
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobHeader.tsx b/apps/erp/app/modules/production/ui/Jobs/JobHeader.tsx
index caa25a1d75..0f0305967b 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobHeader.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobHeader.tsx
@@ -48,14 +48,13 @@ import {
LuClipboardList,
LuClock,
LuEllipsisVertical,
- LuEye,
- LuFile,
LuHardHat,
LuList,
LuLoaderCircle,
LuPackage,
LuPanelLeft,
LuPanelRight,
+ LuQrCode,
LuSettings,
LuShoppingCart,
LuSquareSigma,
@@ -202,6 +201,16 @@ const JobHeader = () => {
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent className="w-56">
+ <DropdownMenuItem asChild>
+ <a
+ target="_blank"
+ href={path.to.file.jobTravelerByJobId(jobId)}
+ rel="noreferrer"
+ >
+ <DropdownMenuIcon icon={<LuQrCode />} />
+ Job Traveler
+ </a>
+ </DropdownMenuItem>
<DropdownMenuRadioGroup
value={currentValue}
onValueChange={(option) => {
@@ -230,30 +239,6 @@ const JobHeader = () => {
</DropdownMenuContent>
</DropdownMenu>
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <Button
- leftIcon={<LuEye />}
- variant="secondary"
- rightIcon={<LuChevronDown />}
- >
- Preview
- </Button>
- </DropdownMenuTrigger>
- <DropdownMenuContent>
- <DropdownMenuItem asChild>
- <a
- target="_blank"
- href={path.to.file.jobTravelerByJobId(jobId)}
- rel="noreferrer"
- >
- <DropdownMenuIcon icon={<LuFile />} />
- Job Traveler
- </a>
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
-
{status !== "Paused" ? (
<statusFetcher.Form method="post" action={path.to.jobStatus(jobId)}>
<input type="hidden" name="status" value="Paused" />
@@ -865,7 +850,7 @@ function JobCompleteModal({
);
const [quantityComplete, setQuantityComplete] = useState<number>(
- job?.quantity ?? 0
+ job?.quantityComplete ?? 0
);
const [hasTrackedQuantity, setHasTrackedQuantity] = useState<boolean>(false);
@@ -1114,38 +1099,29 @@ function JobCompleteModal({
{leftoverAction === "split" && (
<HStack className="w-full">
<div className="flex-1">
- <label className="text-sm font-medium">
- Ship to Customer
- </label>
- <input
- type="number"
- className="w-full mt-1 px-3 py-2 border rounded-md"
+ <NumberControlled
+ name="leftoverShipQuantity"
+ label="Ship to Customer"
value={leftoverShipQuantity}
- onChange={(e) => {
- const shipQty = Math.min(
- Number(e.target.value),
- leftoverQuantity
- );
+ onChange={(value) => {
+ const shipQty = Math.min(value, leftoverQuantity);
setLeftoverShipQuantity(shipQty);
setLeftoverReceiveQuantity(
leftoverQuantity - shipQty
);
}}
- min={0}
- max={leftoverQuantity}
+ minValue={0}
+ maxValue={leftoverQuantity}
/>
</div>
<div className="flex-1">
- <label className="text-sm font-medium">
- Receive to Inventory
- </label>
- <input
- type="number"
- className="w-full mt-1 px-3 py-2 border rounded-md"
+ <NumberControlled
+ name="leftoverReceiveQuantity"
+ label="Receive to Inventory"
value={leftoverReceiveQuantity}
- onChange={(e) => {
+ onChange={(value) => {
const receiveQty = Math.min(
- Number(e.target.value),
+ value,
leftoverQuantity
);
setLeftoverReceiveQuantity(receiveQty);
@@ -1153,8 +1129,8 @@ function JobCompleteModal({
leftoverQuantity - receiveQty
);
}}
- min={0}
- max={leftoverQuantity}
+ minValue={0}
+ maxValue={leftoverQuantity}
/>
</div>
</HStack>