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: supplier quote line pricing ui

Brad Barbin6b0d41f214b5
diff --git a/apps/carbon/app/entry.client.tsx b/apps/carbon/app/entry.client.tsx
index 6ebc2c895e..0c91f0eeae 100644
--- a/apps/carbon/app/entry.client.tsx
+++ b/apps/carbon/app/entry.client.tsx
@@ -1,4 +1,8 @@
-import { POSTHOG_API_HOST, POSTHOG_PROJECT_PUBLIC_KEY } from "@carbon/auth";
+import {
+ POSTHOG_API_HOST,
+ POSTHOG_PROJECT_PUBLIC_KEY,
+ VERCEL_URL,
+} from "@carbon/auth";
import { OperatingSystemContextProvider } from "@carbon/react";
import { I18nProvider } from "@react-aria/i18n";
import { RemixBrowser } from "@remix-run/react";
@@ -8,11 +12,13 @@ import { hydrateRoot } from "react-dom/client";
function PosthogInit() {
useEffect(() => {
- posthog.init(POSTHOG_PROJECT_PUBLIC_KEY, {
- api_host: POSTHOG_API_HOST,
- autocapture: false,
- capture_pageview: false,
- });
+ if (VERCEL_URL && !VERCEL_URL?.includes("localhost")) {
+ posthog.init(POSTHOG_PROJECT_PUBLIC_KEY, {
+ api_host: POSTHOG_API_HOST,
+ autocapture: false,
+ capture_pageview: false,
+ });
+ }
}, []);
return null;
}
diff --git a/apps/carbon/app/modules/purchasing/purchasing.service.ts b/apps/carbon/app/modules/purchasing/purchasing.service.ts
index 6b6346da89..e9200819aa 100644
--- a/apps/carbon/app/modules/purchasing/purchasing.service.ts
+++ b/apps/carbon/app/modules/purchasing/purchasing.service.ts
@@ -482,6 +482,17 @@ export async function getSupplierQuotes(
return query;
}
+export async function getSupplierQuoteLine(
+ client: SupabaseClient<Database>,
+ supplierQuoteLineId: string
+) {
+ return client
+ .from("supplierQuoteLines")
+ .select("*")
+ .eq("id", supplierQuoteLineId)
+ .single();
+}
+
export async function getSupplierQuoteLines(
client: SupabaseClient<Database>,
supplierQuoteId: string
@@ -492,6 +503,16 @@ export async function getSupplierQuoteLines(
.eq("supplierQuoteId", supplierQuoteId);
}
+export async function getSupplierQuoteLinePrices(
+ client: SupabaseClient<Database>,
+ supplierQuoteLineId: string
+) {
+ return client
+ .from("supplierQuoteLinePrice")
+ .select("*")
+ .eq("supplierQuoteLineId", supplierQuoteLineId);
+}
+
export async function getSupplierQuoteLinePricesByQuoteId(
client: SupabaseClient<Database>,
supplierQuoteId: string
diff --git a/apps/carbon/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteLinePricing.tsx b/apps/carbon/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteLinePricing.tsx
new file mode 100644
index 0000000000..4336574543
--- /dev/null
+++ b/apps/carbon/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteLinePricing.tsx
@@ -0,0 +1,385 @@
+import { useCarbon } from "@carbon/auth";
+import {
+ Card,
+ CardContent,
+ CardHeader,
+ CardTitle,
+ HStack,
+ NumberField,
+ NumberInput,
+ Table,
+ Tbody,
+ Td,
+ Th,
+ Thead,
+ toast,
+ Tr,
+ VStack,
+} from "@carbon/react";
+import { useFetcher, useParams } from "@remix-run/react";
+import { useEffect, useState } from "react";
+import {
+ useCurrencyFormatter,
+ usePermissions,
+ useRouteData,
+ useUser,
+} from "~/hooks";
+import { path } from "~/utils/path";
+import type {
+ SupplierQuote,
+ SupplierQuoteLine,
+ SupplierQuoteLinePrice,
+} from "../../types";
+
+const SupplierQuoteLinePricing = ({
+ line,
+ pricesByQuantity,
+}: {
+ line: SupplierQuoteLine;
+ pricesByQuantity: Record<number, SupplierQuoteLinePrice>;
+}) => {
+ const permissions = usePermissions();
+
+ const quantities = line.quantity ?? [1];
+
+ console.log({ line, pricesByQuantity });
+
+ const { id, lineId } = useParams();
+ if (!id) throw new Error("Could not find id");
+ if (!lineId) throw new Error("Could not find lineId");
+ const [prices, setPrices] =
+ useState<Record<number, SupplierQuoteLinePrice>>(pricesByQuantity);
+
+ useEffect(() => {
+ setPrices(pricesByQuantity);
+ }, [pricesByQuantity]);
+
+ const routeData = useRouteData<{
+ quote: SupplierQuote;
+ }>(path.to.supplierQuote(id));
+ const isEditable =
+ permissions.can("update", "purchasing") &&
+ ["Draft"].includes(routeData?.quote?.status ?? "");
+
+ const { carbon } = useCarbon();
+ const fetcher = useFetcher<{ id?: string; error: string | null }>();
+ useEffect(() => {
+ if (fetcher.data?.error) {
+ toast.error(fetcher.data.error);
+ }
+ }, [fetcher.data]);
+
+ const { id: userId, company } = useUser();
+ const baseCurrency = company?.baseCurrencyCode ?? "USD";
+
+ const formatter = useCurrencyFormatter();
+ const presentationCurrencyFormatter = useCurrencyFormatter(
+ routeData?.quote?.currencyCode ?? baseCurrency
+ );
+
+ const netPricesByQuantity = quantities.map((quantity, index) => {
+ const price = prices[quantity]?.unitPrice ?? 0;
+ const discount = prices[quantity]?.discountPercent ?? 0;
+ const netPrice = price * (1 - discount);
+ return netPrice;
+ });
+
+ const onUpdatePrice = async (
+ key: "leadTime" | "unitPrice" | "shippingCost",
+ quantity: number,
+ value: number
+ ) => {
+ if (!carbon) return;
+ const supplierQuoteExchangeRate = await carbon
+ .from("supplierQuote")
+ .select("id, exchangeRate")
+ .eq("id", id)
+ .single();
+
+ const hasPrice = prices[quantity];
+ const oldPrices = { ...prices };
+ const newPrices = { ...oldPrices };
+ if (!hasPrice) {
+ newPrices[quantity] = {
+ supplierQuoteId: id,
+ supplierQuoteLineId: lineId,
+ quantity,
+ leadTime: 0,
+ unitPrice: 0,
+ discountPercent: 0,
+ exchangeRate: supplierQuoteExchangeRate.data?.exchangeRate ?? 1,
+ shippingCost: 0,
+ createdBy: userId,
+ } as unknown as SupplierQuoteLinePrice;
+ }
+ newPrices[quantity] = { ...newPrices[quantity], [key]: value };
+
+ setPrices(newPrices);
+
+ if (hasPrice) {
+ const { error } = await carbon
+ .from("supplierQuoteLinePrice")
+ .update({ [key]: value })
+ .eq("supplierQuoteLineId", lineId)
+ .eq("quantity", quantity);
+ if (error) {
+ setPrices(oldPrices);
+ }
+ } else {
+ const { error } = await carbon.from("supplierQuoteLinePrice").insert([
+ {
+ ...newPrices[quantity],
+ },
+ ]);
+ if (error) {
+ setPrices(oldPrices);
+ }
+ }
+ };
+
+ return (
+ <Card>
+ <CardHeader>
+ <CardTitle>Prices</CardTitle>
+ </CardHeader>
+
+ <CardContent>
+ <Table>
+ <Thead>
+ <Tr>
+ <Th className="w-[300px]" />
+ {quantities.map((quantity) => (
+ <Th key={quantity.toString()}>{quantity}</Th>
+ ))}
+ </Tr>
+ </Thead>
+ <Tbody>
+ <Tr>
+ <Td className="border-r border-border group-hover:bg-muted/50">
+ <HStack className="w-full justify-between ">
+ <span>Lead Time</span>
+ </HStack>
+ </Td>
+ {quantities.map((quantity) => {
+ const leadTime = prices[quantity]?.leadTime ?? 0;
+ return (
+ <Td
+ key={quantity.toString()}
+ className="group-hover:bg-muted/50"
+ >
+ <NumberField
+ value={leadTime}
+ formatOptions={{
+ style: "unit",
+ unit: "day",
+ unitDisplay: "long",
+ }}
+ minValue={0}
+ onChange={(value) => {
+ if (Number.isFinite(value) && value !== leadTime) {
+ onUpdatePrice("leadTime", quantity, value);
+ }
+ }}
+ >
+ <NumberInput
+ className="border-0 -ml-3 shadow-none disabled:bg-transparent disabled:opacity-100"
+ isDisabled={!isEditable}
+ size="sm"
+ min={0}
+ />
+ </NumberField>
+ </Td>
+ );
+ })}
+ </Tr>
+
+ <Tr>
+ <Td className="border-r border-border">
+ <HStack className="w-full justify-between ">
+ <span>Unit Price</span>
+ </HStack>
+ </Td>
+ {quantities.map((quantity) => {
+ const price = prices[quantity]?.unitPrice;
+ return (
+ <Td key={quantity.toString()}>
+ <NumberField
+ value={price}
+ formatOptions={{
+ style: "currency",
+ currency: baseCurrency,
+ }}
+ minValue={0}
+ onChange={(value) => {
+ if (Number.isFinite(value) && value !== price) {
+ onUpdatePrice("unitPrice", quantity, value);
+ }
+ }}
+ >
+ <NumberInput
+ className="border-0 -ml-3 shadow-none disabled:bg-transparent disabled:opacity-100"
+ isDisabled={!isEditable}
+ size="sm"
+ min={0}
+ />
+ </NumberField>
+ </Td>
+ );
+ })}
+ </Tr>
+
+ <Tr className="[&>td]:bg-muted/60">
+ <Td className="border-r border-border group-hover:bg-muted/50">
+ <HStack className="w-full justify-between ">
+ <span>Net Unit Price</span>
+ </HStack>
+ </Td>
+ {netPricesByQuantity.map((price, index) => {
+ return (
+ <Td key={index} className="group-hover:bg-muted/50">
+ <VStack spacing={0}>
+ <span>{formatter.format(price)}</span>
+ </VStack>
+ </Td>
+ );
+ })}
+ </Tr>
+
+ <Tr>
+ <Td className="border-r border-border">
+ <HStack className="w-full justify-between ">
+ <span>Shipping Cost</span>
+ </HStack>
+ </Td>
+ {quantities.map((quantity) => {
+ const shippingCost = prices[quantity]?.shippingCost;
+ return (
+ <Td key={quantity.toString()}>
+ <NumberField
+ value={shippingCost}
+ formatOptions={{
+ style: "currency",
+ currency: baseCurrency,
+ }}
+ minValue={0}
+ onChange={(value) => {
+ if (Number.isFinite(value) && value !== shippingCost) {
+ onUpdatePrice("shippingCost", quantity, value);
+ }
+ }}
+ >
+ <NumberInput
+ className="border-0 -ml-3 shadow-none disabled:bg-transparent disabled:opacity-100"
+ isDisabled={!isEditable}
+ size="sm"
+ min={0}
+ />
+ </NumberField>
+ </Td>
+ );
+ })}
+ </Tr>
+
+ <Tr className="[&>td]:bg-muted/60">
+ <Td className="border-r border-border group-hover:bg-muted/50">
+ <HStack className="w-full justify-between ">
+ <span>Tax Percent</span>
+ </HStack>
+ </Td>
+ {quantities.map((quantity, index) => {
+ const taxPercent = line.taxPercent ?? 0;
+ return (
+ <Td key={index} className="group-hover:bg-muted/50">
+ <NumberField
+ value={taxPercent}
+ formatOptions={{
+ style: "percent",
+ maximumFractionDigits: 2,
+ }}
+ >
+ <NumberInput
+ className="border-0 -ml-3 shadow-none disabled:bg-transparent disabled:opacity-100"
+ size="sm"
+ />
+ </NumberField>
+ </Td>
+ );
+ })}
+ </Tr>
+ <Tr className="font-bold [&>td]:bg-muted/60">
+ <Td className="border-r border-border group-hover:bg-muted/50">
+ <HStack className="w-full justify-between ">
+ <span>Total Price</span>
+ </HStack>
+ </Td>
+ {quantities.map((quantity, index) => {
+ const subtotal =
+ (netPricesByQuantity[index] ?? 0) * quantity +
+ (prices[quantity]?.shippingCost ?? 0);
+ const tax = subtotal * (line.taxPercent ?? 0);
+ const price = subtotal + tax;
+ return (
+ <Td key={index} className="group-hover:bg-muted/50">
+ <VStack spacing={0}>
+ <span>{formatter.format(price)}</span>
+ </VStack>
+ </Td>
+ );
+ })}
+ </Tr>
+ {routeData?.quote?.currencyCode !== baseCurrency && (
+ <>
+ <Tr className="[&>td]:bg-muted/60">
+ <Td className="border-r border-border group-hover:bg-muted/50">
+ <HStack className="w-full justify-between ">
+ <span>Exchange Rate</span>
+ </HStack>
+ </Td>
+ {quantities.map((quantity, index) => {
+ const exchangeRate = prices[quantity]?.exchangeRate;
+ return (
+ <Td key={index} className="group-hover:bg-muted/50">
+ <VStack spacing={0}>
+ <span>{exchangeRate ?? 1}</span>
+ </VStack>
+ </Td>
+ );
+ })}
+ </Tr>
+ <Tr className="font-bold [&>td]:bg-muted/60">
+ <Td className="border-r border-border group-hover:bg-muted/50">
+ <HStack className="w-full justify-between ">
+ <span>Converted Total Price</span>
+ </HStack>
+ </Td>
+ {quantities.map((quantity, index) => {
+ const subtotal =
+ (netPricesByQuantity[index] ?? 0) * quantity +
+ (prices[quantity]?.shippingCost ?? 0);
+ const tax = subtotal * (line.taxPercent ?? 0);
+ const price = subtotal + tax;
+ const exchangeRate = prices[quantity]?.exchangeRate;
+ const convertedPrice = price * (exchangeRate ?? 1);
+ return (
+ <Td key={index} className="group-hover:bg-muted/50">
+ <VStack spacing={0}>
+ <span>
+ {presentationCurrencyFormatter.format(
+ convertedPrice
+ )}
+ </span>
+ </VStack>
+ </Td>
+ );
+ })}
+ </Tr>
+ </>
+ )}
+ </Tbody>
+ </Table>
+ </CardContent>
+ </Card>
+ );
+};
+
+export default SupplierQuoteLinePricing;
diff --git a/apps/carbon/app/modules/purchasing/ui/SupplierQuote/index.ts b/apps/carbon/app/modules/purchasing/ui/SupplierQuote/index.ts
index fa96cec646..e0fad16032 100644
--- a/apps/carbon/app/modules/purchasing/ui/SupplierQuote/index.ts
+++ b/apps/carbon/app/modules/purchasing/ui/SupplierQuote/index.ts
@@ -1,6 +1,7 @@
import DeleteSupplierQuoteLine from "./DeleteSupplierQuoteLine";
import SupplierQuoteForm from "./SupplierQuoteForm";
import SupplierQuoteLineForm from "./SupplierQuoteLineForm";
+import SupplierQuoteLinePricing from "./SupplierQuoteLinePricing";
import SupplierQuoteStatus from "./SupplierQuoteStatus";
import SupplierQuotesTable from "./SupplierQuotesTable";
@@ -8,6 +9,7 @@ export {
DeleteSupplierQuoteLine,
SupplierQuoteForm,
SupplierQuoteLineForm,
+ SupplierQuoteLinePricing,
SupplierQuoteStatus,
SupplierQuotesTable,
};
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 e34e2937ca..c71b5ab75c 100644
--- a/apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.details.tsx
+++ b/apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.details.tsx
@@ -165,6 +165,19 @@ export default function QuoteLine() {
return (
<Fragment key={lineId}>
<QuoteLineForm key={lineId} initialValues={initialValues} />
+ {line.status !== "No Quote" && (
+ <QuoteLinePricing
+ line={line}
+ pricesByQuantity={pricesByQuantity}
+ getLineCosts={getLineCosts}
+ />
+ )}
+ {line.methodType === "Make" && line.status !== "No Quote" && (
+ <QuoteLineCosting
+ quantities={line.quantity ?? [1]}
+ getLineCosts={getLineCosts}
+ />
+ )}
<OpportunityLineNotes
id={line.id}
table="quoteLine"
@@ -206,19 +219,6 @@ export default function QuoteLine() {
/>
</div>
- {line.methodType === "Make" && line.status !== "No Quote" && (
- <QuoteLineCosting
- quantities={line.quantity ?? [1]}
- getLineCosts={getLineCosts}
- />
- )}
- {line.status !== "No Quote" && (
- <QuoteLinePricing
- line={line}
- pricesByQuantity={pricesByQuantity}
- getLineCosts={getLineCosts}
- />
- )}
<Outlet />
</Fragment>
);
diff --git a/apps/carbon/app/routes/x+/supplier-quote+/$id.$lineId.details.tsx b/apps/carbon/app/routes/x+/supplier-quote+/$id.$lineId.details.tsx
index 9f881fe9f8..49e7bee245 100644
--- a/apps/carbon/app/routes/x+/supplier-quote+/$id.$lineId.details.tsx
+++ b/apps/carbon/app/routes/x+/supplier-quote+/$id.$lineId.details.tsx
@@ -8,19 +8,19 @@ import { Await, Outlet, useLoaderData, useParams } from "@remix-run/react";
import type { ActionFunctionArgs, LoaderFunctionArgs } from "@vercel/remix";
import { defer, redirect } from "@vercel/remix";
import { Fragment, Suspense } from "react";
-import { CadModel } from "~/components";
-import { usePermissions } from "~/hooks";
import type { SupplierQuoteLinePrice } from "~/modules/purchasing";
import {
getSupplierInteractionLineDocuments,
+ getSupplierQuoteLine,
getSupplierQuoteLinePrices,
- getSupplierQuoteLines,
SupplierInteractionLineDocuments,
SupplierInteractionLineNotes,
SupplierQuoteLineForm,
+ SupplierQuoteLinePricing,
supplierQuoteLineValidator,
upsertSupplierQuoteLine,
} from "~/modules/purchasing";
+import type { MethodItemType } from "~/modules/shared";
import { setCustomFields } from "~/utils/form";
import { path } from "~/utils/path";
@@ -40,13 +40,13 @@ export const loader = async ({ request, params }: LoaderFunctionArgs) => {
const serviceRole = await getCarbonServiceRole();
const [line, prices] = await Promise.all([
- getSupplierQuoteLines(serviceRole, lineId),
+ getSupplierQuoteLine(serviceRole, lineId),
getSupplierQuoteLinePrices(serviceRole, lineId),
]);
if (line.error) {
throw redirect(
- path.to.quote(id),
+ path.to.supplierQuote(id),
await flash(request, error(line.error, "Failed to load line"))
);
}
@@ -94,20 +94,23 @@ export async function action({ request, params }: ActionFunctionArgs) {
if (updateSupplierQuoteLine.error) {
throw redirect(
- path.to.quoteLine(id, lineId),
+ path.to.supplierQuoteLine(id, lineId),
await flash(
request,
- error(updateSupplierQuoteLine.error, "Failed to update quote line")
+ error(
+ updateSupplierQuoteLine.error,
+ "Failed to update supplierQuote line"
+ )
)
);
}
- throw redirect(path.to.quoteLine(id, lineId));
+ throw redirect(path.to.supplierQuoteLine(id, lineId));
}
-export default function QuoteLine() {
+export default function SupplierQuoteLine() {
const { line, files, pricesByQuantity } = useLoaderData<typeof loader>();
- const permissions = usePermissions();
+
const { id, lineId } = useParams();
if (!id) throw new Error("Could not find id");
if (!lineId) throw new Error("Could not find lineId");
@@ -115,25 +118,27 @@ export default function QuoteLine() {
const initialValues = {
...line,
id: line.id ?? undefined,
- purchasingQuoteId: line.purchasingQuoteId ?? "",
- customerPartId: line.customerPartId ?? "",
- customerPartRevision: line.customerPartRevision ?? "",
+ supplierQuoteId: line.supplierQuoteId ?? "",
+ supplierPartId: line.supplierPartId ?? "",
+ supplierPartRevision: line.supplierPartRevision ?? "",
description: line.description ?? "",
- estimatorId: line.estimatorId ?? "",
itemId: line.itemId ?? "",
itemReadableId: line.itemReadableId ?? "",
- methodType: line.methodType ?? "Make",
- modelUploadId: line.modelUploadId ?? undefined,
- noQuoteReason: line.noQuoteReason ?? undefined,
- status: line.status ?? "Not Started",
quantity: line.quantity ?? [1],
- unitOfMeasureCode: line.unitOfMeasureCode ?? "",
+ inventoryUnitOfMeasureCode: line.inventoryUnitOfMeasureCode ?? "",
+ purchaseUnitOfMeasureCode: line.purchaseUnitOfMeasureCode ?? "",
+ conversionFactor: line.conversionFactor ?? undefined,
taxPercent: line.taxPercent ?? 0,
+ itemType: (line.itemType ?? "Part") as MethodItemType,
};
return (
<Fragment key={lineId}>
<SupplierQuoteLineForm key={lineId} initialValues={initialValues} />
+ <SupplierQuoteLinePricing
+ line={line}
+ pricesByQuantity={pricesByQuantity}
+ />
<SupplierInteractionLineNotes
id={line.id}
table="supplierQuoteLine"
@@ -141,40 +146,25 @@ export default function QuoteLine() {
subTitle={line.itemReadableId ?? ""}
notes={line.notes as JSONContent}
/>
- <div className="grid grid-cols-1 2xl:grid-cols-2 w-full flex-grow gap-2 ">
- <Suspense
- fallback={
- <div className="flex w-full h-full rounded bg-gradient-to-tr from-background to-card items-center justify-center">
- <Spinner className="h-10 w-10" />
- </div>
- }
- >
- <Await resolve={files}>
- {(resolvedFiles) => (
- <SupplierInteractionLineDocuments
- files={resolvedFiles ?? []}
- id={id}
- lineId={lineId}
- type="Supplier Quote"
- />
- )}
- </Await>
- </Suspense>
-
- <CadModel
- isReadOnly={!permissions.can("update", "purchasing")}
- metadata={{
- quoteLineId: line.id ?? undefined,
- itemId: line.itemId ?? undefined,
- }}
- modelPath={line?.modelPath ?? null}
- title="CAD Model"
- uploadClassName="aspect-square min-h-[420px] max-h-[70vh]"
- viewerClassName="aspect-square min-h-[420px] max-h-[70vh]"
- />
- </div>
-
- <QuoteLinePricing line={line} pricesByQuantity={pricesByQuantity} />
+
+ <Suspense
+ fallback={
+ <div className="flex w-full h-full rounded bg-gradient-to-tr from-background to-card items-center justify-center">
+ <Spinner className="h-10 w-10" />
+ </div>
+ }
+ >
+ <Await resolve={files}>
+ {(resolvedFiles) => (
+ <SupplierInteractionLineDocuments
+ files={resolvedFiles ?? []}
+ id={id}
+ lineId={lineId}
+ type="Supplier Quote"
+ />
+ )}
+ </Await>
+ </Suspense>
<Outlet />
</Fragment>
diff --git a/apps/developers/app/entry.client.tsx b/apps/developers/app/entry.client.tsx
index 6ebc2c895e..0c91f0eeae 100644
--- a/apps/developers/app/entry.client.tsx
+++ b/apps/developers/app/entry.client.tsx
@@ -1,4 +1,8 @@
-import { POSTHOG_API_HOST, POSTHOG_PROJECT_PUBLIC_KEY } from "@carbon/auth";
+import {
+ POSTHOG_API_HOST,
+ POSTHOG_PROJECT_PUBLIC_KEY,
+ VERCEL_URL,
+} from "@carbon/auth";
import { OperatingSystemContextProvider } from "@carbon/react";
import { I18nProvider } from "@react-aria/i18n";
import { RemixBrowser } from "@remix-run/react";
@@ -8,11 +12,13 @@ import { hydrateRoot } from "react-dom/client";
function PosthogInit() {
useEffect(() => {
- posthog.init(POSTHOG_PROJECT_PUBLIC_KEY, {
- api_host: POSTHOG_API_HOST,
- autocapture: false,
- capture_pageview: false,
- });
+ if (VERCEL_URL && !VERCEL_URL?.includes("localhost")) {
+ posthog.init(POSTHOG_PROJECT_PUBLIC_KEY, {
+ api_host: POSTHOG_API_HOST,
+ autocapture: false,
+ capture_pageview: false,
+ });
+ }
}, []);
return null;
}
diff --git a/apps/mes/app/entry.client.tsx b/apps/mes/app/entry.client.tsx
index 6ebc2c895e..0c91f0eeae 100644
--- a/apps/mes/app/entry.client.tsx
+++ b/apps/mes/app/entry.client.tsx
@@ -1,4 +1,8 @@
-import { POSTHOG_API_HOST, POSTHOG_PROJECT_PUBLIC_KEY } from "@carbon/auth";
+import {
+ POSTHOG_API_HOST,
+ POSTHOG_PROJECT_PUBLIC_KEY,
+ VERCEL_URL,
+} from "@carbon/auth";
import { OperatingSystemContextProvider } from "@carbon/react";
import { I18nProvider } from "@react-aria/i18n";
import { RemixBrowser } from "@remix-run/react";
@@ -8,11 +12,13 @@ import { hydrateRoot } from "react-dom/client";
function PosthogInit() {
useEffect(() => {
- posthog.init(POSTHOG_PROJECT_PUBLIC_KEY, {
- api_host: POSTHOG_API_HOST,
- autocapture: false,
- capture_pageview: false,
- });
+ if (VERCEL_URL && !VERCEL_URL?.includes("localhost")) {
+ posthog.init(POSTHOG_PROJECT_PUBLIC_KEY, {
+ api_host: POSTHOG_API_HOST,
+ autocapture: false,
+ capture_pageview: false,
+ });
+ }
}, []);
return null;
}
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index 5226f69952..24d6219a4a 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -21601,6 +21601,7 @@ export type Database = {
itemReadableId: string | null;
notes: Json | null;
purchaseUnitOfMeasureCode: string | null;
+ quantity: number[] | null;
supplierPartId: string | null;
supplierPartRevision: string | null;
supplierQuoteId: string;
@@ -21622,6 +21623,7 @@ export type Database = {
itemReadableId?: string | null;
notes?: Json | null;
purchaseUnitOfMeasureCode?: string | null;
+ quantity?: number[] | null;
supplierPartId?: string | null;
supplierPartRevision?: string | null;
supplierQuoteId: string;
@@ -21643,6 +21645,7 @@ export type Database = {
itemReadableId?: string | null;
notes?: Json | null;
purchaseUnitOfMeasureCode?: string | null;
+ quantity?: number[] | null;
supplierPartId?: string | null;
supplierPartRevision?: string | null;
supplierQuoteId?: string;
@@ -30256,8 +30259,10 @@ export type Database = {
inventoryUnitOfMeasureCode: string | null;
itemId: string | null;
itemReadableId: string | null;
+ itemType: Database["public"]["Enums"]["itemType"] | null;
notes: Json | null;
purchaseUnitOfMeasureCode: string | null;
+ quantity: number[] | null;
supplierPartId: string | null;
supplierPartRevision: string | null;
supplierQuoteId: string | null;
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index 5226f69952..24d6219a4a 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -21601,6 +21601,7 @@ export type Database = {
itemReadableId: string | null;
notes: Json | null;
purchaseUnitOfMeasureCode: string | null;
+ quantity: number[] | null;
supplierPartId: string | null;
supplierPartRevision: string | null;
supplierQuoteId: string;
@@ -21622,6 +21623,7 @@ export type Database = {
itemReadableId?: string | null;
notes?: Json | null;
purchaseUnitOfMeasureCode?: string | null;
+ quantity?: number[] | null;
supplierPartId?: string | null;
supplierPartRevision?: string | null;
supplierQuoteId: string;
@@ -21643,6 +21645,7 @@ export type Database = {
itemReadableId?: string | null;
notes?: Json | null;
purchaseUnitOfMeasureCode?: string | null;
+ quantity?: number[] | null;
supplierPartId?: string | null;
supplierPartRevision?: string | null;
supplierQuoteId?: string;
@@ -30256,8 +30259,10 @@ export type Database = {
inventoryUnitOfMeasureCode: string | null;
itemId: string | null;
itemReadableId: string | null;
+ itemType: Database["public"]["Enums"]["itemType"] | null;
notes: Json | null;
purchaseUnitOfMeasureCode: string | null;
+ quantity: number[] | null;
supplierPartId: string | null;
supplierPartRevision: string | null;
supplierQuoteId: string | null;
diff --git a/packages/database/supabase/migrations/20241202192419_supplier-quotes.sql b/packages/database/supabase/migrations/20241202192419_supplier-quotes.sql
index f4b0d3fc5c..95f92a211a 100644
--- a/packages/database/supabase/migrations/20241202192419_supplier-quotes.sql
+++ b/packages/database/supabase/migrations/20241202192419_supplier-quotes.sql
@@ -209,6 +209,7 @@ DROP VIEW IF EXISTS "supplierQuoteLines";
CREATE OR REPLACE VIEW "supplierQuoteLines" WITH(SECURITY_INVOKER=true) AS (
SELECT
ql.*,
+ i."type" as "itemType",
i."thumbnailPath",
ic."unitCost" as "unitCost"
FROM "supplierQuoteLine" ql