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 lot and serial tracking types

Brad Barbin5f367e6ccfc7
diff --git a/apps/erp/app/components/Icons.tsx b/apps/erp/app/components/Icons.tsx
index de0cacbe8a..49ce72b236 100644
--- a/apps/erp/app/components/Icons.tsx
+++ b/apps/erp/app/components/Icons.tsx
@@ -3,9 +3,12 @@ import { AiOutlinePartition } from "react-icons/ai";
import { FaCodePullRequest } from "react-icons/fa6";
import {
LuAtom,
+ LuBarcode,
+ LuBox,
LuCircleCheck,
LuCircleX,
LuExternalLink,
+ LuGroup,
LuHammer,
LuHardHat,
LuHeadphones,
@@ -16,7 +19,7 @@ import {
} from "react-icons/lu";
import { RxCodesandboxLogo } from "react-icons/rx";
-import { TbTargetArrow, TbTargetOff } from "react-icons/tb";
+import { TbTargetOff } from "react-icons/tb";
import { getColor } from "@carbon/utils";
import { Link } from "@remix-run/react";
@@ -152,8 +155,12 @@ export const TrackingTypeIcon = ({
className?: string;
}) => {
switch (type) {
+ case "Serial":
+ return <LuBarcode className={cn("text-foreground", className)} />;
+ case "Lot":
+ return <LuGroup className={cn("text-emerald-500", className)} />;
case "Inventory":
- return <TbTargetArrow className={cn("text-blue-500", className)} />;
+ return <LuBox className={cn("text-blue-500", className)} />;
case "Non-Inventory":
return <TbTargetOff className={cn("text-red-500", className)} />;
default:
diff --git a/apps/erp/app/modules/inventory/ui/Receipts/ReceiptsTable.tsx b/apps/erp/app/modules/inventory/ui/Receipts/ReceiptsTable.tsx
index 355d08ca7a..c03967f497 100644
--- a/apps/erp/app/modules/inventory/ui/Receipts/ReceiptsTable.tsx
+++ b/apps/erp/app/modules/inventory/ui/Receipts/ReceiptsTable.tsx
@@ -10,12 +10,17 @@ import {
LuClock,
LuFileText,
LuHash,
- LuMapPin,
LuPencil,
LuTrash,
LuUser,
} from "react-icons/lu";
-import { EmployeeAvatar, Hyperlink, New, Table } from "~/components";
+import {
+ EmployeeAvatar,
+ Hyperlink,
+ New,
+ SupplierAvatar,
+ Table,
+} from "~/components";
import { Enumerable } from "~/components/Enumerable";
import { ConfirmDelete } from "~/components/Modals";
import { usePermissions, useRealtime, useUrlParams } from "~/hooks";
@@ -26,7 +31,7 @@ import {
receiptSourceDocumentType,
receiptStatusType,
} from "~/modules/inventory";
-import { usePeople } from "~/stores";
+import { usePeople, useSuppliers } from "~/stores";
import type { ListItem } from "~/types";
import { path } from "~/utils/path";
@@ -45,6 +50,7 @@ const ReceiptsTable = memo(({ data, count, locations }: ReceiptsTableProps) => {
const rows = useMemo(() => data, [data]);
const [people] = usePeople();
+ const [suppliers] = useSuppliers();
const customColumns = useCustomColumns<Receipt>("receipt");
const columns = useMemo<ColumnDef<Receipt>[]>(() => {
@@ -108,21 +114,7 @@ const ReceiptsTable = memo(({ data, count, locations }: ReceiptsTableProps) => {
icon: <LuHash />,
},
},
- {
- accessorKey: "locationName",
- header: "Location",
- cell: (item) => <Enumerable value={item.getValue<string>()} />,
- meta: {
- filter: {
- type: "static",
- options: locations.map(({ name }) => ({
- value: name,
- label: <Enumerable value={name} />,
- })),
- },
- icon: <LuMapPin />,
- },
- },
+
{
accessorKey: "status",
header: "Status",
@@ -143,10 +135,10 @@ const ReceiptsTable = memo(({ data, count, locations }: ReceiptsTableProps) => {
},
},
{
- id: "assignee",
- header: "Assignee",
+ id: "postedBy",
+ header: "Posted By",
cell: ({ row }) => (
- <EmployeeAvatar employeeId={row.original.assignee} />
+ <EmployeeAvatar employeeId={row.original.postedBy} />
),
meta: {
filter: {
@@ -167,23 +159,41 @@ const ReceiptsTable = memo(({ data, count, locations }: ReceiptsTableProps) => {
icon: <LuCalendar />,
},
},
- // {
- // id: "supplierId",
- // header: "Supplier",
- // cell: ({ row }) => {
- // return <SupplierAvatar supplierId={row.original.supplierId} />;
- // },
- // meta: {
- // filter: {
- // type: "static",
- // options: suppliers?.map((supplier) => ({
- // value: supplier.id,
- // label: supplier.name,
- // })),
- // },
- // icon: <LuUser />,
- // },
- // },
+ {
+ accessorKey: "assignee",
+ header: "Assignee",
+ cell: ({ row }) => (
+ <EmployeeAvatar employeeId={row.original.assignee} />
+ ),
+ meta: {
+ filter: {
+ type: "static",
+ options: people.map((employee) => ({
+ value: employee.id,
+ label: employee.name,
+ })),
+ },
+ icon: <LuUser />,
+ },
+ },
+ {
+ id: "supplierId",
+ header: "Supplier",
+ cell: ({ row }) => {
+ return <SupplierAvatar supplierId={row.original.supplierId} />;
+ },
+ meta: {
+ filter: {
+ type: "static",
+ options: suppliers?.map((supplier) => ({
+ value: supplier.id,
+ label: supplier.name,
+ })),
+ },
+ icon: <LuUser />,
+ },
+ },
+
{
accessorKey: "invoiced",
header: "Invoiced",
@@ -261,7 +271,7 @@ const ReceiptsTable = memo(({ data, count, locations }: ReceiptsTableProps) => {
];
return [...result, ...customColumns];
- }, [locations, people, customColumns]);
+ }, [people, suppliers, customColumns]);
const [selectedReceipt, setSelectedReceipt] = useState<Receipt | null>(null);
const deleteReceiptModal = useDisclosure();
diff --git a/apps/erp/app/modules/inventory/ui/useInventorySubmodules.tsx b/apps/erp/app/modules/inventory/ui/useInventorySubmodules.tsx
index 0a3aa93588..9684ff01c9 100644
--- a/apps/erp/app/modules/inventory/ui/useInventorySubmodules.tsx
+++ b/apps/erp/app/modules/inventory/ui/useInventorySubmodules.tsx
@@ -1,4 +1,4 @@
-import { LuArrowDownToLine, LuBox, LuTruck } from "react-icons/lu";
+import { LuBox, LuHandCoins, LuTruck } from "react-icons/lu";
import { usePermissions } from "~/hooks";
import type { AuthenticatedRouteGroup } from "~/types";
import { path } from "~/utils/path";
@@ -42,7 +42,7 @@ const inventoryRoutes: AuthenticatedRouteGroup[] = [
{
name: "Receipts",
to: path.to.receipts,
- icon: <LuArrowDownToLine />,
+ icon: <LuHandCoins />,
},
// {
// name: "Shipments",
diff --git a/apps/erp/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceHeader.tsx b/apps/erp/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceHeader.tsx
index 28e25a3793..210dddd060 100644
--- a/apps/erp/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceHeader.tsx
+++ b/apps/erp/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceHeader.tsx
@@ -14,8 +14,8 @@ import { Link, useParams } from "@remix-run/react";
import { useEffect, useState } from "react";
import { flushSync } from "react-dom";
import {
- LuArrowDownToLine,
LuCheckCheck,
+ LuHandCoins,
LuPanelLeft,
LuPanelRight,
LuShoppingCart,
@@ -156,11 +156,7 @@ const PurchaseInvoiceHeader = () => {
)}
{relatedDocs.receipts.length === 1 && (
- <Button
- variant="secondary"
- leftIcon={<LuArrowDownToLine />}
- asChild
- >
+ <Button variant="secondary" leftIcon={<LuHandCoins />} asChild>
<Link to={path.to.receipt(relatedDocs.receipts[0].id)}>
Receipt
</Link>
@@ -189,7 +185,7 @@ const PurchaseInvoiceHeader = () => {
{relatedDocs.receipts.length > 1 && (
<DropdownMenu>
<DropdownMenuTrigger asChild>
- <Button variant="secondary" leftIcon={<LuArrowDownToLine />}>
+ <Button variant="secondary" leftIcon={<LuHandCoins />}>
Receipts
</Button>
</DropdownMenuTrigger>
diff --git a/apps/erp/app/modules/items/items.models.ts b/apps/erp/app/modules/items/items.models.ts
index 53a7a5ebf6..edbf5911a0 100644
--- a/apps/erp/app/modules/items/items.models.ts
+++ b/apps/erp/app/modules/items/items.models.ts
@@ -15,7 +15,12 @@ export const configurationParameterDataTypes = [
"list",
] as const;
-export const itemTrackingTypes = ["Inventory", "Non-Inventory"] as const;
+export const itemTrackingTypes = [
+ "Inventory",
+ "Non-Inventory",
+ "Serial",
+ "Lot",
+] as const;
export const itemCostingMethods = [
"Standard",
diff --git a/apps/erp/app/modules/items/ui/Consumables/ConsumablesTable.tsx b/apps/erp/app/modules/items/ui/Consumables/ConsumablesTable.tsx
index 18a57c8a2e..f2de5bdb6d 100644
--- a/apps/erp/app/modules/items/ui/Consumables/ConsumablesTable.tsx
+++ b/apps/erp/app/modules/items/ui/Consumables/ConsumablesTable.tsx
@@ -78,7 +78,6 @@ const ConsumablesTable = memo(
cell: ({ row }) => (
<HStack className="py-1 min-w-[200px] truncate">
<ItemThumbnail
- size="sm"
thumbnailPath={row.original.thumbnailPath}
type="Consumable"
/>
@@ -332,7 +331,7 @@ const ConsumablesTable = memo(
</DropdownMenuPortal>
</DropdownMenuSub>
<DropdownMenuSub>
- <DropdownMenuSubTrigger>Inventory</DropdownMenuSubTrigger>
+ <DropdownMenuSubTrigger>Tracking Type</DropdownMenuSubTrigger>
<DropdownMenuPortal>
<DropdownMenuSubContent>
{itemTrackingTypes.map((type) => (
diff --git a/apps/erp/app/modules/items/ui/Materials/MaterialsTable.tsx b/apps/erp/app/modules/items/ui/Materials/MaterialsTable.tsx
index 8efd342947..d691f04847 100644
--- a/apps/erp/app/modules/items/ui/Materials/MaterialsTable.tsx
+++ b/apps/erp/app/modules/items/ui/Materials/MaterialsTable.tsx
@@ -377,7 +377,7 @@ const MaterialsTable = memo(({ data, tags, count }: MaterialsTableProps) => {
</DropdownMenuPortal>
</DropdownMenuSub>
<DropdownMenuSub>
- <DropdownMenuSubTrigger>Inventory</DropdownMenuSubTrigger>
+ <DropdownMenuSubTrigger>Tracking Type</DropdownMenuSubTrigger>
<DropdownMenuPortal>
<DropdownMenuSubContent>
{itemTrackingTypes.map((type) => (
diff --git a/apps/erp/app/modules/items/ui/Parts/PartsTable.tsx b/apps/erp/app/modules/items/ui/Parts/PartsTable.tsx
index 161a93b553..2e1ce91969 100644
--- a/apps/erp/app/modules/items/ui/Parts/PartsTable.tsx
+++ b/apps/erp/app/modules/items/ui/Parts/PartsTable.tsx
@@ -350,7 +350,7 @@ const PartsTable = memo(({ data, tags, count }: PartsTableProps) => {
</DropdownMenuPortal>
</DropdownMenuSub>
<DropdownMenuSub>
- <DropdownMenuSubTrigger>Inventory</DropdownMenuSubTrigger>
+ <DropdownMenuSubTrigger>Tracking Type</DropdownMenuSubTrigger>
<DropdownMenuPortal>
<DropdownMenuSubContent>
{itemTrackingTypes.map((type) => (
diff --git a/apps/erp/app/modules/items/ui/Tools/ToolsTable.tsx b/apps/erp/app/modules/items/ui/Tools/ToolsTable.tsx
index 6d057c8658..e5f3f40756 100644
--- a/apps/erp/app/modules/items/ui/Tools/ToolsTable.tsx
+++ b/apps/erp/app/modules/items/ui/Tools/ToolsTable.tsx
@@ -346,7 +346,7 @@ const ToolsTable = memo(({ data, tags, count }: ToolsTableProps) => {
</DropdownMenuPortal>
</DropdownMenuSub>
<DropdownMenuSub>
- <DropdownMenuSubTrigger>Inventory</DropdownMenuSubTrigger>
+ <DropdownMenuSubTrigger>Tracking Type</DropdownMenuSubTrigger>
<DropdownMenuPortal>
<DropdownMenuSubContent>
{itemTrackingTypes.map((type) => (
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobMaterialsTable.tsx b/apps/erp/app/modules/production/ui/Jobs/JobMaterialsTable.tsx
index 9f2d4d25f1..f8d96e13cc 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobMaterialsTable.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobMaterialsTable.tsx
@@ -159,7 +159,7 @@ const JobMaterialsTable = memo(({ data, count }: JobMaterialsTableProps) => {
},
cell: ({ row }) => {
const isInventoried =
- row.original.item?.itemTrackingType === "Inventory";
+ row.original.item?.itemTrackingType !== "Non-Inventory";
if (!isInventoried)
return (
<Badge variant="secondary">
diff --git a/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderHeader.tsx b/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderHeader.tsx
index da08f930f8..c623769510 100644
--- a/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderHeader.tsx
+++ b/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderHeader.tsx
@@ -14,13 +14,13 @@ import {
import { Link, useFetcher, useParams } from "@remix-run/react";
import {
- LuArrowDownToLine,
LuCheckCheck,
LuChevronDown,
LuCirclePlus,
LuCreditCard,
LuEye,
LuFile,
+ LuHandCoins,
LuPanelLeft,
LuPanelRight,
LuRefreshCw,
@@ -126,7 +126,7 @@ const PurchaseOrderHeader = () => {
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
- leftIcon={<LuArrowDownToLine />}
+ leftIcon={<LuHandCoins />}
variant={
["To Receive", "To Receive and Invoice"].includes(
routeData?.purchaseOrder?.status ?? ""
@@ -159,7 +159,7 @@ const PurchaseOrderHeader = () => {
{receipts.map((receipt) => (
<DropdownMenuItem key={receipt.id} asChild>
<Link to={path.to.receipt(receipt.id)}>
- <DropdownMenuIcon icon={<LuArrowDownToLine />} />
+ <DropdownMenuIcon icon={<LuHandCoins />} />
<HStack spacing={8}>
<span>{receipt.receiptId}</span>
<ReceiptStatus status={receipt.status} />
@@ -171,7 +171,7 @@ const PurchaseOrderHeader = () => {
</DropdownMenu>
) : (
<Button
- leftIcon={<LuArrowDownToLine />}
+ leftIcon={<LuHandCoins />}
isDisabled={
!["To Receive", "To Receive and Invoice"].includes(
routeData?.purchaseOrder?.status ?? ""
diff --git a/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrdersTable.tsx b/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrdersTable.tsx
index 0b990bdb76..a4dd895171 100644
--- a/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrdersTable.tsx
+++ b/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrdersTable.tsx
@@ -10,12 +10,12 @@ import { getLocalTimeZone, today } from "@internationalized/date";
import type { ColumnDef } from "@tanstack/react-table";
import { memo, useMemo, useState } from "react";
import {
- LuArrowDownToLine,
LuBookMarked,
LuCalendar,
LuContainer,
LuCreditCard,
LuDollarSign,
+ LuHandCoins,
LuPencil,
LuQrCode,
LuStar,
@@ -337,7 +337,7 @@ const PurchaseOrdersTable = memo(
receive(row);
}}
>
- <MenuIcon icon={<LuArrowDownToLine />} />
+ <MenuIcon icon={<LuHandCoins />} />
Receive
</MenuItem>
<MenuItem
diff --git a/apps/erp/app/modules/shared/imports.models.ts b/apps/erp/app/modules/shared/imports.models.ts
index 1d256164a8..0453cb2b82 100644
--- a/apps/erp/app/modules/shared/imports.models.ts
+++ b/apps/erp/app/modules/shared/imports.models.ts
@@ -4,7 +4,12 @@ import { z } from "zod";
// to avoid a circular dependency
const methodType = ["Buy", "Make", "Pick"] as const;
const itemReplenishmentSystems = ["Buy", "Make", "Buy and Make"] as const;
-const itemTrackingTypes = ["Inventory", "Non-Inventory"] as const;
+const itemTrackingTypes = [
+ "Inventory",
+ "Non-Inventory",
+ "Serial",
+ "Lot",
+] as const;
export const fieldMappings = {
customer: {
diff --git a/apps/erp/app/routes/x+/receipt+/$receiptId.tsx b/apps/erp/app/routes/x+/receipt+/$receiptId.tsx
index e6cef2eeaa..1dd66d1b4d 100644
--- a/apps/erp/app/routes/x+/receipt+/$receiptId.tsx
+++ b/apps/erp/app/routes/x+/receipt+/$receiptId.tsx
@@ -54,8 +54,11 @@ export default function ReceiptRoute() {
<PanelProvider>
<div className="flex flex-col h-[calc(100dvh-49px)] overflow-hidden w-full">
<ReceiptHeader />
- <div className="flex h-[calc(100dvh-99px)] overflow-hidden w-full">
- <VStack spacing={4} className="h-full p-2 w-full max-w-5xl mx-auto">
+ <div className="flex h-[calc(100dvh-99px)] overflow-y-auto scrollbar-hide w-full">
+ <VStack
+ spacing={4}
+ className="h-full p-2 w-full max-w-5xl mx-auto pb-32"
+ >
<Outlet />
</VStack>
</div>
diff --git a/apps/erp/app/routes/x+/receipt+/_layout.tsx b/apps/erp/app/routes/x+/receipt+/_layout.tsx
index c849336591..c513f13b2b 100644
--- a/apps/erp/app/routes/x+/receipt+/_layout.tsx
+++ b/apps/erp/app/routes/x+/receipt+/_layout.tsx
@@ -13,6 +13,6 @@ export const handle: Handle = {
module: "inventory",
};
-export default function ReceiptsRoute() {
+export default function ReceiptRoute() {
return <Outlet />;
}
diff --git a/packages/database/supabase/functions/import-csv/index.ts b/packages/database/supabase/functions/import-csv/index.ts
index ecaf508036..0413332430 100644
--- a/packages/database/supabase/functions/import-csv/index.ts
+++ b/packages/database/supabase/functions/import-csv/index.ts
@@ -361,7 +361,12 @@ serve(async (req: Request) => {
.enum(["Buy", "Make", "Buy and Make"])
.optional(),
defaultMethodType: z.enum(["Buy", "Make", "Pick"]).optional(),
- itemTrackingType: z.enum(["Inventory", "Non-Inventory"]),
+ itemTrackingType: z.enum([
+ "Inventory",
+ "Non-Inventory",
+ "Serial",
+ "Lot",
+ ]),
});
const materialValidator = itemValidator.extend({
diff --git a/packages/database/supabase/functions/post-purchase-invoice/index.ts b/packages/database/supabase/functions/post-purchase-invoice/index.ts
index 829fc732df..1a7918ad9e 100644
--- a/packages/database/supabase/functions/post-purchase-invoice/index.ts
+++ b/packages/database/supabase/functions/post-purchase-invoice/index.ts
@@ -1014,6 +1014,7 @@ serve(async (req: Request) => {
supplierId: purchaseInvoice.data.supplierId,
status: "Posted",
postingDate: today,
+ postedBy: userId,
invoiced: true,
companyId,
createdBy: purchaseInvoice.data.createdBy,
diff --git a/packages/database/supabase/functions/post-receipt/index.ts b/packages/database/supabase/functions/post-receipt/index.ts
index 0f4a9f6095..e992ae5fd9 100644
--- a/packages/database/supabase/functions/post-receipt/index.ts
+++ b/packages/database/supabase/functions/post-receipt/index.ts
@@ -745,6 +745,7 @@ serve(async (req: Request) => {
.set({
status: "Posted",
postingDate: today,
+ postedBy: userId,
})
.where("id", "=", receiptId)
.execute();
diff --git a/packages/database/supabase/migrations/20250125094053_traceability.sql b/packages/database/supabase/migrations/20250125094053_traceability.sql
new file mode 100644
index 0000000000..c6b080f4f4
--- /dev/null
+++ b/packages/database/supabase/migrations/20250125094053_traceability.sql
@@ -0,0 +1,4 @@
+ALTER TABLE "receipt" ADD COLUMN "postedBy" TEXT REFERENCES "user"("id") ON DELETE CASCADE;
+
+ALTER TYPE "itemTrackingType" ADD VALUE IF NOT EXISTS 'Serial';
+ALTER TYPE "itemTrackingType" ADD VALUE IF NOT EXISTS 'Lot';