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.

fix:quote quantities sort least-to-most everywhere; quote PDF no longer crashes on missing thumbnails

aashu4ce9a97cfb21
diff --git a/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.details.tsx b/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.details.tsx
index 1461e66447..c28da93b51 100644
--- a/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.details.tsx
+++ b/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.details.tsx
@@ -146,7 +146,14 @@ export const loader = async ({ request, params }: LoaderFunctionArgs) => {
: null;
return {
- line: line.data,
+ // Quantity breaks are stored in entry order; every surface renders them
+ // least-to-most (the summary, share page, and PDF sort the same way).
+ line: {
+ ...line.data,
+ quantity: line.data.quantity
+ ? [...line.data.quantity].sort((a, b) => a - b)
+ : line.data.quantity
+ },
operations: operations?.data ?? [],
files: getOpportunityLineDocuments(serviceRole, companyId, lineId, itemId),
pricesByQuantity: (prices?.data ?? []).reduce<
diff --git a/packages/auth/src/utils/result.ts b/packages/auth/src/utils/result.ts
index e78609d430..0ce7a6c834 100644
--- a/packages/auth/src/utils/result.ts
+++ b/packages/auth/src/utils/result.ts
@@ -4,7 +4,13 @@ import type { Result } from "../types";
const log = getLogger("auth");
export function error(error: any, message = "Request failed"): Result {
- if (error) log.error(message, { error });
+ // The dev text formatter prints only the message template, never unreferenced
+ // properties — so the cause must be a `{error}` placeholder or it is silently
+ // dropped. Braces in the message are escaped so they aren't read as placeholders.
+ if (error) {
+ const template = message.replaceAll("{", "{{").replaceAll("}", "}}");
+ log.error(`${template}: {error}`, { error });
+ }
return {
success: false,
diff --git a/packages/documents/src/pdf/QuotePDF.tsx b/packages/documents/src/pdf/QuotePDF.tsx
index 45ea93912b..72ebc1af1d 100644
--- a/packages/documents/src/pdf/QuotePDF.tsx
+++ b/packages/documents/src/pdf/QuotePDF.tsx
@@ -44,7 +44,7 @@ const QuotePDF = ({
meta,
exchangeRate,
quote,
- quoteLines,
+ quoteLines: unsortedQuoteLines,
quoteLinePrices,
quoteCustomerDetails,
payment,
@@ -58,6 +58,15 @@ const QuotePDF = ({
sections = {},
title = "Quote"
}: QuotePDFProps) => {
+ // Quantity breaks are stored in entry order; the PDF renders them
+ // least-to-most, and the single-quantity totals below use the smallest
+ // break — matching the in-app summary and the share page, which sort too.
+ const quoteLines = unsortedQuoteLines.map((line) =>
+ line.quantity
+ ? { ...line, quantity: [...line.quantity].sort((a, b) => a - b) }
+ : line
+ );
+
const currencyCode = quote.currencyCode ?? company.baseCurrencyCode;
const shouldConvertCurrency =
!!currencyCode && currencyCode !== company.baseCurrencyCode;
diff --git a/packages/documents/src/pdf/blocks/quote/LineItemsBlock.tsx b/packages/documents/src/pdf/blocks/quote/LineItemsBlock.tsx
index 7f33638182..70458ea883 100644
--- a/packages/documents/src/pdf/blocks/quote/LineItemsBlock.tsx
+++ b/packages/documents/src/pdf/blocks/quote/LineItemsBlock.tsx
@@ -170,9 +170,8 @@ export function LineItemsBlock({
{getLineDescriptionDetails(line)}
</Text>
{opts.showThumbnails &&
- thumbnails &&
line.id != null &&
- line.id in thumbnails && (
+ thumbnails?.[line.id] && (
<View style={tw("mt-2")}>
<Image
src={thumbnails[line.id]!}