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: include operation in get method

Brad Barbin4faa220c446a
diff --git a/apps/carbon/app/components/Layout/Navigation/IconSidebar.tsx b/apps/carbon/app/components/Layout/Navigation/IconSidebar.tsx
index e802a13038..3379f2ddfd 100644
--- a/apps/carbon/app/components/Layout/Navigation/IconSidebar.tsx
+++ b/apps/carbon/app/components/Layout/Navigation/IconSidebar.tsx
@@ -125,11 +125,11 @@ const NavigationIconLink = forwardRef<
"flex items-center rounded-md",
"group-data-[state=collapsed]:justify-center",
"group-data-[state=expanded]:-space-x-2",
- "hover:bg-secondary active:",
+ "hover:bg-active/80 hover:text-active-foreground",
`${
isActive
- ? "bg-primary/10 text-primary shadow-sm hover:text-primary hover:bg-primary/20 dark:shadow-inner"
- : "hover:text-foreground"
+ ? "bg-active text-active-foreground shadow-sm hover:text-active-foreground hover:bg-active/90"
+ : "hover:text-active-foreground"
}`,
"group/item",
];
diff --git a/apps/carbon/app/modules/sales/ui/Quotes/QuoteBreadcrumbs.tsx b/apps/carbon/app/modules/sales/ui/Quotes/QuoteBreadcrumbs.tsx
index e9354d2db9..a9c6ca6415 100644
--- a/apps/carbon/app/modules/sales/ui/Quotes/QuoteBreadcrumbs.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotes/QuoteBreadcrumbs.tsx
@@ -119,6 +119,11 @@ const QuoteBreadcrumbs = () => {
action={path.to.quoteMethodGet}
validator={getMethodValidator}
onSubmit={getMethodModal.onClose}
+ defaultValues={{
+ quoteId,
+ quoteLineId: lineId,
+ itemId: line?.itemId,
+ }}
>
<ModalHeader>
<ModalTitle>Get Method</ModalTitle>
@@ -133,7 +138,7 @@ const QuoteBreadcrumbs = () => {
<Item
name="itemId"
label="Source Method"
- type="Part"
+ type={(line?.itemType ?? "Part") as "Part"}
replenishmentSystem="Make"
/>
{hasMethods && (
diff --git a/apps/carbon/app/routes/x+/quote+/methods.get.tsx b/apps/carbon/app/routes/x+/quote+/methods.get.tsx
index c056e02d15..f3c69d1942 100644
--- a/apps/carbon/app/routes/x+/quote+/methods.get.tsx
+++ b/apps/carbon/app/routes/x+/quote+/methods.get.tsx
@@ -19,7 +19,7 @@ export async function action({ request }: ActionFunctionArgs) {
const supabaseServiceRole = getSupabaseServiceRole();
const { error } = await supabaseServiceRole.functions.invoke("get-method", {
body: {
- type: "quote",
+ type: "itemToQuoteLine",
sourceId: itemId,
targetId: `${quoteId}:${quoteLineId}`,
companyId,
diff --git a/apps/carbon/app/styles/tailwind.css b/apps/carbon/app/styles/tailwind.css
index 87994851e1..f4e8409550 100644
--- a/apps/carbon/app/styles/tailwind.css
+++ b/apps/carbon/app/styles/tailwind.css
@@ -61,6 +61,8 @@
--card-foreground: 240 10% 3.9%;
--popover: 0 0% 100%;
--popover-foreground: 240 10% 3.9%;
+ --active: 240 5.9% 10%;
+ --active-foreground: 0 0% 98%;
--primary: 240 5.9% 10%;
--primary-foreground: 0 0% 98%;
--secondary: 240 4.8% 95.9%;
@@ -86,6 +88,8 @@
--popover-foreground: 0 0% 98%;
--primary: 0 0% 98%;
--primary-foreground: 240 5.9% 10%;
+ --active: 0 0% 98%;
+ --active-foreground: 240 5.9% 10%;
--secondary: 240 3.7% 15.9%;
--secondary-foreground: 0 0% 98%;
--muted: 240 3.7% 15.9%;
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index 532f8d7bff..2afa94bf49 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -25614,6 +25614,7 @@ export type Database = {
methodType: Database["public"]["Enums"]["methodType"]
parentMaterialId: string
order: number
+ operationId: string
isRoot: boolean
}[]
}
diff --git a/packages/database/supabase/functions/get-method/index.ts b/packages/database/supabase/functions/get-method/index.ts
index 18951efb3c..6a44992755 100644
--- a/packages/database/supabase/functions/get-method/index.ts
+++ b/packages/database/supabase/functions/get-method/index.ts
@@ -17,7 +17,7 @@ const pool = getConnectionPool(1);
const db = getDatabaseClient<DB>(pool);
const payloadValidator = z.object({
- type: z.string(),
+ type: z.enum(["itemToQuoteLine"]),
sourceId: z.string(),
targetId: z.string(),
companyId: z.string(),
@@ -37,7 +37,7 @@ serve(async (req: Request) => {
const client = getSupabaseServiceRole(req.headers.get("Authorization"));
switch (type) {
- case "quote": {
+ case "itemToQuoteLine": {
const [quoteId, quoteLineId] = (targetId as string).split(":");
if (!quoteId || !quoteLineId) {
throw new Error("Invalid targetId");
@@ -103,13 +103,6 @@ serve(async (req: Request) => {
node: MethodTreeItem,
parentQuoteMakeMethodId: string | null
) {
- const madeChildren = node.children.filter(
- (child) => child.data.methodType === "Make"
- );
- const unmadeChildren = node.children.filter(
- (child) => child.data.methodType !== "Make"
- );
-
const relatedOperations = await client
.from("methodOperation")
.select("*, workCellType(quotingRate, laborRate, overheadRate)")
@@ -154,6 +147,14 @@ serve(async (req: Request) => {
},
{}
) ?? {};
+
+ console.log({
+ node: node.data.itemReadableId,
+ operationId: node.data.operationId,
+ quoteOperations,
+ operationIds,
+ methodOperationsToQuoteOperations,
+ });
}
const mapMethodMaterialToQuoteMaterial = (
@@ -162,11 +163,12 @@ serve(async (req: Request) => {
quoteId,
quoteLineId,
quoteMakeMethodId: parentQuoteMakeMethodId!,
+ quoteOperationId:
+ methodOperationsToQuoteOperations[child.data.operationId],
itemId: child.data.itemId,
itemReadableId: child.data.itemReadableId,
itemType: child.data.itemType,
methodType: child.data.methodType,
- // operation: methodOperationsToQuoteOperations[child.data.operationId], // TODO
order: child.data.order,
description: child.data.description,
quantity: child.data.quantity,
@@ -177,6 +179,13 @@ serve(async (req: Request) => {
customFields: {},
});
+ const madeChildren = node.children.filter(
+ (child) => child.data.methodType === "Make"
+ );
+ const unmadeChildren = node.children.filter(
+ (child) => child.data.methodType !== "Make"
+ );
+
const madeMaterials = madeChildren.map(
mapMethodMaterialToQuoteMaterial
);
@@ -214,6 +223,7 @@ serve(async (req: Request) => {
}
}
+ console.log(methodTree);
await traverseMethodToQuote(methodTree, quoteMakeMethod.data.id);
});
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index 532f8d7bff..2afa94bf49 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -25614,6 +25614,7 @@ export type Database = {
methodType: Database["public"]["Enums"]["methodType"]
parentMaterialId: string
order: number
+ operationId: string
isRoot: boolean
}[]
}
diff --git a/packages/database/supabase/migrations/20240807112857_add-description-unit-cost-to-method-tree.sql b/packages/database/supabase/migrations/20240807112857_add-description-unit-cost-to-method-tree.sql
index 3ccb6ec56f..a3c438e655 100644
--- a/packages/database/supabase/migrations/20240807112857_add-description-unit-cost-to-method-tree.sql
+++ b/packages/database/supabase/migrations/20240807112857_add-description-unit-cost-to-method-tree.sql
@@ -14,6 +14,7 @@ RETURNS TABLE (
"methodType" "methodType",
"parentMaterialId" TEXT,
"order" DOUBLE PRECISION,
+ "operationId" TEXT,
"isRoot" BOOLEAN
) AS $$
WITH RECURSIVE material AS (
@@ -26,6 +27,7 @@ WITH RECURSIVE material AS (
"itemType",
"quantity",
"makeMethodId" AS "parentMaterialId",
+ NULL AS "operationId",
CAST(1 AS DOUBLE PRECISION) AS "order"
FROM
"methodMaterial"
@@ -41,6 +43,7 @@ WITH RECURSIVE material AS (
child."itemType",
child."quantity",
parent."id" AS "parentMaterialId",
+ child."methodOperationId" AS "operationId",
child."order"
FROM
"methodMaterial" child
@@ -60,6 +63,7 @@ SELECT
material."methodType",
material."parentMaterialId",
material."order",
+ material."operationId",
false AS "isRoot"
FROM material
INNER JOIN item
@@ -81,6 +85,7 @@ SELECT
'Make' AS "methodType",
NULL AS "parentMaterialId",
CAST(1 AS DOUBLE PRECISION) AS "order",
+ NULL AS "operationId",
true AS "isRoot"
FROM "makeMethod" mm
diff --git a/packages/react/src/Button.tsx b/packages/react/src/Button.tsx
index a8e88e7bda..a32538738b 100644
--- a/packages/react/src/Button.tsx
+++ b/packages/react/src/Button.tsx
@@ -15,7 +15,7 @@ export const buttonVariants = cva(
primary:
"bg-primary text-primary-foreground hover:bg-primary/90 shadow-sm",
active:
- "bg-primary/10 text-primary hover:bg-primary/5 dark:shadow-inner",
+ "bg-active text-active-foreground hover:bg-active/90 hover:text-active-foreground",
secondary:
"border border-input bg-background hover:bg-accent hover:text-accent-foreground",
solid: "bg-accent text-accent-foreground hover:bg-accent/90",
diff --git a/packages/react/src/Resizable.tsx b/packages/react/src/Resizable.tsx
index 660fbebfdf..2718198895 100644
--- a/packages/react/src/Resizable.tsx
+++ b/packages/react/src/Resizable.tsx
@@ -29,7 +29,7 @@ const ResizableHandle = ({
}) => (
<ResizablePrimitive.PanelResizeHandle
className={cn(
- "relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90",
+ "relative flex w-px items-center justify-center bg-border hover:bg-border-primary after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90",
className
)}
{...props}
diff --git a/packages/tailwind/tailwind.config.js b/packages/tailwind/tailwind.config.js
index f7b4ce43fc..7b5ad140ef 100644
--- a/packages/tailwind/tailwind.config.js
+++ b/packages/tailwind/tailwind.config.js
@@ -22,6 +22,10 @@ module.exports = {
ring: "hsl(var(--ring))",
background: "hsl(var(--background))",
foreground: "hsl(var(--foreground))",
+ active: {
+ DEFAULT: "hsl(var(--active))",
+ foreground: "hsl(var(--active-foreground))",
+ },
primary: {
DEFAULT: "hsl(var(--primary))",
foreground: "hsl(var(--primary-foreground))",
diff --git a/packages/utils/src/themes.ts b/packages/utils/src/themes.ts
index b6664fc7bb..16d8a83a60 100644
--- a/packages/utils/src/themes.ts
+++ b/packages/utils/src/themes.ts
@@ -16,6 +16,8 @@ export const themes = [
"card-foreground": "220 10% 3.9%",
popover: "0 0% 100%",
"popover-foreground": "220 10% 3.9%",
+ active: "220 5.9% 10%",
+ "active-foreground": "0 0% 98%",
primary: "220 5.9% 10%",
"primary-foreground": "0 0% 98%",
secondary: "220 4.8% 95.9%",
@@ -39,6 +41,8 @@ export const themes = [
"popover-foreground": "0 0% 98%",
primary: "0 0% 98%",
"primary-foreground": "220 5.9% 10%",
+ active: "220 5.2% 33.9%",
+ "active-foreground": "0 0% 98%",
secondary: "220 3.7% 15.9%",
"secondary-foreground": "0 0% 98%",
muted: "220 3.7% 15.9%",
@@ -70,6 +74,8 @@ export const themes = [
"popover-foreground": "0 0% 3.9%",
primary: "0 0% 9%",
"primary-foreground": "0 0% 98%",
+ active: "0 0% 45.1%",
+ "active-foreground": "0 0% 98%",
secondary: "0 0% 96.1%",
"secondary-foreground": "0 0% 9%",
muted: "0 0% 96.1%",
@@ -91,6 +97,8 @@ export const themes = [
"popover-foreground": "0 0% 98%",
primary: "30 24% 81%",
"primary-foreground": "0 0% 9%",
+ active: "0 0% 32.2%",
+ "active-foreground": "0 0% 98%",
secondary: "0 0% 14.9%",
"secondary-foreground": "0 0% 98%",
muted: "0 0% 14.9%",
@@ -122,6 +130,8 @@ export const themes = [
"popover-foreground": "0 0% 3.9%",
primary: "0 72.2% 50.6%",
"primary-foreground": "0 85.7% 97.3%",
+ active: "0 0% 32.2%",
+ "active-foreground": "0 0% 98%",
secondary: "0 0% 96.1%",
"secondary-foreground": "0 0% 9%",
muted: "0 0% 96.1%",
@@ -143,6 +153,8 @@ export const themes = [
"popover-foreground": "0 0% 98%",
primary: "0 72.2% 50.6%",
"primary-foreground": "0 85.7% 97.3%",
+ active: "0 0% 32.2%",
+ "active-foreground": "0 0% 98%",
secondary: "0 0% 14.9%",
"secondary-foreground": "0 0% 98%",
muted: "0 0% 14.9%",
@@ -174,6 +186,8 @@ export const themes = [
"popover-foreground": "240 10% 3.9%",
primary: "346.8 77.2% 49.8%",
"primary-foreground": "355.7 100% 97.3%",
+ active: "0 0% 32.2%",
+ "active-foreground": "0 0% 98%",
secondary: "240 4.8% 95.9%",
"secondary-foreground": "240 5.9% 10%",
muted: "240 4.8% 95.9%",
@@ -195,6 +209,8 @@ export const themes = [
"card-foreground": "0 0% 95%",
primary: "346.8 77.2% 49.8%",
"primary-foreground": "355.7 100% 97.3%",
+ active: "0 0% 32.2%",
+ "active-foreground": "0 0% 98%",
secondary: "240 3.7% 15.9%",
"secondary-foreground": "0 0% 98%",
muted: "0 0% 15%",
@@ -226,6 +242,8 @@ export const themes = [
"popover-foreground": "20 14.3% 4.1%",
primary: "24.6 95% 53.1%",
"primary-foreground": "60 9.1% 97.8%",
+ active: "20 84.3% 84.1%",
+ "active-foreground": "20 84.3% 34.1%",
secondary: "60 4.8% 95.9%",
"secondary-foreground": "24 9.8% 10%",
muted: "60 4.8% 95.9%",
@@ -247,6 +265,8 @@ export const themes = [
"popover-foreground": "60 9.1% 97.8%",
primary: "20.5 90.2% 48.2%",
"primary-foreground": "60 9.1% 97.8%",
+ active: "20 24.3% 14.1%",
+ "active-foreground": "0 0% 98%",
secondary: "12 6.5% 15.1%",
"secondary-foreground": "60 9.1% 97.8%",
muted: "12 6.5% 15.1%",
@@ -278,6 +298,8 @@ export const themes = [
"popover-foreground": "240 10% 3.9%",
primary: "151 47% 40%",
"primary-foreground": "355.7 100% 97.3%",
+ active: "0 0% 32.2%",
+ "active-foreground": "0 0% 98%",
secondary: "240 4.8% 95.9%",
"secondary-foreground": "240 5.9% 10%",
muted: "240 4.8% 95.9%",
@@ -299,6 +321,8 @@ export const themes = [
"card-foreground": "2400 0% 95%",
primary: "142.1 87.6% 63.3%",
"primary-foreground": "144.9 80.4% 10%",
+ active: "137 18% 15%",
+ "active-foreground": "142.1 87.6% 63.3%",
secondary: "240 3.7% 15.9%",
"secondary-foreground": "0 0% 98%",
muted: "240 0% 15%",
@@ -330,6 +354,8 @@ export const themes = [
"popover-foreground": "222.2 84% 4.9%",
primary: "221.2 83.2% 53.3%",
"primary-foreground": "210 40% 98%",
+ active: "222.2 84% 78.9%",
+ "active-foreground": "222.2 84% 2.9%",
secondary: "210 40% 96.1%",
"secondary-foreground": "222.2 47.4% 11.2%",
muted: "210 40% 96.1%",
@@ -351,6 +377,8 @@ export const themes = [
"popover-foreground": "210 40% 98%",
primary: "217.2 91.2% 59.8%",
"primary-foreground": "222.2 47.4% 11.2%",
+ active: "217.2 91.2% 81.8%",
+ "active-foreground": "217.2 91.2% 52.8%",
secondary: "217.2 32.6% 17.5%",
"secondary-foreground": "210 40% 98%",
muted: "217.2 32.6% 17.5%",
@@ -382,6 +410,8 @@ export const themes = [
"popover-foreground": "20 14.3% 4.1%",
primary: "47.9 95.8% 53.1%",
"primary-foreground": "26 83.3% 14.1%",
+ active: "0 0% 32.2%",
+ "active-foreground": "0 0% 98%",
secondary: "60 4.8% 95.9%",
"secondary-foreground": "24 9.8% 10%",
muted: "60 4.8% 95.9%",
@@ -403,6 +433,8 @@ export const themes = [
"popover-foreground": "60 9.1% 97.8%",
primary: "47.9 95.8% 53.1%",
"primary-foreground": "26 83.3% 14.1%",
+ active: "47.9 95.8% 13.1%",
+ "active-foreground": "47.9 95.8% 53.1%",
secondary: "12 6.5% 15.1%",
"secondary-foreground": "60 9.1% 97.8%",
muted: "12 6.5% 15.1%",
@@ -434,6 +466,8 @@ export const themes = [
"popover-foreground": "224 71.4% 4.1%",
primary: "252.1 83.3% 47.8%",
"primary-foreground": "210 20% 98%",
+ active: "224 71.4% 4.1%",
+ "active-foreground": "0 0% 98%",
secondary: "220 14.3% 95.9%",
"secondary-foreground": "220.9 39.3% 11%",
muted: "220 14.3% 95.9%",
@@ -455,6 +489,8 @@ export const themes = [
"popover-foreground": "210 20% 98%",
primary: "253.4 70% 40.4%",
"primary-foreground": "210 20% 98%",
+ active: "224 71.4% 4.1%",
+ "active-foreground": "0 0% 98%",
secondary: "215 27.9% 16.9%",
"secondary-foreground": "210 20% 98%",
muted: "215 27.9% 16.9%",
@@ -483,6 +519,8 @@ export const BASE_THEME_WITH_VARIABLES = `
--popover-foreground: <%- colors.light["popover-foreground"] %>;
--primary: <%- colors.light["primary"] %>;
--primary-foreground: <%- colors.light["primary-foreground"] %>;
+ --active: <%- colors.light["active"] %>;
+ --active-foreground: <%- colors.light["active-foreground"] %>;
--secondary: <%- colors.light["secondary"] %>;
--secondary-foreground: <%- colors.light["secondary-foreground"] %>;
--muted: <%- colors.light["muted"] %>;
@@ -506,6 +544,8 @@ export const BASE_THEME_WITH_VARIABLES = `
--popover-foreground: <%- colors.dark["popover-foreground"] %>;
--primary: <%- colors.dark["primary"] %>;
--primary-foreground: <%- colors.dark["primary-foreground"] %>;
+ --active: <%- colors.dark["active"] %>;
+ --active-foreground: <%- colors.dark["active-foreground"] %>;
--secondary: <%- colors.dark["secondary"] %>;
--secondary-foreground: <%- colors.dark["secondary-foreground"] %>;
--muted: <%- colors.dark["muted"] %>;