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.

fix: use operation order on job traveler

Brad Barbin05a09e5e4b5d
diff --git a/apps/erp/app/routes/file+/traveler+/$id[.]pdf.tsx b/apps/erp/app/routes/file+/traveler+/$id[.]pdf.tsx
index bfeaa44617..9d13af593b 100644
--- a/apps/erp/app/routes/file+/traveler+/$id[.]pdf.tsx
+++ b/apps/erp/app/routes/file+/traveler+/$id[.]pdf.tsx
@@ -53,7 +53,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
.maybeSingle(),
client
.from("item")
- .select("*")
+ .select("*, modelUpload(thumbnailPath)")
.eq("id", jobMakeMethod.data.itemId ?? "")
.single(),
]);
@@ -84,10 +84,10 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
// Get thumbnail if it exists
let thumbnail: string | null = null;
- if (item.data.thumbnailPath) {
+ if (item.data.thumbnailPath || item.data.modelUpload?.thumbnailPath) {
thumbnail = await getBase64ImageFromSupabase(
client,
- item.data.thumbnailPath
+ item.data.thumbnailPath ?? item.data.modelUpload?.thumbnailPath ?? ""
);
}
diff --git a/packages/documents/src/pdf/JobTravelerPDF.tsx b/packages/documents/src/pdf/JobTravelerPDF.tsx
index 5dca977e35..8f0f4bfd56 100644
--- a/packages/documents/src/pdf/JobTravelerPDF.tsx
+++ b/packages/documents/src/pdf/JobTravelerPDF.tsx
@@ -106,6 +106,7 @@ const JobHeader = ({
batchNumber,
thumbnail,
}: JobHeaderProps) => {
+ console.log(thumbnail);
const getTargetInfo = () => {
if (job.salesOrderId && job.salesOrderLineId) {
return `Sales Order: ${job.salesOrderReadableId || "Make to Order"}`;
@@ -280,88 +281,98 @@ const JobTravelerPDF = ({
<Text style={tw("w-2/3 text-right pr-4")}>Actions</Text>
</View>
- {jobOperations.map((operation, index) => {
- const isInside = operation.operationType === "Inside";
- const setupQrCode =
- operation.setupTime > 0
- ? generateQRCode(`${getStartPath(operation.id)}?type=Setup`, 10)
- : null;
- let laborQrCode =
- operation.laborTime > 0
- ? generateQRCode(`${getStartPath(operation.id)}?type=Labor`, 10)
- : null;
- let machiningQrCode =
- operation.machineTime > 0
- ? generateQRCode(
- `${getStartPath(operation.id)}?type=Machine`,
- 10
- )
- : null;
- let completeQrCode = generateQRCode(getEndPath(operation.id), 10);
+ {jobOperations
+ .sort((a, b) => a.order - b.order)
+ .map((operation, index) => {
+ const isInside = operation.operationType === "Inside";
+ const setupQrCode =
+ operation.setupTime > 0
+ ? generateQRCode(
+ `${getStartPath(operation.id)}?type=Setup`,
+ 10
+ )
+ : null;
+ let laborQrCode =
+ operation.laborTime > 0
+ ? generateQRCode(
+ `${getStartPath(operation.id)}?type=Labor`,
+ 10
+ )
+ : null;
+ let machiningQrCode =
+ operation.machineTime > 0
+ ? generateQRCode(
+ `${getStartPath(operation.id)}?type=Machine`,
+ 10
+ )
+ : null;
+ let completeQrCode = generateQRCode(getEndPath(operation.id), 10);
- if (
- setupQrCode === null &&
- laborQrCode === null &&
- machiningQrCode === null
- ) {
- laborQrCode = generateQRCode(
- `${getStartPath(operation.id)}?type=Labor`,
- 10
- );
- }
+ if (
+ setupQrCode === null &&
+ laborQrCode === null &&
+ machiningQrCode === null
+ ) {
+ laborQrCode = generateQRCode(
+ `${getStartPath(operation.id)}?type=Labor`,
+ 10
+ );
+ }
- return (
- <View
- style={tw(
- "flex flex-col border-b border-gray-300 py-4 px-[6px] page-break-inside-avoid"
- )}
- key={operation.id}
- >
- <View style={tw("flex flex-row justify-between items-start")}>
- <Text style={tw("w-1/12 text-left")}>
- {getParallelizedOrder(index, operation, jobOperations)}
- </Text>
- <View style={tw("w-3/12 text-left")}>
- <Text style={tw("font-bold")}>{operation.description}</Text>
- </View>
- <View style={tw("w-2/3 flex flex-row justify-end gap-2")}>
- {isInside && setupQrCode && (
- <View style={tw("flex flex-col items-center w-1/4")}>
- <>
- <Image src={setupQrCode} style={tw("w-16 h-16")} />
- <Text style={tw("text-[8px] mt-1")}>Setup</Text>
- </>
- </View>
- )}
+ return (
+ <View
+ style={tw(
+ "flex flex-col border-b border-gray-300 py-4 px-[6px] page-break-inside-avoid"
+ )}
+ key={operation.id}
+ >
+ <View style={tw("flex flex-row justify-between items-start")}>
+ <Text style={tw("w-1/12 text-left")}>
+ {getParallelizedOrder(index, operation, jobOperations)}
+ </Text>
+ <View style={tw("w-3/12 text-left")}>
+ <Text style={tw("font-bold")}>
+ {operation.description}
+ </Text>
+ </View>
+ <View style={tw("w-2/3 flex flex-row justify-end gap-2")}>
+ {isInside && setupQrCode && (
+ <View style={tw("flex flex-col items-center w-1/4")}>
+ <>
+ <Image src={setupQrCode} style={tw("w-16 h-16")} />
+ <Text style={tw("text-[8px] mt-1")}>Setup</Text>
+ </>
+ </View>
+ )}
- {isInside && laborQrCode && (
- <View style={tw("flex flex-col items-center w-1/4")}>
- <>
- <Image src={laborQrCode} style={tw("w-16 h-16")} />
- <Text style={tw("text-[8px] mt-1")}>Labor</Text>
- </>
- </View>
- )}
- {isInside && machiningQrCode && (
+ {isInside && laborQrCode && (
+ <View style={tw("flex flex-col items-center w-1/4")}>
+ <>
+ <Image src={laborQrCode} style={tw("w-16 h-16")} />
+ <Text style={tw("text-[8px] mt-1")}>Labor</Text>
+ </>
+ </View>
+ )}
+ {isInside && machiningQrCode && (
+ <View style={tw("flex flex-col items-center w-1/4")}>
+ <>
+ <Image
+ src={machiningQrCode}
+ style={tw("w-16 h-16")}
+ />
+ <Text style={tw("text-[8px] mt-1")}>Machine</Text>
+ </>
+ </View>
+ )}
<View style={tw("flex flex-col items-center w-1/4")}>
- <>
- <Image
- src={machiningQrCode}
- style={tw("w-16 h-16")}
- />
- <Text style={tw("text-[8px] mt-1")}>Machine</Text>
- </>
+ <Image src={completeQrCode} style={tw("w-16 h-16")} />
+ <Text style={tw("text-[8px] mt-1")}>Complete</Text>
</View>
- )}
- <View style={tw("flex flex-col items-center w-1/4")}>
- <Image src={completeQrCode} style={tw("w-16 h-16")} />
- <Text style={tw("text-[8px] mt-1")}>Complete</Text>
</View>
</View>
</View>
- </View>
- );
- })}
+ );
+ })}
</View>
{/* Notes Section */}