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 replenishment system and reorder policy to inventory table

Brad Barbin7f63ae3686ec
diff --git a/apps/erp/app/modules/inventory/ui/Inventory/InventoryTable.tsx b/apps/erp/app/modules/inventory/ui/Inventory/InventoryTable.tsx
index 26bf8d1be2..680765eac9 100644
--- a/apps/erp/app/modules/inventory/ui/Inventory/InventoryTable.tsx
+++ b/apps/erp/app/modules/inventory/ui/Inventory/InventoryTable.tsx
@@ -17,10 +17,12 @@ import {
LuBox,
LuCalculator,
LuCheck,
+ LuCircleCheck,
LuCirclePlay,
LuClock,
LuExpand,
LuGlassWater,
+ LuLoaderCircle,
LuMoveDown,
LuMoveUp,
LuPackage,
@@ -42,6 +44,14 @@ import { useLocations } from "~/components/Form/Location";
import { useUnitOfMeasure } from "~/components/Form/UnitOfMeasure";
import { useFilters } from "~/components/Table/components/Filter/useFilters";
import { useUrlParams } from "~/hooks";
+import {
+ itemReorderingPolicies,
+ itemReplenishmentSystems,
+} from "~/modules/items";
+import {
+ ItemReorderPolicy,
+ getReorderPolicyDescription,
+} from "~/modules/items/ui/Item/ItemReorderPolicy";
import type { action as mrpAction } from "~/routes/api+/mrp";
import type { ListItem } from "~/types";
import { path } from "~/utils/path";
@@ -121,6 +131,59 @@ const InventoryTable = memo(
icon: <LuClock />,
},
},
+ {
+ accessorKey: "reorderingPolicy",
+ header: "Reorder Policy",
+ cell: ({ row }) => {
+ return (
+ <HStack>
+ <Tooltip>
+ <TooltipTrigger>
+ <ItemReorderPolicy
+ reorderingPolicy={row.original.reorderingPolicy}
+ />
+ </TooltipTrigger>
+ <TooltipContent>
+ {getReorderPolicyDescription(row.original)}
+ </TooltipContent>
+ </Tooltip>
+ </HStack>
+ );
+ },
+ meta: {
+ filter: {
+ type: "static",
+ options: itemReorderingPolicies.map((policy) => ({
+ label: <ItemReorderPolicy reorderingPolicy={policy} />,
+ value: policy,
+ })),
+ },
+ icon: <LuCircleCheck />,
+ },
+ },
+ {
+ accessorKey: "replenishmentSystem",
+ header: "Replenishment",
+ cell: (item) => <Enumerable value={item.getValue<string>()} />,
+ meta: {
+ filter: {
+ type: "static",
+ options: itemReplenishmentSystems.map((type) => ({
+ value: type,
+ label: <Enumerable value={type} />,
+ })),
+ },
+ icon: <LuLoaderCircle />,
+ },
+ },
+ {
+ accessorKey: "leadTime",
+ header: "Lead Time",
+ cell: ({ row }) => numberFormatter.format(row.original.leadTime),
+ meta: {
+ icon: <LuClock />,
+ },
+ },
{
accessorKey: "usageLast30Days",
header: "Usage/Day (30d)",
diff --git a/apps/erp/app/modules/items/ui/Item/ItemReorderPolicy.tsx b/apps/erp/app/modules/items/ui/Item/ItemReorderPolicy.tsx
index 806e2f1a3a..b124556744 100644
--- a/apps/erp/app/modules/items/ui/Item/ItemReorderPolicy.tsx
+++ b/apps/erp/app/modules/items/ui/Item/ItemReorderPolicy.tsx
@@ -11,6 +11,7 @@ import type {
PurchasingPlanningItem,
} from "~/modules/purchasing";
import type { Item } from "~/stores";
+import type { ItemReorderingPolicy } from "../../types";
export function ItemReorderPolicy({
reorderingPolicy,
@@ -47,9 +48,14 @@ export function ItemReorderPolicy({
}
}
-export function getReorderPolicyDescription(
- itemPlanning: ProductionPlanningItem | PurchasingPlanningItem
-) {
+export function getReorderPolicyDescription(itemPlanning: {
+ reorderingPolicy: ItemReorderingPolicy;
+ reorderPoint: number;
+ reorderQuantity: number;
+ maximumInventoryQuantity: number;
+ demandAccumulationPeriod: number;
+ demandAccumulationSafetyStock: number;
+}) {
const reorderPoint = itemPlanning.reorderPoint;
switch (itemPlanning.reorderingPolicy) {
case "Manual Reorder":
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index f390011aed..018499e4d8 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -47050,6 +47050,17 @@ export type Database = {
materialTypeId: string
thumbnailPath: string
unitOfMeasureCode: string
+ leadTime: number
+ lotSize: number
+ reorderingPolicy: Database["public"]["Enums"]["itemReorderingPolicy"]
+ demandAccumulationPeriod: number
+ demandAccumulationSafetyStock: number
+ reorderPoint: number
+ reorderQuantity: number
+ minimumOrderQuantity: number
+ maximumOrderQuantity: number
+ maximumInventoryQuantity: number
+ orderMultiple: number
quantityOnHand: number
quantityOnSalesOrder: number
quantityOnPurchaseOrder: number
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index f390011aed..018499e4d8 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -47050,6 +47050,17 @@ export type Database = {
materialTypeId: string
thumbnailPath: string
unitOfMeasureCode: string
+ leadTime: number
+ lotSize: number
+ reorderingPolicy: Database["public"]["Enums"]["itemReorderingPolicy"]
+ demandAccumulationPeriod: number
+ demandAccumulationSafetyStock: number
+ reorderPoint: number
+ reorderQuantity: number
+ minimumOrderQuantity: number
+ maximumOrderQuantity: number
+ maximumInventoryQuantity: number
+ orderMultiple: number
quantityOnHand: number
quantityOnSalesOrder: number
quantityOnPurchaseOrder: number
diff --git a/packages/database/supabase/migrations/20250908232732_days-in-quantities.sql b/packages/database/supabase/migrations/20250908232732_days-in-quantities.sql
index 87082802dc..384005cdbb 100644
--- a/packages/database/supabase/migrations/20250908232732_days-in-quantities.sql
+++ b/packages/database/supabase/migrations/20250908232732_days-in-quantities.sql
@@ -23,6 +23,17 @@ CREATE OR REPLACE FUNCTION get_inventory_quantities(company_id TEXT, location_id
"materialTypeId" TEXT,
"thumbnailPath" TEXT,
"unitOfMeasureCode" TEXT,
+ "leadTime" INTEGER,
+ "lotSize" INTEGER,
+ "reorderingPolicy" "itemReorderingPolicy",
+ "demandAccumulationPeriod" INTEGER,
+ "demandAccumulationSafetyStock" NUMERIC,
+ "reorderPoint" INTEGER,
+ "reorderQuantity" INTEGER,
+ "minimumOrderQuantity" INTEGER,
+ "maximumOrderQuantity" INTEGER,
+ "maximumInventoryQuantity" NUMERIC,
+ "orderMultiple" INTEGER,
"quantityOnHand" NUMERIC,
"quantityOnSalesOrder" NUMERIC,
"quantityOnPurchaseOrder" NUMERIC,
@@ -152,6 +163,17 @@ SELECT
ELSE i."thumbnailPath"
END AS "thumbnailPath",
i."unitOfMeasureCode",
+ ir."leadTime",
+ ir."lotSize",
+ ip."reorderingPolicy",
+ ip."demandAccumulationPeriod",
+ ip."demandAccumulationSafetyStock",
+ ip."reorderPoint",
+ ip."reorderQuantity",
+ ip."minimumOrderQuantity",
+ ip."maximumOrderQuantity",
+ ip."maximumInventoryQuantity",
+ ip."orderMultiple",
COALESCE(il."quantityOnHand", 0) AS "quantityOnHand",
COALESCE(so."quantityOnSalesOrder", 0) AS "quantityOnSalesOrder",
COALESCE(po."quantityOnPurchaseOrder", 0) AS "quantityOnPurchaseOrder",
@@ -177,6 +199,8 @@ FROM
LEFT JOIN "materialFinish" mf ON m."finishId" = mf."id"
LEFT JOIN "materialGrade" mg ON m."gradeId" = mg."id"
LEFT JOIN "materialType" mt ON m."materialTypeId" = mt."id"
+ LEFT JOIN "itemReplenishment" ir ON i."id" = ir."itemId"
+ LEFT JOIN "itemPlanning" ip ON i."id" = ip."itemId" AND ip."locationId" = location_id
WHERE
i."itemTrackingType" <> 'Non-Inventory' AND i."companyId" = company_id;
END;