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.

feat: warn if lines are missing shipping costs

Brad Barbinda5be5b50422
diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteFinalizeModal.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteFinalizeModal.tsx
index 06c36b7632..3162ec8542 100644
--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteFinalizeModal.tsx
+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteFinalizeModal.tsx
@@ -27,11 +27,19 @@ import {
getQuoteLinePricesByQuoteId,
getQuoteLines,
} from "../../sales.service";
-import type { Quotation, QuotationLine, QuotationPrice } from "../../types";
+import type {
+ Quotation,
+ QuotationLine,
+ QuotationPrice,
+ QuotationShipment,
+} from "../../types";
type QuotationFinalizeModalProps = {
onClose: () => void;
quote?: Quotation;
+ lines: QuotationLine[];
+ pricing: QuotationPrice[];
+ shipment: QuotationShipment | null;
fetcher: FetcherWithComponents<{}>;
};
@@ -39,6 +47,8 @@ const QuotationFinalizeModal = ({
quote,
onClose,
fetcher,
+ shipment,
+ pricing,
}: QuotationFinalizeModalProps) => {
const { quoteId } = useParams();
if (!quoteId) throw new Error("quoteId not found");
@@ -100,6 +110,15 @@ const QuotationFinalizeModal = ({
]),
];
+ const hasShippingCost = shipment?.shippingCost && shipment.shippingCost > 0;
+ const allLinesHaveShippingCosts = lines.every((line) => {
+ const linePrices = prices.filter((price) => price.quoteLineId === line.id);
+ return linePrices.every(
+ (price) => price.shippingCost && price.shippingCost > 0
+ );
+ });
+ const showShippingWarning = !hasShippingCost && !allLinesHaveShippingCosts;
+
return (
<Modal
open
@@ -128,21 +147,32 @@ const QuotationFinalizeModal = ({
</ModalDescription>
</ModalHeader>
<ModalBody>
- {warningLineReadableIds.length > 0 && (
- <Alert variant="destructive">
- <LuTriangleAlert className="h-4 w-4" />
- <AlertTitle>Lines need prices or lead times</AlertTitle>
- <AlertDescription>
- The following line items are missing prices or lead times:
- <ul className="list-disc py-2 pl-4">
- {warningLineReadableIds.map((readableId) => (
- <li key={readableId}>{readableId}</li>
- ))}
- </ul>
- </AlertDescription>
- </Alert>
- )}
<VStack spacing={4}>
+ {warningLineReadableIds.length > 0 && (
+ <Alert variant="destructive">
+ <LuTriangleAlert className="h-4 w-4" />
+ <AlertTitle>Lines need prices or lead times</AlertTitle>
+ <AlertDescription>
+ The following line items are missing prices or lead times:
+ <ul className="list-disc py-2 pl-4">
+ {warningLineReadableIds.map((readableId) => (
+ <li key={readableId}>{readableId}</li>
+ ))}
+ </ul>
+ </AlertDescription>
+ </Alert>
+ )}
+ {showShippingWarning && (
+ <Alert variant="destructive">
+ <LuTriangleAlert className="h-4 w-4" />
+ <AlertTitle>Missing Shipping Costs</AlertTitle>
+ <AlertDescription>
+ This quote has no shipping costs defined. Please add
+ shipping costs either at the quote level or for individual
+ line items.
+ </AlertDescription>
+ </Alert>
+ )}
{canEmail && (
<SelectControlled
label="Send Via"
diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteHeader.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteHeader.tsx
index 289a6bb73d..1d68185c3f 100644
--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteHeader.tsx
+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteHeader.tsx
@@ -49,6 +49,7 @@ import type {
Quotation,
QuotationLine,
QuotationPrice,
+ QuotationShipment,
} from "../../types";
import QuoteFinalizeModal from "./QuoteFinalizeModal";
import QuoteStatus from "./QuoteStatus";
@@ -66,6 +67,7 @@ const QuoteHeader = () => {
lines: QuotationLine[];
opportunity: Opportunity;
prices: QuotationPrice[];
+ shipment: QuotationShipment;
}>(path.to.quote(quoteId));
const eligibleLines = routeData?.lines.filter(
@@ -286,6 +288,9 @@ const QuoteHeader = () => {
{finalizeModal.isOpen && (
<QuoteFinalizeModal
quote={routeData?.quote}
+ lines={eligibleLines ?? []}
+ pricing={routeData?.prices ?? []}
+ shipment={routeData?.shipment ?? null}
onClose={finalizeModal.onClose}
fetcher={finalizeFetcher}
/>