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.

feat: don't require serial tracking on shipments and receipts for outside operations

Brad Barbinb94d8e736b1e
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobHeader.tsx b/apps/erp/app/modules/production/ui/Jobs/JobHeader.tsx
index ad49a8fe26..4eb372822a 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobHeader.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobHeader.tsx
@@ -46,6 +46,7 @@ import {
LuPanelRight,
LuRefreshCw,
LuSettings,
+ LuShoppingCart,
LuSquareSigma,
LuTable,
LuTriangleAlert,
@@ -374,6 +375,7 @@ function JobStartModal({
eachOutsideOperationHasASupplier,
setEachOutsideOperationHasASupplier,
] = useState(false);
+ const [hasOutsideOperations, setHasOutsideOperations] = useState(false);
const validate = async () => {
if (!carbon || !job) return;
@@ -411,6 +413,12 @@ function JobStartModal({
)
);
+ setHasOutsideOperations(
+ Array.isArray(operations?.data) &&
+ operations.data.length > 0 &&
+ operations.data.some((op) => op.operationType === "Outside")
+ );
+
setEachOutsideOperationHasASupplier(
operations.data?.every(
(op) =>
@@ -452,36 +460,47 @@ function JobStartModal({
) : (
<>
<ModalBody>
- {eachAssemblyHasAnOperation &&
- eachOutsideOperationHasASupplier && (
- <p>
- Are you sure you want to start this job? It will become
- available to the shop floor and purchase orders will be
- created for any outside operations.
- </p>
+ <VStack>
+ {eachAssemblyHasAnOperation &&
+ eachOutsideOperationHasASupplier && (
+ <p>
+ Are you sure you want to start this job? It will become
+ available to the shop floor.
+ </p>
+ )}
+ {hasOutsideOperations && eachOutsideOperationHasASupplier && (
+ <Alert>
+ <LuShoppingCart />
+ <AlertTitle>Purchase orders will be created</AlertTitle>
+ <AlertDescription>
+ Purchase orders will be created for any outside
+ operations.
+ </AlertDescription>
+ </Alert>
+ )}
+ {!eachAssemblyHasAnOperation && (
+ <Alert variant="warning">
+ <LuTriangleAlert />
+ <AlertTitle>Missing Operations</AlertTitle>
+ <AlertDescription>
+ There are Bills of Processes associated with this job that
+ have no operations. Please assign an operation to each
+ make method before releasing it.
+ </AlertDescription>
+ </Alert>
)}
- {!eachAssemblyHasAnOperation && (
- <Alert variant="warning">
- <LuTriangleAlert />
- <AlertTitle>Missing Operations</AlertTitle>
- <AlertDescription>
- There are Bills of Processes associated with this job that
- have no operations. Please assign an operation to each make
- method before releasing it.
- </AlertDescription>
- </Alert>
- )}
- {!eachOutsideOperationHasASupplier && (
- <Alert variant="warning">
- <LuTriangleAlert />
- <AlertTitle>Missing Suppliers</AlertTitle>
- <AlertDescription>
- There are outside operations associated with this job that
- have no suppliers. Please assign a supplier to each outside
- operation before releasing it.
- </AlertDescription>
- </Alert>
- )}
+ {!eachOutsideOperationHasASupplier && (
+ <Alert variant="warning">
+ <LuTriangleAlert />
+ <AlertTitle>Missing Suppliers</AlertTitle>
+ <AlertDescription>
+ There are outside operations associated with this job that
+ have no suppliers. Please assign a supplier to each
+ outside operation before releasing it.
+ </AlertDescription>
+ </Alert>
+ )}
+ </VStack>
</ModalBody>
<ModalFooter>
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobProperties.tsx b/apps/erp/app/modules/production/ui/Jobs/JobProperties.tsx
index 2e5fb8ac70..2252285e03 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobProperties.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobProperties.tsx
@@ -8,7 +8,7 @@ import {
VStack,
toast,
} from "@carbon/react";
-import { Link, useFetcher, useParams } from "@remix-run/react";
+import { useFetcher, useParams } from "@remix-run/react";
import { useCallback, useEffect, useState } from "react";
import { LuBox, LuCopy, LuLink, LuUnlink2 } from "react-icons/lu";
import { usePermissions, useRouteData } from "~/hooks";
@@ -24,7 +24,7 @@ import {
import { RiProgress8Line } from "react-icons/ri";
import { z } from "zod";
import { zfd } from "zod-form-data";
-import { Assignee, useOptimisticAssignment } from "~/components";
+import { Assignee, Hyperlink, useOptimisticAssignment } from "~/components";
import {
Customer,
Item,
@@ -185,7 +185,7 @@ const JobProperties = () => {
routeData?.job?.salesOrderId &&
routeData?.job?.salesOrderLineId ? (
<HStack className="group" spacing={1}>
- <Link
+ <Hyperlink
to={path.to.salesOrderLine(
routeData.job.salesOrderId,
routeData?.job.salesOrderLineId
@@ -195,7 +195,7 @@ const JobProperties = () => {
<RiProgress8Line className="w-3 h-3 mr-1" />
{routeData?.job.salesOrderReadableId ?? "Make to Order"}
</Badge>
- </Link>
+ </Hyperlink>
<Button
className="group-hover:opacity-100 opacity-0 transition-opacity duration-200"
variant="ghost"
diff --git a/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderProperties.tsx b/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderProperties.tsx
index 6de47d281c..e4e5974ca6 100644
--- a/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderProperties.tsx
+++ b/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderProperties.tsx
@@ -24,7 +24,7 @@ import {
} from "react-icons/lu";
import { z } from "zod";
import { zfd } from "zod-form-data";
-import { Assignee, useOptimisticAssignment } from "~/components";
+import { Assignee, Hyperlink, useOptimisticAssignment } from "~/components";
import {
Currency,
Location,
@@ -179,12 +179,12 @@ const PurchaseOrderProperties = () => {
<VStack spacing={2}>
<span className="text-xs text-muted-foreground">Job</span>
- <Link to={path.to.jobDetails(routeData?.purchaseOrder?.jobId)}>
+ <Hyperlink to={path.to.jobDetails(routeData?.purchaseOrder?.jobId)}>
<Badge variant="secondary">
<LuHardHat className="w-3 h-3 mr-1" />
{routeData?.purchaseOrder?.jobReadableId ?? "Job"}
</Badge>
- </Link>
+ </Hyperlink>
</VStack>
)}
diff --git a/apps/erp/app/modules/resources/ui/Processes/ProcessForm.tsx b/apps/erp/app/modules/resources/ui/Processes/ProcessForm.tsx
index d7246dd5de..98446f9373 100644
--- a/apps/erp/app/modules/resources/ui/Processes/ProcessForm.tsx
+++ b/apps/erp/app/modules/resources/ui/Processes/ProcessForm.tsx
@@ -174,7 +174,7 @@ function SupplierProcesses({ processId }: { processId?: string }) {
{processes.map((sp) => (
<HStack
key={sp.id}
- className="w-full justify-between rounded-md border border-border p-2"
+ className="w-full justify-between rounded-md border border-border p-2 text-sm"
>
<SupplierAvatar supplierId={sp.supplierId} />
<DropdownMenu>
diff --git a/apps/erp/app/routes/x+/job+/$jobId.details.tsx b/apps/erp/app/routes/x+/job+/$jobId.details.tsx
index e343f32c9e..3e6c59688c 100644
--- a/apps/erp/app/routes/x+/job+/$jobId.details.tsx
+++ b/apps/erp/app/routes/x+/job+/$jobId.details.tsx
@@ -245,11 +245,11 @@ function JobPurchaseOrderLineItem({ line }: { line: JobPurchaseOrderLine }) {
: "To Ship";
const statusColor = isReceived
- ? "blue"
+ ? "green"
: isPartiallyReceived
? "yellow"
: isShipped
- ? "green"
+ ? "blue"
: isPartiallyShipped
? "orange"
: "gray";
diff --git a/packages/database/supabase/functions/create-inventory-document/index.ts b/packages/database/supabase/functions/create-inventory-document/index.ts
index b2b8ad4d83..b5220ba43c 100644
--- a/packages/database/supabase/functions/create-inventory-document/index.ts
+++ b/packages/database/supabase/functions/create-inventory-document/index.ts
@@ -523,6 +523,8 @@ serve(async (req: Request) => {
);
const hasReceipt = !!receipt.data?.id;
+ const isOutsideOperation =
+ purchaseOrder.data.purchaseOrderType === "Outside Processing";
const previouslyReceivedQuantitiesByLine = (
purchaseOrderLines.data ?? []
@@ -562,8 +564,10 @@ serve(async (req: Request) => {
outstandingQuantity * (d.conversionFactor ?? 1),
receivedQuantity: outstandingQuantity * (d.conversionFactor ?? 1),
conversionFactor: d.conversionFactor ?? 1,
- requiresSerialTracking: serializedItems.has(d.itemId),
- requiresBatchTracking: batchItems.has(d.itemId),
+ requiresSerialTracking:
+ serializedItems.has(d.itemId) && !isOutsideOperation,
+ requiresBatchTracking:
+ batchItems.has(d.itemId) && !isOutsideOperation,
unitPrice:
d.unitPrice / (d.conversionFactor ?? 1) + shippingAndTaxUnitCost,
unitOfMeasure: d.inventoryUnitOfMeasureCode ?? "EA",
@@ -880,6 +884,8 @@ serve(async (req: Request) => {
);
const hasShipment = !!shipment.data?.id;
+ const isOutsideOperation =
+ purchaseOrder.data.purchaseOrderType === "Outside Processing";
const previouslyShippedQuantitiesByLine = (
purchaseOrderLines.data ?? []
@@ -979,8 +985,8 @@ serve(async (req: Request) => {
orderQuantity: purchaseOrderLine.purchaseQuantity,
outstandingQuantity: outstandingQuantity,
shippedQuantity: outstandingQuantity ?? 0,
- requiresSerialTracking: isSerial,
- requiresBatchTracking: isBatch,
+ requiresSerialTracking: isSerial && !isOutsideOperation,
+ requiresBatchTracking: isBatch && !isOutsideOperation,
unitPrice: shippingAndTaxUnitCost,
unitOfMeasure:
purchaseOrderLine.purchaseUnitOfMeasureCode ?? "EA",
diff --git a/packages/database/supabase/functions/post-shipment/index.ts b/packages/database/supabase/functions/post-shipment/index.ts
index 50d447d157..20867dc7f4 100644
--- a/packages/database/supabase/functions/post-shipment/index.ts
+++ b/packages/database/supabase/functions/post-shipment/index.ts
@@ -955,7 +955,6 @@ serve(async (req: Request) => {
}
acc[trackedEntity.id] = {
- status: "On Hold",
quantity: shipmentLine?.shippedQuantity ?? trackedEntity.quantity,
};