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 thumbnail to quotes and sales order table

Brad Barbindb8fbbda5c30
diff --git a/apps/carbon/app/modules/sales/ui/Quotes/QuotesTable.tsx b/apps/carbon/app/modules/sales/ui/Quotes/QuotesTable.tsx
index 6063098463..bcecef4369 100644
--- a/apps/carbon/app/modules/sales/ui/Quotes/QuotesTable.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotes/QuotesTable.tsx
@@ -25,6 +25,7 @@ import {
CustomerAvatar,
EmployeeAvatar,
Hyperlink,
+ ItemThumbnail,
New,
Table,
} from "~/components";
@@ -117,6 +118,12 @@ const QuotesTable = memo(({ data, count }: QuotesTableProps) => {
</button>
</fetcher.Form>
)}
+ <ItemThumbnail
+ size="sm"
+ thumbnailPath={row.original.thumbnailPath}
+ // @ts-ignore
+ type={row.original.itemType}
+ />
<Hyperlink to={path.to.quoteDetails(row.original.id!)}>
{row.original.quoteId}
</Hyperlink>
diff --git a/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrdersTable.tsx b/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrdersTable.tsx
index 9649da7478..668a690fa0 100644
--- a/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrdersTable.tsx
+++ b/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrdersTable.tsx
@@ -26,6 +26,7 @@ import {
CustomerAvatar,
EmployeeAvatar,
Hyperlink,
+ ItemThumbnail,
New,
Table,
} from "~/components";
@@ -116,6 +117,12 @@ const SalesOrdersTable = memo(({ data, count }: SalesOrdersTableProps) => {
</fetcher.Form>
)}
+ <ItemThumbnail
+ size="sm"
+ thumbnailPath={row.original.thumbnailPath}
+ // @ts-ignore
+ type={row.original.itemType}
+ />
<Hyperlink to={path.to.salesOrderDetails(row.original.id!)}>
{row.original.salesOrderId}
</Hyperlink>
diff --git a/apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.details.tsx b/apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.details.tsx
index 3f9a17bea4..ddf6affaa5 100644
--- a/apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.details.tsx
+++ b/apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.details.tsx
@@ -34,6 +34,11 @@ import {
import { setCustomFields } from "~/utils/form";
import { path } from "~/utils/path";
+// the edge function grows larger than 2MB - so this is a workaround to avoid the edge function limit
+export const config = {
+ runtime: "nodejs",
+};
+
export const loader = async ({ request, params }: LoaderFunctionArgs) => {
const { companyId } = await requirePermissions(request, {
view: "sales",
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index 801244c852..aa54cd3ead 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -25942,14 +25942,14 @@ export type Database = {
},
{
foreignKeyName: "partner_id_fkey"
- columns: ["supplierLocationId"]
+ columns: ["id"]
isOneToOne: false
referencedRelation: "supplierLocation"
referencedColumns: ["id"]
},
{
foreignKeyName: "partner_id_fkey"
- columns: ["id"]
+ columns: ["supplierLocationId"]
isOneToOne: false
referencedRelation: "supplierLocation"
referencedColumns: ["id"]
@@ -27832,6 +27832,7 @@ export type Database = {
favorite: boolean | null
id: string | null
internalNotes: Json | null
+ itemType: Database["public"]["Enums"]["itemType"] | null
lines: number | null
locationId: string | null
locationName: string | null
@@ -27843,6 +27844,7 @@ export type Database = {
shippingCost: number | null
status: Database["public"]["Enums"]["quoteStatus"] | null
tags: string[] | null
+ thumbnailPath: string | null
updatedAt: string | null
updatedBy: string | null
}
@@ -28620,18 +28622,13 @@ export type Database = {
assignee: string | null
closedAt: string | null
closedBy: string | null
- closedByAvatar: string | null
- closedByFullName: string | null
companyId: string | null
createdAt: string | null
createdBy: string | null
- createdByAvatar: string | null
- createdByFullName: string | null
currencyCode: string | null
customerContactId: string | null
customerId: string | null
customerLocationId: string | null
- customerName: string | null
customerReference: string | null
customFields: Json | null
dropShipment: boolean | null
@@ -28641,6 +28638,7 @@ export type Database = {
favorite: boolean | null
id: string | null
internalNotes: Json | null
+ itemType: Database["public"]["Enums"]["itemType"] | null
locationId: string | null
locationName: string | null
orderDate: string | null
@@ -28654,10 +28652,9 @@ export type Database = {
shippingMethodName: string | null
shippingTermName: string | null
status: Database["public"]["Enums"]["salesOrderStatus"] | null
+ thumbnailPath: string | null
updatedAt: string | null
updatedBy: string | null
- updatedByAvatar: string | null
- updatedByFullName: string | null
}
Relationships: [
{
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index 801244c852..aa54cd3ead 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -25942,14 +25942,14 @@ export type Database = {
},
{
foreignKeyName: "partner_id_fkey"
- columns: ["supplierLocationId"]
+ columns: ["id"]
isOneToOne: false
referencedRelation: "supplierLocation"
referencedColumns: ["id"]
},
{
foreignKeyName: "partner_id_fkey"
- columns: ["id"]
+ columns: ["supplierLocationId"]
isOneToOne: false
referencedRelation: "supplierLocation"
referencedColumns: ["id"]
@@ -27832,6 +27832,7 @@ export type Database = {
favorite: boolean | null
id: string | null
internalNotes: Json | null
+ itemType: Database["public"]["Enums"]["itemType"] | null
lines: number | null
locationId: string | null
locationName: string | null
@@ -27843,6 +27844,7 @@ export type Database = {
shippingCost: number | null
status: Database["public"]["Enums"]["quoteStatus"] | null
tags: string[] | null
+ thumbnailPath: string | null
updatedAt: string | null
updatedBy: string | null
}
@@ -28620,18 +28622,13 @@ export type Database = {
assignee: string | null
closedAt: string | null
closedBy: string | null
- closedByAvatar: string | null
- closedByFullName: string | null
companyId: string | null
createdAt: string | null
createdBy: string | null
- createdByAvatar: string | null
- createdByFullName: string | null
currencyCode: string | null
customerContactId: string | null
customerId: string | null
customerLocationId: string | null
- customerName: string | null
customerReference: string | null
customFields: Json | null
dropShipment: boolean | null
@@ -28641,6 +28638,7 @@ export type Database = {
favorite: boolean | null
id: string | null
internalNotes: Json | null
+ itemType: Database["public"]["Enums"]["itemType"] | null
locationId: string | null
locationName: string | null
orderDate: string | null
@@ -28654,10 +28652,9 @@ export type Database = {
shippingMethodName: string | null
shippingTermName: string | null
status: Database["public"]["Enums"]["salesOrderStatus"] | null
+ thumbnailPath: string | null
updatedAt: string | null
updatedBy: string | null
- updatedByAvatar: string | null
- updatedByFullName: string | null
}
Relationships: [
{
diff --git a/packages/database/supabase/migrations/20241201200041_quote-order-job-thumbnails.sql b/packages/database/supabase/migrations/20241201200041_quote-order-job-thumbnails.sql
new file mode 100644
index 0000000000..8cd1da8465
--- /dev/null
+++ b/packages/database/supabase/migrations/20241201200041_quote-order-job-thumbnails.sql
@@ -0,0 +1,64 @@
+DROP VIEW IF EXISTS "salesOrders";
+CREATE OR REPLACE VIEW "salesOrders" WITH(SECURITY_INVOKER=true) AS
+ SELECT
+ s.*,
+ sl."thumbnailPath",
+ sl."itemType",
+ sm."name" AS "shippingMethodName",
+ st."name" AS "shippingTermName",
+ pt."name" AS "paymentTermName",
+ ss."receiptRequestedDate",
+ ss."receiptPromisedDate",
+ ss."dropShipment",
+ ss."shippingCost",
+ l."name" AS "locationName",
+ EXISTS(SELECT 1 FROM "salesOrderFavorite" sf WHERE sf."salesOrderId" = s.id AND sf."userId" = auth.uid()::text) AS favorite
+ FROM "salesOrder" s
+ LEFT JOIN (
+ SELECT
+ "salesOrderId",
+ MIN(i."thumbnailPath") AS "thumbnailPath",
+ MIN(i."type") AS "itemType"
+ FROM "salesOrderLine"
+ INNER JOIN "item" i
+ ON i."id" = "salesOrderLine"."itemId"
+ GROUP BY "salesOrderId"
+ ) sl ON sl."salesOrderId" = s."id"
+ LEFT JOIN "salesOrderShipment" ss ON ss."id" = s."id"
+ LEFT JOIN "shippingMethod" sm ON sm."id" = ss."shippingMethodId"
+ LEFT JOIN "shippingTerm" st ON st."id" = ss."shippingTermId"
+ LEFT JOIN "salesOrderPayment" sp ON sp."id" = s."id"
+ LEFT JOIN "paymentTerm" pt ON pt."id" = sp."paymentTermId"
+ LEFT JOIN "location" l ON l."id" = ss."locationId";
+
+DROP VIEW IF EXISTS "quotes";
+CREATE OR REPLACE VIEW "quotes" WITH(SECURITY_INVOKER=true) AS
+ SELECT
+ q.*,
+ ql."thumbnailPath",
+ ql."itemType",
+ l."name" AS "locationName",
+ ql."lines",
+ ql."completedLines",
+ EXISTS(SELECT 1 FROM "quoteFavorite" pf WHERE pf."quoteId" = q.id AND pf."userId" = auth.uid()::text) AS favorite,
+ opp."salesRfqId",
+ opp."salesOrderId",
+ qs."shippingCost"
+ FROM "quote" q
+ LEFT JOIN (
+ SELECT
+ "quoteId",
+ COUNT("quoteLine"."id") FILTER (WHERE "quoteLine"."status" != 'No Quote') AS "lines",
+ COUNT("quoteLine"."id") FILTER (WHERE "quoteLine"."status" = 'Complete') AS "completedLines",
+ MIN(i."thumbnailPath") AS "thumbnailPath",
+ MIN(i."type") AS "itemType"
+ FROM "quoteLine"
+ INNER JOIN "item" i
+ ON i."id" = "quoteLine"."itemId"
+ GROUP BY "quoteId"
+ ) ql ON ql."quoteId" = q.id
+ LEFT JOIN "quoteShipment" qs ON qs."id" = q."id"
+ LEFT JOIN "location" l
+ ON l.id = q."locationId"
+ LEFT JOIN "opportunity" opp
+ ON opp."quoteId" = q.id;
\ No newline at end of file