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(sales): quote Costing and Pricing labels ellipsize instead of wrapping; values stay on one line
aashu9e705c54946e
diff --git a/apps/erp/app/modules/sales/ui/Quotes/CostRowLabel.tsx b/apps/erp/app/modules/sales/ui/Quotes/CostRowLabel.tsxnew file mode 100644index 0000000000..e9aa48e764--- /dev/null+++ b/apps/erp/app/modules/sales/ui/Quotes/CostRowLabel.tsx@@ -0,0 +1,39 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,+// including ports, remain AGPLv3; serving them over a network requires releasing their source.++import { cn, TruncatedTooltipText } from "@carbon/react";+import type { ReactNode } from "react";++// First column of the quote line Costing / Pricing grids. Wide enough for the+// label and its badge; anything longer ellipsizes instead of wrapping.+export const costRowLabelCellClass =+ "min-w-[280px] w-[300px] max-w-[300px] border-r border-border";++type CostRowLabelProps = {+ label: ReactNode;+ /** Inline help right after the label. */+ info?: ReactNode;+ /** Badge or control pinned to the right of the cell. */+ badge?: ReactNode;+ className?: string;+};++export function CostRowLabel({+ label,+ info,+ badge,+ className+}: CostRowLabelProps) {+ return (+ <div className={cn("flex w-full min-w-0 items-center gap-2", className)}>+ <TruncatedTooltipText tooltip={label} className="block min-w-0 truncate">+ {label}+ </TruncatedTooltipText>+ {info && <span className="flex shrink-0 items-center">{info}</span>}+ {badge && (+ <span className="ml-auto flex shrink-0 items-center">{badge}</span>+ )}+ </div>+ );+}diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteLineCosting.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteLineCosting.tsxindex 29f882c3f0..eb790fcc6c 100644--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteLineCosting.tsx+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteLineCosting.tsx@@ -9,6 +9,7 @@ import {CardContent,CardHeader,CardTitle,+ cn,HStack,Switch,Table,@@ -32,6 +33,7 @@ import { MethodItemTypeIcon, TimeTypeIcon } from "~/components";import { Enumerable } from "~/components/Enumerable";import { useCurrencyFormatter } from "~/hooks";import type { Costs } from "../../types";+import { CostRowLabel, costRowLabelCellClass } from "./CostRowLabel";const QuoteLineCosting = ({quantities,@@ -76,28 +78,33 @@ const QuoteLineCosting = ({id="cost-details"/><label className="text-sm" htmlFor="cost-details">- Show Details+ <Trans>Show Details</Trans></label></div></CardAction></HStack><CardContent>- <Table>+ <Table className="[&_td]:whitespace-nowrap [&_td]:tabular-nums"><Thead><Tr>- <Th className="w-[300px]" />+ <Th className={costRowLabelCellClass} />{quantities.map((quantity) => (- <Th key={quantity.toString()}>{quantity}</Th>+ <Th+ key={quantity.toString()}+ className="min-w-[140px] tabular-nums"+ >+ {quantity}+ </Th>))}</Tr></Thead><Tbody><Tr>- <Td className="border-r border-border ">- <HStack className="w-full justify-between ">- <span>Total Material Cost</span>- <Enumerable value="Material" />- </HStack>+ <Td className={costRowLabelCellClass}>+ <CostRowLabel+ badge={<Enumerable value="Material" />}+ label={<Trans>Total Material Cost</Trans>}+ /></Td>{quantityCosts.map(({ quantity, costs }, index) => {const totalMaterialCost =@@ -130,23 +137,25 @@ const QuoteLineCosting = ({{detailsDisclosure.isOpen && (<><Tr>- <Td className="border-r border-border pl-10 ">- <HStack className="w-full justify-between ">- <span className="whitespace-nowrap flex items-center justify-start gap-2">- Part Cost{" "}+ <Td className={cn(costRowLabelCellClass, "pl-10")}>+ <CostRowLabel+ badge={+ <Badge variant="secondary">+ <MethodItemTypeIcon type="Part" />+ </Badge>+ }+ label={<Trans>Part Cost</Trans>}+ info={<Tooltip><TooltipTrigger><LuInfo className="w-4 h-4" /></TooltipTrigger><TooltipContent>- Includes bought and picked parts+ <Trans>Includes bought and picked parts</Trans></TooltipContent></Tooltip>- </span>- <Badge variant="secondary">- <MethodItemTypeIcon type="Part" />- </Badge>- </HStack>+ }+ /></Td>{quantityCosts.map(({ quantity, costs }) => {return (@@ -170,13 +179,15 @@ const QuoteLineCosting = ({})}</Tr><Tr>- <Td className="border-r border-border pl-10 ">- <HStack className="w-full justify-between ">- <span className="whitespace-nowrap">Material Cost</span>- <Badge variant="secondary">- <MethodItemTypeIcon type="Material" />- </Badge>- </HStack>+ <Td className={cn(costRowLabelCellClass, "pl-10")}>+ <CostRowLabel+ badge={+ <Badge variant="secondary">+ <MethodItemTypeIcon type="Material" />+ </Badge>+ }+ label={<Trans>Material Cost</Trans>}+ /></Td>{quantityCosts.map(({ quantity, costs }) => {return (@@ -200,13 +211,15 @@ const QuoteLineCosting = ({})}</Tr><Tr>- <Td className="border-r border-border pl-10 ">- <HStack className="w-full justify-between ">- <span className="whitespace-nowrap">Tooling Cost</span>- <Badge variant="secondary">- <MethodItemTypeIcon type="Tool" />- </Badge>- </HStack>+ <Td className={cn(costRowLabelCellClass, "pl-10")}>+ <CostRowLabel+ badge={+ <Badge variant="secondary">+ <MethodItemTypeIcon type="Tool" />+ </Badge>+ }+ label={<Trans>Tooling Cost</Trans>}+ /></Td>{quantityCosts.map(({ quantity, costs }) => {return (@@ -230,13 +243,15 @@ const QuoteLineCosting = ({})}</Tr><Tr>- <Td className="border-r border-border pl-10 ">- <HStack className="w-full justify-between ">- <span className="whitespace-nowrap">Consumable Cost</span>- <Badge variant="secondary">- <MethodItemTypeIcon type="Consumable" />- </Badge>- </HStack>+ <Td className={cn(costRowLabelCellClass, "pl-10")}>+ <CostRowLabel+ badge={+ <Badge variant="secondary">+ <MethodItemTypeIcon type="Consumable" />+ </Badge>+ }+ label={<Trans>Consumable Cost</Trans>}+ /></Td>{quantityCosts.map(({ quantity, costs }) => {return (@@ -260,14 +275,9 @@ const QuoteLineCosting = ({})}</Tr>{/* <Tr>- <Td className="border-r border-border pl-10 ">- <HStack className="w-full justify-between ">- <span className="whitespace-nowrap">Service Cost</span>- <Badge variant="secondary">- <MethodItemTypeIcon type="Service" />- </Badge>- </HStack>- </Td>+ <Td className={cn(costRowLabelCellClass, "pl-10")}>+<CostRowLabel badge={<Badge variant="secondary"><MethodItemTypeIcon type="Service" /></Badge>} label={<Trans>Service Cost</Trans>} />+</Td>{quantityCosts.map(({ quantity, costs }) => {return (<Td key={quantity.toString()}>@@ -292,11 +302,11 @@ const QuoteLineCosting = ({</>)}<Tr>- <Td className="border-r border-border ">- <HStack className="w-full justify-between ">- <span>Total Direct Cost</span>- <Enumerable value="Direct" />- </HStack>+ <Td className={costRowLabelCellClass}>+ <CostRowLabel+ badge={<Enumerable value="Direct" />}+ label={<Trans>Total Direct Cost</Trans>}+ /></Td>{quantityCosts.map(({ quantity, costs }, index) => {const totalDirectCost =@@ -319,15 +329,15 @@ const QuoteLineCosting = ({{detailsDisclosure.isOpen && (<><Tr>- <Td className="border-r border-border pl-10 ">- <HStack className="w-full justify-between ">- <span className="whitespace-nowrap flex items-center justify-start gap-2">- Labor Costs- </span>- <Badge variant="secondary">- <TimeTypeIcon type="Labor" />- </Badge>- </HStack>+ <Td className={cn(costRowLabelCellClass, "pl-10")}>+ <CostRowLabel+ badge={+ <Badge variant="secondary">+ <TimeTypeIcon type="Labor" />+ </Badge>+ }+ label={<Trans>Labor Costs</Trans>}+ /></Td>{quantityCosts.map(({ quantity, costs }) => {return (@@ -351,15 +361,15 @@ const QuoteLineCosting = ({})}</Tr><Tr>- <Td className="border-r border-border pl-14 ">- <HStack className="w-full justify-between ">- <span className="whitespace-nowrap flex items-center justify-start gap-2">- Labor Hours- </span>- <Badge variant="secondary">- <LuClock />- </Badge>- </HStack>+ <Td className={cn(costRowLabelCellClass, "pl-14")}>+ <CostRowLabel+ badge={+ <Badge variant="secondary">+ <LuClock />+ </Badge>+ }+ label={<Trans>Labor Hours</Trans>}+ /></Td>{quantityCosts.map(({ quantity, costs }) => {const laborHours =@@ -379,15 +389,15 @@ const QuoteLineCosting = ({})}</Tr><Tr>- <Td className="border-r border-border pl-10 ">- <HStack className="w-full justify-between ">- <span className="whitespace-nowrap flex items-center justify-start gap-2">- Machine Costs- </span>- <Badge variant="secondary">- <TimeTypeIcon type="Machine" />- </Badge>- </HStack>+ <Td className={cn(costRowLabelCellClass, "pl-10")}>+ <CostRowLabel+ badge={+ <Badge variant="secondary">+ <TimeTypeIcon type="Machine" />+ </Badge>+ }+ label={<Trans>Machine Costs</Trans>}+ /></Td>{quantityCosts.map(({ quantity, costs }) => {return (@@ -411,15 +421,15 @@ const QuoteLineCosting = ({})}</Tr><Tr>- <Td className="border-r border-border pl-14 ">- <HStack className="w-full justify-between ">- <span className="whitespace-nowrap flex items-center justify-start gap-2">- Machine Hours- </span>- <Badge variant="secondary">- <LuClock />- </Badge>- </HStack>+ <Td className={cn(costRowLabelCellClass, "pl-14")}>+ <CostRowLabel+ badge={+ <Badge variant="secondary">+ <LuClock />+ </Badge>+ }+ label={<Trans>Machine Hours</Trans>}+ /></Td>{quantityCosts.map(({ quantity, costs }) => {const machineHours = costs.machineHours ?? 0;@@ -440,11 +450,11 @@ const QuoteLineCosting = ({</>)}<Tr>- <Td className="border-r border-border ">- <HStack className="w-full justify-between ">- <span>Total Indirect Cost</span>- <Enumerable value="Indirect" />- </HStack>+ <Td className={costRowLabelCellClass}>+ <CostRowLabel+ badge={<Enumerable value="Indirect" />}+ label={<Trans>Total Indirect Cost</Trans>}+ /></Td>{quantityCosts.map(({ quantity, costs }, index) => {return (@@ -468,11 +478,11 @@ const QuoteLineCosting = ({})}</Tr><Tr>- <Td className="border-r border-border ">- <HStack className="w-full justify-between ">- <span>Total Outside Cost</span>- <Enumerable value="Outside" />- </HStack>+ <Td className={costRowLabelCellClass}>+ <CostRowLabel+ badge={<Enumerable value="Outside" />}+ label={<Trans>Total Outside Cost</Trans>}+ /></Td>{quantityCosts.map(({ quantity, costs }) => {return (@@ -497,7 +507,9 @@ const QuoteLineCosting = ({</Tr><Tr className="font-bold ">- <Td className="border-r border-border ">Total Estimated Cost</Td>+ <Td className={costRowLabelCellClass}>+ <CostRowLabel label={<Trans>Total Estimated Cost</Trans>} />+ </Td>{quantityCosts.map(({ quantity, costs }) => {const totalCost =costs.consumableCost +@@ -530,7 +542,7 @@ const QuoteLineCosting = ({</Tbody><Tfoot>{/* <Tr className="font-bold">- <Td className="border-r border-border" />+ <Td className={costRowLabelCellClass} />{quantityCosts.map(({ quantity }) => (<Td key={quantity} ><Button variant="secondary">Add</Button>diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteLinePricing.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteLinePricing.tsxindex 374df3fb64..2f618e43aa 100644--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteLinePricing.tsx+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteLinePricing.tsx@@ -74,6 +74,7 @@ import type {QuotationLine,QuotationPrice} from "../../types";+import { CostRowLabel, costRowLabelCellClass } from "./CostRowLabel";import QuoteLeadTimeModal from "./QuoteLeadTimeModal";const logger = getLogger("erp", "sales", "quote-line-pricing");@@ -107,7 +108,7 @@ const QuoteLinePricing = ({const hasCalculatedCost = line.methodType !== "Pull from Inventory";// Present quantity breaks least-to-greatest; every column loop and the// derived `...ByQuantity` arrays read from this one variable.- const quantities = [...(line.quantity ?? [1])].sort((a, b) => a - b);+ const quantities = [...new Set(line.quantity ?? [1])].sort((a, b) => a - b);const { quoteId, lineId } = useParams();if (!quoteId) throw new Error("Could not find quoteId");@@ -882,30 +883,37 @@ const QuoteLinePricing = ({)}</HStack><CardContent>- <Table>+ <Table className="[&_td]:whitespace-nowrap [&_td]:tabular-nums"><Thead><Tr>- <Th className="w-[300px]" />+ <Th className={costRowLabelCellClass} />{quantities.map((quantity) => (- <Th key={quantity.toString()}>{quantity}</Th>+ <Th+ key={quantity.toString()}+ className="min-w-[140px] tabular-nums"+ >+ {quantity}+ </Th>))}</Tr></Thead><Tbody><Tr>- <Td className="border-r border-border group-hover:bg-muted/50">- <HStack className="w-full justify-between ">- <span>Lead Time</span>- {isEmployee && hasCalculatedCost && (- <IconButton- aria-label={t`Predict lead time`}- icon={<LuCalendarClock />}- variant="ghost"- size="sm"- onClick={() => setLeadTimeModalOpen(true)}- />- )}- </HStack>+ <Td className={costRowLabelCellClass}>+ <CostRowLabel+ label={<Trans>Lead Time</Trans>}+ badge={+ isEmployee && hasCalculatedCost ? (+ <IconButton+ aria-label={t`Predict lead time`}+ icon={<LuCalendarClock />}+ variant="ghost"+ size="sm"+ onClick={() => setLeadTimeModalOpen(true)}+ />+ ) : undefined+ }+ /></Td>{quantities.map((quantity) => {const leadTime = editableFields.prices[quantity]?.leadTime ?? 0;@@ -933,10 +941,8 @@ const QuoteLinePricing = ({</Tr>{isEmployee && (<Tr className={cn(hasCalculatedCost && "[&>td]:bg-muted/60")}>- <Td className="border-r border-border group-hover:bg-muted/50">- <HStack className="w-full justify-between ">- <span>Unit Cost</span>- </HStack>+ <Td className={costRowLabelCellClass}>+ <CostRowLabel label={<Trans>Unit Cost</Trans>} /></Td>{unitCostsByQuantity.map((cost, index) => {@@ -970,18 +976,18 @@ const QuoteLinePricing = ({{isEmployee && (<Tr>- <Td className="border-r border-border">- <HStack className="w-full justify-between ">- <span className="flex items-center justify-start gap-2">- Markup Percent+ <Td className={costRowLabelCellClass}>+ <CostRowLabel+ label={<Trans>Markup Percent</Trans>}+ info={<Tooltip><TooltipTrigger tabIndex={-1}><LuInfo className="w-4 h-4" /></TooltipTrigger><TooltipContent>(Price - Cost) / Cost</TooltipContent></Tooltip>- </span>- </HStack>+ }+ /></Td>{quantities.map((quantity, index) => {const price = editableFields.prices[quantity]?.unitPrice ?? 0;@@ -1016,7 +1022,7 @@ const QuoteLinePricing = ({{isEmployee && hasCalculatedCost && (<><Tr>- <Td className="border-r border-border">+ <Td className={costRowLabelCellClass}><Buttonvariant="ghost"className="-ml-3"@@ -1031,7 +1037,7 @@ const QuoteLinePricing = ({setShowCategoryMarkups(!showCategoryMarkups)}>- Markup by Category+ <Trans>Markup by Category</Trans></Button></Td>{quantities.map((quantity) => (@@ -1042,8 +1048,8 @@ const QuoteLinePricing = ({visibleCategories.map((category: CostCategoryKey) => {return (<Tr key={category}>- <Td className="border-r border-border pl-8">- <span>{categoryLabels[category]}</span>+ <Td className={cn(costRowLabelCellClass, "pl-8")}>+ <CostRowLabel label={categoryLabels[category]} /></Td>{quantities.map((quantity, index) => {const categoryCost =@@ -1084,10 +1090,8 @@ const QuoteLinePricing = ({</>)}<Tr>- <Td className="border-r border-border">- <HStack className="w-full justify-between ">- <span>Unit Price</span>- </HStack>+ <Td className={costRowLabelCellClass}>+ <CostRowLabel label={<Trans>Unit Price</Trans>} /></Td>{quantities.map((quantity) => {const price = editableFields.prices[quantity]?.unitPrice;@@ -1111,10 +1115,8 @@ const QuoteLinePricing = ({</Tr><Tr>- <Td className="border-r border-border">- <HStack className="w-full justify-between ">- <span>Discount Percent</span>- </HStack>+ <Td className={costRowLabelCellClass}>+ <CostRowLabel label={<Trans>Discount Percent</Trans>} /></Td>{quantities.map((quantity, index) => {const discount =@@ -1137,10 +1139,8 @@ const QuoteLinePricing = ({})}</Tr><Tr className="[&>td]:bg-muted/60">- <Td className="border-r border-border group-hover:bg-muted/50">- <HStack className="w-full justify-between ">- <span>Net Unit Price</span>- </HStack>+ <Td className={costRowLabelCellClass}>+ <CostRowLabel label={<Trans>Net Unit Price</Trans>} /></Td>{netPricesByQuantity.map((price, index) => {return (@@ -1155,18 +1155,18 @@ const QuoteLinePricing = ({{isEmployee && (<Tr className="[&>td]:bg-muted/60">- <Td className="border-r border-border group-hover:bg-muted/50">- <HStack className="w-full justify-between ">- <span className="flex items-center justify-start gap-2">- Profit Percent+ <Td className={costRowLabelCellClass}>+ <CostRowLabel+ label={<Trans>Profit Percent</Trans>}+ info={<Tooltip><TooltipTrigger tabIndex={-1}><LuInfo className="w-4 h-4" /></TooltipTrigger><TooltipContent>(Price - Cost) / Price</TooltipContent></Tooltip>- </span>- </HStack>+ }+ /></Td>{netPricesByQuantity.map((price, index) => {const cost = unitCostsByQuantity[index];@@ -1191,10 +1191,8 @@ const QuoteLinePricing = ({)}{isEmployee && (<Tr className="[&>td]:bg-muted/60">- <Td className="border-r border-border group-hover:bg-muted/50">- <HStack className="w-full justify-between ">- <span>Total Profit</span>- </HStack>+ <Td className={costRowLabelCellClass}>+ <CostRowLabel label={<Trans>Total Profit</Trans>} /></Td>{quantities.map((quantity, index) => {const price = netPricesByQuantity[index];@@ -1219,10 +1217,8 @@ const QuoteLinePricing = ({</Tr>)}<Tr>- <Td className="border-r border-border">- <HStack className="w-full justify-between ">- <span>Shipping Cost</span>- </HStack>+ <Td className={costRowLabelCellClass}>+ <CostRowLabel label={<Trans>Shipping Cost</Trans>} /></Td>{quantities.map((quantity) => {const shippingCost =@@ -1257,7 +1253,7 @@ const QuoteLinePricing = ({fetcher.formData?.get("id") === chargeId;return (<Tr key={chargeId}>- <Td className="border-r border-border">+ <Td className={costRowLabelCellClass}><HStack className="w-full justify-between "><InputdefaultValue={charge.description}@@ -1347,7 +1343,7 @@ const QuoteLinePricing = ({);})}<Tr>- <Td className="border-r border-border">+ <Td className={costRowLabelCellClass}><HStack className="w-full justify-between "><fetcher.Formmethod="post"@@ -1385,10 +1381,8 @@ const QuoteLinePricing = ({})}</Tr><Tr className="[&>td]:bg-muted/60">- <Td className="border-r border-border group-hover:bg-muted/50">- <HStack className="w-full justify-between ">- <span>Subtotal</span>- </HStack>+ <Td className={costRowLabelCellClass}>+ <CostRowLabel label={<Trans>Subtotal</Trans>} /></Td>{quantities.map((quantity, index) => {const price =@@ -1405,10 +1399,8 @@ const QuoteLinePricing = ({})}</Tr><Tr className="[&>td]:bg-muted/60">- <Td className="border-r border-border group-hover:bg-muted/50">- <HStack className="w-full justify-between ">- <span>Tax Percent</span>- </HStack>+ <Td className={costRowLabelCellClass}>+ <CostRowLabel label={<Trans>Tax Percent</Trans>} /></Td>{quantities.map((quantity, index) => {const taxPercent = editableFields.taxPercent;@@ -1433,10 +1425,8 @@ const QuoteLinePricing = ({})}</Tr><Tr className="font-bold [&>td]:bg-muted/60">- <Td className="border-r border-border group-hover:bg-muted/50">- <HStack className="w-full justify-between ">- <span>Total Price</span>- </HStack>+ <Td className={costRowLabelCellClass}>+ <CostRowLabel label={<Trans>Total Price</Trans>} /></Td>{quantities.map((quantity, index) => {const subtotal =@@ -1461,10 +1451,8 @@ const QuoteLinePricing = ({{routeData?.quote?.currencyCode !== baseCurrency && (<><Tr className="[&>td]:bg-muted/60">- <Td className="border-r border-border group-hover:bg-muted/50">- <HStack className="w-full justify-between ">- <span>Exchange Rate</span>- </HStack>+ <Td className={costRowLabelCellClass}>+ <CostRowLabel label={<Trans>Exchange Rate</Trans>} /></Td>{quantities.map((quantity, index) => {const exchangeRate =@@ -1479,10 +1467,10 @@ const QuoteLinePricing = ({})}</Tr><Tr className="font-bold [&>td]:bg-muted/60">- <Td className="border-r border-border group-hover:bg-muted/50">- <HStack className="w-full justify-between ">- <span>Converted Total Price</span>- </HStack>+ <Td className={costRowLabelCellClass}>+ <CostRowLabel+ label={<Trans>Converted Total Price</Trans>}+ /></Td>{quantities.map((quantity, index) => {const subtotal =