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.

refactor: enhance supplier quote line item handling

naveenkash90ad8b71e33d
diff --git a/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteExplorer.tsx b/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteExplorer.tsx
index a6148fd906..fce69b4f28 100644
--- a/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteExplorer.tsx
+++ b/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteExplorer.tsx
@@ -262,6 +262,7 @@ function SupplierQuoteLineItem({
const { id, lineId } = useParams();
if (!id) throw new Error("Could not find id");
const [items] = useItems();
+ const itemType = items.find((i) => i.id === line.itemId)?.type;
const permissions = usePermissions();
const disclosure = useDisclosure();
const location = useOptimisticLocation();
@@ -331,25 +332,29 @@ function SupplierQuoteLineItem({
<Trans>Delete Line</Trans>
</DropdownMenuItem>
- {/* @ts-expect-error */}
- {methodItemType.includes(line.supplierQuoteLineType ?? "") && (
- <DropdownMenuItem
- asChild
- onClick={(e) => e.stopPropagation()}
- >
- <Link
- to={getLinkToItemDetails(
- line.supplierQuoteLineType as MethodItemType,
- line.itemId!
- )}
+ {itemType &&
+ methodItemType.includes(itemType as MethodItemType) && (
+ <DropdownMenuItem
+ asChild
+ onClick={(e) => e.stopPropagation()}
>
- <DropdownMenuIcon
- icon={<MethodItemTypeIcon type="Part" />}
- />
- <Trans>View Item Master</Trans>
- </Link>
- </DropdownMenuItem>
- )}
+ <Link
+ to={getLinkToItemDetails(
+ itemType as MethodItemType,
+ line.itemId!
+ )}
+ >
+ <DropdownMenuIcon
+ icon={
+ <MethodItemTypeIcon
+ type={itemType as MethodItemType}
+ />
+ }
+ />
+ <Trans>View Item Master</Trans>
+ </Link>
+ </DropdownMenuItem>
+ )}
</DropdownMenuContent>
</DropdownMenu>
</div>
diff --git a/apps/erp/app/routes/x+/purchasing-rfq+/$rfqId.convert.tsx b/apps/erp/app/routes/x+/purchasing-rfq+/$rfqId.convert.tsx
index 3ca6c4ec68..e94b064d70 100644
--- a/apps/erp/app/routes/x+/purchasing-rfq+/$rfqId.convert.tsx
+++ b/apps/erp/app/routes/x+/purchasing-rfq+/$rfqId.convert.tsx
@@ -11,6 +11,8 @@ import {
updatePurchasingRFQStatus,
upsertSupplierQuoteLine
} from "~/modules/purchasing";
+import type { MethodItemType } from "~/modules/shared";
+import { methodItemType } from "~/modules/shared";
import { path } from "~/utils/path";
export async function action({ request, params }: ActionFunctionArgs) {
@@ -107,7 +109,11 @@ export async function action({ request, params }: ActionFunctionArgs) {
await upsertSupplierQuoteLine(client, {
supplierQuoteId,
- supplierQuoteLineType: "Part",
+ supplierQuoteLineType: methodItemType.includes(
+ line.itemType as MethodItemType
+ )
+ ? (line.itemType as MethodItemType)
+ : "Part",
itemId: line.itemId,
description: line.description ?? "",
quantity: line.quantity ?? [1],
diff --git a/apps/erp/app/routes/x+/purchasing-rfq+/$rfqId.finalize.tsx b/apps/erp/app/routes/x+/purchasing-rfq+/$rfqId.finalize.tsx
index cb5110236f..330de4e69e 100644
--- a/apps/erp/app/routes/x+/purchasing-rfq+/$rfqId.finalize.tsx
+++ b/apps/erp/app/routes/x+/purchasing-rfq+/$rfqId.finalize.tsx
@@ -20,7 +20,8 @@ import {
upsertSupplierQuoteLine
} from "~/modules/purchasing";
import { getCompany } from "~/modules/settings";
-import { upsertExternalLink } from "~/modules/shared";
+import type { MethodItemType } from "~/modules/shared";
+import { methodItemType, upsertExternalLink } from "~/modules/shared";
import { getUser } from "~/modules/users/users.server";
import { path } from "~/utils/path";
@@ -147,7 +148,11 @@ export async function action({ request, params }: ActionFunctionArgs) {
await upsertSupplierQuoteLine(client, {
supplierQuoteId,
- supplierQuoteLineType: "Part",
+ supplierQuoteLineType: methodItemType.includes(
+ line.itemType as MethodItemType
+ )
+ ? (line.itemType as MethodItemType)
+ : "Part",
itemId: line.itemId,
description: line.description ?? "",
quantity: line.quantity ?? [1],