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.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
fix: only pull shelves that are associated with the location
Brad Barbinf372ccdd881d
diff --git a/apps/erp/app/modules/inventory/ui/Inventory/InventoryDetails.tsx b/apps/erp/app/modules/inventory/ui/Inventory/InventoryDetails.tsxindex 61cfec92f7..e6b78d09fd 100644--- a/apps/erp/app/modules/inventory/ui/Inventory/InventoryDetails.tsx+++ b/apps/erp/app/modules/inventory/ui/Inventory/InventoryDetails.tsx@@ -14,7 +14,6 @@ import type {itemTrackingTypes,pickMethodValidator,} from "~/modules/items";-import type { ListItem } from "~/types";import InventoryShelves from "./InventoryShelves";type InventoryDetailsProps = {@@ -23,7 +22,7 @@ type InventoryDetailsProps = {itemTrackingType: (typeof itemTrackingTypes)[number];pickMethod: z.infer<typeof pickMethodValidator>;quantities: ItemQuantities | null;- shelves: ListItem[];+ shelves: { value: string; label: string }[];};const InventoryDetails = ({diff --git a/apps/erp/app/modules/inventory/ui/Inventory/InventoryShelves.tsx b/apps/erp/app/modules/inventory/ui/Inventory/InventoryShelves.tsxindex 6f1654b43e..22f09ba67f 100644--- a/apps/erp/app/modules/inventory/ui/Inventory/InventoryShelves.tsx+++ b/apps/erp/app/modules/inventory/ui/Inventory/InventoryShelves.tsx@@ -43,7 +43,6 @@ import type {itemTrackingTypes,pickMethodValidator,} from "~/modules/items";-import type { ListItem } from "~/types";import { path } from "~/utils/path";import { inventoryAdjustmentValidator } from "../../inventory.models";@@ -52,7 +51,7 @@ type InventoryShelvesProps = {itemShelfQuantities: ItemShelfQuantities[];itemUnitOfMeasureCode: string;itemTrackingType: (typeof itemTrackingTypes)[number];- shelves: ListItem[];+ shelves: { value: string; label: string }[];};const InventoryShelves = ({@@ -111,7 +110,7 @@ const InventoryShelves = ({<Tr><Th>Shelf</Th>- <Th>QoH</Th>+ <Th>Quantity</Th><Th>Tracking ID</Th><Th className="flex flex-shrink-0 justify-end" /></Tr>@@ -122,7 +121,7 @@ const InventoryShelves = ({.map((item, index) => (<Tr key={index}><Td>- {shelves.find((s) => s.id === item.shelfId)?.name ||+ {shelves.find((s) => s.value === item.shelfId)?.label ||item.shelfId}</Td>diff --git a/apps/erp/app/modules/items/ui/Item/PickMethodForm.tsx b/apps/erp/app/modules/items/ui/Item/PickMethodForm.tsxindex c67e597725..7495fe0156 100644--- a/apps/erp/app/modules/items/ui/Item/PickMethodForm.tsx+++ b/apps/erp/app/modules/items/ui/Item/PickMethodForm.tsx@@ -24,8 +24,8 @@ import { pickMethodValidator } from "../../items.models";type PickMethodFormProps = {initialValues: z.infer<typeof pickMethodValidator>;locations: ListItem[];- shelves: ListItem[];type: "Part" | "Material" | "Tool" | "Consumable";+ shelves: { value: string; label: string }[];};const PickMethodForm = ({@@ -36,10 +36,6 @@ const PickMethodForm = ({}: PickMethodFormProps) => {const permissions = usePermissions();- const shelfOptions = shelves.map((shelf) => ({- value: shelf.id,- label: shelf.name,- }));const locationOptions = locations.map((location) => ({label: location.name,value: location.id,@@ -82,7 +78,7 @@ const PickMethodForm = ({<ComboboxFormFieldname="defaultShelfId"label="Default Shelf"- options={shelfOptions}+ options={shelves}className="w-full"/>diff --git a/apps/erp/app/modules/purchasing/ui/Planning/PurchasingPlanningTable.tsx b/apps/erp/app/modules/purchasing/ui/Planning/PurchasingPlanningTable.tsxindex c94b0b3af6..80d9ab305d 100644--- a/apps/erp/app/modules/purchasing/ui/Planning/PurchasingPlanningTable.tsx+++ b/apps/erp/app/modules/purchasing/ui/Planning/PurchasingPlanningTable.tsx@@ -505,6 +505,27 @@ const OrderDrawer = memo(};});++ // Auto-select the newly added supplier if it's the only one+ if (data.length === 1 && selectedItem.id) {+ onSupplierChange(+ selectedItem.id,+ data[0].supplierId+ );++ const updatedOrders = orders.map(+ (order) => ({+ ...order,+ supplierId: data[0].supplierId,+ })+ );+ setOrders(selectedItem, updatedOrders);++ toast.success(+ "Supplier added and selected"+ );+ setActiveTab("ordering");+ }}});}diff --git a/apps/erp/app/routes/x+/consumable+/$itemId.view.inventory.tsx b/apps/erp/app/routes/x+/consumable+/$itemId.view.inventory.tsxindex 565c4f76e1..02d57265a3 100644--- a/apps/erp/app/routes/x+/consumable+/$itemId.view.inventory.tsx+++ b/apps/erp/app/routes/x+/consumable+/$itemId.view.inventory.tsx@@ -6,6 +6,7 @@ import { VStack } from "@carbon/react";import { useLoaderData } from "@remix-run/react";import type { ActionFunctionArgs, LoaderFunctionArgs } from "@vercel/remix";import { json, redirect } from "@vercel/remix";+import { useShelves } from "~/components/Form/Shelf";import { useRouteData } from "~/hooks";import { InventoryDetails } from "~/modules/inventory";@@ -194,7 +195,6 @@ export async function action({ request, params }: ActionFunctionArgs) {export default function ConsumableInventoryRoute() {const sharedConsumablesData = useRouteData<{locations: ListItem[];- shelves: ListItem[];unitOfMeasures: UnitOfMeasureListItem[];}>(path.to.consumableRoot);@@ -214,6 +214,8 @@ export default function ConsumableInventoryRoute() {...getCustomFields(consumableInventory.customFields ?? {}),};+ const shelves = useShelves(consumableInventory?.locationId);+const [items] = useItems();const itemTrackingType = items.find((i) => i.id === itemId)?.itemTrackingType;@@ -223,7 +225,7 @@ export default function ConsumableInventoryRoute() {key={initialValues.itemId}initialValues={initialValues}locations={sharedConsumablesData?.locations ?? []}- shelves={sharedConsumablesData?.shelves ?? []}+ shelves={shelves.options}type="Part"/><InventoryDetails@@ -232,7 +234,7 @@ export default function ConsumableInventoryRoute() {itemTrackingType={itemTrackingType ?? "Inventory"}pickMethod={initialValues}quantities={quantities}- shelves={sharedConsumablesData?.shelves ?? []}+ shelves={shelves.options}/></VStack>);diff --git a/apps/erp/app/routes/x+/consumable+/_layout.tsx b/apps/erp/app/routes/x+/consumable+/_layout.tsxindex 24a372dae2..2d4892cd71 100644--- a/apps/erp/app/routes/x+/consumable+/_layout.tsx+++ b/apps/erp/app/routes/x+/consumable+/_layout.tsx@@ -1,7 +1,6 @@import { requirePermissions } from "@carbon/auth/auth.server";import { Outlet } from "@remix-run/react";import type { LoaderFunctionArgs, MetaFunction } from "@vercel/remix";-import { getShelvesList } from "~/modules/inventory";import { getUnitOfMeasuresList } from "~/modules/items";import { getLocationsList } from "~/modules/resources";import type { Handle } from "~/utils/handle";@@ -26,16 +25,14 @@ export async function loader({ request }: LoaderFunctionArgs) {view: "parts",});- const [unitOfMeasures, locations, shelves] = await Promise.all([+ const [unitOfMeasures, locations] = await Promise.all([getUnitOfMeasuresList(client, companyId),getLocationsList(client, companyId),- getShelvesList(client, companyId),]);return {locations: locations?.data ?? [],unitOfMeasures: unitOfMeasures?.data ?? [],- shelves: shelves?.data ?? [],};}diff --git a/apps/erp/app/routes/x+/inventory+/_layout.tsx b/apps/erp/app/routes/x+/inventory+/_layout.tsxindex 8e560dbb3d..ca0dd7bab5 100644--- a/apps/erp/app/routes/x+/inventory+/_layout.tsx+++ b/apps/erp/app/routes/x+/inventory+/_layout.tsx@@ -4,7 +4,7 @@ import { Outlet } from "@remix-run/react";import type { LoaderFunctionArgs, MetaFunction } from "@vercel/remix";import { GroupedContentSidebar } from "~/components/Layout";import { CollapsibleSidebarProvider } from "~/components/Layout/Navigation";-import { getShelvesList, useInventorySubmodules } from "~/modules/inventory";+import { useInventorySubmodules } from "~/modules/inventory";import { getUnitOfMeasuresList } from "~/modules/items";import { getLocationsList } from "~/modules/resources";import type { Handle } from "~/utils/handle";@@ -29,15 +29,13 @@ export async function loader({ request }: LoaderFunctionArgs) {view: "inventory",});- const [unitOfMeasures, locations, shelves] = await Promise.all([+ const [unitOfMeasures, locations] = await Promise.all([getUnitOfMeasuresList(client, companyId),getLocationsList(client, companyId),- getShelvesList(client, companyId),]);return {locations: locations?.data ?? [],- shelves: shelves?.data ?? [],unitOfMeasures: unitOfMeasures?.data ?? [],};}diff --git a/apps/erp/app/routes/x+/inventory+/quantities+/$itemId.details.tsx b/apps/erp/app/routes/x+/inventory+/quantities+/$itemId.details.tsxindex fad557c9c8..4f909bfa4c 100644--- a/apps/erp/app/routes/x+/inventory+/quantities+/$itemId.details.tsx+++ b/apps/erp/app/routes/x+/inventory+/quantities+/$itemId.details.tsx@@ -4,7 +4,7 @@ import { flash } from "@carbon/auth/session.server";import { useLoaderData } from "@remix-run/react";import type { LoaderFunctionArgs } from "@vercel/remix";import { json, redirect } from "@vercel/remix";-import { useRouteData } from "~/hooks";+import { useShelves } from "~/components/Form/Shelf";import { InventoryDetails } from "~/modules/inventory";import {getItem,@@ -16,7 +16,6 @@ import {import { getLocationsList } from "~/modules/resources";import { getUserDefaults } from "~/modules/users/users.server";import { useItems } from "~/stores/items";-import type { ListItem } from "~/types";import { path } from "~/utils/path";export async function loader({ request, params }: LoaderFunctionArgs) {@@ -144,15 +143,13 @@ export default function ItemInventoryRoute() {const { pickMethod, quantities, itemShelfQuantities, item } =useLoaderData<typeof loader>();- const routeData = useRouteData<{- shelves: ListItem[];- }>(path.to.inventoryRoot);-const [items] = useItems();const itemTrackingType = items.find((i) => i.id === item.id)?.itemTrackingType;+ const shelves = useShelves(pickMethod?.locationId);+return (<InventoryDetailsitemShelfQuantities={itemShelfQuantities}@@ -163,7 +160,7 @@ export default function ItemInventoryRoute() {defaultShelfId: pickMethod.defaultShelfId ?? undefined,}}quantities={quantities}- shelves={routeData?.shelves ?? []}+ shelves={shelves.options}/>);}diff --git a/apps/erp/app/routes/x+/material+/$itemId.view.inventory.tsx b/apps/erp/app/routes/x+/material+/$itemId.view.inventory.tsxindex 495340c215..b3b6a970e2 100644--- a/apps/erp/app/routes/x+/material+/$itemId.view.inventory.tsx+++ b/apps/erp/app/routes/x+/material+/$itemId.view.inventory.tsx@@ -6,6 +6,7 @@ import { VStack } from "@carbon/react";import { useLoaderData } from "@remix-run/react";import type { ActionFunctionArgs, LoaderFunctionArgs } from "@vercel/remix";import { json, redirect } from "@vercel/remix";+import { useShelves } from "~/components/Form/Shelf";import { useRouteData } from "~/hooks";import { InventoryDetails } from "~/modules/inventory";import type { Material, UnitOfMeasureListItem } from "~/modules/items";@@ -190,7 +191,6 @@ export async function action({ request, params }: ActionFunctionArgs) {export default function MaterialInventoryRoute() {const sharedMaterialsData = useRouteData<{locations: ListItem[];- shelves: ListItem[];unitOfMeasures: UnitOfMeasureListItem[];}>(path.to.materialRoot);@@ -213,13 +213,15 @@ export default function MaterialInventoryRoute() {const [items] = useItems();const itemTrackingType = items.find((i) => i.id === itemId)?.itemTrackingType;+ const shelves = useShelves(materialInventory?.locationId);+return (<VStack spacing={2} className="p-2"><PickMethodFormkey={initialValues.itemId}initialValues={initialValues}locations={sharedMaterialsData?.locations ?? []}- shelves={sharedMaterialsData?.shelves ?? []}+ shelves={shelves.options}type="Material"/><InventoryDetails@@ -228,7 +230,7 @@ export default function MaterialInventoryRoute() {itemTrackingType={itemTrackingType ?? "Inventory"}pickMethod={initialValues}quantities={quantities}- shelves={sharedMaterialsData?.shelves ?? []}+ shelves={shelves.options}/></VStack>);diff --git a/apps/erp/app/routes/x+/material+/_layout.tsx b/apps/erp/app/routes/x+/material+/_layout.tsxindex dbf36f31e4..36d27365fe 100644--- a/apps/erp/app/routes/x+/material+/_layout.tsx+++ b/apps/erp/app/routes/x+/material+/_layout.tsx@@ -1,7 +1,6 @@import { requirePermissions } from "@carbon/auth/auth.server";import { Outlet } from "@remix-run/react";import type { LoaderFunctionArgs, MetaFunction } from "@vercel/remix";-import { getShelvesList } from "~/modules/inventory";import {getMaterialFormsList,getMaterialSubstancesList,@@ -30,21 +29,18 @@ export async function loader({ request }: LoaderFunctionArgs) {view: "parts",});- const [unitOfMeasures, locations, forms, substances, shelves] =- await Promise.all([- getUnitOfMeasuresList(client, companyId),- getLocationsList(client, companyId),- getMaterialFormsList(client, companyId),- getMaterialSubstancesList(client, companyId),- getShelvesList(client, companyId),- ]);+ const [unitOfMeasures, locations, forms, substances] = await Promise.all([+ getUnitOfMeasuresList(client, companyId),+ getLocationsList(client, companyId),+ getMaterialFormsList(client, companyId),+ getMaterialSubstancesList(client, companyId),+ ]);return {locations: locations?.data ?? [],unitOfMeasures: unitOfMeasures?.data ?? [],forms: forms?.data ?? [],substances: substances?.data ?? [],- shelves: shelves?.data ?? [],};}diff --git a/apps/erp/app/routes/x+/part+/$itemId.view.inventory.tsx b/apps/erp/app/routes/x+/part+/$itemId.view.inventory.tsxindex 68cdf83f7f..0ee911c763 100644--- a/apps/erp/app/routes/x+/part+/$itemId.view.inventory.tsx+++ b/apps/erp/app/routes/x+/part+/$itemId.view.inventory.tsx@@ -6,6 +6,7 @@ import { VStack } from "@carbon/react";import { useLoaderData } from "@remix-run/react";import type { ActionFunctionArgs, LoaderFunctionArgs } from "@vercel/remix";import { json, redirect } from "@vercel/remix";+import { useShelves } from "~/components/Form/Shelf";import { useRouteData } from "~/hooks";import { InventoryDetails } from "~/modules/inventory";import type { PartSummary, UnitOfMeasureListItem } from "~/modules/items";@@ -182,7 +183,6 @@ export async function action({ request, params }: ActionFunctionArgs) {export default function PartInventoryRoute() {const sharedPartsData = useRouteData<{locations: ListItem[];- shelves: ListItem[];unitOfMeasures: UnitOfMeasureListItem[];}>(path.to.partRoot);@@ -204,13 +204,15 @@ export default function PartInventoryRoute() {const [items] = useItems();const itemTrackingType = items.find((i) => i.id === itemId)?.itemTrackingType;+ const shelves = useShelves(partInventory?.locationId);+return (<VStack spacing={2} className="p-2"><PickMethodFormkey={initialValues.itemId}initialValues={initialValues}locations={sharedPartsData?.locations ?? []}- shelves={sharedPartsData?.shelves ?? []}+ shelves={shelves.options}type="Part"/><InventoryDetails@@ -219,7 +221,7 @@ export default function PartInventoryRoute() {itemTrackingType={itemTrackingType ?? "Inventory"}pickMethod={initialValues}quantities={quantities}- shelves={sharedPartsData?.shelves ?? []}+ shelves={shelves.options}/></VStack>);diff --git a/apps/erp/app/routes/x+/part+/_layout.tsx b/apps/erp/app/routes/x+/part+/_layout.tsxindex ddcd42eb72..f732583ddc 100644--- a/apps/erp/app/routes/x+/part+/_layout.tsx+++ b/apps/erp/app/routes/x+/part+/_layout.tsx@@ -1,7 +1,6 @@import { requirePermissions } from "@carbon/auth/auth.server";import { Outlet } from "@remix-run/react";import type { LoaderFunctionArgs, MetaFunction } from "@vercel/remix";-import { getShelvesList } from "~/modules/inventory";import { getUnitOfMeasuresList } from "~/modules/items";import { getLocationsList } from "~/modules/resources";import type { Handle } from "~/utils/handle";@@ -22,15 +21,13 @@ export async function loader({ request }: LoaderFunctionArgs) {view: "parts",});- const [unitOfMeasures, locations, shelves] = await Promise.all([+ const [unitOfMeasures, locations] = await Promise.all([getUnitOfMeasuresList(client, companyId),getLocationsList(client, companyId),- getShelvesList(client, companyId),]);return {locations: locations?.data ?? [],- shelves: shelves?.data ?? [],unitOfMeasures: unitOfMeasures?.data ?? [],};}diff --git a/apps/erp/app/routes/x+/tool+/$itemId.view.inventory.tsx b/apps/erp/app/routes/x+/tool+/$itemId.view.inventory.tsxindex ef50282d0e..4d6500bf18 100644--- a/apps/erp/app/routes/x+/tool+/$itemId.view.inventory.tsx+++ b/apps/erp/app/routes/x+/tool+/$itemId.view.inventory.tsx@@ -6,6 +6,7 @@ import { VStack } from "@carbon/react";import { useLoaderData } from "@remix-run/react";import type { ActionFunctionArgs, LoaderFunctionArgs } from "@vercel/remix";import { json, redirect } from "@vercel/remix";+import { useShelves } from "~/components/Form/Shelf";import { useRouteData } from "~/hooks";import { InventoryDetails } from "~/modules/inventory";import type { ToolSummary, UnitOfMeasureListItem } from "~/modules/items";@@ -182,7 +183,6 @@ export async function action({ request, params }: ActionFunctionArgs) {export default function ToolInventoryRoute() {const sharedToolsData = useRouteData<{locations: ListItem[];- shelves: ListItem[];unitOfMeasures: UnitOfMeasureListItem[];}>(path.to.toolRoot);@@ -204,13 +204,15 @@ export default function ToolInventoryRoute() {const [items] = useItems();const itemTrackingType = items.find((i) => i.id === itemId)?.itemTrackingType;+ const shelves = useShelves(toolInventory?.locationId);+return (<VStack spacing={2} className="p-2"><PickMethodFormkey={initialValues.itemId}initialValues={initialValues}locations={sharedToolsData?.locations ?? []}- shelves={sharedToolsData?.shelves ?? []}+ shelves={shelves.options}type="Part"/><InventoryDetails@@ -219,7 +221,7 @@ export default function ToolInventoryRoute() {itemTrackingType={itemTrackingType ?? "Inventory"}pickMethod={initialValues}quantities={quantities}- shelves={sharedToolsData?.shelves ?? []}+ shelves={shelves.options}/></VStack>);diff --git a/apps/erp/app/routes/x+/tool+/_layout.tsx b/apps/erp/app/routes/x+/tool+/_layout.tsxindex 06a0421eed..d7d145accf 100644--- a/apps/erp/app/routes/x+/tool+/_layout.tsx+++ b/apps/erp/app/routes/x+/tool+/_layout.tsx@@ -1,7 +1,6 @@import { requirePermissions } from "@carbon/auth/auth.server";import { Outlet } from "@remix-run/react";import type { LoaderFunctionArgs, MetaFunction } from "@vercel/remix";-import { getShelvesList } from "~/modules/inventory";import { getUnitOfMeasuresList } from "~/modules/items";import { getLocationsList } from "~/modules/resources";import type { Handle } from "~/utils/handle";@@ -26,15 +25,13 @@ export async function loader({ request }: LoaderFunctionArgs) {view: "parts",});- const [unitOfMeasures, locations, shelves] = await Promise.all([+ const [unitOfMeasures, locations] = await Promise.all([getUnitOfMeasuresList(client, companyId),getLocationsList(client, companyId),- getShelvesList(client, companyId),]);return {locations: locations?.data ?? [],- shelves: shelves?.data ?? [],unitOfMeasures: unitOfMeasures?.data ?? [],};}diff --git a/packages/jobs/trigger/sales-order-to-jobs.ts b/packages/jobs/trigger/sales-order-to-jobs.tsindex 0bff73c2d1..5a0eab88fa 100644--- a/packages/jobs/trigger/sales-order-to-jobs.ts+++ b/packages/jobs/trigger/sales-order-to-jobs.ts@@ -156,7 +156,7 @@ export const salesOrderToJobsTask = task({sourceId: `${quoteId}:${line.id}`,targetId: createJob.data.id,companyId,- createdBy: userId,+ userId,},});@@ -175,7 +175,7 @@ export const salesOrderToJobsTask = task({sourceId: data.itemId,targetId: createJob.data.id,companyId,- createdBy: userId,+ userId,},});