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.

fix: update unit cost from price changes to quote line

Brad Barbinaf9be4deef9b
diff --git a/apps/carbon/app/modules/sales/ui/Quotes/QuoteExplorer.tsx b/apps/carbon/app/modules/sales/ui/Quotes/QuoteExplorer.tsx
index 4203988e74..c8df9c8bf1 100644
--- a/apps/carbon/app/modules/sales/ui/Quotes/QuoteExplorer.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotes/QuoteExplorer.tsx
@@ -18,7 +18,7 @@ import {
VStack,
} from "@carbon/react";
import { prettifyKeyboardShortcut } from "@carbon/utils";
-import { useNavigate, useParams } from "@remix-run/react";
+import { Link, useNavigate, useParams } from "@remix-run/react";
import { useRef, useState } from "react";
import {
LuCheckCircle,
@@ -30,7 +30,7 @@ import {
LuTrash,
LuXCircle,
} from "react-icons/lu";
-import { Empty, ItemThumbnail } from "~/components";
+import { Empty, ItemThumbnail, MethodItemTypeIcon } from "~/components";
import type { Tree } from "~/components/TreeView";
import { flattenTree } from "~/components/TreeView";
import {
@@ -40,6 +40,7 @@ import {
useRouteData,
useUser,
} from "~/hooks";
+import { getLinkToItemDetails } from "~/modules/items/ui/Item/ItemForm";
import type { MethodItemType } from "~/modules/shared";
import { path } from "~/utils/path";
import type { quoteLineStatusType } from "../../sales.models";
@@ -290,6 +291,23 @@ function QuoteLineItem({
<DropdownMenuIcon icon={<LuTrash />} />
Delete Line
</DropdownMenuItem>
+ <DropdownMenuItem asChild>
+ <Link
+ to={getLinkToItemDetails(
+ line.itemType as MethodItemType,
+ line.itemId!
+ )}
+ >
+ <DropdownMenuIcon
+ icon={
+ <MethodItemTypeIcon
+ type={line.itemType as MethodItemType}
+ />
+ }
+ />
+ View Item Master
+ </Link>
+ </DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</HStack>
diff --git a/apps/carbon/app/modules/sales/ui/Quotes/QuoteLineForm.tsx b/apps/carbon/app/modules/sales/ui/Quotes/QuoteLineForm.tsx
index 92ab8cb5e2..c2b92ad6f8 100644
--- a/apps/carbon/app/modules/sales/ui/Quotes/QuoteLineForm.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotes/QuoteLineForm.tsx
@@ -22,7 +22,7 @@ import {
import { useCarbon } from "@carbon/auth";
import { TextArea, ValidatedForm } from "@carbon/form";
-import { useParams } from "@remix-run/react";
+import { Link, useParams } from "@remix-run/react";
import { useState } from "react";
import { BsThreeDotsVertical } from "react-icons/bs";
import { LuTrash } from "react-icons/lu";
@@ -41,6 +41,8 @@ import {
import { usePermissions, useRouteData, useUser } from "~/hooks";
import type { Quotation, QuotationLine } from "../../types";
+import { MethodItemTypeIcon } from "~/components";
+import { getLinkToItemDetails } from "~/modules/items/ui/Item/ItemForm";
import { methodType } from "~/modules/shared";
import { path } from "~/utils/path";
import { quoteLineStatusType, quoteLineValidator } from "../../sales.models";
@@ -231,6 +233,16 @@ const QuoteLineForm = ({
<DropdownMenuIcon icon={<LuTrash />} />
Delete Line
</DropdownMenuItem>
+ <DropdownMenuItem asChild>
+ <Link
+ to={getLinkToItemDetails("Part", itemData.itemId!)}
+ >
+ <DropdownMenuIcon
+ icon={<MethodItemTypeIcon type="Part" />}
+ />
+ View Item Master
+ </Link>
+ </DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</CardAction>
diff --git a/apps/carbon/app/routes/x+/items+/cost.$itemId.tsx b/apps/carbon/app/routes/x+/items+/cost.$itemId.tsx
index f3f0b3d578..f072d8ec22 100644
--- a/apps/carbon/app/routes/x+/items+/cost.$itemId.tsx
+++ b/apps/carbon/app/routes/x+/items+/cost.$itemId.tsx
@@ -10,17 +10,17 @@ export async function action({ request, params }: ActionFunctionArgs) {
});
const formData = await request.formData();
- const unitCost = parseInt(formData.get("unitCost") as string);
+ const unitCost = parseFloat(formData.get("unitCost") as string);
const { itemId } = params;
if (!itemId) throw new Error("Could not find itemId");
- const deletion = await updateItemCost(client, itemId, {
+ const update = await updateItemCost(client, itemId, {
unitCost,
updatedBy: userId,
});
- if (deletion.error) {
- console.error("Failed to update item cost", deletion.error);
+ if (update.error) {
+ console.error("Failed to update item cost", update.error);
return json({
error: "Failed to update item cost",
});
diff --git a/packages/auth/src/lib/supabase/provider.tsx b/packages/auth/src/lib/supabase/provider.tsx
index d4cbe050a1..26884d3a80 100644
--- a/packages/auth/src/lib/supabase/provider.tsx
+++ b/packages/auth/src/lib/supabase/provider.tsx
@@ -28,20 +28,25 @@ export const CarbonProvider = ({
const refresh = useFetcher<{}>();
useEffect(() => {
- const handleFocus = () => {
- refresh.submit(null, {
- method: "post",
- action: path.to.refreshSession,
- });
+ const handleVisibilityChange = () => {
+ if (document.visibilityState === "visible") {
+ refresh.submit(null, {
+ method: "post",
+ action: path.to.refreshSession,
+ });
+ }
};
if (isBrowser) {
- window.addEventListener("focus", handleFocus);
+ document.addEventListener("visibilitychange", handleVisibilityChange);
}
return () => {
if (isBrowser) {
- window.removeEventListener("focus", handleFocus);
+ document.removeEventListener(
+ "visibilitychange",
+ handleVisibilityChange
+ );
}
};
}, [refresh]);