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

Brad Barbin471e95194850
diff --git a/apps/carbon/app/components/Layout/Navigation/GroupedContentSidebar.tsx b/apps/carbon/app/components/Layout/Navigation/GroupedContentSidebar.tsx
index eb51e4ee83..28a0b9beec 100644
--- a/apps/carbon/app/components/Layout/Navigation/GroupedContentSidebar.tsx
+++ b/apps/carbon/app/components/Layout/Navigation/GroupedContentSidebar.tsx
@@ -20,8 +20,8 @@ const GroupedContentSidebar = ({
{groups.map((group) => (
<VStack
key={group.name}
- spacing={1}
className="border-b border-border p-2"
+ spacing={1}
>
<h4 className="text-xs text-muted-foreground font-mono pl-2 py-1 uppercase">
{group.name}
diff --git a/apps/carbon/app/modules/items/ui/Parts/PartForm.tsx b/apps/carbon/app/modules/items/ui/Parts/PartForm.tsx
index 8c6c454a4c..ff9986db60 100644
--- a/apps/carbon/app/modules/items/ui/Parts/PartForm.tsx
+++ b/apps/carbon/app/modules/items/ui/Parts/PartForm.tsx
@@ -170,7 +170,7 @@ const PartForm = ({ initialValues, type = "card", onClose }: PartFormProps) => {
label="Unit of Measure"
/>
- {!isEditing && replenishmentSystem !== "Make" && (
+ {!isEditing && (
<Number
name="unitCost"
label="Unit Cost"
diff --git a/apps/carbon/app/modules/sales/ui/Quotes/useLineCosts.tsx b/apps/carbon/app/modules/sales/ui/Quotes/useLineCosts.tsx
index 72a29b6e42..f8fef5c9ff 100644
--- a/apps/carbon/app/modules/sales/ui/Quotes/useLineCosts.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotes/useLineCosts.tsx
@@ -39,6 +39,8 @@ export function useLineCosts({
if (!quoteId) throw new Error("Could not find quoteId");
if (!lineId) throw new Error("Could not find lineId");
+ console.log({ originalMethodTree });
+
// TODO: instead of walking the tree twice (once for the quantities/operations and once for the effects)
// we could do it all in one pass
@@ -49,7 +51,7 @@ export function useLineCosts({
const tree = structuredClone(originalMethodTree);
- function walkTree(tree: EnhancedTree, parentQuantity: number) {
+ function traverseTree(tree: EnhancedTree, parentQuantity: number) {
// multiply quantity by parent quantity
tree.data.quantity = tree.data.quantity * parentQuantity;
tree.data.operations = operations.filter(
@@ -58,12 +60,12 @@ export function useLineCosts({
if (tree.children) {
for (const child of tree.children) {
- walkTree(child, tree.data.quantity);
+ traverseTree(child, tree.data.quantity);
}
}
}
- walkTree(tree, 1);
+ traverseTree(tree, 1);
return tree;
}, [operations, originalMethodTree]);
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 64ae72c772..a60b50c84b 100644
--- a/apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.details.tsx
+++ b/apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.details.tsx
@@ -120,15 +120,12 @@ export default function QuoteLine() {
useRealtime("quoteMaterial", `quoteLineId=eq.${lineId}`);
useRealtime("quoteOperation", `quoteLineId=eq.${lineId}`);
- const quoteData = useRouteData<{
- methods: Promise<Tree<QuoteMethod>[]> | Tree<QuoteMethod>[];
- }>(path.to.quote(quoteId));
+ const quoteData = useRouteData<{ methods: Tree<QuoteMethod>[] }>(
+ path.to.quote(quoteId)
+ );
const methodTree = useMemo(
- () =>
- Array.isArray(quoteData?.methods)
- ? quoteData.methods.find((m) => m.data.quoteLineId === line.id)
- : undefined,
+ () => quoteData?.methods?.find((m) => m.data.quoteLineId === line.id),
[quoteData, line.id]
);
diff --git a/apps/carbon/app/routes/x+/quote+/$quoteId.tsx b/apps/carbon/app/routes/x+/quote+/$quoteId.tsx
index ee0218c17e..538ba006d6 100644
--- a/apps/carbon/app/routes/x+/quote+/$quoteId.tsx
+++ b/apps/carbon/app/routes/x+/quote+/$quoteId.tsx
@@ -6,11 +6,9 @@ import {
ScrollArea,
VStack,
} from "@carbon/react";
-import { Await, Outlet, useLoaderData, useParams } from "@remix-run/react";
+import { Outlet, useLoaderData, useParams } from "@remix-run/react";
import type { LoaderFunctionArgs } from "@vercel/remix";
import { defer, redirect } from "@vercel/remix";
-import { Suspense } from "react";
-import { ExplorerSkeleton } from "~/components/Skeletons";
import {
getOpportunityByQuote,
getOpportunityDocuments,
@@ -44,7 +42,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
const { quoteId } = params;
if (!quoteId) throw new Error("Could not find quoteId");
- const [quote, shipment, payment, lines, prices, opportunity] =
+ const [quote, shipment, payment, lines, prices, opportunity, methods] =
await Promise.all([
getQuote(client, quoteId),
getQuoteShipment(client, quoteId),
@@ -52,6 +50,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
getQuoteLines(client, quoteId),
getQuoteLinePricesByQuoteId(client, quoteId),
getOpportunityByQuote(client, quoteId),
+ getQuoteMethodTrees(client, quoteId),
]);
if (!opportunity.data) throw new Error("Failed to get opportunity record");
@@ -88,7 +87,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
return defer({
quote: quote.data,
lines: lines.data ?? [],
- methods: getQuoteMethodTrees(client, quoteId),
+ methods: methods.data ?? [],
files: files.data ?? [],
prices: prices.data ?? [],
shipment: shipment.data,
@@ -120,33 +119,7 @@ export default function QuoteRoute() {
>
<ScrollArea className="h-[calc(100vh-99px)]">
<div className="grid w-full h-full overflow-hidden">
- <Suspense
- fallback={
- <div className="p-2">
- <ExplorerSkeleton />
- </div>
- }
- >
- <Await
- resolve={methods}
- errorElement={
- <div className="p-2 text-red-500">
- Error loading quote tree.
- </div>
- }
- >
- {(resolvedMethods) => (
- <QuoteExplorer
- methods={
- resolvedMethods.data &&
- resolvedMethods.data.length > 0
- ? resolvedMethods.data
- : []
- }
- />
- )}
- </Await>
- </Suspense>
+ <QuoteExplorer methods={methods} />
</div>
</ScrollArea>
</ResizablePanel>
diff --git a/apps/carbon/app/styles/background.css b/apps/carbon/app/styles/background.css
index 8bcd13aac2..a657c06762 100644
--- a/apps/carbon/app/styles/background.css
+++ b/apps/carbon/app/styles/background.css
@@ -23,7 +23,7 @@
.dark .background:before {
background: radial-gradient(
circle,
- hsl(var(--muted)) 0,
+ hsl(240 3.7 11%) 0,
hsl(var(--background)) 100%
);
}
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index 11056a461d..e15f64e5c5 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -28659,10 +28659,10 @@ export type Database = {
dimensions: string
finish: string
readableId: string
- type: string
+ type: Database["public"]["Enums"]["itemType"]
name: string
active: boolean
- itemTrackingType: string
+ itemTrackingType: Database["public"]["Enums"]["itemTrackingType"]
thumbnailPath: string
locationName: string
unitOfMeasureCode: string
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index 11056a461d..e15f64e5c5 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -28659,10 +28659,10 @@ export type Database = {
dimensions: string
finish: string
readableId: string
- type: string
+ type: Database["public"]["Enums"]["itemType"]
name: string
active: boolean
- itemTrackingType: string
+ itemTrackingType: Database["public"]["Enums"]["itemTrackingType"]
thumbnailPath: string
locationName: string
unitOfMeasureCode: string