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.

- ux changes

Gaurav Bhatte465062cac92
diff --git a/apps/erp/app/modules/purchasing/purchasing.service.ts b/apps/erp/app/modules/purchasing/purchasing.service.ts
index b11c40b12b..48fe147ea7 100644
--- a/apps/erp/app/modules/purchasing/purchasing.service.ts
+++ b/apps/erp/app/modules/purchasing/purchasing.service.ts
@@ -2007,22 +2007,29 @@ export async function getSupplierQuotesForComparison(
return { data: { quotes: [], lines: [], prices: [] }, error: linksError };
}
- // Extract quotes and filter for Active status only
+ // Extract all quotes (for comparison header count)
const allQuotes = links
.map((l) => l.supplierQuote)
- .filter(
- (q): q is NonNullable<typeof q> => q !== null && q.status === "Active"
- );
+ .filter((q): q is NonNullable<typeof q> => q !== null);
if (allQuotes.length === 0) {
return { data: { quotes: [], lines: [], prices: [] }, error: null };
}
+ // Get IDs of Active quotes only (for fetching lines/prices)
const activeQuoteIds = allQuotes
+ .filter((q) => q.status === "Active")
.map((q) => q.id)
.filter((id): id is string => !!id);
- // 2. Fetch lines and pricing for all active quotes
+ // 2. Fetch lines and pricing for active quotes only (if any)
+ if (activeQuoteIds.length === 0) {
+ return {
+ data: { quotes: allQuotes, lines: [], prices: [] },
+ error: null
+ };
+ }
+
const lines = await client
.from("supplierQuoteLines")
.select("*")
diff --git a/apps/erp/app/modules/purchasing/ui/PurchasingRfq/PurchasingRFQHeader.tsx b/apps/erp/app/modules/purchasing/ui/PurchasingRfq/PurchasingRFQHeader.tsx
index 73e38080bc..eb88750afb 100644
--- a/apps/erp/app/modules/purchasing/ui/PurchasingRfq/PurchasingRFQHeader.tsx
+++ b/apps/erp/app/modules/purchasing/ui/PurchasingRfq/PurchasingRFQHeader.tsx
@@ -81,7 +81,10 @@ const PurchasingRFQHeader = () => {
const statusFetcher = useFetcher<{}>();
const hasSuppliers = (routeData?.suppliers?.length ?? 0) > 0;
- const hasLinkedQuotes = (routeData?.linkedQuotes?.length ?? 0) > 0;
+ const activeLinkedQuotes = (routeData?.linkedQuotes ?? []).filter(
+ (q: any) => q.status === "Active"
+ );
+ const canCompareQuotes = activeLinkedQuotes.length > 1;
return (
<div className="flex flex-shrink-0 items-center justify-between p-2 bg-card border-b h-[50px] overflow-x-auto scrollbar-hide ">
@@ -203,7 +206,7 @@ const PurchasingRFQHeader = () => {
No Quote
</Button>
- {hasLinkedQuotes && (
+ {canCompareQuotes && (
<Button
onClick={compareQuotesModal.onOpen}
leftIcon={<LuGitCompare />}
diff --git a/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteCompareDrawer.tsx b/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteCompareDrawer.tsx
index 780d42da89..6c8947b716 100644
--- a/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteCompareDrawer.tsx
+++ b/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteCompareDrawer.tsx
@@ -1,3 +1,4 @@
+import type { Database } from "@carbon/database";
import {
Badge,
Button,
@@ -39,16 +40,9 @@ import type { SupplierQuoteLine, SupplierQuoteLinePrice } from "../../types";
type SelectedLine = z.infer<typeof selectedLineSchema>;
-// Type for quotes returned from comparison API (includes supplier info)
-type ComparisonQuote = {
- id: string | null;
- supplierQuoteId: string | null;
- revisionId: number | null;
- status: string | null;
- supplierId: string | null;
- currencyCode: string | null;
- exchangeRate: number | null;
- supplier: { name: string } | null;
+// Type for quotes returned from comparison API (includes supplier relation)
+type ComparisonQuote = Database["public"]["Tables"]["supplierQuote"]["Row"] & {
+ supplier: Database["public"]["Tables"]["supplier"]["Row"] | null;
};
type ComparisonData = {
@@ -113,6 +107,10 @@ const SupplierQuoteCompareDrawer = ({
const lines = fetcher.data?.lines ?? [];
const prices = fetcher.data?.prices ?? [];
+ // Calculate submission stats for header
+ const totalQuotes = quotes.length;
+ const submittedQuotes = quotes.filter((q) => q.status === "Active").length;
+
// Get all unique quantity tiers across all quotes
const quantityTiers = useMemo(() => {
const tiers = new Set<number>();
@@ -196,11 +194,18 @@ const SupplierQuoteCompareDrawer = ({
Back
</Button>
)}
- <DrawerTitle>
- {step === "compare"
- ? "Compare Supplier Quotes"
- : `Create Order from ${selectedQuote?.supplier?.name ?? selectedQuote?.supplierQuoteId}`}
- </DrawerTitle>
+ <VStack spacing={0} className="items-start">
+ <DrawerTitle>
+ {step === "compare"
+ ? "Compare Supplier Quotes"
+ : `Create Order from ${selectedQuote?.supplier?.name ?? selectedQuote?.supplierQuoteId}`}
+ </DrawerTitle>
+ {step === "compare" && totalQuotes > 0 && (
+ <span className="text-sm text-muted-foreground">
+ {submittedQuotes} out of {totalQuotes} submitted
+ </span>
+ )}
+ </VStack>
</HStack>
{/* Quantity tier selector in Step 1 */}
diff --git a/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteHeader.tsx b/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteHeader.tsx
index 474102aa6a..c1ca3cb612 100644
--- a/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteHeader.tsx
+++ b/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteHeader.tsx
@@ -74,7 +74,9 @@ const SupplierQuoteHeader = () => {
lines: SupplierQuoteLine[];
interaction: SupplierInteraction;
prices: SupplierQuoteLinePrice[];
- purchasingRfqs: { id: string; rfqId: string; status: string }[];
+ siblingQuotes: (SupplierQuote & {
+ supplier: { id: string; name: string };
+ })[];
}>(path.to.supplierQuote(id));
const isOutsideProcessing =
@@ -97,7 +99,10 @@ const SupplierQuoteHeader = () => {
const isEditableStatus = editableStatuses.includes(quoteStatus);
// Get the first linked RFQ ID for comparison
- const linkedRfqId = routeData?.purchasingRfqs?.[0]?.id ?? null;
+ const linkedRfqId = routeData?.interaction.purchasingRfq?.id ?? null;
+
+ // Check if sibling quotes exist (for showing Compare option)
+ const hasSiblingQuotes = (routeData?.siblingQuotes ?? []).length > 0;
const canSend =
isEditableStatus && permissions.can("update", "purchasing") && hasLines;
@@ -211,26 +216,40 @@ const SupplierQuoteHeader = () => {
</Button>
)}
- {routeData?.quote?.status === "Active" && (
- <Button
- isDisabled={!permissions.can("update", "purchasing")}
- variant="primary"
- leftIcon={<LuShoppingCart />}
- onClick={convertToOrderModal.onOpen}
- >
- Order
- </Button>
- )}
-
- {routeData?.quote?.status === "Active" && linkedRfqId && (
- <Button
- variant="secondary"
- leftIcon={<LuGitCompare />}
- onClick={compareModal.onOpen}
- >
- Compare
- </Button>
- )}
+ {routeData?.quote?.status === "Active" &&
+ (hasSiblingQuotes ? (
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button
+ isDisabled={!permissions.can("update", "purchasing")}
+ variant="primary"
+ leftIcon={<LuShoppingCart />}
+ rightIcon={<LuChevronDown />}
+ >
+ Order
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent>
+ <DropdownMenuItem onClick={convertToOrderModal.onOpen}>
+ <DropdownMenuIcon icon={<LuShoppingCart />} />
+ Order
+ </DropdownMenuItem>
+ <DropdownMenuItem onClick={compareModal.onOpen}>
+ <DropdownMenuIcon icon={<LuGitCompare />} />
+ Compare and Order
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ ) : (
+ <Button
+ isDisabled={!permissions.can("update", "purchasing")}
+ variant="primary"
+ leftIcon={<LuShoppingCart />}
+ onClick={convertToOrderModal.onOpen}
+ >
+ Order
+ </Button>
+ ))}
{routeData?.quote?.status === "Draft" && (
<statusFetcher.Form