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: add internal and external notes to sales order

Brad Barbin9de728ce5c84
diff --git a/apps/carbon/app/modules/sales/ui/OpportunityDocuments/OpportunityDocuments.tsx b/apps/carbon/app/modules/sales/ui/Opportunity/OpportunityDocuments.tsx
similarity index 100%
rename from apps/carbon/app/modules/sales/ui/OpportunityDocuments/OpportunityDocuments.tsx
rename to apps/carbon/app/modules/sales/ui/Opportunity/OpportunityDocuments.tsx
diff --git a/apps/carbon/app/modules/sales/ui/OpportunityDocuments/OpportunityLineDocuments.tsx b/apps/carbon/app/modules/sales/ui/Opportunity/OpportunityLineDocuments.tsx
similarity index 100%
rename from apps/carbon/app/modules/sales/ui/OpportunityDocuments/OpportunityLineDocuments.tsx
rename to apps/carbon/app/modules/sales/ui/Opportunity/OpportunityLineDocuments.tsx
diff --git a/apps/carbon/app/modules/sales/ui/Opportunity/OpportunityNotes.tsx b/apps/carbon/app/modules/sales/ui/Opportunity/OpportunityNotes.tsx
new file mode 100644
index 0000000000..c683ee05e4
--- /dev/null
+++ b/apps/carbon/app/modules/sales/ui/Opportunity/OpportunityNotes.tsx
@@ -0,0 +1,127 @@
+import { useCarbon } from "@carbon/auth";
+import type { JSONContent } from "@carbon/react";
+import {
+ Card,
+ CardContent,
+ CardHeader,
+ CardTitle,
+ Editor,
+ generateHTML,
+ HStack,
+ toast,
+ useThrottle,
+} from "@carbon/react";
+import { getLocalTimeZone, today } from "@internationalized/date";
+import { nanoid } from "nanoid";
+import { usePermissions, useUser } from "~/hooks";
+import { getPrivateUrl } from "~/utils/path";
+
+const OpportunityNotes = ({
+ id,
+ table,
+ internalNotes,
+ externalNotes,
+}: {
+ id: string | null;
+ table: "salesRfq" | "quote" | "salesOrder";
+ internalNotes?: JSONContent;
+ externalNotes?: JSONContent;
+}) => {
+ const {
+ id: userId,
+ company: { id: companyId },
+ } = useUser();
+ const { carbon } = useCarbon();
+ const permissions = usePermissions();
+
+ const onUploadImage = async (file: File) => {
+ const fileType = file.name.split(".").pop();
+ const fileName = `${companyId}/opportunity/${id}/${nanoid()}.${fileType}`;
+
+ const result = await carbon?.storage.from("private").upload(fileName, file);
+
+ if (result?.error) {
+ toast.error("Failed to upload image");
+ throw new Error(result.error.message);
+ }
+
+ if (!result?.data) {
+ throw new Error("Failed to upload image");
+ }
+
+ return getPrivateUrl(result.data.path);
+ };
+
+ const onUpdateExternalNotes = useThrottle(async (content: JSONContent) => {
+ await carbon
+ ?.from(table)
+ .update({
+ externalNotes: content,
+ updatedAt: today(getLocalTimeZone()).toString(),
+ updatedBy: userId,
+ })
+ .eq("id", id!);
+ }, 2500);
+
+ const onUpdateInternalNotes = useThrottle(async (content: JSONContent) => {
+ await carbon
+ ?.from(table)
+ .update({
+ internalNotes: content,
+ updatedAt: today(getLocalTimeZone()).toString(),
+ updatedBy: userId,
+ })
+ .eq("id", id!);
+ }, 2500);
+
+ if (!id) return null;
+
+ return (
+ <HStack className="w-full justify-between items-stretch">
+ <Card>
+ <CardHeader>
+ <CardTitle>External Notes</CardTitle>
+ </CardHeader>
+ <CardContent>
+ {permissions.can("update", "sales") ? (
+ <Editor
+ initialValue={(externalNotes ?? {}) as JSONContent}
+ onUpload={onUploadImage}
+ onChange={onUpdateExternalNotes}
+ />
+ ) : (
+ <div
+ className="prose dark:prose-invert"
+ dangerouslySetInnerHTML={{
+ __html: generateHTML(externalNotes as JSONContent),
+ }}
+ />
+ )}
+ </CardContent>
+ </Card>
+ <Card>
+ <CardHeader>
+ <CardTitle>Internal Notes</CardTitle>
+ </CardHeader>
+ <CardContent>
+ {permissions.can("update", "sales") ? (
+ <Editor
+ initialValue={(internalNotes ?? {}) as JSONContent}
+ onUpload={onUploadImage}
+ onChange={onUpdateInternalNotes}
+ />
+ ) : (
+ <div
+ className="prose dark:prose-invert"
+ dangerouslySetInnerHTML={{
+ __html: generateHTML(internalNotes as JSONContent),
+ }}
+ />
+ )}
+ </CardContent>
+ </Card>
+ </HStack>
+ );
+};
+
+export default OpportunityNotes;
diff --git a/apps/carbon/app/modules/sales/ui/Opportunity/index.ts b/apps/carbon/app/modules/sales/ui/Opportunity/index.ts
new file mode 100644
index 0000000000..9f498b5663
--- /dev/null
+++ b/apps/carbon/app/modules/sales/ui/Opportunity/index.ts
@@ -0,0 +1,5 @@
+import OpportunityDocuments from "./OpportunityDocuments";
+import OpportunityLineDocuments from "./OpportunityLineDocuments";
+import OpportunityNotes from "./OpportunityNotes";
+
+export { OpportunityDocuments, OpportunityLineDocuments, OpportunityNotes };
diff --git a/apps/carbon/app/modules/sales/ui/OpportunityDocuments/index.ts b/apps/carbon/app/modules/sales/ui/OpportunityDocuments/index.ts
deleted file mode 100644
index 72fcd12276..0000000000
--- a/apps/carbon/app/modules/sales/ui/OpportunityDocuments/index.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-import OpportunityDocuments from "./OpportunityDocuments";
-import OpportunityLineDocuments from "./OpportunityLineDocuments";
-
-export { OpportunityDocuments, OpportunityLineDocuments };
diff --git a/apps/carbon/app/modules/sales/ui/Quotes/QuoteToOrderModal.tsx b/apps/carbon/app/modules/sales/ui/Quotes/QuoteToOrderModal.tsx
index e979f24431..7fea2e2e11 100644
--- a/apps/carbon/app/modules/sales/ui/Quotes/QuoteToOrderModal.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotes/QuoteToOrderModal.tsx
@@ -57,7 +57,7 @@ import type {
QuotationPrice,
QuotationShipment,
} from "../../types";
-import { useOpportunityDocuments } from "../OpportunityDocuments/OpportunityDocuments";
+import { useOpportunityDocuments } from "../Opportunity/OpportunityDocuments";
type QuoteToOrderDrawerProps = {
isOpen: boolean;
diff --git a/apps/carbon/app/modules/sales/ui/index.ts b/apps/carbon/app/modules/sales/ui/index.ts
index 65c31e98a7..6e52d2a0f8 100644
--- a/apps/carbon/app/modules/sales/ui/index.ts
+++ b/apps/carbon/app/modules/sales/ui/index.ts
@@ -3,7 +3,7 @@ export * from "./Customer";
export * from "./Customers";
export * from "./CustomerStatuses";
export * from "./CustomerTypes";
-export * from "./OpportunityDocuments";
+export * from "./Opportunity";
export * from "./Quotes";
export * from "./SalesOrder";
export * from "./SalesOrders";
diff --git a/apps/carbon/app/routes/x+/quote+/$quoteId.details.tsx b/apps/carbon/app/routes/x+/quote+/$quoteId.details.tsx
index bb0c4a6017..e836d20264 100644
--- a/apps/carbon/app/routes/x+/quote+/$quoteId.details.tsx
+++ b/apps/carbon/app/routes/x+/quote+/$quoteId.details.tsx
@@ -1,26 +1,13 @@
-import { assertIsPost, error, success, useCarbon } from "@carbon/auth";
+import { assertIsPost, error, success } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { validationError, validator } from "@carbon/form";
import type { JSONContent } from "@carbon/react";
-import {
- Card,
- CardContent,
- CardHeader,
- CardTitle,
- Editor,
- generateHTML,
- HStack,
- toast,
- useThrottle,
-} from "@carbon/react";
-import { getLocalTimeZone, today } from "@internationalized/date";
import { useParams } from "@remix-run/react";
import type { FileObject } from "@supabase/storage-js";
import type { ActionFunctionArgs } from "@vercel/remix";
import { redirect } from "@vercel/remix";
-import { nanoid } from "nanoid";
-import { usePermissions, useRouteData, useUser } from "~/hooks";
+import { useRouteData } from "~/hooks";
import type {
Opportunity,
Quotation,
@@ -29,6 +16,7 @@ import type {
} from "~/modules/sales";
import {
OpportunityDocuments,
+ OpportunityNotes,
QuoteForm,
QuotePaymentForm,
QuoteShipmentForm,
@@ -36,7 +24,7 @@ import {
upsertQuote,
} from "~/modules/sales";
import { setCustomFields } from "~/utils/form";
-import { getPrivateUrl, path } from "~/utils/path";
+import { path } from "~/utils/path";
export async function action({ request, params }: ActionFunctionArgs) {
assertIsPost(request);
@@ -142,102 +130,13 @@ export default function QuoteDetailsRoute() {
key={`shipment-${initialValues.id}`}
initialValues={shipmentInitialValues}
/>
- <QuoteNotes quote={quoteData?.quote} />
+ <OpportunityNotes
+ key={`notes-${initialValues.id}`}
+ id={quoteData.quote.id}
+ table="quote"
+ internalNotes={quoteData.quote.internalNotes as JSONContent}
+ externalNotes={quoteData.quote.externalNotes as JSONContent}
+ />
</>
);
}
-
-const QuoteNotes = ({ quote }: { quote: Quotation }) => {
- const {
- id: userId,
- company: { id: companyId },
- } = useUser();
- const { carbon } = useCarbon();
- const permissions = usePermissions();
-
- const onUploadImage = async (file: File) => {
- const fileType = file.name.split(".").pop();
- const fileName = `${companyId}/quote/${quote.id}/${nanoid()}.${fileType}`;
- const result = await carbon?.storage.from("private").upload(fileName, file);
-
- if (result?.error) {
- toast.error("Failed to upload image");
- throw new Error(result.error.message);
- }
-
- if (!result?.data) {
- throw new Error("Failed to upload image");
- }
-
- return getPrivateUrl(result.data.path);
- };
-
- const onUpdateExternalNotes = useThrottle(async (content: JSONContent) => {
- await carbon
- ?.from("quote")
- .update({
- externalNotes: content,
- updatedAt: today(getLocalTimeZone()).toString(),
- updatedBy: userId,
- })
- .eq("id", quote.id!);
- }, 2500);
-
- const onUpdateInternalNotes = useThrottle(async (content: JSONContent) => {
- await carbon
- ?.from("quote")
- .update({
- internalNotes: content,
- updatedAt: today(getLocalTimeZone()).toString(),
- updatedBy: userId,
- })
- .eq("id", quote.id!);
- }, 2500);
-
- return (
- <HStack className="w-full justify-between items-stretch">
- <Card>
- <CardHeader>
- <CardTitle>External Notes</CardTitle>
- </CardHeader>
- <CardContent>
- {permissions.can("update", "sales") ? (
- <Editor
- initialValue={(quote.externalNotes ?? {}) as JSONContent}
- onUpload={onUploadImage}
- onChange={onUpdateExternalNotes}
- />
- ) : (
- <div
- className="prose dark:prose-invert"
- dangerouslySetInnerHTML={{
- __html: generateHTML(quote.externalNotes as JSONContent),
- }}
- />
- )}
- </CardContent>
- </Card>
- <Card>
- <CardHeader>
- <CardTitle>Internal Notes</CardTitle>
- </CardHeader>
- <CardContent>
- {permissions.can("update", "sales") ? (
- <Editor
- initialValue={(quote.internalNotes ?? {}) as JSONContent}
- onUpload={onUploadImage}
- onChange={onUpdateInternalNotes}
- />
- ) : (
- <div
- className="prose dark:prose-invert"
- dangerouslySetInnerHTML={{
- __html: generateHTML(quote.internalNotes as JSONContent),
- }}
- />
- )}
- </CardContent>
- </Card>
- </HStack>
- );
-};
diff --git a/apps/carbon/app/routes/x+/sales-order+/$orderId.details.tsx b/apps/carbon/app/routes/x+/sales-order+/$orderId.details.tsx
index 7d5af6bef1..3320764c3c 100644
--- a/apps/carbon/app/routes/x+/sales-order+/$orderId.details.tsx
+++ b/apps/carbon/app/routes/x+/sales-order+/$orderId.details.tsx
@@ -12,6 +12,7 @@ import {
getSalesOrderPayment,
getSalesOrderShipment,
OpportunityDocuments,
+ OpportunityNotes,
SalesOrderForm,
SalesOrderPaymentForm,
SalesOrderShipmentForm,
@@ -22,6 +23,7 @@ import {
import { assertIsPost, error, success } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
+import type { JSONContent } from "@carbon/react";
import { getCustomFields, setCustomFields } from "~/utils/form";
import { path } from "~/utils/path";
@@ -157,7 +159,8 @@ export default function SalesOrderRoute() {
status: orderData?.salesOrder?.status ?? ("Draft" as "Draft"),
receiptRequestedDate: orderData?.salesOrder?.receiptRequestedDate ?? "",
receiptPromisedDate: orderData?.salesOrder?.receiptPromisedDate ?? "",
- notes: orderData?.salesOrder?.notes ?? "",
+ externalNotes: orderData?.salesOrder?.externalNotes ?? {},
+ internalNotes: orderData?.salesOrder?.internalNotes ?? {},
currencyCode: orderData?.salesOrder?.currencyCode ?? "",
exchangeRate: orderData?.salesOrder?.exchangeRate ?? undefined,
exchangeRateUpdatedAt: orderData?.salesOrder?.exchangeRateUpdatedAt ?? "",
@@ -195,20 +198,28 @@ export default function SalesOrderRoute() {
<>
<SalesOrderForm key={initialValues.id} initialValues={initialValues} />
<OpportunityDocuments
+ key={`documents-${initialValues.id}`}
opportunity={orderData?.opportunity!}
attachments={orderData?.files ?? []}
id={orderId}
type="Sales Order"
/>
+ <OpportunityNotes
+ key={`notes-${orderId}`}
+ id={orderData.salesOrder.id}
+ table="salesOrder"
+ internalNotes={orderData.salesOrder.internalNotes as JSONContent}
+ externalNotes={orderData.salesOrder.externalNotes as JSONContent}
+ />
<SalesOrderShipmentForm
- key={initialValues.id}
+ key={`shipment-${initialValues.id}`}
initialValues={shipmentInitialValues}
// shippingTerms={shippingTerms as ListItem[]}
/>
<SalesOrderPaymentForm
- key={initialValues.id}
+ key={`payment-${initialValues.id}`}
initialValues={paymentInitialValues}
/>
</>
diff --git a/apps/carbon/app/routes/x+/sales-rfq+/$rfqId.details.tsx b/apps/carbon/app/routes/x+/sales-rfq+/$rfqId.details.tsx
index 7f9f9705e2..20f73dae63 100644
--- a/apps/carbon/app/routes/x+/sales-rfq+/$rfqId.details.tsx
+++ b/apps/carbon/app/routes/x+/sales-rfq+/$rfqId.details.tsx
@@ -1,27 +1,15 @@
-import { assertIsPost, error, success, useCarbon } from "@carbon/auth";
+import { assertIsPost, error, success } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { validationError, validator } from "@carbon/form";
import type { JSONContent } from "@carbon/react";
-import {
- Card,
- CardContent,
- CardHeader,
- CardTitle,
- Editor,
- generateHTML,
- HStack,
- toast,
- useThrottle,
- VStack,
-} from "@carbon/react";
-import { getLocalTimeZone, parseDate, today } from "@internationalized/date";
+import { VStack } from "@carbon/react";
+import { parseDate } from "@internationalized/date";
import { useParams } from "@remix-run/react";
import type { FileObject } from "@supabase/storage-js";
import type { ActionFunctionArgs } from "@vercel/remix";
import { redirect } from "@vercel/remix";
-import { nanoid } from "nanoid";
-import { usePermissions, useRouteData, useUser } from "~/hooks";
+import { useRouteData } from "~/hooks";
import type {
Opportunity,
SalesRFQ,
@@ -30,12 +18,13 @@ import type {
} from "~/modules/sales";
import {
OpportunityDocuments,
+ OpportunityNotes,
SalesRFQForm,
salesRfqValidator,
upsertSalesRFQ,
} from "~/modules/sales";
import { getCustomFields, setCustomFields } from "~/utils/form";
-import { getPrivateUrl, path } from "~/utils/path";
+import { path } from "~/utils/path";
export async function action({ request, params }: ActionFunctionArgs) {
assertIsPost(request);
@@ -114,110 +103,19 @@ export default function SalesRFQDetailsRoute() {
initialValues={initialValues}
/>
<OpportunityDocuments
+ key={`documents-${rfqId}`}
opportunity={rfqData?.opportunity!}
attachments={rfqData?.files ?? []}
id={rfqId}
type="Request for Quote"
/>
- <SalesRFQNotes salesRfq={rfqData.rfqSummary} />
+ <OpportunityNotes
+ key={`notes-${rfqId}`}
+ id={rfqData.rfqSummary.id}
+ table="salesRfq"
+ internalNotes={rfqData.rfqSummary.internalNotes as JSONContent}
+ externalNotes={rfqData.rfqSummary.externalNotes as JSONContent}
+ />
</VStack>
);
}
-
-const SalesRFQNotes = ({ salesRfq }: { salesRfq: SalesRFQ }) => {
- const {
- id: userId,
- company: { id: companyId },
- } = useUser();
- const { carbon } = useCarbon();
- const permissions = usePermissions();
-
- const onUploadImage = async (file: File) => {
- const fileType = file.name.split(".").pop();
- const fileName = `${companyId}/opportunity/${
- salesRfq.id
- }/${nanoid()}.${fileType}`;
-
- const result = await carbon?.storage.from("private").upload(fileName, file);
-
- if (result?.error) {
- toast.error("Failed to upload image");
- throw new Error(result.error.message);
- }
-
- if (!result?.data) {
- throw new Error("Failed to upload image");
- }
-
- return getPrivateUrl(result.data.path);
- };
-
- const onUpdateExternalNotes = useThrottle(async (content: JSONContent) => {
- await carbon
- ?.from("salesRfq")
- .update({
- externalNotes: content,
- updatedAt: today(getLocalTimeZone()).toString(),
- updatedBy: userId,
- })
- .eq("id", salesRfq.id!);
- }, 2500);
-
- const onUpdateInternalNotes = useThrottle(async (content: JSONContent) => {
- await carbon
- ?.from("salesRfq")
- .update({
- internalNotes: content,
- updatedAt: today(getLocalTimeZone()).toString(),
- updatedBy: userId,
- })
- .eq("id", salesRfq.id!);
- }, 2500);
-
- return (
- <HStack className="w-full justify-between items-stretch">
- <Card>
- <CardHeader>
- <CardTitle>External Notes</CardTitle>
- </CardHeader>
- <CardContent>
- {permissions.can("update", "sales") ? (
- <Editor
- initialValue={(salesRfq.externalNotes ?? {}) as JSONContent}
- onUpload={onUploadImage}
- onChange={onUpdateExternalNotes}
- />
- ) : (
- <div
- className="prose dark:prose-invert"
- dangerouslySetInnerHTML={{
- __html: generateHTML(salesRfq.externalNotes as JSONContent),
- }}
- />
- )}
- </CardContent>
- </Card>
- <Card>
- <CardHeader>
- <CardTitle>Internal Notes</CardTitle>
- </CardHeader>
- <CardContent>
- {permissions.can("update", "sales") ? (
- <Editor
- initialValue={(salesRfq.internalNotes ?? {}) as JSONContent}
- onUpload={onUploadImage}
- onChange={onUpdateInternalNotes}
- />
- ) : (
- <div
- className="prose dark:prose-invert"
- dangerouslySetInnerHTML={{
- __html: generateHTML(salesRfq.internalNotes as JSONContent),
- }}
- />
- )}
- </CardContent>
- </Card>
- </HStack>
- );
-};
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index e8b7768c2f..aafa4514f2 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -16441,9 +16441,10 @@ export type Database = {
customFields: Json | null
exchangeRate: number | null
exchangeRateUpdatedAt: string | null
+ externalNotes: Json | null
id: string
+ internalNotes: Json | null
locationId: string | null
- notes: string | null
orderDate: string
revisionId: number
salesOrderId: string
@@ -16466,9 +16467,10 @@ export type Database = {
customFields?: Json | null
exchangeRate?: number | null
exchangeRateUpdatedAt?: string | null
+ externalNotes?: Json | null
id?: string
+ internalNotes?: Json | null
locationId?: string | null
- notes?: string | null
orderDate?: string
revisionId?: number
salesOrderId: string
@@ -16491,9 +16493,10 @@ export type Database = {
customFields?: Json | null
exchangeRate?: number | null
exchangeRateUpdatedAt?: string | null
+ externalNotes?: Json | null
id?: string
+ internalNotes?: Json | null
locationId?: string | null
- notes?: string | null
orderDate?: string
revisionId?: number
salesOrderId?: string
@@ -27691,11 +27694,12 @@ export type Database = {
dropShipment: boolean | null
exchangeRate: number | null
exchangeRateUpdatedAt: string | null
+ externalNotes: Json | null
favorite: boolean | null
id: string | null
+ internalNotes: Json | null
locationId: string | null
locationName: string | null
- notes: string | null
orderDate: string | null
paymentTermName: string | null
receiptPromisedDate: string | null
diff --git a/packages/database/supabase/functions/convert/index.ts b/packages/database/supabase/functions/convert/index.ts
index f97ab2b164..3f5a00769c 100644
--- a/packages/database/supabase/functions/convert/index.ts
+++ b/packages/database/supabase/functions/convert/index.ts
@@ -117,6 +117,8 @@ serve(async (req: Request) => {
quote.data.currencyCode ??
company.data?.baseCurrencyCode ??
"USD",
+ externalNotes: quote.data.externalNotes,
+ internalNotes: quote.data.internalNotes,
exchangeRate: quote.data.exchangeRate ?? 1,
exchangeRateUpdatedAt:
quote.data.exchangeRateUpdatedAt ?? new Date().toISOString(),
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index e8b7768c2f..aafa4514f2 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -16441,9 +16441,10 @@ export type Database = {
customFields: Json | null
exchangeRate: number | null
exchangeRateUpdatedAt: string | null
+ externalNotes: Json | null
id: string
+ internalNotes: Json | null
locationId: string | null
- notes: string | null
orderDate: string
revisionId: number
salesOrderId: string
@@ -16466,9 +16467,10 @@ export type Database = {
customFields?: Json | null
exchangeRate?: number | null
exchangeRateUpdatedAt?: string | null
+ externalNotes?: Json | null
id?: string
+ internalNotes?: Json | null
locationId?: string | null
- notes?: string | null
orderDate?: string
revisionId?: number
salesOrderId: string
@@ -16491,9 +16493,10 @@ export type Database = {
customFields?: Json | null
exchangeRate?: number | null
exchangeRateUpdatedAt?: string | null
+ externalNotes?: Json | null
id?: string
+ internalNotes?: Json | null
locationId?: string | null
- notes?: string | null
orderDate?: string
revisionId?: number
salesOrderId?: string
@@ -27691,11 +27694,12 @@ export type Database = {
dropShipment: boolean | null
exchangeRate: number | null
exchangeRateUpdatedAt: string | null
+ externalNotes: Json | null
favorite: boolean | null
id: string | null
+ internalNotes: Json | null
locationId: string | null
locationName: string | null
- notes: string | null
orderDate: string | null
paymentTermName: string | null
receiptPromisedDate: string | null
diff --git a/packages/database/supabase/migrations/20241104114102_sales-order-notes.sql b/packages/database/supabase/migrations/20241104114102_sales-order-notes.sql
new file mode 100644
index 0000000000..f7fd7373d2
--- /dev/null
+++ b/packages/database/supabase/migrations/20241104114102_sales-order-notes.sql
@@ -0,0 +1,4 @@
+ALTER TABLE "salesOrder"
+ DROP COLUMN IF EXISTS "notes",
+ ADD COLUMN "externalNotes" JSON DEFAULT '{}',
+ ADD COLUMN "internalNotes" JSON DEFAULT '{}';
\ No newline at end of file
diff --git a/packages/documents/src/pdf/SalesOrderPDF.tsx b/packages/documents/src/pdf/SalesOrderPDF.tsx
index d450eeeb29..774c990011 100644
--- a/packages/documents/src/pdf/SalesOrderPDF.tsx
+++ b/packages/documents/src/pdf/SalesOrderPDF.tsx
@@ -231,17 +231,13 @@ const SalesOrderPDF = ({
</Text>
</View>
</View>
- {salesOrder?.notes && (
- <View style={tw("flex flex-row mb-5")}>
- <View style={tw("w-1/2")}>
- <Text style={tw("text-gray-500 text-xs")}>Notes</Text>
- <Text style={tw("text-sm")}>{salesOrder?.notes}</Text>
- </View>
- </View>
- )}
- </View>
- <View style={tw("flex flex-col gap-4 w-full")}>
- <Note title="Standard Terms & Conditions" content={terms} />
+ <View style={tw("flex flex-col gap-4 w-full")}>
+ <Note
+ title="Notes"
+ content={(salesOrder.externalNotes ?? {}) as JSONContent}
+ />
+ <Note title="Standard Terms & Conditions" content={terms} />
+ </View>
</View>
</Template>
);