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
feat: add payment terms and shipping to quote pdf
Brad Barbinee950e39925b
diff --git a/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderLineForm.tsx b/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderLineForm.tsxindex b3dface003..4e3d3e1fc0 100644--- a/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderLineForm.tsx+++ b/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderLineForm.tsx@@ -31,6 +31,7 @@ import {DatePicker,Hidden,Item,+ Location,Number,NumberControlled,Select,@@ -46,7 +47,6 @@ import type {SalesOrderLineType,} from "~/modules/sales";import { salesOrderLineType, salesOrderLineValidator } from "~/modules/sales";-import type { ListItem } from "~/types";import { path } from "~/utils/path";import DeleteSalesOrderLine from "./DeleteSalesOrderLine";@@ -69,16 +69,9 @@ const SalesOrderLineForm = ({if (!orderId) throw new Error("orderId not found");const routeData = useRouteData<{- locations: ListItem[];salesOrder: SalesOrder;}>(path.to.salesOrder(orderId));- const locations = routeData?.locations ?? [];- const locationOptions = locations.map((location) => ({- label: location.name,- value: location.id,- }));-const isEditable = ["Draft", "To Review"].includes(routeData?.salesOrder?.status ?? "");@@ -336,11 +329,9 @@ const SalesOrderLineForm = ({"Fixture","Consumable",].includes(lineType) && (- <ComboboxControlled+ <Locationname="locationId"label="Location"- options={locationOptions}- value={locationId}onChange={onLocationChange}/>)}diff --git a/apps/carbon/app/routes/file+/quote+/$id[.]pdf.tsx b/apps/carbon/app/routes/file+/quote+/$id[.]pdf.tsxindex 155f6a131b..68299407e7 100644--- a/apps/carbon/app/routes/file+/quote+/$id[.]pdf.tsx+++ b/apps/carbon/app/routes/file+/quote+/$id[.]pdf.tsx@@ -2,11 +2,15 @@ import { QuotePDF } from "@carbon/documents";import { renderToStream } from "@react-pdf/renderer";import { type LoaderFunctionArgs } from "@remix-run/node";import logger from "~/lib/logger";+import { getPaymentTermsList } from "~/modules/accounting";+import { getShippingMethodsList } from "~/modules/inventory";import {getQuote,getQuoteCustomerDetails,getQuoteLinePricesByQuoteId,getQuoteLines,+ getQuotePayment,+ getQuoteShipment,} from "~/modules/sales";import { getCompany } from "~/modules/settings";import { getBase64ImageFromSupabase } from "~/modules/shared";@@ -20,14 +24,27 @@ export async function loader({ request, params }: LoaderFunctionArgs) {const { id } = params;if (!id) throw new Error("Could not find id");- const [company, quote, quoteLines, quoteLinePrices, quoteLocations] =- await Promise.all([- getCompany(client, companyId),- getQuote(client, id),- getQuoteLines(client, id),- getQuoteLinePricesByQuoteId(client, id),- getQuoteCustomerDetails(client, id),- ]);+ const [+ company,+ quote,+ quoteLines,+ quoteLinePrices,+ quoteLocations,+ quotePayment,+ quoteShipment,+ paymentTerms,+ shippingMethods,+ ] = await Promise.all([+ getCompany(client, companyId),+ getQuote(client, id),+ getQuoteLines(client, id),+ getQuoteLinePricesByQuoteId(client, id),+ getQuoteCustomerDetails(client, id),+ getQuotePayment(client, id),+ getQuoteShipment(client, id),+ getPaymentTermsList(client, companyId),+ getShippingMethodsList(client, companyId),+ ]);if (company.error) {logger.error(company.error);@@ -91,6 +108,10 @@ export async function loader({ request, params }: LoaderFunctionArgs) {quoteLines={quoteLines.data ?? []}quoteLinePrices={quoteLinePrices.data ?? []}quoteCustomerDetails={quoteLocations.data}+ payment={quotePayment?.data}+ shipment={quoteShipment?.data}+ paymentTerms={paymentTerms.data ?? []}+ shippingMethods={shippingMethods.data ?? []}thumbnails={thumbnails}/>);diff --git a/apps/carbon/app/routes/x+/sales-order+/$orderId.$lineId.details.tsx b/apps/carbon/app/routes/x+/sales-order+/$orderId.$lineId.details.tsxindex 18f80531f5..2a73e29467 100644--- a/apps/carbon/app/routes/x+/sales-order+/$orderId.$lineId.details.tsx+++ b/apps/carbon/app/routes/x+/sales-order+/$orderId.$lineId.details.tsx@@ -99,6 +99,7 @@ export default function EditSalesOrderLineRoute() {assetId: salesOrderLine?.assetId ?? "",description: salesOrderLine?.description ?? "",itemReadableId: salesOrderLine?.itemReadableId ?? "",+ locationId: salesOrderLine?.locationId ?? undefined,promisedDate: salesOrderLine?.promisedDate ?? undefined,saleQuantity: salesOrderLine?.saleQuantity ?? 1,setupPrice: salesOrderLine?.setupPrice ?? 0,diff --git a/packages/documents/src/pdf/QuotePDF.tsx b/packages/documents/src/pdf/QuotePDF.tsxindex 4007633daa..bd1fc9ff69 100644--- a/packages/documents/src/pdf/QuotePDF.tsx+++ b/packages/documents/src/pdf/QuotePDF.tsx@@ -13,6 +13,10 @@ interface QuotePDFProps extends PDF {quoteLines: Database["public"]["Views"]["quoteLines"]["Row"][];quoteCustomerDetails: Database["public"]["Views"]["quoteCustomerDetails"]["Row"];quoteLinePrices: Database["public"]["Tables"]["quoteLinePrice"]["Row"][];+ payment?: Database["public"]["Tables"]["quotePayment"]["Row"] | null;+ shipment?: Database["public"]["Tables"]["quoteShipment"]["Row"] | null;+ paymentTerms: { id: string; name: string }[];+ shippingMethods: { id: string; name: string }[];thumbnails: Record<string, string | null>;}@@ -29,6 +33,10 @@ const QuotePDF = ({quoteLines,quoteLinePrices,quoteCustomerDetails,+ payment,+ paymentTerms,+ shipment,+ shippingMethods,thumbnails,title = "Quote",}: QuotePDFProps) => {@@ -52,6 +60,13 @@ const QuotePDF = ({return acc;}, {});+ const paymentTerm = paymentTerms?.find(+ (paymentTerm) => paymentTerm.id === payment.paymentTermId+ );+ const shippingMethod = shippingMethods?.find(+ (method) => method.id === shipment.shippingMethodId+ );+return (<Templatetitle={title}@@ -65,42 +80,44 @@ const QuotePDF = ({<Header title={title} company={company} /><Summarycompany={company}- items={- quote.expirationDate+ items={[+ {+ label: "Ref #",+ value: quote?.customerReference,+ },+ {+ label: "Date",+ value: today(getLocalTimeZone()).toString(),+ },+ ...(shippingMethod? [{- label: "Ref #",- value: quote?.customerReference,- },- {- label: "Date",- value: today(getLocalTimeZone()).toString(),- },- {- label: "Expires",- value: quote?.expirationDate ?? "",- },- {- label: "Quote #",- value: quote?.quoteId,+ label: "Shipping Method",+ value: shippingMethod.name,},]- : [- {- label: "Ref #",- value: quote?.customerReference,- },+ : []),+ ...(paymentTerm+ ? [{- label: "Date",- value: today(getLocalTimeZone()).toString(),+ label: "Payment Term",+ value: paymentTerm.name,},-+ ]+ : []),+ ...(quote.expirationDate+ ? [{- label: "Quote #",- value: quote?.quoteId,+ label: "Expires",+ value: quote.expirationDate,},]- }+ : []),+ {+ label: "Quote #",+ value: quote?.quoteId,+ },+ ]}/><View style={styles.row}><View style={{ ...styles.colThird, ...styles.header }}>diff --git a/packages/documents/src/pdf/components/Summary.tsx b/packages/documents/src/pdf/components/Summary.tsxindex d592c23851..a8a83a55b5 100644--- a/packages/documents/src/pdf/components/Summary.tsx+++ b/packages/documents/src/pdf/components/Summary.tsx@@ -23,7 +23,7 @@ const styles = StyleSheet.create({rowGap: 3,fontSize: 11,fontWeight: 500,- width: "68%",+ width: "60%",},companyName: {fontSize: 13,@@ -37,7 +37,7 @@ const styles = StyleSheet.create({rowGap: 3,fontSize: 11,fontWeight: 500,- width: "32%",+ width: "40%",},documentSummaryItem: {display: "flex",@@ -48,7 +48,7 @@ const styles = StyleSheet.create({documentSummaryLabel: {color: "#7d7d7d",fontWeight: 700,- width: "30%",+ width: "50%",},documentSummaryValue: {fontWeight: 500,