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
fix: quote line history should show revisions
Brad Barbind6fde585bd4d
diff --git a/apps/erp/app/modules/sales/sales.service.ts b/apps/erp/app/modules/sales/sales.service.tsindex 918e325a58..18c519bf2b 100644--- a/apps/erp/app/modules/sales/sales.service.ts+++ b/apps/erp/app/modules/sales/sales.service.ts@@ -931,6 +931,20 @@ export async function getQuoteLinePricesByItemId(.order("qty", { ascending: true });}+export async function getQuoteLinePricesByItemIds(+ client: SupabaseClient<Database>,+ itemIds: string[],+ currentQuoteId: string+) {+ return client+ .from("quoteLinePrices")+ .select("*")+ .in("itemId", itemIds)+ .neq("quoteId", currentQuoteId)+ .order("quoteCreatedAt", { ascending: false })+ .order("qty", { ascending: true });+}+export async function getQuoteMaterials(client: SupabaseClient<Database>,quoteId: string@@ -1040,10 +1054,20 @@ export async function getRelatedPricesForQuoteLine(itemId: string,quoteId: string) {+ const item = await client+ .rpc("get_part_details", {+ item_id: itemId,+ })+ .single();++ const itemIds = (item.data?.revisions as { id: string }[])?.map(+ (revision) => revision.id+ ) ?? [itemId];+const [historicalQuoteLinePrices, relatedSalesOrderLines] = await Promise.all([- getQuoteLinePricesByItemId(client, itemId, quoteId),- getSalesOrderLinesByItemId(client, itemId),+ getQuoteLinePricesByItemIds(client, itemIds, quoteId),+ getSalesOrderLinesByItemIds(client, itemIds),]);@@ -1236,6 +1260,18 @@ export async function getSalesOrderLinesByItemId(.order("createdAt", { ascending: false });}+export async function getSalesOrderLinesByItemIds(+ client: SupabaseClient<Database>,+ itemIds: string[]+) {+ return client+ .from("salesOrderLines")+ .select("*")+ .in("itemId", itemIds)+ .order("orderDate", { ascending: false })+ .order("createdAt", { ascending: false });+}+export async function getSalesOrderLine(client: SupabaseClient<Database>,salesOrderLineId: stringdiff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteLinePricingHistory.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteLinePricingHistory.tsxindex 91bba28052..3be56e90e1 100644--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteLinePricingHistory.tsx+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteLinePricingHistory.tsx@@ -27,9 +27,9 @@ import { Link } from "@remix-run/react";import { Empty } from "~/components";import { path } from "~/utils/path";-import type { HistoricalQuotationPrice, SalesOrderLine } from "../../types";import { formatDate } from "@carbon/utils";import { useCustomers } from "~/stores/customers";+import type { HistoricalQuotationPrice, SalesOrderLine } from "../../types";const QuoteLinePricingHistory = ({baseCurrency,@@ -106,26 +106,19 @@ const QuoteLinePricingHistory = ({key={line.id}className="pl-4 basis-full lg:basis-1/2 xl:basis-1/3">- <Card className="w-full p-0">+ <Card className="w-full p-0 bg-gradient-to-b from-card to-card via-card dark:from-card dark:to-card dark:via-card"><CardContent className="p-4"><HStack className="flex justify-between">- <Link- to={path.to.salesOrderLine(- line.salesOrderId!,- line.id!- )}- className="text-sm font-medium hover:underline"- >- {line.salesOrderReadableId}- </Link>- <div>- <span className="text-xs text-muted-foreground">- {formatDate(line.orderDate!)}- </span>- </div>- </HStack>- <div className="space-y-4">- <div className="flex justify-between">+ <div className="flex flex-col gap-1">+ <Link+ to={path.to.salesOrderLine(+ line.salesOrderId!,+ line.id!+ )}+ className="text-sm font-medium hover:underline"+ >+ {line.salesOrderReadableId}+ </Link><span className="text-sm text-muted-foreground">{customers.find(@@ -135,7 +128,16 @@ const QuoteLinePricingHistory = ({}</span></div>-+ <div className="flex flex-col gap-1 items-end">+ <span className="text-xs text-muted-foreground">+ {formatDate(line.orderDate!)}+ </span>+ <span className="text-xs text-muted-foreground">+ {line.itemReadableId}+ </span>+ </div>+ </HStack>+ <div className="my-4"><Table><Thead><Tr className="border-b border-border">@@ -190,36 +192,42 @@ const QuoteLinePricingHistory = ({key={line.id}className="pl-4 basis-full lg:basis-1/2 xl:basis-1/3">- <Card className="w-full p-0">+ <Card className="w-full p-0 bg-gradient-to-b from-card to-card via-card dark:from-card dark:to-card dark:via-card"><CardContent className="p-4">- <HStack className="flex justify-between">- <Link- to={path.to.quoteLine(- line.quoteId!,- line.id!- )}- className="text-sm font-medium hover:underline"- >- {line.quoteReadableId}- </Link>- <div>- <span className="text-xs text-muted-foreground">- {formatDate(line.quoteCreatedAt!)}- </span>- </div>- </HStack>- <div className="space-y-4">- <div className="flex justify-between">- <span className="text-sm text-muted-foreground">- {- customers.find(- (customer) =>- customer.id === line.customerId- )?.name- }- </span>- </div>+ <div className="flex flex-col gap-4">+ <HStack className="flex justify-between">+ <div className="flex flex-col gap-1">+ <Link+ to={path.to.quoteLine(+ line.quoteId!,+ line.id!+ )}+ className="text-sm font-medium hover:underline"+ >+ {line.quoteReadableId}+ </Link>++ <span className="text-sm text-muted-foreground">+ {+ customers.find(+ (customer) =>+ customer.id === line.customerId+ )?.name+ }+ </span>+ </div>+ <div className="flex flex-col gap-1 items-end">+ <span className="text-xs text-muted-foreground">+ {formatDate(line.quoteCreatedAt!)}+ </span>+ <span className="text-xs text-muted-foreground">+ {line.itemReadableId}+ </span>+ </div>+ </HStack>+ </div>+ <div className="my-4"><Table><Thead><Tr>diff --git a/apps/erp/app/routes/x+/part+/$itemId.view.details.tsx b/apps/erp/app/routes/x+/part+/$itemId.view.details.tsxindex a05a5f962a..180a22ee88 100644--- a/apps/erp/app/routes/x+/part+/$itemId.view.details.tsx+++ b/apps/erp/app/routes/x+/part+/$itemId.view.details.tsx@@ -5,30 +5,18 @@ import { validationError, validator } from "@carbon/form";import type { JSONContent } from "@carbon/react";import { Spinner, VStack } from "@carbon/react";import { Await, useParams } from "@remix-run/react";-import type { ActionFunctionArgs, LoaderFunctionArgs } from "@vercel/remix";-import { defer, redirect } from "@vercel/remix";+import type { ActionFunctionArgs } from "@vercel/remix";+import { redirect } from "@vercel/remix";import { Suspense } from "react";import { CadModel } from "~/components";import { usePermissions, useRouteData } from "~/hooks";import type { ItemFile, PartSummary } from "~/modules/items";-import { getPartUsedIn, partValidator, upsertPart } from "~/modules/items";+import { partValidator, upsertPart } from "~/modules/items";import { ItemDocuments, ItemNotes } from "~/modules/items/ui/Item";import { setCustomFields } from "~/utils/form";import { path } from "~/utils/path";-export async function loader({ request, params }: LoaderFunctionArgs) {- const { client, companyId } = await requirePermissions(request, {- view: "parts",- bypassRls: true,- });-- const { itemId } = params;- if (!itemId) throw new Error("Could not find itemId");-- return defer({ usedIn: getPartUsedIn(client, itemId, companyId) });-}-export async function action({ request, params }: ActionFunctionArgs) {assertIsPost(request);const { client, userId } = await requirePermissions(request, {