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
Add Customer to quote pdf and update column order
neilk171704018bebb0
diff --git a/apps/carbon/app/routes/file+/quote+/$id[.]pdf.tsx b/apps/carbon/app/routes/file+/quote+/$id[.]pdf.tsxindex fb3e9593bf..6bd9aac65a 100644--- a/apps/carbon/app/routes/file+/quote+/$id[.]pdf.tsx+++ b/apps/carbon/app/routes/file+/quote+/$id[.]pdf.tsx@@ -6,6 +6,7 @@ import {getQuote,getQuoteLineQuantitiesByQuoteId,getQuoteLines,+ getCustomer,} from "~/modules/sales";import { getCompany } from "~/modules/settings";import { requirePermissions } from "~/services/auth";@@ -42,13 +43,28 @@ export async function loader({ request, params }: LoaderFunctionArgs) {logger.error(quoteLineQuantitiesByQuoteId.error);}- if (company.error || quote.error || quoteLines.error) {+ const customer = await Promise.resolve(+ getCustomer(client, quote.data?.customerId ?? "")+ );++ if (customer.error) {+ logger.error(customer.error);+ }++ if (+ company.error ||+ customer.error ||+ customer.error ||+ quote.error ||+ quoteLines.error+ ) {throw new Error("Failed to load quote");}const stream = await renderToStream(<QuotePDFcompany={company.data}+ customer={customer.data}quote={quote.data}quoteLines={quoteLines.data}quoteLineQuantities={quoteLineQuantitiesByQuoteId.data}diff --git a/packages/documents/src/pdf/QuotePDF.tsx b/packages/documents/src/pdf/QuotePDF.tsxindex d9d90a0ec4..28ef87af80 100644--- a/packages/documents/src/pdf/QuotePDF.tsx+++ b/packages/documents/src/pdf/QuotePDF.tsx@@ -6,6 +6,7 @@ import { QuoteSummary, Template, QuoteHeader } from "./components";import { getExtendedPrice, getUnitCost } from "../utils/quote";interface QuotePDFProps extends PDF {+ customer: Database["public"]["Tables"]["customer"]["Row"];quote: Database["public"]["Views"]["quotes"]["Row"];quoteLines: Database["public"]["Tables"]["quoteLine"]["Row"][];quoteLineQuantities:@@ -15,6 +16,7 @@ interface QuotePDFProps extends PDF {const QuotePDF = ({company,+ customer,meta,quote,quoteLines,@@ -38,6 +40,7 @@ const QuotePDF = ({/><QuoteSummarycompany={company}+ customer={customer}items={[{label: "Date",@@ -48,8 +51,8 @@ const QuotePDF = ({<View style={styles.table}><View style={styles.thead}><Text style={styles.tableCol1}>Description</Text>- <Text style={styles.tableCol2}>Lead Time</Text>- <Text style={styles.tableCol3}>Qty</Text>+ <Text style={styles.tableCol2}>Qty</Text>+ <Text style={styles.tableCol3}>Time</Text><Text style={styles.tableCol4}>Cost</Text><Text style={styles.tableCol5}>Total</Text></View>@@ -65,10 +68,10 @@ const QuotePDF = ({quantity.quoteLineId === line.id ? (<View style={styles.quantityRow} key={quantity.id}><View style={styles.quantityCol1}>- <Text>{quantity.leadTime} days</Text>+ <Text>{quantity.quantity}</Text></View><View style={styles.quantityCol2}>- <Text>{quantity.quantity}</Text>+ <Text>{quantity.leadTime} d</Text></View><View style={styles.quantityCol3}><Text>{getUnitCost(quantity).toFixed(2)}</Text>diff --git a/packages/documents/src/pdf/components/QuoteSummary.tsx b/packages/documents/src/pdf/components/QuoteSummary.tsxindex d4a4d950ec..e806729e8f 100644--- a/packages/documents/src/pdf/components/QuoteSummary.tsx+++ b/packages/documents/src/pdf/components/QuoteSummary.tsx@@ -1,8 +1,9 @@import { StyleSheet, Text, View } from "@react-pdf/renderer";-import type { Company } from "../../types";+import type { Company, Customer } from "../../types";type SummaryProps = {company: Company;+ customer: Customer;items: {label: string;value?: string | null;@@ -57,10 +58,11 @@ const styles = StyleSheet.create({},});-const QuoteSummary = ({ company, items }: SummaryProps) => {+const QuoteSummary = ({ company, customer, items }: SummaryProps) => {return (<View style={styles.summary}><View style={styles.companyDetails}>+ <Text style={styles.documentSummaryLabel}>From</Text><Text style={styles.companyName}>{company.name}</Text>{company.addressLine1 && <Text>{company.addressLine1}</Text>}{company.addressLine2 && <Text>{company.addressLine2}</Text>}@@ -69,7 +71,10 @@ const QuoteSummary = ({ company, items }: SummaryProps) => {)}{company.phone && <Text>{company.phone}</Text>}{company.email && <Text>{company.email}</Text>}- {company.website && <Text>{company.website}</Text>}+ </View>+ <View style={styles.companyDetails}>+ <Text style={styles.documentSummaryLabel}>To</Text>+ <Text style={styles.companyName}>{customer.name}</Text></View><View style={styles.documentSummary}>{items.map((item) => (diff --git a/packages/documents/src/types.ts b/packages/documents/src/types.tsindex fbc0d9c5de..437be2a024 100644--- a/packages/documents/src/types.ts+++ b/packages/documents/src/types.ts@@ -27,3 +27,4 @@ export type Meta = {};export type Company = Database["public"]["Tables"]["company"]["Row"];+export type Customer = Database["public"]["Tables"]["customer"]["Row"];