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: add purchase order and sales order to packing slip

Brad Barbin0193a3a877d0
diff --git a/apps/erp/app/modules/inventory/ui/Shipments/ShipmentHeader.tsx b/apps/erp/app/modules/inventory/ui/Shipments/ShipmentHeader.tsx
index cc93426169..de9940942e 100644
--- a/apps/erp/app/modules/inventory/ui/Shipments/ShipmentHeader.tsx
+++ b/apps/erp/app/modules/inventory/ui/Shipments/ShipmentHeader.tsx
@@ -9,10 +9,9 @@ import {
import { Link, useParams } from "@remix-run/react";
import {
LuCheckCheck,
- LuFile,
+ LuBarcode,
LuPanelLeft,
LuPanelRight,
- LuShoppingCart,
} from "react-icons/lu";
import { usePanels } from "~/components/Layout";
import { usePermissions, useRouteData } from "~/hooks";
@@ -21,6 +20,7 @@ import type { Shipment, ShipmentLine } from "~/modules/inventory";
import { path } from "~/utils/path";
import ShipmentStatus from "./ShipmentStatus";
import ShipmentPostModal from "./ShipmentPostModal";
+import { RiProgress8Line } from "react-icons/ri";
const ShipmentHeader = () => {
const { shipmentId } = useParams();
@@ -64,7 +64,7 @@ const ShipmentHeader = () => {
</HStack>
<HStack>
<DropdownMenu>
- <Button variant="secondary" leftIcon={<LuFile />} asChild>
+ <Button variant="secondary" leftIcon={<LuBarcode />} asChild>
<a
target="_blank"
href={path.to.file.shipment(shipmentId)}
@@ -116,12 +116,15 @@ function SourceDocumentLink({
sourceDocumentId?: string;
sourceDocumentReadableId?: string;
}) {
+ const permissions = usePermissions();
+
if (!sourceDocument || !sourceDocumentId || !sourceDocumentReadableId)
return null;
switch (sourceDocument) {
case "Sales Order":
+ if (!permissions.can("view", "sales")) return null;
return (
- <Button variant="secondary" leftIcon={<LuShoppingCart />} asChild>
+ <Button variant="secondary" leftIcon={<RiProgress8Line />} asChild>
<Link to={path.to.salesOrderDetails(sourceDocumentId!)}>
Sales Order
</Link>
diff --git a/apps/erp/app/routes/file+/shipment+/$id[.]pdf.tsx b/apps/erp/app/routes/file+/shipment+/$id[.]pdf.tsx
index d8619245d6..6f7e1c63b5 100644
--- a/apps/erp/app/routes/file+/shipment+/$id[.]pdf.tsx
+++ b/apps/erp/app/routes/file+/shipment+/$id[.]pdf.tsx
@@ -99,6 +99,8 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
keywords: "packing slip",
subject: "Packing Slip",
}}
+ purchaseOrder={salesOrder.data?.customerReference ?? undefined}
+ salesOrder={salesOrder.data?.salesOrderId ?? undefined}
shipment={shipment.data}
shipmentLines={shipmentLines.data ?? []}
// @ts-ignore
diff --git a/packages/documents/src/pdf/PackingSlipPDF.tsx b/packages/documents/src/pdf/PackingSlipPDF.tsx
index 5218c186ab..a20f351b3d 100644
--- a/packages/documents/src/pdf/PackingSlipPDF.tsx
+++ b/packages/documents/src/pdf/PackingSlipPDF.tsx
@@ -9,6 +9,8 @@ import { Header, Note, Summary, Template } from "./components";
interface PackingSlipProps extends PDF {
customer: Database["public"]["Tables"]["customer"]["Row"];
+ purchaseOrder?: string;
+ salesOrder?: string;
shipment: Database["public"]["Tables"]["shipment"]["Row"];
shipmentLines: Database["public"]["Views"]["shipmentLines"]["Row"][];
shippingAddress: Database["public"]["Tables"]["address"]["Row"] | null;
@@ -37,6 +39,8 @@ const PackingSlipPDF = ({
company,
customer,
meta,
+ purchaseOrder,
+ salesOrder,
shipment,
shipmentLines,
shippingAddress,
@@ -54,6 +58,31 @@ const PackingSlipPDF = ({
countryCode,
} = shippingAddress ?? {};
+ const details = [
+ {
+ label: "Date",
+ value: shipment?.postingDate,
+ },
+ {
+ label: "Shipment",
+ value: shipment?.shipmentId,
+ },
+ ];
+
+ if (purchaseOrder) {
+ details.push({
+ label: "Purchase Order",
+ value: purchaseOrder,
+ });
+ }
+
+ if (salesOrder) {
+ details.push({
+ label: "Sales Order",
+ value: salesOrder,
+ });
+ }
+
return (
<Template
title={title}
@@ -65,19 +94,7 @@ const PackingSlipPDF = ({
>
<View>
<Header title={title} company={company} />
- <Summary
- company={company}
- items={[
- {
- label: "Date",
- value: shipment?.postingDate,
- },
- {
- label: "Shipment #",
- value: shipment?.shipmentId,
- },
- ]}
- />
+ <Summary company={company} items={details} />
{shipment?.trackingNumber && (
<View style={tw("flex flex-col gap-2 justify-between mb-5")}>
<Text style={tw("text-gray-500 text-xs")}>Tracking Number</Text>