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: add tools tab to bill of process

Brad Barbine77c94918361
diff --git a/apps/carbon/app/components/Form/Tool.tsx b/apps/carbon/app/components/Form/Tool.tsx
new file mode 100644
index 0000000000..871b913ec1
--- /dev/null
+++ b/apps/carbon/app/components/Form/Tool.tsx
@@ -0,0 +1,144 @@
+import type { ComboboxProps } from "@carbon/form";
+import { useControlField, useField } from "@carbon/form";
+import {
+ cn,
+ CreatableCombobox,
+ FormControl,
+ FormErrorMessage,
+ FormHelperText,
+ FormLabel,
+ useDisclosure,
+ VStack,
+} from "@carbon/react";
+import { useEffect, useMemo, useRef, useState } from "react";
+import { ToolForm } from "~/modules/items";
+
+import { useTools } from "~/stores";
+
+type ToolSelectProps = Omit<ComboboxProps, "options" | "type" | "inline"> & {
+ disabledTools?: string[];
+ includeInactive?: boolean;
+ inline?: boolean;
+ typeFieldName?: string;
+};
+
+const ToolPreview = (
+ value: string,
+ options: { value: string; label: string; helper?: string }[]
+) => {
+ const item = options.find((o) => o.value === value);
+ if (!item) return null;
+ return (
+ <VStack spacing={0}>
+ <span className="font-medium text-sm">{item.label}</span>
+ {item.helper && (
+ <span className="text-xs text-muted-foreground">{item.helper}</span>
+ )}
+ </VStack>
+ );
+};
+
+const Tool = ({ name, label, helperText, ...props }: ToolSelectProps) => {
+ const tools = useTools();
+
+ const options = useMemo(
+ () =>
+ tools.map((item) => ({
+ value: item.id,
+ label: item.readableId,
+ helper: item.name,
+ })) ?? [],
+ [tools]
+ );
+
+ const newToolsModal = useDisclosure();
+ const [created, setCreated] = useState<string>("");
+ const triggerRef = useRef<HTMLButtonElement>(null);
+
+ const { getInputProps, error } = useField(name);
+ const [value, setValue] = useControlField<string | undefined>(name);
+
+ useEffect(() => {
+ if (props.value !== null && props.value !== undefined)
+ setValue(props.value);
+ }, [props.value, setValue]);
+
+ const onChange = (value: string) => {
+ if (value) {
+ props?.onChange?.(options.find((o) => o.value === value) ?? null);
+ } else {
+ props?.onChange?.(null);
+ }
+ };
+
+ return (
+ <>
+ <FormControl isInvalid={!!error} className="w-full">
+ {label && <FormLabel>{label}</FormLabel>}
+ <input
+ {...getInputProps({
+ id: name,
+ })}
+ type="hidden"
+ name={name}
+ id={name}
+ value={value}
+ />
+
+ <div className="flex flex-grow tools-start min-w-0">
+ <CreatableCombobox
+ className={cn("flex-grow min-w-0")}
+ ref={triggerRef}
+ options={options}
+ {...props}
+ inline={props.inline ? ToolPreview : undefined}
+ inlineAddLabel="Add Tool"
+ value={value?.replace(/"/g, '\\"')}
+ onChange={(newValue) => {
+ setValue(newValue?.replace(/"/g, '\\"') ?? "");
+ onChange(newValue?.replace(/"/g, '\\"') ?? "");
+ }}
+ label={label}
+ itemHeight={44}
+ onCreateOption={(option) => {
+ newToolsModal.onOpen();
+ setCreated(option);
+ }}
+ />
+ </div>
+ {error ? (
+ <FormErrorMessage>{error}</FormErrorMessage>
+ ) : (
+ helperText && <FormHelperText>{helperText}</FormHelperText>
+ )}
+ </FormControl>
+
+ {newToolsModal.isOpen && (
+ <ToolForm
+ type="modal"
+ onClose={() => {
+ setCreated("");
+ newToolsModal.onClose();
+ triggerRef.current?.click();
+ }}
+ initialValues={{
+ id: "",
+ name: created,
+ description: "",
+ itemTrackingType: "Inventory",
+ unitOfMeasureCode: "EA",
+ replenishmentSystem: "Buy",
+ defaultMethodType: "Buy",
+ active: props?.includeInactive === undefined,
+ unitCost: 0,
+ tags: [],
+ }}
+ />
+ )}
+ </>
+ );
+};
+
+Tool.displayName = "Tool";
+
+export default Tool;
diff --git a/apps/carbon/app/components/Form/index.ts b/apps/carbon/app/components/Form/index.ts
index b518516751..71b119e2d3 100644
--- a/apps/carbon/app/components/Form/index.ts
+++ b/apps/carbon/app/components/Form/index.ts
@@ -65,6 +65,7 @@ import SupplierStatus from "./SupplierStatus";
import SupplierType from "./SupplierType";
import Suppliers from "./Suppliers";
import Tags from "./Tags";
+import Tool from "./Tool";
import UnitHint, { getUnitHint } from "./UnitHint";
import UnitOfMeasure from "./UnitOfMeasure";
import User from "./User";
@@ -138,6 +139,7 @@ export {
TextArea,
TimePicker,
Timezone,
+ Tool,
UnitHint,
UnitOfMeasure,
User,
diff --git a/apps/carbon/app/modules/inventory/ui/Inventory/InventoryTable.tsx b/apps/carbon/app/modules/inventory/ui/Inventory/InventoryTable.tsx
index 152b21f552..3607ae052b 100644
--- a/apps/carbon/app/modules/inventory/ui/Inventory/InventoryTable.tsx
+++ b/apps/carbon/app/modules/inventory/ui/Inventory/InventoryTable.tsx
@@ -181,9 +181,11 @@ const InventoryTable = memo(
const unitOfMeasure = unitOfMeasures.find(
(uom) => uom.code === row.original.unitOfMeasureCode
);
- return unitOfMeasure
- ? unitOfMeasure.name
- : row.original.unitOfMeasureCode;
+ return (
+ <Enumerable
+ value={unitOfMeasure?.name ?? row.original.unitOfMeasureCode}
+ />
+ );
},
meta: {
icon: <LuRuler />,
diff --git a/apps/carbon/app/modules/items/items.service.ts b/apps/carbon/app/modules/items/items.service.ts
index ddf95b729d..3741c1e70e 100644
--- a/apps/carbon/app/modules/items/items.service.ts
+++ b/apps/carbon/app/modules/items/items.service.ts
@@ -6,6 +6,7 @@ import { type z } from "zod";
import type { GenericQueryFilters } from "~/utils/query";
import { setGenericQueryFilters } from "~/utils/query";
import { sanitize } from "~/utils/supabase";
+import type { operationToolValidator } from "../shared";
import type {
buyMethodValidator,
consumableValidator,
@@ -616,11 +617,27 @@ export async function getMethodOperationsByMakeMethodId(
) {
return client
.from("methodOperation")
- .select("*")
+ .select("*, methodOperationTool(id, operationId, toolId, quantity)")
.eq("makeMethodId", makeMethodId)
.order("order", { ascending: true });
}
+export async function getMethodOperationToolsByOperationIds(
+ client: SupabaseClient<Database>,
+ operationIds: string[]
+) {
+ if (operationIds.length === 0) {
+ return {
+ data: [],
+ error: null,
+ };
+ }
+ return client
+ .from("methodOperationTool")
+ .select("*")
+ .in("operationId", operationIds);
+}
+
type Method = NonNullable<
Awaited<ReturnType<typeof getMethodTreeArray>>["data"]
>[number];
@@ -1488,6 +1505,34 @@ export async function upsertMethodOperation(
.single();
}
+export async function upsertMethodOperationTool(
+ client: SupabaseClient<Database>,
+ methodOperationTool:
+ | (Omit<z.infer<typeof operationToolValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ })
+ | (Omit<z.infer<typeof operationToolValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ })
+) {
+ if ("createdBy" in methodOperationTool) {
+ return client
+ .from("methodOperationTool")
+ .insert(methodOperationTool)
+ .select("id")
+ .single();
+ }
+
+ return client
+ .from("methodOperationTool")
+ .update(sanitize(methodOperationTool))
+ .eq("id", methodOperationTool.id)
+ .select("id")
+ .single();
+}
+
export async function upsertMaterial(
client: SupabaseClient<Database>,
material:
diff --git a/apps/carbon/app/modules/items/ui/Item/BillOfProcess.tsx b/apps/carbon/app/modules/items/ui/Item/BillOfProcess.tsx
index 94b05365a0..9059c46ea6 100644
--- a/apps/carbon/app/modules/items/ui/Item/BillOfProcess.tsx
+++ b/apps/carbon/app/modules/items/ui/Item/BillOfProcess.tsx
@@ -3,6 +3,9 @@ import { useCarbon } from "@carbon/auth";
import { ValidatedForm } from "@carbon/form";
import type { JSONContent } from "@carbon/react";
import {
+ Alert,
+ AlertDescription,
+ AlertTitle,
Badge,
Button,
Card,
@@ -14,9 +17,23 @@ import {
HStack,
IconButton,
Label,
+ Modal,
+ ModalBody,
+ ModalContent,
+ ModalFooter,
+ ModalHeader,
+ ModalTitle,
+ Table,
+ Tbody,
+ Td,
+ Th,
+ Thead,
+ Tr,
+ VStack,
cn,
generateHTML,
useDebounce,
+ useDisclosure,
} from "@carbon/react";
import { getLocalTimeZone, today } from "@internationalized/date";
import { useFetcher } from "@remix-run/react";
@@ -25,12 +42,21 @@ import { nanoid } from "nanoid";
import type { Dispatch, SetStateAction } from "react";
import { useCallback, useEffect, useState } from "react";
import { flushSync } from "react-dom";
-import { LuChevronDown, LuSettings2, LuX } from "react-icons/lu";
+import {
+ LuAlertTriangle,
+ LuChevronDown,
+ LuHammer,
+ LuPenSquare,
+ LuSettings2,
+ LuTrash2,
+ LuX,
+} from "react-icons/lu";
import type { z } from "zod";
import { DirectionAwareTabs, TimeTypeIcon } from "~/components";
import {
Hidden,
InputControlled,
+ Number,
NumberControlled,
Process,
Select,
@@ -38,6 +64,7 @@ import {
StandardFactor,
Submit,
SupplierProcess,
+ Tool,
UnitHint,
WorkCenter,
getUnitHint,
@@ -45,7 +72,14 @@ import {
import type { Item, SortableItemRenderProps } from "~/components/SortableList";
import { SortableList, SortableListItem } from "~/components/SortableList";
import { usePermissions, useUser } from "~/hooks";
-import { methodOperationOrders, operationTypes } from "~/modules/shared";
+import type { OperationTool } from "~/modules/shared";
+import {
+ methodOperationOrders,
+ operationToolValidator,
+ operationTypes,
+} from "~/modules/shared";
+import type { action as newMethodOperationToolAction } from "~/routes/x+/items+/methods+/operation.tool.new";
+import { useTools } from "~/stores";
import { getPrivateUrl, path } from "~/utils/path";
import { methodOperationValidator } from "../../items.models";
@@ -59,7 +93,7 @@ type ItemWithData = Item & {
type BillOfProcessProps = {
makeMethodId: string;
- operations: Operation[];
+ operations: (Operation & { methodOperationTool: OperationTool[] })[];
};
function makeItems(operations: Operation[]): ItemWithData[] {
@@ -109,7 +143,7 @@ function makeItem(operation: Operation): ItemWithData {
};
}
-const initialOperation: Omit<Operation, "makeMethodId" | "order"> = {
+const initialOperation: Omit<Operation, "makeMethodId" | "order" | "tools"> = {
description: "",
laborTime: 0,
laborUnit: "Minutes/Piece",
@@ -352,6 +386,24 @@ const BillOfProcess = ({ makeMethodId, operations }: BillOfProcessProps) => {
</div>
),
},
+ {
+ id: 2,
+ label: "Tools",
+ content: (
+ <div className="flex w-full flex-col py-4">
+ <ToolsForm
+ tools={
+ operations.find((o) => o.id === item.id)?.methodOperationTool ??
+ []
+ }
+ operationId={item.id!}
+ isDisabled={
+ selectedItemId === null || isTemporaryId(selectedItemId!)
+ }
+ />
+ </div>
+ ),
+ },
];
return (
@@ -976,3 +1028,181 @@ function OperationForm({
</ValidatedForm>
);
}
+
+function ToolPreview({ toolId }: { toolId: string }) {
+ const tools = useTools();
+ const tool = tools.find((t) => t.id === toolId);
+ if (!tool) return null;
+ return (
+ <VStack spacing={0}>
+ <span className="text-sm font-medium">{tool.readableId}</span>
+ <span className="text-xs text-muted-foreground">{tool.name}</span>
+ </VStack>
+ );
+}
+function ToolsForm({
+ operationId,
+ isDisabled,
+ tools,
+}: {
+ operationId: string;
+ isDisabled: boolean;
+ tools: OperationTool[];
+}) {
+ const fetcher = useFetcher<typeof newMethodOperationToolAction>();
+
+ const [selectedTool, setSelectedTool] = useState<OperationTool | null>(null);
+ const addEditDisclosure = useDisclosure();
+ const deleteDisclosure = useDisclosure();
+
+ if (isDisabled && isTemporaryId(operationId)) {
+ return (
+ <Alert className="max-w-[420px] mx-auto my-8">
+ <LuAlertTriangle />
+ <AlertTitle>Cannot add tools to unsaved operation</AlertTitle>
+ <AlertDescription>
+ Please save the operation before adding tools.
+ </AlertDescription>
+ </Alert>
+ );
+ }
+
+ return (
+ <div className="flex flex-col gap-6">
+ {tools.length > 0 && (
+ <Table>
+ <Thead>
+ <Tr>
+ <Th>Tool</Th>
+ <Th>Quantity</Th>
+ <Th />
+ </Tr>
+ </Thead>
+ <Tbody>
+ {tools.map((t) => (
+ <Tr key={t.id}>
+ <Td>
+ <ToolPreview toolId={t.toolId} />
+ </Td>
+ <Td>{t.quantity}</Td>
+ <Td className="flex justify-end gap-2 items-center">
+ <IconButton
+ aria-label="Edit Tool"
+ icon={<LuPenSquare />}
+ size="sm"
+ variant="secondary"
+ onClick={() => {
+ flushSync(() => {
+ setSelectedTool(t);
+ });
+ addEditDisclosure.onOpen();
+ }}
+ />
+ <IconButton
+ aria-label="Remove Tool"
+ icon={<LuTrash2 />}
+ size="sm"
+ variant="secondary"
+ />
+ </Td>
+ </Tr>
+ ))}
+ </Tbody>
+ </Table>
+ )}
+
+ <div className="flex items-center justify-center border border-dashed text-center px-6 py-8 rounded-lg">
+ <Button
+ variant="secondary"
+ leftIcon={<LuHammer />}
+ onClick={() => {
+ flushSync(() => {
+ setSelectedTool(null);
+ });
+ addEditDisclosure.onOpen();
+ }}
+ >
+ New Tool
+ </Button>
+ </div>
+ {addEditDisclosure.isOpen && (
+ <Modal
+ open
+ onOpenChange={(open) => {
+ if (!open) {
+ addEditDisclosure.onClose();
+ }
+ }}
+ >
+ <ModalContent>
+ <ValidatedForm
+ action={path.to.newMethodOperationTool}
+ method="post"
+ validator={operationToolValidator}
+ fetcher={fetcher}
+ resetAfterSubmit
+ onSubmit={() => {
+ flushSync(() => {
+ setSelectedTool(null);
+ });
+ addEditDisclosure.onClose();
+ }}
+ defaultValues={{
+ id: selectedTool?.id,
+ toolId: selectedTool?.toolId ?? "",
+ quantity: selectedTool?.quantity ?? 1,
+ operationId,
+ }}
+ className="w-full"
+ >
+ <ModalHeader>
+ <ModalTitle>
+ {selectedTool ? "Edit Tool" : "Add Tool"}
+ </ModalTitle>
+ </ModalHeader>
+ <ModalBody>
+ <Hidden name="operationId" />
+ <div className="w-full grid grid-cols-1 lg:grid-cols-[1fr_1fr] gap-4 items-start">
+ <Tool name="toolId" label="Tool" autoFocus />
+ <Number name="quantity" label="Quantity" />
+ </div>
+ </ModalBody>
+ <ModalFooter>
+ <Button variant="secondary" onClick={addEditDisclosure.onClose}>
+ Cancel
+ </Button>
+ <Submit
+ isDisabled={isDisabled || fetcher.state !== "idle"}
+ isLoading={fetcher.state !== "idle"}
+ >
+ Save
+ </Submit>
+ </ModalFooter>
+ </ValidatedForm>
+ </ModalContent>
+ </Modal>
+ )}
+ </div>
+ );
+
+ // return (
+ // <ValidatedForm
+ // defaultValues={{ itemId: undefined }}
+ // validator={z.object({
+ // itemId: z.string().min(1, { message: "Item is required" }),
+ // })}
+ // className="w-full"
+ // >
+ // <Tool
+ // name="toolId"
+ // inline
+ // isReadOnly={isDisabled}
+ // onChange={(value) => {
+ // if (value) {
+ // onAddTool(value.value);
+ // }
+ // }}
+ // />
+ // </ValidatedForm>
+ // );
+}
diff --git a/apps/carbon/app/modules/shared/shared.models.ts b/apps/carbon/app/modules/shared/shared.models.ts
index bef41bed9a..916a195cbf 100644
--- a/apps/carbon/app/modules/shared/shared.models.ts
+++ b/apps/carbon/app/modules/shared/shared.models.ts
@@ -60,6 +60,15 @@ export const feedbackValidator = z.object({
location: z.string(),
});
+export const operationToolValidator = z.object({
+ id: zfd.text(z.string().optional()),
+ operationId: z.string().min(1, { message: "Operation is required" }),
+ toolId: z.string().min(1, { message: "Tool is required" }),
+ quantity: zfd.numeric(
+ z.number().min(0.000001, { message: "Quantity is required" })
+ ),
+});
+
export const standardFactorType = [
"Hours/Piece",
"Hours/100 Pieces",
diff --git a/apps/carbon/app/modules/shared/types.ts b/apps/carbon/app/modules/shared/types.ts
index 3b5d488276..3ad11859c4 100644
--- a/apps/carbon/app/modules/shared/types.ts
+++ b/apps/carbon/app/modules/shared/types.ts
@@ -1,7 +1,9 @@
+import type { z } from "zod";
import type { StorageItem } from "~/types";
import type {
methodItemType,
methodType,
+ operationToolValidator,
standardFactorType,
} from "./shared.models";
import type { getNotes } from "./shared.service";
@@ -41,6 +43,8 @@ export type Note = NonNullable<
Awaited<ReturnType<typeof getNotes>>["data"]
>[number];
+export type OperationTool = z.infer<typeof operationToolValidator>;
+
export type OptimisticFileObject = Omit<
StorageItem,
"owner" | "updated_at" | "created_at" | "last_accessed_at" | "buckets"
diff --git a/apps/carbon/app/routes/x+/items+/methods+/operation.tool.new.tsx b/apps/carbon/app/routes/x+/items+/methods+/operation.tool.new.tsx
new file mode 100644
index 0000000000..8d2a80445a
--- /dev/null
+++ b/apps/carbon/app/routes/x+/items+/methods+/operation.tool.new.tsx
@@ -0,0 +1,53 @@
+import { assertIsPost, error } from "@carbon/auth";
+import { requirePermissions } from "@carbon/auth/auth.server";
+import { flash } from "@carbon/auth/session.server";
+import { validationError, validator } from "@carbon/form";
+import { json, type ActionFunctionArgs } from "@vercel/remix";
+import { upsertMethodOperationTool } from "~/modules/items";
+import { operationToolValidator } from "~/modules/shared";
+
+export async function action({ request, params }: ActionFunctionArgs) {
+ assertIsPost(request);
+ const { client, companyId, userId } = await requirePermissions(request, {
+ create: "parts",
+ });
+
+ const formData = await request.formData();
+ const validation = await validator(operationToolValidator).validate(formData);
+
+ if (validation.error) {
+ return validationError(validation.error);
+ }
+
+ const insert = await upsertMethodOperationTool(client, {
+ ...validation.data,
+ companyId,
+ createdBy: userId,
+ });
+ if (insert.error) {
+ return json(
+ {
+ id: null,
+ },
+ await flash(
+ request,
+ error(insert.error, "Failed to insert method operation tool")
+ )
+ );
+ }
+
+ const methodOperationToolId = insert.data?.id;
+ if (!methodOperationToolId) {
+ return json(
+ {
+ id: null,
+ },
+ await flash(
+ request,
+ error(insert.error, "Failed to insert method operation tool")
+ )
+ );
+ }
+
+ return json({ id: methodOperationToolId });
+}
diff --git a/apps/carbon/app/utils/path.ts b/apps/carbon/app/utils/path.ts
index 768f6a0aab..4ed9b8a666 100644
--- a/apps/carbon/app/utils/path.ts
+++ b/apps/carbon/app/utils/path.ts
@@ -486,6 +486,7 @@ export const path = {
newMaterial: `${x}/material/new`,
newMethodMaterial: `${x}/items/methods/material/new`,
newMethodOperation: `${x}/items/methods/operation/new`,
+ newMethodOperationTool: `${x}/items/methods/operation/tool/new`,
newNote: `${x}/shared/notes/new`,
newPart: `${x}/part/new`,
newItemPostingGroup: `${x}/items/groups/new`,
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index 50a98336fa..fd52fbaa49 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -2294,7 +2294,7 @@ export type Database = {
{
foreignKeyName: "consumable_itemId_fkey"
columns: ["itemId"]
- isOneToOne: false
+ isOneToOne: true
referencedRelation: "item"
referencedColumns: ["id"]
},
@@ -8405,6 +8405,169 @@ export type Database = {
},
]
}
+ jobOperationTool: {
+ Row: {
+ companyId: string
+ createdAt: string
+ createdBy: string
+ id: string
+ operationId: string
+ quantity: number
+ toolId: string
+ updatedAt: string
+ updatedBy: string | null
+ }
+ Insert: {
+ companyId: string
+ createdAt?: string
+ createdBy: string
+ id?: string
+ operationId: string
+ quantity?: number
+ toolId: string
+ updatedAt?: string
+ updatedBy?: string | null
+ }
+ Update: {
+ companyId?: string
+ createdAt?: string
+ createdBy?: string
+ id?: string
+ operationId?: string
+ quantity?: number
+ toolId?: string
+ updatedAt?: string
+ updatedBy?: string | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "jobOperationTool_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "jobOperationTool_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "jobOperationTool_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "jobOperationTool_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "jobOperationTool_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "jobOperationTool_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "jobOperationTool_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "jobOperationTool_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "jobOperationTool_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "jobOperationTool_operationId_fkey"
+ columns: ["operationId"]
+ isOneToOne: false
+ referencedRelation: "jobOperation"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "jobOperationTool_operationId_fkey"
+ columns: ["operationId"]
+ isOneToOne: false
+ referencedRelation: "jobOperationsWithMakeMethods"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "jobOperationTool_toolId_fkey"
+ columns: ["toolId"]
+ isOneToOne: false
+ referencedRelation: "tool"
+ referencedColumns: ["itemId"]
+ },
+ {
+ foreignKeyName: "jobOperationTool_toolId_fkey"
+ columns: ["toolId"]
+ isOneToOne: false
+ referencedRelation: "tools"
+ referencedColumns: ["itemId"]
+ },
+ {
+ foreignKeyName: "jobOperationTool_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "jobOperationTool_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "jobOperationTool_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "jobOperationTool_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "jobOperationTool_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ ]
+ }
journal: {
Row: {
accountingPeriodId: string | null
@@ -8939,7 +9102,7 @@ export type Database = {
{
foreignKeyName: "material_itemId_fkey"
columns: ["itemId"]
- isOneToOne: false
+ isOneToOne: true
referencedRelation: "item"
referencedColumns: ["id"]
},
@@ -9806,6 +9969,162 @@ export type Database = {
},
]
}
+ methodOperationTool: {
+ Row: {
+ companyId: string
+ createdAt: string
+ createdBy: string
+ id: string
+ operationId: string
+ quantity: number
+ toolId: string
+ updatedAt: string
+ updatedBy: string | null
+ }
+ Insert: {
+ companyId: string
+ createdAt?: string
+ createdBy: string
+ id?: string
+ operationId: string
+ quantity?: number
+ toolId: string
+ updatedAt?: string
+ updatedBy?: string | null
+ }
+ Update: {
+ companyId?: string
+ createdAt?: string
+ createdBy?: string
+ id?: string
+ operationId?: string
+ quantity?: number
+ toolId?: string
+ updatedAt?: string
+ updatedBy?: string | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "methodOperationTool_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "methodOperationTool_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "methodOperationTool_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "methodOperationTool_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "methodOperationTool_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "methodOperationTool_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "methodOperationTool_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "methodOperationTool_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "methodOperationTool_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "methodOperationTool_operationId_fkey"
+ columns: ["operationId"]
+ isOneToOne: false
+ referencedRelation: "methodOperation"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "methodOperationTool_toolId_fkey"
+ columns: ["toolId"]
+ isOneToOne: false
+ referencedRelation: "tool"
+ referencedColumns: ["itemId"]
+ },
+ {
+ foreignKeyName: "methodOperationTool_toolId_fkey"
+ columns: ["toolId"]
+ isOneToOne: false
+ referencedRelation: "tools"
+ referencedColumns: ["itemId"]
+ },
+ {
+ foreignKeyName: "methodOperationTool_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "methodOperationTool_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "methodOperationTool_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "methodOperationTool_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "methodOperationTool_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ ]
+ }
modelUpload: {
Row: {
autodeskUrn: string | null
@@ -10563,7 +10882,7 @@ export type Database = {
{
foreignKeyName: "part_id_fkey"
columns: ["itemId"]
- isOneToOne: false
+ isOneToOne: true
referencedRelation: "item"
referencedColumns: ["id"]
},
@@ -15969,6 +16288,169 @@ export type Database = {
},
]
}
+ quoteOperationTool: {
+ Row: {
+ companyId: string
+ createdAt: string
+ createdBy: string
+ id: string
+ operationId: string
+ quantity: number
+ toolId: string
+ updatedAt: string
+ updatedBy: string | null
+ }
+ Insert: {
+ companyId: string
+ createdAt?: string
+ createdBy: string
+ id?: string
+ operationId: string
+ quantity?: number
+ toolId: string
+ updatedAt?: string
+ updatedBy?: string | null
+ }
+ Update: {
+ companyId?: string
+ createdAt?: string
+ createdBy?: string
+ id?: string
+ operationId?: string
+ quantity?: number
+ toolId?: string
+ updatedAt?: string
+ updatedBy?: string | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "quoteOperationTool_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteOperationTool_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteOperationTool_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "quoteOperationTool_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "quoteOperationTool_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteOperationTool_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteOperationTool_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteOperationTool_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteOperationTool_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "quoteOperationTool_operationId_fkey"
+ columns: ["operationId"]
+ isOneToOne: false
+ referencedRelation: "quoteOperation"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteOperationTool_operationId_fkey"
+ columns: ["operationId"]
+ isOneToOne: false
+ referencedRelation: "quoteOperationsWithMakeMethods"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteOperationTool_toolId_fkey"
+ columns: ["toolId"]
+ isOneToOne: false
+ referencedRelation: "tool"
+ referencedColumns: ["itemId"]
+ },
+ {
+ foreignKeyName: "quoteOperationTool_toolId_fkey"
+ columns: ["toolId"]
+ isOneToOne: false
+ referencedRelation: "tools"
+ referencedColumns: ["itemId"]
+ },
+ {
+ foreignKeyName: "quoteOperationTool_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteOperationTool_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteOperationTool_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteOperationTool_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteOperationTool_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ ]
+ }
quotePayment: {
Row: {
companyId: string
@@ -21393,7 +21875,7 @@ export type Database = {
{
foreignKeyName: "tool_itemId_fkey"
columns: ["itemId"]
- isOneToOne: false
+ isOneToOne: true
referencedRelation: "item"
referencedColumns: ["id"]
},
@@ -23310,7 +23792,7 @@ export type Database = {
{
foreignKeyName: "consumable_itemId_fkey"
columns: ["itemId"]
- isOneToOne: false
+ isOneToOne: true
referencedRelation: "item"
referencedColumns: ["id"]
},
@@ -25276,7 +25758,7 @@ export type Database = {
{
foreignKeyName: "material_itemId_fkey"
columns: ["itemId"]
- isOneToOne: false
+ isOneToOne: true
referencedRelation: "item"
referencedColumns: ["id"]
},
@@ -25653,7 +26135,7 @@ export type Database = {
{
foreignKeyName: "part_id_fkey"
columns: ["itemId"]
- isOneToOne: false
+ isOneToOne: true
referencedRelation: "item"
referencedColumns: ["id"]
},
@@ -29715,7 +30197,7 @@ export type Database = {
{
foreignKeyName: "tool_itemId_fkey"
columns: ["itemId"]
- isOneToOne: false
+ isOneToOne: true
referencedRelation: "item"
referencedColumns: ["id"]
},
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index 50a98336fa..fd52fbaa49 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -2294,7 +2294,7 @@ export type Database = {
{
foreignKeyName: "consumable_itemId_fkey"
columns: ["itemId"]
- isOneToOne: false
+ isOneToOne: true
referencedRelation: "item"
referencedColumns: ["id"]
},
@@ -8405,6 +8405,169 @@ export type Database = {
},
]
}
+ jobOperationTool: {
+ Row: {
+ companyId: string
+ createdAt: string
+ createdBy: string
+ id: string
+ operationId: string
+ quantity: number
+ toolId: string
+ updatedAt: string
+ updatedBy: string | null
+ }
+ Insert: {
+ companyId: string
+ createdAt?: string
+ createdBy: string
+ id?: string
+ operationId: string
+ quantity?: number
+ toolId: string
+ updatedAt?: string
+ updatedBy?: string | null
+ }
+ Update: {
+ companyId?: string
+ createdAt?: string
+ createdBy?: string
+ id?: string
+ operationId?: string
+ quantity?: number
+ toolId?: string
+ updatedAt?: string
+ updatedBy?: string | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "jobOperationTool_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "jobOperationTool_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "jobOperationTool_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "jobOperationTool_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "jobOperationTool_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "jobOperationTool_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "jobOperationTool_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "jobOperationTool_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "jobOperationTool_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "jobOperationTool_operationId_fkey"
+ columns: ["operationId"]
+ isOneToOne: false
+ referencedRelation: "jobOperation"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "jobOperationTool_operationId_fkey"
+ columns: ["operationId"]
+ isOneToOne: false
+ referencedRelation: "jobOperationsWithMakeMethods"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "jobOperationTool_toolId_fkey"
+ columns: ["toolId"]
+ isOneToOne: false
+ referencedRelation: "tool"
+ referencedColumns: ["itemId"]
+ },
+ {
+ foreignKeyName: "jobOperationTool_toolId_fkey"
+ columns: ["toolId"]
+ isOneToOne: false
+ referencedRelation: "tools"
+ referencedColumns: ["itemId"]
+ },
+ {
+ foreignKeyName: "jobOperationTool_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "jobOperationTool_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "jobOperationTool_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "jobOperationTool_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "jobOperationTool_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ ]
+ }
journal: {
Row: {
accountingPeriodId: string | null
@@ -8939,7 +9102,7 @@ export type Database = {
{
foreignKeyName: "material_itemId_fkey"
columns: ["itemId"]
- isOneToOne: false
+ isOneToOne: true
referencedRelation: "item"
referencedColumns: ["id"]
},
@@ -9806,6 +9969,162 @@ export type Database = {
},
]
}
+ methodOperationTool: {
+ Row: {
+ companyId: string
+ createdAt: string
+ createdBy: string
+ id: string
+ operationId: string
+ quantity: number
+ toolId: string
+ updatedAt: string
+ updatedBy: string | null
+ }
+ Insert: {
+ companyId: string
+ createdAt?: string
+ createdBy: string
+ id?: string
+ operationId: string
+ quantity?: number
+ toolId: string
+ updatedAt?: string
+ updatedBy?: string | null
+ }
+ Update: {
+ companyId?: string
+ createdAt?: string
+ createdBy?: string
+ id?: string
+ operationId?: string
+ quantity?: number
+ toolId?: string
+ updatedAt?: string
+ updatedBy?: string | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "methodOperationTool_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "methodOperationTool_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "methodOperationTool_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "methodOperationTool_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "methodOperationTool_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "methodOperationTool_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "methodOperationTool_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "methodOperationTool_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "methodOperationTool_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "methodOperationTool_operationId_fkey"
+ columns: ["operationId"]
+ isOneToOne: false
+ referencedRelation: "methodOperation"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "methodOperationTool_toolId_fkey"
+ columns: ["toolId"]
+ isOneToOne: false
+ referencedRelation: "tool"
+ referencedColumns: ["itemId"]
+ },
+ {
+ foreignKeyName: "methodOperationTool_toolId_fkey"
+ columns: ["toolId"]
+ isOneToOne: false
+ referencedRelation: "tools"
+ referencedColumns: ["itemId"]
+ },
+ {
+ foreignKeyName: "methodOperationTool_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "methodOperationTool_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "methodOperationTool_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "methodOperationTool_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "methodOperationTool_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ ]
+ }
modelUpload: {
Row: {
autodeskUrn: string | null
@@ -10563,7 +10882,7 @@ export type Database = {
{
foreignKeyName: "part_id_fkey"
columns: ["itemId"]
- isOneToOne: false
+ isOneToOne: true
referencedRelation: "item"
referencedColumns: ["id"]
},
@@ -15969,6 +16288,169 @@ export type Database = {
},
]
}
+ quoteOperationTool: {
+ Row: {
+ companyId: string
+ createdAt: string
+ createdBy: string
+ id: string
+ operationId: string
+ quantity: number
+ toolId: string
+ updatedAt: string
+ updatedBy: string | null
+ }
+ Insert: {
+ companyId: string
+ createdAt?: string
+ createdBy: string
+ id?: string
+ operationId: string
+ quantity?: number
+ toolId: string
+ updatedAt?: string
+ updatedBy?: string | null
+ }
+ Update: {
+ companyId?: string
+ createdAt?: string
+ createdBy?: string
+ id?: string
+ operationId?: string
+ quantity?: number
+ toolId?: string
+ updatedAt?: string
+ updatedBy?: string | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "quoteOperationTool_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteOperationTool_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteOperationTool_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "quoteOperationTool_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "quoteOperationTool_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteOperationTool_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteOperationTool_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteOperationTool_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteOperationTool_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "quoteOperationTool_operationId_fkey"
+ columns: ["operationId"]
+ isOneToOne: false
+ referencedRelation: "quoteOperation"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteOperationTool_operationId_fkey"
+ columns: ["operationId"]
+ isOneToOne: false
+ referencedRelation: "quoteOperationsWithMakeMethods"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteOperationTool_toolId_fkey"
+ columns: ["toolId"]
+ isOneToOne: false
+ referencedRelation: "tool"
+ referencedColumns: ["itemId"]
+ },
+ {
+ foreignKeyName: "quoteOperationTool_toolId_fkey"
+ columns: ["toolId"]
+ isOneToOne: false
+ referencedRelation: "tools"
+ referencedColumns: ["itemId"]
+ },
+ {
+ foreignKeyName: "quoteOperationTool_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteOperationTool_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteOperationTool_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteOperationTool_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteOperationTool_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ ]
+ }
quotePayment: {
Row: {
companyId: string
@@ -21393,7 +21875,7 @@ export type Database = {
{
foreignKeyName: "tool_itemId_fkey"
columns: ["itemId"]
- isOneToOne: false
+ isOneToOne: true
referencedRelation: "item"
referencedColumns: ["id"]
},
@@ -23310,7 +23792,7 @@ export type Database = {
{
foreignKeyName: "consumable_itemId_fkey"
columns: ["itemId"]
- isOneToOne: false
+ isOneToOne: true
referencedRelation: "item"
referencedColumns: ["id"]
},
@@ -25276,7 +25758,7 @@ export type Database = {
{
foreignKeyName: "material_itemId_fkey"
columns: ["itemId"]
- isOneToOne: false
+ isOneToOne: true
referencedRelation: "item"
referencedColumns: ["id"]
},
@@ -25653,7 +26135,7 @@ export type Database = {
{
foreignKeyName: "part_id_fkey"
columns: ["itemId"]
- isOneToOne: false
+ isOneToOne: true
referencedRelation: "item"
referencedColumns: ["id"]
},
@@ -29715,7 +30197,7 @@ export type Database = {
{
foreignKeyName: "tool_itemId_fkey"
columns: ["itemId"]
- isOneToOne: false
+ isOneToOne: true
referencedRelation: "item"
referencedColumns: ["id"]
},
diff --git a/packages/database/supabase/migrations/20241127174710_process-tools.sql b/packages/database/supabase/migrations/20241127174710_process-tools.sql
new file mode 100644
index 0000000000..f7da123e2a
--- /dev/null
+++ b/packages/database/supabase/migrations/20241127174710_process-tools.sql
@@ -0,0 +1,155 @@
+ALTER TABLE "part" ADD CONSTRAINT "part_itemId_unique" UNIQUE ("itemId");
+ALTER TABLE "tool" ADD CONSTRAINT "tool_itemId_unique" UNIQUE ("itemId");
+ALTER TABLE "consumable" ADD CONSTRAINT "consumable_itemId_unique" UNIQUE ("itemId");
+ALTER TABLE "material" ADD CONSTRAINT "material_itemId_unique" UNIQUE ("itemId");
+
+CREATE TABLE "methodOperationTool" (
+ "id" TEXT NOT NULL DEFAULT xid(),
+ "operationId" TEXT NOT NULL,
+ "toolId" TEXT NOT NULL,
+ "quantity" INTEGER NOT NULL DEFAULT 1,
+ "companyId" TEXT NOT NULL,
+ "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
+ "createdBy" TEXT NOT NULL,
+ "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
+ "updatedBy" TEXT,
+
+ CONSTRAINT "methodOperationTool_pkey" PRIMARY KEY ("id"),
+ CONSTRAINT "methodOperationTool_operationId_fkey" FOREIGN KEY ("operationId") REFERENCES "methodOperation"("id"),
+ CONSTRAINT "methodOperationTool_toolId_fkey" FOREIGN KEY ("toolId") REFERENCES "tool"("itemId"),
+ CONSTRAINT "methodOperationTool_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company"("id"),
+ CONSTRAINT "methodOperationTool_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id") ON DELETE RESTRICT,
+ CONSTRAINT "methodOperationTool_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id") ON DELETE RESTRICT
+);
+
+CREATE INDEX "methodOperationTool_operationId_idx" ON "methodOperationTool" ("operationId");
+CREATE INDEX "methodOperationTool_toolId_idx" ON "methodOperationTool" ("toolId");
+
+CREATE POLICY "Employees with parts_view can view method operation tools" ON "methodOperationTool"
+ FOR SELECT
+ USING (
+ has_role('employee', "companyId") AND
+ has_company_permission('parts_view', "companyId")
+ );
+
+CREATE POLICY "Employees with parts_create can create method operation tools" ON "methodOperationTool"
+ FOR INSERT
+ WITH CHECK (
+ has_role('employee', "companyId") AND
+ has_company_permission('parts_create', "companyId")
+ );
+
+CREATE POLICY "Employees with parts_update can update method operation tools" ON "methodOperationTool"
+ FOR UPDATE
+ USING (
+ has_role('employee', "companyId") AND
+ has_company_permission('parts_update', "companyId")
+ );
+
+CREATE POLICY "Employees with parts_delete can delete method operation tools" ON "methodOperationTool"
+ FOR DELETE
+ USING (
+ has_role('employee', "companyId") AND
+ has_company_permission('parts_delete', "companyId")
+ );
+
+
+CREATE TABLE "quoteOperationTool" (
+ "id" TEXT NOT NULL DEFAULT xid(),
+ "operationId" TEXT NOT NULL,
+ "toolId" TEXT NOT NULL,
+ "quantity" INTEGER NOT NULL DEFAULT 1,
+ "companyId" TEXT NOT NULL,
+ "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
+ "createdBy" TEXT NOT NULL,
+ "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
+ "updatedBy" TEXT,
+
+ CONSTRAINT "quoteOperationTool_pkey" PRIMARY KEY ("id"),
+ CONSTRAINT "quoteOperationTool_operationId_fkey" FOREIGN KEY ("operationId") REFERENCES "quoteOperation"("id"),
+ CONSTRAINT "quoteOperationTool_toolId_fkey" FOREIGN KEY ("toolId") REFERENCES "tool"("itemId"),
+ CONSTRAINT "quoteOperationTool_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company"("id"),
+ CONSTRAINT "quoteOperationTool_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id") ON DELETE RESTRICT,
+ CONSTRAINT "quoteOperationTool_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id") ON DELETE RESTRICT
+);
+
+CREATE INDEX "quoteOperationTool_operationId_idx" ON "quoteOperationTool" ("operationId");
+CREATE INDEX "quoteOperationTool_toolId_idx" ON "quoteOperationTool" ("toolId");
+
+CREATE POLICY "Employees with sales_view can view quote operation tools" ON "quoteOperationTool"
+ FOR SELECT
+ USING (
+ has_role('employee', "companyId") AND
+ has_company_permission('sales_view', "companyId")
+ );
+
+CREATE POLICY "Employees with sales_create can create quote operation tools" ON "quoteOperationTool"
+ FOR INSERT
+ WITH CHECK (
+ has_role('employee', "companyId") AND
+ has_company_permission('sales_create', "companyId")
+ );
+
+CREATE POLICY "Employees with sales_update can update quote operation tools" ON "quoteOperationTool"
+ FOR UPDATE
+ USING (
+ has_role('employee', "companyId") AND
+ has_company_permission('sales_update', "companyId")
+ );
+
+CREATE POLICY "Employees with sales_delete can delete quote operation tools" ON "quoteOperationTool"
+ FOR DELETE
+ USING (
+ has_role('employee', "companyId") AND
+ has_company_permission('sales_delete', "companyId")
+ );
+
+CREATE TABLE "jobOperationTool" (
+ "id" TEXT NOT NULL DEFAULT xid(),
+ "operationId" TEXT NOT NULL,
+ "toolId" TEXT NOT NULL,
+ "quantity" INTEGER NOT NULL DEFAULT 1,
+ "companyId" TEXT NOT NULL,
+ "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
+ "createdBy" TEXT NOT NULL,
+ "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
+ "updatedBy" TEXT,
+
+ CONSTRAINT "jobOperationTool_pkey" PRIMARY KEY ("id"),
+ CONSTRAINT "jobOperationTool_operationId_fkey" FOREIGN KEY ("operationId") REFERENCES "jobOperation"("id"),
+ CONSTRAINT "jobOperationTool_toolId_fkey" FOREIGN KEY ("toolId") REFERENCES "tool"("itemId"),
+ CONSTRAINT "jobOperationTool_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company"("id"),
+ CONSTRAINT "jobOperationTool_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id") ON DELETE RESTRICT,
+ CONSTRAINT "jobOperationTool_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id") ON DELETE RESTRICT
+);
+
+CREATE INDEX "jobOperationTool_operationId_idx" ON "jobOperationTool" ("operationId");
+CREATE INDEX "jobOperationTool_toolId_idx" ON "jobOperationTool" ("toolId");
+
+CREATE POLICY "Employees with production_view can view job operation tools" ON "jobOperationTool"
+ FOR SELECT
+ USING (
+ has_role('employee', "companyId") AND
+ has_company_permission('production_view', "companyId")
+ );
+
+CREATE POLICY "Employees with production_create can create job operation tools" ON "jobOperationTool"
+ FOR INSERT
+ WITH CHECK (
+ has_role('employee', "companyId") AND
+ has_company_permission('production_create', "companyId")
+ );
+
+CREATE POLICY "Employees with production_update can update job operation tools" ON "jobOperationTool"
+ FOR UPDATE
+ USING (
+ has_role('employee', "companyId") AND
+ has_company_permission('production_update', "companyId")
+ );
+
+CREATE POLICY "Employees with production_delete can delete job operation tools" ON "jobOperationTool"
+ FOR DELETE
+ USING (
+ has_role('employee', "companyId") AND
+ has_company_permission('production_delete', "companyId")
+ );
diff --git a/packages/react/src/CreateableCombobox.tsx b/packages/react/src/CreateableCombobox.tsx
index cf3f9be2b6..8951e5a4d5 100644
--- a/packages/react/src/CreateableCombobox.tsx
+++ b/packages/react/src/CreateableCombobox.tsx
@@ -34,6 +34,7 @@ export type CreatableComboboxProps = Omit<
value: string,
options: { value: string; label: string; helper?: string }[]
) => React.ReactNode;
+ inlineAddLabel?: string;
onChange?: (selected: string) => void;
onCreateOption?: (inputValue: string) => void;
itemHeight?: number;
@@ -53,6 +54,7 @@ const CreatableCombobox = forwardRef<HTMLButtonElement, CreatableComboboxProps>(
label,
itemHeight = 40,
inline,
+ inlineAddLabel,
onCreateOption,
...props
},
@@ -76,15 +78,22 @@ const CreatableCombobox = forwardRef<HTMLButtonElement, CreatableComboboxProps>(
<Popover open={open} onOpenChange={setOpen}>
<PopoverTrigger asChild>
{inline ? (
- <IconButton
- size={size ?? "sm"}
- variant="secondary"
- aria-label={value ? "Edit" : "Add"}
- icon={value ? <LuSettings2 /> : <LuPlus />}
- ref={ref}
- isDisabled={isReadOnly}
- onClick={() => setOpen(true)}
- />
+ <HStack>
+ <IconButton
+ size={size ?? "sm"}
+ variant="secondary"
+ aria-label={value ? "Edit" : "Add"}
+ icon={value ? <LuSettings2 /> : <LuPlus />}
+ ref={ref}
+ isDisabled={isReadOnly}
+ onClick={() => setOpen(true)}
+ />
+ {!value && inlineAddLabel && (
+ <span className="text-muted-foreground text-sm">
+ {inlineAddLabel}
+ </span>
+ )}
+ </HStack>
) : (
<CommandTrigger
size={size}