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: crud for work centers and refactored bill of process

Brad Barbindde15f4736a5
diff --git a/apps/carbon/app/components/CreateableMultiSelect.tsx b/apps/carbon/app/components/CreateableMultiSelect.tsx
new file mode 100644
index 0000000000..a60abcb205
--- /dev/null
+++ b/apps/carbon/app/components/CreateableMultiSelect.tsx
@@ -0,0 +1,220 @@
+import {
+ Badge,
+ BadgeCloseButton,
+ Button,
+ Command,
+ CommandGroup,
+ CommandInput,
+ CommandItem,
+ HStack,
+ IconButton,
+ Popover,
+ PopoverContent,
+ PopoverTrigger,
+ cn,
+ multiSelectTriggerVariants,
+} from "@carbon/react";
+import { getColor } from "@carbon/utils";
+import type { ComponentPropsWithoutRef } from "react";
+import { forwardRef, useId, useState } from "react";
+import { MdClose } from "react-icons/md";
+import { RxCheck, RxMagnifyingGlass } from "react-icons/rx";
+
+export type CreatableMultiSelectProps = Omit<
+ ComponentPropsWithoutRef<"button">,
+ "onChange"
+> & {
+ size?: "sm" | "md" | "lg";
+ value: string[];
+ options: {
+ label: string;
+ value: string;
+ helper?: string;
+ }[];
+ selected?: string[];
+ isClearable?: boolean;
+ isReadOnly?: boolean;
+ label?: string;
+ placeholder?: string;
+ onChange: (selected: string[]) => void;
+ onCreateOption?: (inputValue: string) => void;
+};
+
+const CreatableMultiSelect = forwardRef<
+ HTMLButtonElement,
+ CreatableMultiSelectProps
+>(
+ (
+ {
+ size,
+ value,
+ options,
+ selected,
+ isClearable,
+ isReadOnly,
+ placeholder,
+ onChange,
+ label,
+ className,
+ ...props
+ },
+ ref
+ ) => {
+ const [open, setOpen] = useState(false);
+ const [search, setSearch] = useState("");
+ const isExactMatch = options.some((option) =>
+ [option.label.toLowerCase(), option.helper?.toLowerCase()].includes(
+ search.toLowerCase()
+ )
+ );
+
+ const id = useId();
+
+ const handleUnselect = (item: string) => {
+ onChange(value.filter((i) => i !== item));
+ };
+
+ const hasSelections = value.length > 0;
+
+ return (
+ <HStack spacing={1}>
+ <Popover open={open} onOpenChange={setOpen}>
+ <PopoverTrigger asChild>
+ <Button
+ aria-controls={id}
+ aria-expanded={open}
+ role="combobox"
+ tabIndex={0}
+ variant="secondary"
+ className={cn(
+ multiSelectTriggerVariants({ size, hasSelections }),
+ "bg-transparent px-2",
+ className
+ )}
+ onClick={() => setOpen(!open)}
+ onKeyDown={() => setOpen(!open)}
+ asChild
+ >
+ <div>
+ {hasSelections ? (
+ <div className="flex gap-1 flex-wrap">
+ {value.map((item) => (
+ <SelectedOption
+ key={item.toString()}
+ item={item}
+ options={options}
+ onUnselect={handleUnselect}
+ />
+ ))}
+ </div>
+ ) : (
+ <span className="text-muted-foreground">
+ {placeholder ?? "Search..."}
+ </span>
+ )}
+
+ <RxMagnifyingGlass className="h-4 w-4 shrink-0 opacity-50" />
+ </div>
+ </Button>
+ </PopoverTrigger>
+ <PopoverContent className="min-w-[200px] w-[--radix-popover-trigger-width] p-0">
+ <Command>
+ <CommandInput
+ placeholder="Search..."
+ value={search}
+ onValueChange={setSearch}
+ className="h-9"
+ />
+ <CommandGroup className="max-h-64 overflow-auto">
+ {options.map((option) => (
+ <CommandItem
+ key={option.value}
+ onSelect={() => {
+ onChange(
+ value.includes(option.value)
+ ? value.filter((item) => item !== option.value)
+ : [...value, option.value]
+ );
+ setOpen(true);
+ }}
+ >
+ <RxCheck
+ className={cn(
+ "mr-2 h-4 w-4",
+ value.includes(option.value)
+ ? "opacity-100"
+ : "opacity-0"
+ )}
+ />
+ {option.label}
+ </CommandItem>
+ ))}
+ {!isExactMatch && (
+ <CommandItem
+ onSelect={() => {
+ props.onCreateOption?.(search);
+ setSearch("");
+ }}
+ value={search?.replace(/"/g, '\\"').trim() || ""}
+ className="cursor-pointer"
+ >
+ <span>Create</span>
+ <span className="ml-1 font-bold">{search || label}</span>
+ </CommandItem>
+ )}
+ </CommandGroup>
+ </Command>
+ </PopoverContent>
+ </Popover>
+ {isClearable && !isReadOnly && value && (
+ <IconButton
+ variant="ghost"
+ aria-label="Clear"
+ icon={<MdClose />}
+ onClick={() => onChange?.([])}
+ size={size === "sm" ? "md" : size}
+ />
+ )}
+ </HStack>
+ );
+ }
+);
+CreatableMultiSelect.displayName = "CreatableMultiSelect";
+
+export default CreatableMultiSelect;
+
+function SelectedOption({
+ item,
+ options,
+ onUnselect,
+}: {
+ item: string;
+ options: CreatableMultiSelectProps["options"];
+ onUnselect: (item: string) => void;
+}) {
+ const label = options.find((o) => o.value === item)?.label ?? "";
+ const colors = getColor(label);
+
+ return (
+ <Badge key={item} onClick={() => onUnselect(item)} style={colors}>
+ {options.find((option) => option.value === item)?.label}
+ <BadgeCloseButton
+ style={{ color: colors.color }}
+ onKeyDown={(e) => {
+ if (e.key === "Enter") {
+ onUnselect(item);
+ }
+ }}
+ onMouseDown={(e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ }}
+ onClick={(e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ onUnselect(item);
+ }}
+ />
+ </Badge>
+ );
+}
diff --git a/apps/carbon/app/components/Form/Combobox.tsx b/apps/carbon/app/components/Form/Combobox.tsx
index 2acc141afa..292e06bc6e 100644
--- a/apps/carbon/app/components/Form/Combobox.tsx
+++ b/apps/carbon/app/components/Form/Combobox.tsx
@@ -12,11 +12,18 @@ import type { ComboboxProps as ComboboxBaseProps } from "~/components/Combobox";
export type ComboboxProps = Omit<ComboboxBaseProps, "onChange"> & {
name: string;
label?: string;
+ isOptional?: boolean;
helperText?: string;
onChange?: (newValue: { value: string; label: string } | null) => void;
};
-const Combobox = ({ name, label, helperText, ...props }: ComboboxProps) => {
+const Combobox = ({
+ name,
+ label,
+ isOptional = false,
+ helperText,
+ ...props
+}: ComboboxProps) => {
const { getInputProps, error } = useField(name);
const [value, setValue] = useControlField<string | undefined>(name);
@@ -30,7 +37,11 @@ const Combobox = ({ name, label, helperText, ...props }: ComboboxProps) => {
return (
<FormControl isInvalid={!!error}>
- {label && <FormLabel htmlFor={name}>{label}</FormLabel>}
+ {label && (
+ <FormLabel htmlFor={name} isOptional={isOptional}>
+ {label}
+ </FormLabel>
+ )}
<input
{...getInputProps({
id: name,
@@ -47,6 +58,7 @@ const Combobox = ({ name, label, helperText, ...props }: ComboboxProps) => {
setValue(newValue ?? "");
onChange(newValue ?? "");
}}
+ isClearable={isOptional && !props.isReadOnly}
className="w-full"
/>
diff --git a/apps/carbon/app/components/Form/CreatableCombobox.tsx b/apps/carbon/app/components/Form/CreatableCombobox.tsx
index d95b667ed5..f7a951d0ce 100644
--- a/apps/carbon/app/components/Form/CreatableCombobox.tsx
+++ b/apps/carbon/app/components/Form/CreatableCombobox.tsx
@@ -17,11 +17,12 @@ export type CreatableComboboxProps = Omit<
name: string;
label?: string;
helperText?: string;
+ isOptional?: boolean;
onChange?: (newValue: { value: string; label: string } | null) => void;
};
const CreatableCombobox = forwardRef<HTMLButtonElement, CreatableComboboxProps>(
- ({ name, label, helperText, ...props }, ref) => {
+ ({ name, label, helperText, isOptional = false, ...props }, ref) => {
const { getInputProps, error } = useField(name);
const [value, setValue] = useControlField<string | undefined>(name);
@@ -39,7 +40,11 @@ const CreatableCombobox = forwardRef<HTMLButtonElement, CreatableComboboxProps>(
return (
<FormControl isInvalid={!!error}>
- {label && <FormLabel htmlFor={name}>{label}</FormLabel>}
+ {label && (
+ <FormLabel htmlFor={name} isOptional={isOptional}>
+ {label}
+ </FormLabel>
+ )}
<input
{...getInputProps({
id: name,
@@ -57,6 +62,7 @@ const CreatableCombobox = forwardRef<HTMLButtonElement, CreatableComboboxProps>(
setValue(newValue?.replace(/"/g, '\\"') ?? "");
onChange(newValue?.replace(/"/g, '\\"') ?? "");
}}
+ isClearable={isOptional && !props.isReadOnly}
label={label}
className="w-full"
/>
diff --git a/apps/carbon/app/components/Form/CreatableMultiSelect.tsx b/apps/carbon/app/components/Form/CreatableMultiSelect.tsx
new file mode 100644
index 0000000000..5514deee4c
--- /dev/null
+++ b/apps/carbon/app/components/Form/CreatableMultiSelect.tsx
@@ -0,0 +1,80 @@
+import {
+ FormControl,
+ FormErrorMessage,
+ FormHelperText,
+ FormLabel,
+} from "@carbon/react";
+import { forwardRef, useEffect } from "react";
+
+import { useControlField, useField } from "@carbon/remix-validated-form";
+import { CreatableMultiSelect as CreatableMultiSelectBase } from "~/components";
+import type { CreatableMultiSelectProps as CreatableMultiSelectBaseProps } from "~/components/CreateableMultiSelect";
+
+export type CreatableMultiSelectProps = Omit<
+ CreatableMultiSelectBaseProps,
+ "onChange" | "value"
+> & {
+ name: string;
+ label?: string;
+ helperText?: string;
+ isOptional?: boolean;
+ value?: string[];
+ onChange?: (newValue: string[]) => void;
+};
+
+const CreatableMultiSelect = forwardRef<
+ HTMLButtonElement,
+ CreatableMultiSelectProps
+>(({ name, label, helperText, isOptional = false, ...props }, ref) => {
+ const { error } = useField(name);
+ const [value, setValue] = useControlField<string[] | undefined>(name);
+
+ useEffect(() => {
+ if (props.value) setValue(props.value);
+ }, [props.value, setValue]);
+
+ const onChange = (value: string[]) => {
+ setValue(value);
+ props.onChange?.(value);
+ };
+
+ return (
+ <FormControl isInvalid={!!error}>
+ {label && (
+ <FormLabel htmlFor={name} isOptional={isOptional}>
+ {label}
+ </FormLabel>
+ )}
+ {(value ?? []).filter(Boolean).map((selection, index) => (
+ <input
+ key={`${name}[${index}]`}
+ type="hidden"
+ name={`${name}[${index}]`}
+ value={selection}
+ />
+ ))}
+ <CreatableMultiSelectBase
+ ref={ref}
+ {...props}
+ value={(value ?? []).map((v) => v.replace(/"/g, '\\"'))}
+ onChange={(newValue) => {
+ setValue((newValue ?? []).map((v) => v.replace(/"/g, '\\"') ?? ""));
+ onChange((newValue ?? []).map((v) => v.replace(/"/g, '\\"') ?? ""));
+ }}
+ isClearable={isOptional && !props.isReadOnly}
+ label={label}
+ className="w-full"
+ />
+
+ {error ? (
+ <FormErrorMessage>{error}</FormErrorMessage>
+ ) : (
+ helperText && <FormHelperText>{helperText}</FormHelperText>
+ )}
+ </FormControl>
+ );
+});
+
+CreatableMultiSelect.displayName = "CreatableMultiSelect";
+
+export default CreatableMultiSelect;
diff --git a/apps/carbon/app/components/Form/EquipmentType.tsx b/apps/carbon/app/components/Form/Process.tsx
similarity index 50%
rename from apps/carbon/app/components/Form/EquipmentType.tsx
rename to apps/carbon/app/components/Form/Process.tsx
index c333fab5c5..50af113be7 100644
--- a/apps/carbon/app/components/Form/EquipmentType.tsx
+++ b/apps/carbon/app/components/Form/Process.tsx
@@ -1,20 +1,20 @@
import { useDisclosure, useMount } from "@carbon/react";
import { useFetcher } from "@remix-run/react";
import { useMemo, useRef, useState } from "react";
-import type { getEquipmentTypesList } from "~/modules/resources";
-import { EquipmentTypeForm } from "~/modules/resources";
+import type { getProcessesList } from "~/modules/resources";
+import { ProcessForm } from "~/modules/resources";
import { path } from "~/utils/path";
import type { ComboboxProps } from "./Combobox";
import CreatableCombobox from "./CreatableCombobox";
-type EquipmentTypeSelectProps = Omit<ComboboxProps, "options">;
+type ProcessSelectProps = Omit<ComboboxProps, "options">;
-const EquipmentType = (props: EquipmentTypeSelectProps) => {
- const triggerRef = useRef<HTMLButtonElement>(null);
- const newEquipmentTypeModal = useDisclosure();
+const Process = (props: ProcessSelectProps) => {
+ const newProcessModal = useDisclosure();
const [created, setCreated] = useState<string>("");
+ const triggerRef = useRef<HTMLButtonElement>(null);
- const options = useEquipmentTypes();
+ const options = useProcesses();
return (
<>
@@ -22,50 +22,50 @@ const EquipmentType = (props: EquipmentTypeSelectProps) => {
ref={triggerRef}
options={options}
{...props}
- label={props?.label ?? "EquipmentType"}
+ label={props?.label ?? "Work Center"}
onCreateOption={(option) => {
- newEquipmentTypeModal.onOpen();
+ newProcessModal.onOpen();
setCreated(option);
}}
/>
- {newEquipmentTypeModal.isOpen && (
- <EquipmentTypeForm
+ {newProcessModal.isOpen && (
+ <ProcessForm
type="modal"
onClose={() => {
setCreated("");
- newEquipmentTypeModal.onClose();
+ newProcessModal.onClose();
triggerRef.current?.click();
}}
initialValues={{
name: created,
- description: "",
- setupHours: 0,
+ defaultStandardFactor: "Minutes/Piece" as "Total Hours",
}}
/>
)}
</>
);
};
-export default EquipmentType;
-EquipmentType.displayName = "EquipmentType";
-const useEquipmentTypes = () => {
- const equipmentTypeFetcher =
- useFetcher<Awaited<ReturnType<typeof getEquipmentTypesList>>>();
+Process.displayName = "Process";
+
+export default Process;
+
+export const useProcesses = () => {
+ const fetcher = useFetcher<Awaited<ReturnType<typeof getProcessesList>>>();
useMount(() => {
- equipmentTypeFetcher.load(path.to.api.equipmentTypes);
+ fetcher.load(path.to.api.processes);
});
const options = useMemo(
() =>
- equipmentTypeFetcher.data?.data
- ? equipmentTypeFetcher.data?.data.map((c) => ({
+ fetcher.data?.data
+ ? fetcher.data?.data.map((c) => ({
value: c.id,
label: c.name,
}))
: [],
- [equipmentTypeFetcher.data]
+ [fetcher.data]
);
return options;
diff --git a/apps/carbon/app/components/Form/Processes.tsx b/apps/carbon/app/components/Form/Processes.tsx
new file mode 100644
index 0000000000..a84c04fb1e
--- /dev/null
+++ b/apps/carbon/app/components/Form/Processes.tsx
@@ -0,0 +1,72 @@
+import { useDisclosure, useMount } from "@carbon/react";
+import { useFetcher } from "@remix-run/react";
+import { useMemo, useRef, useState } from "react";
+import type { getProcessesList } from "~/modules/resources";
+import { ProcessForm } from "~/modules/resources";
+import { path } from "~/utils/path";
+import type { CreatableMultiSelectProps } from "./CreatableMultiSelect";
+import CreatableMultiSelect from "./CreatableMultiSelect";
+
+type ProcessSelectProps = Omit<CreatableMultiSelectProps, "options">;
+
+const Processes = (props: ProcessSelectProps) => {
+ const newProcessModal = useDisclosure();
+ const [created, setCreated] = useState<string>("");
+ const triggerRef = useRef<HTMLButtonElement>(null);
+
+ const options = useProcesses();
+
+ return (
+ <>
+ <CreatableMultiSelect
+ ref={triggerRef}
+ options={options}
+ {...props}
+ label={props?.label ?? "Work Center"}
+ onCreateOption={(option) => {
+ newProcessModal.onOpen();
+ setCreated(option);
+ }}
+ />
+ {newProcessModal.isOpen && (
+ <ProcessForm
+ type="modal"
+ onClose={() => {
+ setCreated("");
+ newProcessModal.onClose();
+ triggerRef.current?.click();
+ }}
+ initialValues={{
+ name: created,
+ defaultStandardFactor: "Minutes/Piece" as "Total Hours",
+ }}
+ />
+ )}
+ </>
+ );
+};
+
+Processes.displayName = "Process";
+
+export default Processes;
+
+export const useProcesses = () => {
+ const fetcher = useFetcher<Awaited<ReturnType<typeof getProcessesList>>>();
+
+ useMount(() => {
+ fetcher.load(path.to.api.processes);
+ });
+
+ const options = useMemo(
+ () =>
+ fetcher.data?.data
+ ? fetcher.data?.data.map((c) => ({
+ value: c.id,
+ label: c.name,
+ }))
+ : [],
+ [fetcher.data]
+ );
+
+ return options;
+};
diff --git a/apps/carbon/app/components/Form/Select.tsx b/apps/carbon/app/components/Form/Select.tsx
index 5b2c9368c0..cdb1166473 100644
--- a/apps/carbon/app/components/Form/Select.tsx
+++ b/apps/carbon/app/components/Form/Select.tsx
@@ -13,10 +13,17 @@ export type SelectProps = Omit<SelectBaseProps, "onChange"> & {
name: string;
label?: string;
helperText?: string;
+ isOptional?: boolean;
onChange?: (newValue: { value: string; label: string } | null) => void;
};
-const Select = ({ name, label, helperText, ...props }: SelectProps) => {
+const Select = ({
+ name,
+ label,
+ helperText,
+ isOptional = false,
+ ...props
+}: SelectProps) => {
const { getInputProps, error } = useField(name);
const [value, setValue] = useControlField<string | undefined>(name);
@@ -30,7 +37,11 @@ const Select = ({ name, label, helperText, ...props }: SelectProps) => {
return (
<FormControl isInvalid={!!error} className={props.className}>
- {label && <FormLabel htmlFor={name}>{label}</FormLabel>}
+ {label && (
+ <FormLabel htmlFor={name} isOptional={isOptional}>
+ {label}
+ </FormLabel>
+ )}
<input
{...getInputProps({
id: name,
@@ -47,6 +58,7 @@ const Select = ({ name, label, helperText, ...props }: SelectProps) => {
setValue(newValue ?? "");
onChange(newValue ?? "");
}}
+ isClearable={isOptional && !props.isReadOnly}
className="w-full"
/>
diff --git a/apps/carbon/app/components/Form/StandardFactor.tsx b/apps/carbon/app/components/Form/StandardFactor.tsx
index e879c3e4d6..087216a552 100644
--- a/apps/carbon/app/components/Form/StandardFactor.tsx
+++ b/apps/carbon/app/components/Form/StandardFactor.tsx
@@ -2,19 +2,28 @@ import { standardFactorType } from "~/modules/shared";
import type { SelectProps } from "./SelectControlled";
import SelectControlled from "./SelectControlled";
-export type StandardFactorSelectProps = Omit<SelectProps, "options">;
+export type StandardFactorSelectProps = Omit<SelectProps, "options"> & {
+ hint?: string;
+};
const StandardFactor = ({
label = "Default Unit",
+ hint,
...props
}: StandardFactorSelectProps) => {
- return (
- <SelectControlled
- {...props}
- label={label}
- options={standardFactorType.map((t) => ({ value: t, label: t }))}
- />
- );
+ const options = standardFactorType
+ .filter((t) => {
+ if (hint === "Fixed") {
+ return ["Total Hours", "Total Minutes"].includes(t);
+ } else if (hint === "Per Unit") {
+ return !["Total Hours", "Total Minutes"].includes(t);
+ } else {
+ return true;
+ }
+ })
+ .map((t) => ({ value: t, label: t }));
+
+ return <SelectControlled {...props} label={label} options={options} />;
};
export default StandardFactor;
diff --git a/apps/carbon/app/components/Form/UnitHint.tsx b/apps/carbon/app/components/Form/UnitHint.tsx
new file mode 100644
index 0000000000..5b5ef04159
--- /dev/null
+++ b/apps/carbon/app/components/Form/UnitHint.tsx
@@ -0,0 +1,54 @@
+import { FormControl, FormHelperText, FormLabel } from "@carbon/react";
+
+import { Select } from "~/components";
+import type { SelectProps } from "~/components/Select";
+import type { StandardFactor } from "~/modules/shared";
+
+type UnitHints = "Per Unit" | "Fixed";
+
+export type UnitHintProps = Omit<SelectProps, "onChange" | "options"> & {
+ defaultUnit?: StandardFactor;
+ label?: string;
+ helperText?: string;
+ value: string;
+ onChange: (newValue: string) => void;
+};
+
+export const getUnitHint = (u?: string) =>
+ ["Total Minutes", "Total Hours"].includes(u ?? "") ? "Fixed" : "Per Unit";
+
+const UnitHint = ({
+ defaultUnit,
+ name,
+ label,
+ helperText,
+ value = getUnitHint(defaultUnit),
+ ...props
+}: UnitHintProps) => {
+ const onChange = (value: UnitHints) => {
+ props?.onChange?.(value);
+ };
+
+ return (
+ <FormControl className={props.className}>
+ {label && <FormLabel htmlFor={name}>{label}</FormLabel>}
+
+ <Select
+ {...props}
+ value={value}
+ onChange={onChange}
+ className="w-full"
+ options={["Fixed", "Per Unit"].map((u) => ({
+ value: u,
+ label: u,
+ }))}
+ />
+
+ {helperText && <FormHelperText>{helperText}</FormHelperText>}
+ </FormControl>
+ );
+};
+
+UnitHint.displayName = "UnitHint";
+
+export default UnitHint;
diff --git a/apps/carbon/app/components/Form/WorkCellType.tsx b/apps/carbon/app/components/Form/WorkCenter.tsx
similarity index 55%
rename from apps/carbon/app/components/Form/WorkCellType.tsx
rename to apps/carbon/app/components/Form/WorkCenter.tsx
index 0f2c511e7f..72b9c12e88 100644
--- a/apps/carbon/app/components/Form/WorkCellType.tsx
+++ b/apps/carbon/app/components/Form/WorkCenter.tsx
@@ -1,20 +1,20 @@
import { useDisclosure, useMount } from "@carbon/react";
import { useFetcher } from "@remix-run/react";
import { useMemo, useRef, useState } from "react";
-import type { getWorkCellTypesList } from "~/modules/resources";
-import { WorkCellTypeForm } from "~/modules/resources";
+import type { getWorkCentersList } from "~/modules/resources";
+import { WorkCenterForm } from "~/modules/resources";
import { path } from "~/utils/path";
import type { ComboboxProps } from "./Combobox";
import CreatableCombobox from "./CreatableCombobox";
-type WorkCellTypeSelectProps = Omit<ComboboxProps, "options">;
+type WorkCenterSelectProps = Omit<ComboboxProps, "options">;
-const WorkCellType = (props: WorkCellTypeSelectProps) => {
- const newWorkCellTypeModal = useDisclosure();
+const WorkCenter = (props: WorkCenterSelectProps) => {
+ const newWorkCenterModal = useDisclosure();
const [created, setCreated] = useState<string>("");
const triggerRef = useRef<HTMLButtonElement>(null);
- const options = useWorkCellTypes();
+ const options = useWorkCenters();
return (
<>
@@ -22,18 +22,18 @@ const WorkCellType = (props: WorkCellTypeSelectProps) => {
ref={triggerRef}
options={options}
{...props}
- label={props?.label ?? "WorkCellType"}
+ label={props?.label ?? "Work Center"}
onCreateOption={(option) => {
- newWorkCellTypeModal.onOpen();
+ newWorkCenterModal.onOpen();
setCreated(option);
}}
/>
- {newWorkCellTypeModal.isOpen && (
- <WorkCellTypeForm
+ {newWorkCenterModal.isOpen && (
+ <WorkCenterForm
type="modal"
onClose={() => {
setCreated("");
- newWorkCellTypeModal.onClose();
+ newWorkCenterModal.onClose();
triggerRef.current?.click();
}}
initialValues={{
@@ -41,7 +41,6 @@ const WorkCellType = (props: WorkCellTypeSelectProps) => {
description: "",
quotingRate: 0,
laborRate: 0,
- overheadRate: 0,
defaultStandardFactor: "Minutes/Piece" as "Total Hours",
}}
/>
@@ -50,27 +49,27 @@ const WorkCellType = (props: WorkCellTypeSelectProps) => {
);
};
-WorkCellType.displayName = "WorkCellType";
+WorkCenter.displayName = "WorkCenter";
-export default WorkCellType;
+export default WorkCenter;
-export const useWorkCellTypes = () => {
- const workCellTypeFetcher =
- useFetcher<Awaited<ReturnType<typeof getWorkCellTypesList>>>();
+export const useWorkCenters = () => {
+ const workCenterFetcher =
+ useFetcher<Awaited<ReturnType<typeof getWorkCentersList>>>();
useMount(() => {
- workCellTypeFetcher.load(path.to.api.workCellTypes);
+ workCenterFetcher.load(path.to.api.workCenters);
});
const options = useMemo(
() =>
- workCellTypeFetcher.data?.data
- ? workCellTypeFetcher.data?.data.map((c) => ({
+ workCenterFetcher.data?.data
+ ? workCenterFetcher.data?.data.map((c) => ({
value: c.id,
label: c.name,
}))
: [],
- [workCellTypeFetcher.data]
+ [workCenterFetcher.data]
);
return options;
diff --git a/apps/carbon/app/components/Form/index.ts b/apps/carbon/app/components/Form/index.ts
index 4df2165ff8..4a462d05ff 100644
--- a/apps/carbon/app/components/Form/index.ts
+++ b/apps/carbon/app/components/Form/index.ts
@@ -23,7 +23,6 @@ import DefaultMethodType from "./DefaultMethodType";
import Department from "./Department";
import Employee from "./Employee";
import Employees from "./Employees";
-import EquipmentType from "./EquipmentType";
import Hidden from "./Hidden";
import Input from "./Input";
import InputControlled from "./InputControlled";
@@ -35,6 +34,8 @@ import NumberControlled from "./NumberControlled";
import Part from "./Part";
import Password from "./Password";
import PhoneInput from "./PhoneInput";
+import Process from "./Process";
+import Processes from "./Processes";
import Radios from "./Radios";
import RichText from "./RichText";
import Select from "./Select";
@@ -55,7 +56,7 @@ import Timezone from "./Timezone";
import UnitOfMeasure from "./UnitOfMeasure";
import User from "./User";
import Users from "./Users";
-import WorkCellType from "./WorkCellType";
+import WorkCenter from "./WorkCenter";
export {
Abilities,
@@ -83,7 +84,6 @@ export {
Department,
Employee,
Employees,
- EquipmentType,
Hidden,
Input,
InputControlled,
@@ -95,6 +95,8 @@ export {
Part,
Password,
PhoneInput,
+ Process,
+ Processes,
Radios,
RichText,
Select,
@@ -115,5 +117,5 @@ export {
UnitOfMeasure,
User,
Users,
- WorkCellType,
+ WorkCenter,
};
diff --git a/apps/carbon/app/components/index.ts b/apps/carbon/app/components/index.ts
index 9d3f1143c8..a3b972167e 100644
--- a/apps/carbon/app/components/index.ts
+++ b/apps/carbon/app/components/index.ts
@@ -4,6 +4,7 @@ import { BreadcrumbItem, BreadcrumbLink, Breadcrumbs } from "./Breadcrumb";
import Combobox from "./Combobox";
import Contact from "./Contact";
import CreatableCombobox from "./CreateableCombobox";
+import CreatableMultiSelect from "./CreateableMultiSelect";
import CustomerAvatar from "./CustomerAvatar";
import DocumentPreview from "./DocumentPreview";
import EmployeeAvatar from "./EmployeeAvatar";
@@ -27,6 +28,7 @@ export {
Combobox,
Contact,
CreatableCombobox,
+ CreatableMultiSelect,
CustomerAvatar,
DocumentPreview,
EmployeeAvatar,
diff --git a/apps/carbon/app/modules/items/items.models.ts b/apps/carbon/app/modules/items/items.models.ts
index 7804d0a6b2..a888eedad8 100644
--- a/apps/carbon/app/modules/items/items.models.ts
+++ b/apps/carbon/app/modules/items/items.models.ts
@@ -215,20 +215,23 @@ export const methodOperationValidator = z.object({
message: "Operation order is required",
}),
}),
- workCellTypeId: z.string().min(20, { message: "Work cell is required" }),
- equipmentTypeId: zfd.text(z.string().optional()),
+ processId: z.string().min(20, { message: "Process is required" }),
+ workCenterId: zfd.text(z.string().optional()),
description: zfd.text(
z.string().min(0, { message: "Description is required" })
),
- setupHours: zfd.numeric(z.number().min(0)),
- standardFactor: z.enum(standardFactorType, {
- errorMap: () => ({ message: "Standard factor is required" }),
+ setupUnit: z.enum(standardFactorType, {
+ errorMap: () => ({ message: "Setup unit is required" }),
}),
- productionStandard: zfd.numeric(
- z.number().min(0.00000001, {
- message: "Should be greater than 0",
- })
- ),
+ setupTime: zfd.numeric(z.number().min(0)),
+ laborUnit: z.enum(standardFactorType, {
+ errorMap: () => ({ message: "Labor unit is required" }),
+ }),
+ laborTime: zfd.numeric(z.number().min(0)),
+ machineUnit: z.enum(standardFactorType, {
+ errorMap: () => ({ message: "Machine unit is required" }),
+ }),
+ machineTime: zfd.numeric(z.number().min(0)),
});
export const itemCostValidator = z.object({
diff --git a/apps/carbon/app/modules/items/ui/Item/BillOfMaterial.tsx b/apps/carbon/app/modules/items/ui/Item/BillOfMaterial.tsx
index 66899588b0..ca25ac1faa 100644
--- a/apps/carbon/app/modules/items/ui/Item/BillOfMaterial.tsx
+++ b/apps/carbon/app/modules/items/ui/Item/BillOfMaterial.tsx
@@ -535,7 +535,7 @@ function MaterialForm({
<Select
name="methodOperationId"
label="Operation"
- isClearable
+ isOptional
options={methodOperations.map((o) => ({
value: o.id!,
label: o.description,
diff --git a/apps/carbon/app/modules/items/ui/Item/BillOfProcess.tsx b/apps/carbon/app/modules/items/ui/Item/BillOfProcess.tsx
index 2488241d22..afd87e222e 100644
--- a/apps/carbon/app/modules/items/ui/Item/BillOfProcess.tsx
+++ b/apps/carbon/app/modules/items/ui/Item/BillOfProcess.tsx
@@ -26,16 +26,16 @@ import { LuSettings2, LuX } from "react-icons/lu";
import type { z } from "zod";
import { DirectionAwareTabs } from "~/components/DirectionAwareTabs";
import {
- EquipmentType,
Hidden,
InputControlled,
Number,
- NumberControlled,
+ Process,
Select,
StandardFactor,
Submit,
- WorkCellType,
+ WorkCenter,
} from "~/components/Form";
+import UnitHint, { getUnitHint } from "~/components/Form/UnitHint";
import type { Item, SortableItemRenderProps } from "~/components/SortableList";
import { SortableList, SortableListItem } from "~/components/SortableList";
import { usePermissions, useUser } from "~/hooks";
@@ -72,7 +72,7 @@ function makeItem(operation: Operation): ItemWithData {
details: (
<HStack spacing={1}>
<Badge variant="secondary">
- {operation.productionStandard} {operation.standardFactor}
+ {operation.laborTime} {operation.laborUnit}
</Badge>
<Badge variant="secondary">{operation.operationOrder}</Badge>
</HStack>
@@ -83,11 +83,14 @@ function makeItem(operation: Operation): ItemWithData {
const initialMethodOperation: Omit<Operation, "makeMethodId" | "order"> = {
description: "",
- workCellTypeId: "",
- equipmentTypeId: "",
- setupHours: 0,
- productionStandard: 0,
- standardFactor: "Hours/Piece",
+ processId: "",
+ workCenterId: "",
+ setupTime: 0,
+ setupUnit: "Total Minutes",
+ laborTime: 0,
+ laborUnit: "Minutes/Piece",
+ machineTime: 0,
+ machineUnit: "Minutes/Piece",
operationOrder: "After Previous",
methodOperationWorkInstruction: {
content: {},
@@ -514,55 +517,64 @@ function OperationForm({
}
}, [item.id, methodOperationFetcher.data, setItems, setSelectedItemId]);
- const [workCellData, setWorkCellData] = useState<{
- workCellTypeId: string;
+ const [processData, setProcessData] = useState<{
+ processId: string;
description: string;
- standardFactor: string;
+ setupUnitHint: string;
+ setupUnit: string;
+ laborUnitHint: string;
+ laborUnit: string;
+ machineUnitHint: string;
+ machineUnit: string;
}>({
- workCellTypeId: item.data.workCellTypeId ?? "",
+ processId: item.data.processId ?? "",
description: item.data.description ?? "",
- standardFactor: item.data.standardFactor ?? "Hours/Piece",
+ setupUnitHint: getUnitHint(item.data.setupUnit),
+ setupUnit: item.data.setupUnit ?? "Total Minutes",
+ laborUnitHint: getUnitHint(item.data.laborUnit),
+ laborUnit: item.data.laborUnit ?? "Hours/Piece",
+ machineUnitHint: getUnitHint(item.data.machineUnit),
+ machineUnit: item.data.machineUnit ?? "Hours/Piece",
});
- const onWorkCellChange = async (workCellTypeId: string) => {
- if (!supabase || !workCellTypeId) return;
+ const onProcessChange = async (processId: string) => {
+ if (!supabase || !processId) return;
const { data, error } = await supabase
- .from("workCellType")
+ .from("process")
.select("*")
- .eq("id", workCellTypeId)
+ .eq("id", processId)
.single();
if (error) throw new Error(error.message);
- setWorkCellData({
- workCellTypeId,
+ setProcessData((p) => ({
+ ...p,
+ processId,
description: data?.name ?? "",
- standardFactor: data?.defaultStandardFactor ?? "Hours/Piece",
- });
+ laborUnit: data?.defaultStandardFactor ?? "Hours/Piece",
+ laborUnitHint: getUnitHint(data?.defaultStandardFactor),
+ machineUnit: data?.defaultStandardFactor ?? "Hours/Piece",
+ machineUnitHint: getUnitHint(data?.defaultStandardFactor),
+ }));
};
- const [equipmentData, setEquipmentData] = useState<{
- equipmentTypeId: string;
- setupHours: number;
- }>({
- equipmentTypeId: item.data.equipmentTypeId ?? "",
- setupHours: item.data.setupHours ?? 0,
- });
-
- const onEquipmentChange = async (equipmentTypeId: string) => {
- if (!supabase || !equipmentTypeId) return;
+ const onWorkCenterChange = async (workCenterId: string) => {
+ if (!supabase || !workCenterId) return;
const { data, error } = await supabase
- .from("equipmentType")
+ .from("workCenter")
.select("*")
- .eq("id", equipmentTypeId)
+ .eq("id", workCenterId)
.single();
if (error) throw new Error(error.message);
- setEquipmentData({
- equipmentTypeId,
- setupHours: data?.setupHours ?? 0,
- });
+ setProcessData((p) => ({
+ ...p,
+ laborUnit: data?.defaultStandardFactor ?? "Hours/Piece",
+ laborUnitHint: getUnitHint(data?.defaultStandardFactor),
+ machineUnit: data?.defaultStandardFactor ?? "Hours/Piece",
+ machineUnitHint: getUnitHint(data?.defaultStandardFactor),
+ }));
};
return (
@@ -598,18 +610,13 @@ function OperationForm({
<Hidden name="makeMethodId" />
<Hidden name="order" />
<div className="grid w-full gap-x-8 gap-y-4 grid-cols-1 lg:grid-cols-3">
- <WorkCellType
- name="workCellTypeId"
- label="Work Cell"
+ <Process
+ name="processId"
+ label="Process"
onChange={(value) => {
- onWorkCellChange(value?.value as string);
+ onProcessChange(value?.value as string);
}}
/>
- <EquipmentType
- name="equipmentTypeId"
- label="Equipment"
- onChange={(value) => onEquipmentChange(value?.value as string)}
- />
<Select
name="operationOrder"
label="Operation Order"
@@ -619,38 +626,98 @@ function OperationForm({
label: o,
}))}
/>
+ <WorkCenter
+ name="workCenterId"
+ label="Work Center"
+ isOptional
+ onChange={(value) => {
+ if (value) {
+ onWorkCenterChange(value?.value as string);
+ }
+ }}
+ />
</div>
<InputControlled
name="description"
label="Description"
- value={workCellData.description}
+ value={processData.description}
onChange={(newValue) => {
- setWorkCellData((d) => ({ ...d, description: newValue }));
+ setProcessData((d) => ({ ...d, description: newValue }));
}}
/>
<div className="grid w-full gap-x-8 gap-y-4 grid-cols-1 lg:grid-cols-3">
- <NumberControlled
- name="setupHours"
- label="Setup Time (hours)"
- minValue={0}
- value={equipmentData.setupHours}
+ <UnitHint
+ name="setupHint"
+ label="Setup"
+ value={processData.setupUnitHint}
+ onChange={(hint) => {
+ setProcessData((d) => ({
+ ...d,
+ setupUnitHint: hint,
+ setupUnit: hint === "Fixed" ? "Total Minutes" : "Minutes/Piece",
+ }));
+ }}
+ />
+ <Number name="setupTime" label="Setup Time" minValue={0} />
+ <StandardFactor
+ name="setupUnit"
+ label="Setup Unit"
+ hint={processData.setupUnitHint}
+ value={processData.setupUnit}
+ onChange={(newValue) => {
+ setProcessData((d) => ({
+ ...d,
+ setupUnit: newValue?.value ?? "Total Minutes",
+ }));
+ }}
+ />
+ <UnitHint
+ name="laborHint"
+ label="Labor"
+ value={processData.laborUnitHint}
+ onChange={(hint) => {
+ setProcessData((d) => ({
+ ...d,
+ laborUnitHint: hint,
+ laborUnit: hint === "Fixed" ? "Total Minutes" : "Minutes/Piece",
+ }));
+ }}
+ />
+ <Number name="laborTime" label="Labor Time" minValue={0} />
+ <StandardFactor
+ name="laborUnit"
+ label="Labor Unit"
+ hint={processData.laborUnitHint}
+ value={processData.laborUnit}
onChange={(newValue) => {
- setEquipmentData((d) => ({ ...d, setupHours: newValue }));
+ setProcessData((d) => ({
+ ...d,
+ laborUnit: newValue?.value ?? "Hours/Piece",
+ }));
}}
/>
- <Number
- name="productionStandard"
- label="Production Standard"
- minValue={0}
+ <UnitHint
+ name="machineHint"
+ label="Machine"
+ value={processData.machineUnitHint}
+ onChange={(hint) => {
+ setProcessData((d) => ({
+ ...d,
+ machineUnitHint: hint,
+ machineUnit: hint === "Fixed" ? "Total Minutes" : "Minutes/Piece",
+ }));
+ }}
/>
+ <Number name="machineTime" label="Machine Time" minValue={0} />
<StandardFactor
- name="standardFactor"
- label="Standard Factor"
- value={workCellData.standardFactor}
+ name="machineUnit"
+ label="Machine Unit"
+ hint={processData.machineUnitHint}
+ value={processData.machineUnit}
onChange={(newValue) => {
- setWorkCellData((d) => ({
+ setProcessData((d) => ({
...d,
- standardFactor: newValue?.value ?? "Hours/Piece",
+ machineUnit: newValue?.value ?? "Hours/Piece",
}));
}}
/>
diff --git a/apps/carbon/app/modules/resources/resources.models.ts b/apps/carbon/app/modules/resources/resources.models.ts
index a533bbbe8a..82802f2c89 100644
--- a/apps/carbon/app/modules/resources/resources.models.ts
+++ b/apps/carbon/app/modules/resources/resources.models.ts
@@ -67,28 +67,6 @@ export const employeeAbilityValidator = z.object({
trainingDays: zfd.numeric(z.number().optional()),
});
-export const equipmentValidator = z.object({
- id: zfd.text(z.string().optional()),
- name: z.string().min(1, { message: "Name is required" }),
- equipmentId: zfd.text(z.string().optional()),
- description: zfd.text(z.string().optional()),
- equipmentTypeId: z.string().min(1, { message: "Type is required" }),
- operatorsRequired: zfd.numeric(z.number().optional()),
- locationId: z.string().min(1, { message: "Location is required" }),
- workCellId: zfd.text(z.string().optional()),
- setupHours: zfd.numeric(z.number().optional()),
-});
-
-export const equipmentTypeValidator = z.object({
- id: zfd.text(z.string().optional()),
- name: z.string().min(1, { message: "Name is required" }),
- description: z.string(),
- requiredAbility: zfd.text(z.string().optional()),
- setupHours: zfd.numeric(
- z.number().min(0, { message: "Setup hours is required" })
- ),
-});
-
export const locationValidator = z
.object({
id: zfd.text(z.string().optional()),
@@ -129,25 +107,15 @@ export const processValidator = z.object({
}),
});
-export const workCellValidator = z.object({
- id: zfd.text(z.string().optional()),
- name: z.string().min(1, { message: "Name is required" }),
- description: z.string(),
- departmentId: z.string().min(1, { message: "Department is required" }),
- locationId: z.string().min(1, { message: "Location is required" }),
- workCellTypeId: z.string().min(1, { message: "Type is required" }),
- activeDate: zfd.text(z.string().optional()),
-});
-
-export const workCellTypeValidator = z.object({
+export const workCenterValidator = z.object({
id: zfd.text(z.string().optional()),
name: z.string().min(1, { message: "Name is required" }),
description: z.string(),
- requiredAbility: zfd.text(z.string().optional()),
+ requiredAbilityId: zfd.text(z.string().optional()),
quotingRate: zfd.numeric(z.number().min(0)),
laborRate: zfd.numeric(z.number().min(0)),
- overheadRate: zfd.numeric(z.number().min(0)),
defaultStandardFactor: z.enum(standardFactorType, {
errorMap: (issue, ctx) => ({ message: "Standard factor is required" }),
}),
+ processes: z.array(z.string().min(20, { message: "Invalid process" })),
});
diff --git a/apps/carbon/app/modules/resources/resources.service.ts b/apps/carbon/app/modules/resources/resources.service.ts
index f3e58acbb3..a64d9b50b3 100644
--- a/apps/carbon/app/modules/resources/resources.service.ts
+++ b/apps/carbon/app/modules/resources/resources.service.ts
@@ -5,13 +5,10 @@ import type { GenericQueryFilters } from "~/utils/query";
import { setGenericQueryFilters } from "~/utils/query";
import { sanitize } from "~/utils/supabase";
import type {
- equipmentTypeValidator,
- equipmentValidator,
locationValidator,
partnerValidator,
processValidator,
- workCellTypeValidator,
- workCellValidator,
+ workCenterValidator,
} from "./resources.models";
export async function deleteAbility(
@@ -41,26 +38,6 @@ export async function deleteEmployeeAbility(
.eq("id", employeeAbilityId);
}
-export async function deleteEquipment(
- client: SupabaseClient<Database>,
- equipmentId: string
-) {
- return client
- .from("equipment")
- .update({ active: false })
- .eq("id", equipmentId);
-}
-
-export async function deleteEquipmentType(
- client: SupabaseClient<Database>,
- equipmentTypeId: string
-) {
- return client
- .from("equipmentType")
- .update({ active: false })
- .eq("id", equipmentTypeId);
-}
-
export async function deleteLocation(
client: SupabaseClient<Database>,
locationId: string
@@ -90,21 +67,11 @@ export async function deleteShift(
return client.from("shift").update({ active: false }).eq("id", shiftId);
}
-export async function deleteWorkCell(
+export async function deleteWorkCenter(
client: SupabaseClient<Database>,
- workCellId: string
+ id: string
) {
- return client.from("workCell").update({ active: false }).eq("id", workCellId);
-}
-
-export async function deleteWorkCellType(
- client: SupabaseClient<Database>,
- workCellTypeId: string
-) {
- return client
- .from("workCellType")
- .update({ active: false })
- .eq("id", workCellTypeId);
+ return client.from("workCenter").update({ active: false }).eq("id", id);
}
export async function getAbilities(
@@ -224,72 +191,6 @@ export async function getEmployeeAbilities(
.eq("active", true);
}
-export async function getEquipment(
- client: SupabaseClient<Database>,
- equipmentId: string
-) {
- return client
- .from("equipment")
- .select(
- "*, equipmentType(id, name), workCell(id, name), location(id, name)"
- )
- .eq("id", equipmentId)
- .eq("active", true)
- .single();
-}
-
-export async function getEquipmentType(
- client: SupabaseClient<Database>,
- equipmentTypeId: string
-) {
- return client
- .from("equipmentType")
- .select(
- "*, equipment(id, name, equipmentId, description, location(id, name))"
- )
- .eq("active", true)
- .eq("id", equipmentTypeId)
- .single();
-}
-
-export async function getEquipmentTypes(
- client: SupabaseClient<Database>,
- companyId: string,
- args?: { search: string | null } & GenericQueryFilters
-) {
- let query = client
- .from("equipmentType")
- .select("*, equipment(id, name, equipmentId, description)", {
- count: "exact",
- })
- .eq("companyId", companyId)
- .eq("active", true)
- .eq("equipment.active", true);
-
- if (args?.search) {
- query = query.ilike("name", `%${args.search}%`);
- }
-
- if (args) {
- query = setGenericQueryFilters(query, args, [
- { column: "name", ascending: true },
- ]);
- }
-
- return query;
-}
-
-export async function getEquipmentTypesList(
- client: SupabaseClient<Database>,
- companyId: string
-) {
- return client
- .from("equipmentType")
- .select("id, name")
- .eq("companyId", companyId)
- .order("name");
-}
-
export async function getLocation(
client: SupabaseClient<Database>,
locationId: string
@@ -420,63 +321,30 @@ export async function getProcessesList(
.order("name");
}
-export async function getWorkCell(
- client: SupabaseClient<Database>,
- workCellId: string
-) {
- return client
- .from("workCell")
- .select(
- "*, workCellType(id, name), location(id, name), department(id, name)"
- )
- .eq("id", workCellId)
- .eq("active", true)
- .single();
-}
-
-export async function getWorkCellList(
+export async function getWorkCenter(
client: SupabaseClient<Database>,
- locationId: string | null,
- workCellTypeId: string | null
-) {
- let query = client.from("workCell").select(`id, name`).eq("active", true);
-
- if (locationId) {
- query = query.eq("locationId", locationId);
- }
-
- if (workCellTypeId) {
- query = query.eq("workCellTypeId", workCellTypeId);
- }
-
- return query.order("name");
-}
-
-export async function getWorkCellType(
- client: SupabaseClient<Database>,
- workCellTypeId: string
+ id: string
) {
return client
- .from("workCellType")
- .select("*, workCell(id, name, location(id, name), department(id, name))")
+ .from("workCenters")
+ .select("*")
.eq("active", true)
- .eq("id", workCellTypeId)
+ .eq("id", id)
.single();
}
-export async function getWorkCellTypes(
+export async function getWorkCenters(
client: SupabaseClient<Database>,
companyId: string,
args?: { search: string | null } & GenericQueryFilters
) {
let query = client
- .from("workCellType")
- .select("*, workCell(id, name)", {
+ .from("workCenters")
+ .select("*", {
count: "exact",
})
.eq("companyId", companyId)
- .eq("active", true)
- .eq("workCell.active", true);
+ .eq("active", true);
if (args?.search) {
query = query.ilike("name", `%${args.search}%`);
@@ -491,12 +359,12 @@ export async function getWorkCellTypes(
return query;
}
-export async function getWorkCellTypesList(
+export async function getWorkCentersList(
client: SupabaseClient<Database>,
companyId: string
) {
return client
- .from("workCellType")
+ .from("workCenter")
.select("id, name")
.eq("companyId", companyId)
.order("name");
@@ -648,53 +516,6 @@ export async function upsertEmployeeAbility(
.single();
}
-export async function upsertEquipment(
- client: SupabaseClient<Database>,
- equipment:
- | (Omit<z.infer<typeof equipmentValidator>, "id"> & {
- companyId: string;
- createdBy: string;
- customFields?: Json;
- })
- | (Omit<z.infer<typeof equipmentValidator>, "id"> & {
- id: string;
- updatedBy: string;
- customFields?: Json;
- })
-) {
- if ("id" in equipment) {
- const { id, ...update } = equipment;
- return client.from("equipment").update(sanitize(update)).eq("id", id);
- }
-
- return client.from("equipment").insert([equipment]).select("*").single();
-}
-
-export async function upsertEquipmentType(
- client: SupabaseClient<Database>,
- equipmentType:
- | (Omit<z.infer<typeof equipmentTypeValidator>, "id"> & {
- companyId: string;
- createdBy: string;
- customFields?: Json;
- })
- | (Omit<z.infer<typeof equipmentTypeValidator>, "id"> & {
- id: string;
- updatedBy: string;
- customFields?: Json;
- })
-) {
- if ("id" in equipmentType) {
- const { id, ...update } = equipmentType;
- return client.from("equipmentType").update(sanitize(update)).eq("id", id);
- }
- return client
- .from("equipmentType")
- .insert([equipmentType])
- .select("id")
- .single();
-}
-
export async function upsertLocation(
client: SupabaseClient<Database>,
location:
@@ -765,52 +586,80 @@ export async function upsertPartner(
}
}
-export async function upsertWorkCell(
+export async function upsertWorkCenter(
client: SupabaseClient<Database>,
- workCell:
- | (Omit<z.infer<typeof workCellValidator>, "id"> & {
+ workCenter:
+ | (Omit<z.infer<typeof workCenterValidator>, "id"> & {
companyId: string;
createdBy: string;
customFields?: Json;
})
- | (Omit<z.infer<typeof workCellValidator>, "id"> & {
+ | (Omit<z.infer<typeof workCenterValidator>, "id"> & {
id: string;
- updatedBy: string;
- customFields?: Json;
- })
-) {
- if ("createdBy" in workCell) {
- return client.from("workCell").insert([workCell]).select("*").single();
- }
- return client
- .from("workCell")
- .update(sanitize(workCell))
- .eq("id", workCell.id);
-}
-
-export async function upsertWorkCellType(
- client: SupabaseClient<Database>,
- workCellType:
- | (Omit<z.infer<typeof workCellTypeValidator>, "id"> & {
companyId: string;
- createdBy: string;
- customFields?: Json;
- })
- | (Omit<z.infer<typeof workCellTypeValidator>, "id"> & {
- id: string;
updatedBy: string;
customFields?: Json;
})
) {
- if ("createdBy" in workCellType) {
- return client
- .from("workCellType")
- .insert([workCellType])
+ if ("createdBy" in workCenter) {
+ const { processes, ...insert } = workCenter;
+ const workCenterInsert = await client
+ .from("workCenter")
+ .insert([insert])
.select("id")
.single();
+ if (workCenterInsert.error) {
+ return workCenterInsert;
+ }
+ const workCenterId = workCenterInsert.data.id;
+ const workCenterProcesses = processes.map((process) => ({
+ workCenterId,
+ processId: process,
+ companyId: insert.companyId,
+ createdBy: insert.createdBy,
+ }));
+
+ const workCenterProcessInsert = await client
+ .from("workCenterProcess")
+ .insert(workCenterProcesses);
+
+ if (workCenterProcessInsert.error) {
+ return workCenterProcessInsert;
+ }
+
+ return workCenterInsert;
}
- return client
- .from("workCellType")
- .update(sanitize(workCellType))
- .eq("id", workCellType.id);
+ const { processes, ...update } = workCenter;
+ const workCenterUpdate = await client
+ .from("workCenter")
+ .update(sanitize(update))
+ .eq("id", workCenter.id);
+ if (workCenterUpdate.error) {
+ return workCenterUpdate;
+ }
+
+ const deleteProcesses = await client
+ .from("workCenterProcess")
+ .delete()
+ .eq("workCenterId", workCenter.id);
+
+ if (deleteProcesses.error) {
+ return deleteProcesses;
+ }
+
+ const workCenterProcesses = processes.map((process) => ({
+ workCenterId: workCenter.id,
+ processId: process,
+ companyId: update.companyId,
+ createdBy: update.updatedBy,
+ }));
+
+ const workCenterProcessUpdate = await client
+ .from("workCenterProcess")
+ .insert(workCenterProcesses);
+ if (workCenterProcessUpdate.error) {
+ return workCenterProcessUpdate;
+ }
+
+ return workCenterUpdate;
}
diff --git a/apps/carbon/app/modules/resources/types.ts b/apps/carbon/app/modules/resources/types.ts
index 6721c7c06e..06fceb912a 100644
--- a/apps/carbon/app/modules/resources/types.ts
+++ b/apps/carbon/app/modules/resources/types.ts
@@ -3,14 +3,10 @@ import type {
getAbility,
getContractors,
getEmployeeAbilities,
- getEquipment,
- getEquipmentType,
- getEquipmentTypes,
getLocations,
getPartners,
getProcesses,
- getWorkCellType,
- getWorkCellTypes,
+ getWorkCenters,
} from "./resources.service";
export type Ability = NonNullable<
@@ -57,18 +53,6 @@ export type EmployeeAbility = NonNullable<
Awaited<ReturnType<typeof getEmployeeAbilities>>["data"]
>[number];
-export type Equipment = NonNullable<
- Awaited<ReturnType<typeof getEquipment>>["data"]
->;
-
-export type EquipmentType = NonNullable<
- Awaited<ReturnType<typeof getEquipmentTypes>>["data"]
->[number];
-
-export type EquipmentTypeDetailType = NonNullable<
- Awaited<ReturnType<typeof getEquipmentType>>["data"]
->;
-
export type Location = NonNullable<
Awaited<ReturnType<typeof getLocations>>["data"]
>[number];
@@ -85,10 +69,6 @@ export type ShiftLocation = NonNullable<
Awaited<ReturnType<typeof getLocations>>["data"]
>[number];
-export type WorkCellType = NonNullable<
- Awaited<ReturnType<typeof getWorkCellTypes>>["data"]
+export type WorkCenter = NonNullable<
+ Awaited<ReturnType<typeof getWorkCenters>>["data"]
>[number];
-
-export type WorkCellTypeDetailType = NonNullable<
- Awaited<ReturnType<typeof getWorkCellType>>["data"]
->;
diff --git a/apps/carbon/app/modules/resources/ui/Equipment/EquipmentForm.tsx b/apps/carbon/app/modules/resources/ui/Equipment/EquipmentForm.tsx
deleted file mode 100644
index c21d3a0c65..0000000000
--- a/apps/carbon/app/modules/resources/ui/Equipment/EquipmentForm.tsx
+++ /dev/null
@@ -1,209 +0,0 @@
-import {
- Button,
- Drawer,
- DrawerBody,
- DrawerContent,
- DrawerFooter,
- DrawerHeader,
- DrawerTitle,
- FormControl,
- FormErrorMessage,
- FormLabel,
- HStack,
- VStack,
-} from "@carbon/react";
-import {
- ValidatedForm,
- useControlField,
- useField,
-} from "@carbon/remix-validated-form";
-import { useFetcher } from "@remix-run/react";
-import { useEffect, useMemo, useState } from "react";
-import type { z } from "zod";
-import {
- CustomFormFields,
- Hidden,
- Input,
- Location,
- Number,
- Select,
- Submit,
- TextArea,
-} from "~/components/Form";
-import { usePermissions } from "~/hooks";
-import type { getWorkCellList } from "~/modules/resources";
-import { equipmentValidator } from "~/modules/resources";
-import { path } from "~/utils/path";
-
-type EquipmentFormProps = {
- initialValues: z.infer<typeof equipmentValidator>;
- equipmentTypes: {
- id: string;
- name: string;
- }[];
- onClose: () => void;
-};
-
-const EquipmentForm = ({
- initialValues,
- equipmentTypes,
- onClose,
-}: EquipmentFormProps) => {
- const permissions = usePermissions();
-
- const options =
- equipmentTypes?.map((et) => ({
- value: et.id,
- label: et.name,
- })) ?? [];
-
- const isEditing = initialValues.id !== undefined;
- const isDisabled = isEditing
- ? !permissions.can("update", "resources")
- : !permissions.can("create", "resources");
-
- const workCellFetcher =
- useFetcher<Awaited<ReturnType<typeof getWorkCellList>>>();
- const [location, setLocation] = useState<string | null>(
- initialValues.locationId ?? null
- );
-
- const onLocationChange = (location: { value: string } | null) => {
- setLocation((location?.value as string) ?? null);
- };
-
- useEffect(() => {
- if (location) {
- workCellFetcher.load(path.to.api.workCells(location));
- }
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [location]);
-
- const workCells = useMemo(
- () =>
- workCellFetcher.data?.data?.map((cell) => ({
- value: cell.id,
- label: cell.name,
- })) ?? [],
- [workCellFetcher.data]
- );
-
- return (
- <Drawer
- open
- onOpenChange={(open) => {
- if (!open) onClose();
- }}
- >
- <DrawerContent>
- <ValidatedForm
- validator={equipmentValidator}
- method="post"
- action={
- isEditing
- ? path.to.equipmentUnit(initialValues.id!)
- : path.to.newEquipmentUnit
- }
- defaultValues={initialValues}
- className="flex flex-col h-full"
- >
- <DrawerHeader>
- <DrawerTitle>{isEditing ? "Edit" : "New"} Equipment</DrawerTitle>
- </DrawerHeader>
- <DrawerBody>
- <Hidden name="id" />
- <VStack spacing={4}>
- <Input name="name" label="Name" />
- <Input name="equipmentId" label="Equipment ID" />
- <TextArea name="description" label="Description" />
- <Select
- name="equipmentTypeId"
- label="Equipment Type"
- options={options}
- />
- <Location
- name="locationId"
- label="Location"
- onChange={onLocationChange}
- />
- <WorkCellsByLocation
- workCells={workCells}
- initialWorkCell={initialValues.workCellId ?? undefined}
- />
- <Number
- name="setupHours"
- label="Setup Hours"
- minValue={0}
- maxValue={100} // this seems like a reasonable max?
- />
- <Number
- name="operatorsRequired"
- label="Operators Required"
- minValue={0}
- maxValue={100} // this seems like a reasonable max?
- />
- <CustomFormFields table="equipment" />
- </VStack>
- </DrawerBody>
- <DrawerFooter>
- <HStack>
- <Submit isDisabled={isDisabled}>Save</Submit>
- <Button size="md" variant="solid" onClick={onClose}>
- Cancel
- </Button>
- </HStack>
- </DrawerFooter>
- </ValidatedForm>
- </DrawerContent>
- </Drawer>
- );
-};
-
-const WORK_CELL_FIELD = "workCellId";
-
-const WorkCellsByLocation = ({
- workCells,
- initialWorkCell,
-}: {
- workCells: { value: string; label: string }[];
- initialWorkCell?: string;
-}) => {
- const { error } = useField(WORK_CELL_FIELD);
-
- const [workCell, setWorkCell] = useControlField<string | null>(
- WORK_CELL_FIELD
- );
-
- useEffect(() => {
- // if the initial value is in the options, set it, otherwise set to null
- if (workCells) {
- setWorkCell(
- workCells.find((s) => s.value === initialWorkCell)?.value ?? null
- );
- }
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [workCells, initialWorkCell]);
-
- return (
- <FormControl isInvalid={!!error}>
- <FormLabel htmlFor={WORK_CELL_FIELD}>Work Cell</FormLabel>
- <Select
- id={WORK_CELL_FIELD}
- name={WORK_CELL_FIELD}
- options={workCells}
- value={workCell ?? undefined}
- onChange={(newValue) => {
- if (newValue) {
- setWorkCell(newValue.value);
- } else {
- setWorkCell(null);
- }
- }}
- className="w-full"
- />
- {error && <FormErrorMessage>{error}</FormErrorMessage>}
- </FormControl>
- );
-};
-
-export default EquipmentForm;
diff --git a/apps/carbon/app/modules/resources/ui/Equipment/EquipmentTypeDetail.tsx b/apps/carbon/app/modules/resources/ui/Equipment/EquipmentTypeDetail.tsx
deleted file mode 100644
index cda943358c..0000000000
--- a/apps/carbon/app/modules/resources/ui/Equipment/EquipmentTypeDetail.tsx
+++ /dev/null
@@ -1,121 +0,0 @@
-import {
- ActionMenu,
- Button,
- Drawer,
- DrawerBody,
- DrawerContent,
- DrawerFooter,
- DrawerHeader,
- DrawerTitle,
- DropdownMenuIcon,
- DropdownMenuItem,
- Enumerable,
- HStack,
- VStack,
- useDisclosure,
-} from "@carbon/react";
-import { Link } from "@remix-run/react";
-import { useState } from "react";
-import { LuPencil, LuPlus, LuTrash } from "react-icons/lu";
-import { ConfirmDelete } from "~/components/Modals";
-import { useUrlParams } from "~/hooks";
-import type { EquipmentTypeDetailType } from "~/modules/resources";
-import { path } from "~/utils/path";
-
-type Equipment = {
- id: string;
- name: string;
-};
-
-type EquipmentTypeDetailProps = {
- equipmentType: EquipmentTypeDetailType;
- onClose: () => void;
-};
-
-const EquipmentTypeDetail = ({
- equipmentType,
- onClose,
-}: EquipmentTypeDetailProps) => {
- const [params] = useUrlParams();
-
- const deleteModal = useDisclosure();
- const [selectedEquipment, setSelectedEquipment] = useState<
- Equipment | undefined
- >();
-
- const onDelete = (data?: Equipment) => {
- setSelectedEquipment(data);
- deleteModal.onOpen();
- };
-
- const onDeleteCancel = () => {
- setSelectedEquipment(undefined);
- deleteModal.onClose();
- };
-
- return (
- <>
- <Drawer
- open
- onOpenChange={(open) => {
- if (!open) onClose();
- }}
- >
- <DrawerContent>
- <DrawerHeader>
- <DrawerTitle>{equipmentType.name}</DrawerTitle>
- </DrawerHeader>
- <DrawerBody>
- {Array.isArray(equipmentType?.equipment) && (
- <VStack spacing={4}>
- {equipmentType.equipment.map((equipment) => {
- return (
- <HStack key={equipment.id} className="w-full">
- <VStack spacing={1} className="flex-grow">
- <HStack>
- <span className="font-bold">{equipment.name}</span>
- <span className="text-sm text-muted-foreground">
- {equipment.equipmentId ?? null}
- </span>
- </HStack>
- <Enumerable value={equipment?.location?.name ?? null} />
- </VStack>
- <ActionMenu>
- <DropdownMenuItem asChild>
- <Link to={equipment.id}>
- <DropdownMenuIcon icon={<LuPencil />} />
- Edit Unit
- </Link>
- </DropdownMenuItem>
- <DropdownMenuItem onClick={() => onDelete(equipment)}>
- <DropdownMenuIcon icon={<LuTrash />} />
- Delete Unit
- </DropdownMenuItem>
- </ActionMenu>
- </HStack>
- );
- })}
- </VStack>
- )}
- </DrawerBody>
- <DrawerFooter>
- <Button asChild leftIcon={<LuPlus />} size="md">
- <Link to={`new?${params.toString()}`}>New Equipment</Link>
- </Button>
- </DrawerFooter>
- </DrawerContent>
- </Drawer>
- {selectedEquipment && selectedEquipment.id && (
- <ConfirmDelete
- isOpen={deleteModal.isOpen}
- action={path.to.deleteEquipment(selectedEquipment.id)}
- name={selectedEquipment?.name ?? ""}
- text={`Are you sure you want to deactivate ${selectedEquipment?.name}?`}
- onCancel={onDeleteCancel}
- />
- )}
- </>
- );
-};
-
-export default EquipmentTypeDetail;
diff --git a/apps/carbon/app/modules/resources/ui/Equipment/EquipmentTypeForm.tsx b/apps/carbon/app/modules/resources/ui/Equipment/EquipmentTypeForm.tsx
deleted file mode 100644
index 7e0f2d696e..0000000000
--- a/apps/carbon/app/modules/resources/ui/Equipment/EquipmentTypeForm.tsx
+++ /dev/null
@@ -1,122 +0,0 @@
-import {
- Button,
- HStack,
- ModalDrawer,
- ModalDrawerBody,
- ModalDrawerContent,
- ModalDrawerFooter,
- ModalDrawerHeader,
- ModalDrawerProvider,
- ModalDrawerTitle,
- VStack,
- toast,
-} from "@carbon/react";
-import { ValidatedForm } from "@carbon/remix-validated-form";
-import { useFetcher } from "@remix-run/react";
-import type { PostgrestResponse } from "@supabase/supabase-js";
-import { useEffect } from "react";
-import type { z } from "zod";
-import {
- Ability,
- CustomFormFields,
- Hidden,
- Input,
- Number,
- Submit,
- TextArea,
-} from "~/components/Form";
-import { usePermissions } from "~/hooks";
-import { equipmentTypeValidator } from "~/modules/resources";
-import { path } from "~/utils/path";
-
-type EquipmentTypeFormProps = {
- initialValues: z.infer<typeof equipmentTypeValidator>;
- type?: "modal" | "drawer";
- open?: boolean;
- onClose: () => void;
-};
-
-const EquipmentTypeForm = ({
- initialValues,
- open = true,
- type = "drawer",
- onClose,
-}: EquipmentTypeFormProps) => {
- const permissions = usePermissions();
- const fetcher = useFetcher<PostgrestResponse<{ id: string }>>();
-
- useEffect(() => {
- if (type !== "modal") return;
-
- if (fetcher.state === "loading" && fetcher.data?.data) {
- onClose?.();
- toast.success(`Created equipment type`);
- } else if (fetcher.state === "idle" && fetcher.data?.error) {
- toast.error(
- `Failed to create equipment type: ${fetcher.data.error.message}`
- );
- }
- }, [fetcher.data, fetcher.state, onClose, type]);
-
- const isEditing = initialValues.id !== undefined;
- const isDisabled = isEditing
- ? !permissions.can("update", "resources")
- : !permissions.can("create", "resources");
-
- return (
- <ModalDrawerProvider type={type}>
- <ModalDrawer
- open={open}
- onOpenChange={(open) => {
- if (!open) onClose?.();
- }}
- >
- <ModalDrawerContent>
- <ValidatedForm
- validator={equipmentTypeValidator}
- method="post"
- action={
- isEditing
- ? path.to.equipmentType(initialValues.id!)
- : path.to.newEquipmentType
- }
- defaultValues={initialValues}
- fetcher={fetcher}
- className="flex flex-col h-full"
- >
- <ModalDrawerHeader>
- <ModalDrawerTitle>
- {isEditing ? "Edit" : "New"} Equipment Type
- </ModalDrawerTitle>
- </ModalDrawerHeader>
- <ModalDrawerBody>
- <Hidden name="id" />
- <Hidden name="type" value={type} />
- <VStack spacing={4}>
- <Input name="name" label="Name" />
- <TextArea name="description" label="Description" />
- <Ability
- name="requiredAbility"
- label="Required Ability"
- isClearable
- />
- <Number name="setupHours" label="Setup Hours" />
- <CustomFormFields table="equipmentType" />
- </VStack>
- </ModalDrawerBody>
- <ModalDrawerFooter>
- <HStack>
- <Submit isDisabled={isDisabled}>Save</Submit>
- <Button size="md" variant="solid" onClick={() => onClose?.()}>
- Cancel
- </Button>
- </HStack>
- </ModalDrawerFooter>
- </ValidatedForm>
- </ModalDrawerContent>
- </ModalDrawer>
- </ModalDrawerProvider>
- );
-};
-
-export default EquipmentTypeForm;
diff --git a/apps/carbon/app/modules/resources/ui/Equipment/EquipmentTypesTable.tsx b/apps/carbon/app/modules/resources/ui/Equipment/EquipmentTypesTable.tsx
deleted file mode 100644
index d6869bb953..0000000000
--- a/apps/carbon/app/modules/resources/ui/Equipment/EquipmentTypesTable.tsx
+++ /dev/null
@@ -1,173 +0,0 @@
-import {
- Button,
- Enumerable,
- HStack,
- MenuIcon,
- MenuItem,
- useDisclosure,
-} from "@carbon/react";
-import { useNavigate } from "@remix-run/react";
-import type { ColumnDef } from "@tanstack/react-table";
-import { memo, useCallback, useMemo, useState } from "react";
-import { BiAddToQueue } from "react-icons/bi";
-import { BsFillCheckCircleFill, BsListUl } from "react-icons/bs";
-import { LuPencil, LuTrash } from "react-icons/lu";
-import { New, Table } from "~/components";
-import { ConfirmDelete } from "~/components/Modals";
-import { usePermissions, useUrlParams } from "~/hooks";
-import { useCustomColumns } from "~/hooks/useCustomColumns";
-import type { EquipmentType } from "~/modules/resources";
-import { path } from "~/utils/path";
-
-type EquipmentTypesTableProps = {
- data: EquipmentType[];
- count: number;
-};
-
-const EquipmentTypesTable = memo(
- ({ data, count }: EquipmentTypesTableProps) => {
- const navigate = useNavigate();
- const [params] = useUrlParams();
- const permissions = usePermissions();
- const deleteModal = useDisclosure();
- const [selectedType, setSelectedType] = useState<
- EquipmentType | undefined
- >();
-
- const onDelete = (data: EquipmentType) => {
- setSelectedType(data);
- deleteModal.onOpen();
- };
-
- const onDeleteCancel = () => {
- setSelectedType(undefined);
- deleteModal.onClose();
- };
-
- const customColumns = useCustomColumns<EquipmentType>("equipmentType");
- const columns = useMemo<ColumnDef<EquipmentType>[]>(() => {
- const defaultColumns: ColumnDef<EquipmentType>[] = [
- {
- accessorKey: "name",
- header: "Equipment Type",
- cell: ({ row }) => (
- <HStack>
- <Enumerable
- value={row.original.name}
- onClick={() => navigate(row.original.id)}
- className="cursor-pointer"
- />
- {row.original.requiredAbility && (
- <BsFillCheckCircleFill
- className="text-green-500"
- title="Requires ability"
- />
- )}
- </HStack>
- ),
- },
- {
- accessorKey: "description",
- header: "Description",
- cell: ({ row }) => (
- <span className="max-w-[300px] line-clamp-1">
- {row.original.description}
- </span>
- ),
- },
- {
- header: "Equipment",
- cell: ({ row }) => (
- <Button
- variant="secondary"
- onClick={() => {
- navigate(
- `${path.to.equipmentTypeList(
- row.original.id
- )}?${params?.toString()}`
- );
- }}
- >
- {Array.isArray(row.original.equipment)
- ? row.original.equipment?.length ?? 0
- : 0}{" "}
- Units
- </Button>
- ),
- },
- ];
- return [...defaultColumns, ...customColumns];
- }, [navigate, params, customColumns]);
-
- const renderContextMenu = useCallback<(row: EquipmentType) => JSX.Element>(
- (row) => (
- <>
- <MenuItem
- onClick={() => {
- navigate(`${path.to.newEquipment(row.id)}?${params?.toString()}`);
- }}
- >
- <MenuIcon icon={<BiAddToQueue />} />
- New Unit
- </MenuItem>
- <MenuItem
- onClick={() => {
- navigate(
- `${path.to.equipmentTypeList(row.id)}?${params?.toString()}`
- );
- }}
- >
- <MenuIcon icon={<BsListUl />} />
- View Equipment
- </MenuItem>
- <MenuItem
- onClick={() => {
- navigate(path.to.equipmentType(row.id));
- }}
- >
- <MenuIcon icon={<LuPencil />} />
- Edit Equipment Type
- </MenuItem>
- <MenuItem
- disabled={!permissions.can("delete", "users")}
- onClick={() => onDelete(row)}
- >
- <MenuIcon icon={<LuTrash />} />
- Delete Equipment Type
- </MenuItem>
- </>
- ),
- // eslint-disable-next-line react-hooks/exhaustive-deps
- [navigate, params, permissions]
- );
-
- return (
- <>
- <Table<EquipmentType>
- data={data}
- columns={columns}
- count={count ?? 0}
- primaryAction={
- permissions.can("update", "resources") && (
- <New label="Equipment Type" to={`new?${params.toString()}`} />
- )
- }
- renderContextMenu={renderContextMenu}
- />
- {selectedType && selectedType.id && (
- <ConfirmDelete
- action={path.to.deleteEquipmentType(selectedType.id)}
- name={selectedType?.name ?? ""}
- text={`Are you sure you want to deactivate the ${selectedType?.name} equipment type?`}
- isOpen={deleteModal.isOpen}
- onCancel={onDeleteCancel}
- onSubmit={onDeleteCancel}
- />
- )}
- </>
- );
- }
-);
-
-EquipmentTypesTable.displayName = "EquipmentTypesTable";
-export default EquipmentTypesTable;
diff --git a/apps/carbon/app/modules/resources/ui/Equipment/index.ts b/apps/carbon/app/modules/resources/ui/Equipment/index.ts
deleted file mode 100644
index 20bd481dba..0000000000
--- a/apps/carbon/app/modules/resources/ui/Equipment/index.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import EquipmentForm from "./EquipmentForm";
-import EquipmentTypeDetail from "./EquipmentTypeDetail";
-import EquipmentTypeForm from "./EquipmentTypeForm";
-import EquipmentTypesTable from "./EquipmentTypesTable";
-
-export {
- EquipmentForm,
- EquipmentTypeDetail,
- EquipmentTypeForm,
- EquipmentTypesTable,
-};
diff --git a/apps/carbon/app/modules/resources/ui/WorkCells/WorkCellForm.tsx b/apps/carbon/app/modules/resources/ui/WorkCells/WorkCellForm.tsx
deleted file mode 100644
index 91e715a0b2..0000000000
--- a/apps/carbon/app/modules/resources/ui/WorkCells/WorkCellForm.tsx
+++ /dev/null
@@ -1,108 +0,0 @@
-import {
- Button,
- Drawer,
- DrawerBody,
- DrawerContent,
- DrawerFooter,
- DrawerHeader,
- DrawerTitle,
- HStack,
- VStack,
-} from "@carbon/react";
-import { ValidatedForm } from "@carbon/remix-validated-form";
-import type { z } from "zod";
-import {
- CustomFormFields,
- DatePicker,
- Department,
- Hidden,
- Input,
- Location,
- Select,
- Submit,
- TextArea,
-} from "~/components/Form";
-import { usePermissions } from "~/hooks";
-import { workCellValidator } from "~/modules/resources";
-import { path } from "~/utils/path";
-
-type WorkCellFormProps = {
- initialValues: z.infer<typeof workCellValidator>;
- workCellTypes: {
- id: string;
- name: string;
- }[];
- onClose: () => void;
-};
-
-const WorkCellForm = ({
- initialValues,
- workCellTypes,
- onClose,
-}: WorkCellFormProps) => {
- const permissions = usePermissions();
-
- const options =
- workCellTypes?.map((cell) => ({
- value: cell.id,
- label: cell.name,
- })) ?? [];
-
- const isEditing = initialValues.id !== undefined;
- const isDisabled = isEditing
- ? !permissions.can("update", "resources")
- : !permissions.can("create", "resources");
-
- return (
- <Drawer
- open
- onOpenChange={(open) => {
- if (!open) onClose();
- }}
- >
- <DrawerContent>
- <ValidatedForm
- validator={workCellValidator}
- method="post"
- action={
- isEditing
- ? path.to.workCell(initialValues.id!)
- : path.to.newWorkCell
- }
- defaultValues={initialValues}
- className="flex flex-col h-full"
- >
- <DrawerHeader>
- <DrawerTitle>{isEditing ? "Edit" : "New"} Work Cell</DrawerTitle>
- </DrawerHeader>
- <DrawerBody>
- <Hidden name="id" />
- <VStack spacing={4}>
- <Input name="name" label="Name" />
- <TextArea name="description" label="Description" />
- <Select
- name="workCellTypeId"
- label="Work Cell Type"
- options={options}
- />
- <Location name="locationId" label="Location" />
- <Department name="departmentId" label="Department" />
- <DatePicker name="activeDate" label="Active Date" />
- <CustomFormFields table="workCell" />
- </VStack>
- </DrawerBody>
- <DrawerFooter>
- <HStack>
- <Submit isDisabled={isDisabled}>Save</Submit>
- <Button size="md" variant="solid" onClick={onClose}>
- Cancel
- </Button>
- </HStack>
- </DrawerFooter>
- </ValidatedForm>
- </DrawerContent>
- </Drawer>
- );
-};
-
-export default WorkCellForm;
diff --git a/apps/carbon/app/modules/resources/ui/WorkCells/WorkCellTypeDetail.tsx b/apps/carbon/app/modules/resources/ui/WorkCells/WorkCellTypeDetail.tsx
deleted file mode 100644
index e33aaed22a..0000000000
--- a/apps/carbon/app/modules/resources/ui/WorkCells/WorkCellTypeDetail.tsx
+++ /dev/null
@@ -1,125 +0,0 @@
-import {
- ActionMenu,
- Button,
- Drawer,
- DrawerBody,
- DrawerContent,
- DrawerFooter,
- DrawerHeader,
- DrawerTitle,
- DropdownMenuIcon,
- DropdownMenuItem,
- HStack,
- VStack,
- useDisclosure,
-} from "@carbon/react";
-import { Link } from "@remix-run/react";
-import { useState } from "react";
-import { LuPencil, LuTrash } from "react-icons/lu";
-import { ConfirmDelete } from "~/components/Modals";
-import { useUrlParams } from "~/hooks";
-import type { WorkCellTypeDetailType } from "~/modules/resources";
-import type { ListItem } from "~/types";
-import { path } from "~/utils/path";
-
-type WorkCell = NonNullable<WorkCellTypeDetailType["workCell"]>;
-
-type WorkCellTypeDetailProps = {
- workCellType: WorkCellTypeDetailType;
- onClose: () => void;
-};
-
-const WorkCellTypeDetail = ({
- workCellType,
- onClose,
-}: WorkCellTypeDetailProps) => {
- const [params] = useUrlParams();
-
- const deleteModal = useDisclosure();
- const [selectedWorkCell, setSelectedWorkCell] = useState<
- ListItem | undefined
- >();
-
- const onDelete = (data?: WorkCell) => {
- if (!data || Array.isArray(data)) return;
- setSelectedWorkCell(data);
- deleteModal.onOpen();
- };
-
- const onDeleteCancel = () => {
- setSelectedWorkCell(undefined);
- deleteModal.onClose();
- };
-
- return (
- <>
- <Drawer
- open
- onOpenChange={(open) => {
- if (!open) onClose();
- }}
- >
- <DrawerContent>
- <DrawerHeader>
- <DrawerTitle>{workCellType.name}</DrawerTitle>
- </DrawerHeader>
- <DrawerBody>
- {Array.isArray(workCellType?.workCell) && (
- <VStack spacing={4}>
- {workCellType.workCell.map((workCell) => {
- if (
- !workCell ||
- Array.isArray(workCell) ||
- Array.isArray(workCell.location) ||
- Array.isArray(workCell.department)
- )
- return null;
- return (
- <HStack key={workCell.id} className="w-full">
- <VStack spacing={0} className="flex-grow">
- <p className="font-bold">{workCell.name}</p>
- <p className="text-muted-foreground text-sm">
- {workCell.location?.name} /{" "}
- {workCell.department?.name}
- </p>
- </VStack>
- <ActionMenu>
- <DropdownMenuItem asChild>
- <Link to={workCell.id}>
- <DropdownMenuIcon icon={<LuPencil />} />
- Edit Cell
- </Link>
- </DropdownMenuItem>
- {/* @ts-ignore */}
- <DropdownMenuItem onClick={() => onDelete(workCell)}>
- <DropdownMenuIcon icon={<LuTrash />} />
- Delete Cell
- </DropdownMenuItem>
- </ActionMenu>
- </HStack>
- );
- })}
- </VStack>
- )}
- </DrawerBody>
- <DrawerFooter>
- <Button asChild size="md">
- <Link to={`new?${params.toString()}`}>New Work Cell</Link>
- </Button>
- </DrawerFooter>
- </DrawerContent>
- </Drawer>
- {selectedWorkCell && selectedWorkCell.id && (
- <ConfirmDelete
- isOpen={deleteModal.isOpen}
- action={path.to.deleteWorkCell(selectedWorkCell?.id)}
- name={selectedWorkCell?.name ?? ""}
- text={`Are you sure you want to deactivate ${selectedWorkCell?.name}?`}
- onCancel={onDeleteCancel}
- />
- )}
- </>
- );
-};
-
-export default WorkCellTypeDetail;
diff --git a/apps/carbon/app/modules/resources/ui/WorkCells/WorkCellTypesTable.tsx b/apps/carbon/app/modules/resources/ui/WorkCells/WorkCellTypesTable.tsx
deleted file mode 100644
index cedab2ef13..0000000000
--- a/apps/carbon/app/modules/resources/ui/WorkCells/WorkCellTypesTable.tsx
+++ /dev/null
@@ -1,174 +0,0 @@
-import {
- Button,
- Enumerable,
- HStack,
- MenuIcon,
- MenuItem,
- useDisclosure,
-} from "@carbon/react";
-import { useNavigate } from "@remix-run/react";
-import type { ColumnDef } from "@tanstack/react-table";
-import { memo, useCallback, useMemo, useState } from "react";
-import { BiAddToQueue } from "react-icons/bi";
-import { BsFillCheckCircleFill, BsListUl } from "react-icons/bs";
-import { LuPencil, LuTrash } from "react-icons/lu";
-import { New, Table } from "~/components";
-import { ConfirmDelete } from "~/components/Modals";
-import { usePermissions, useUrlParams } from "~/hooks";
-import { useCustomColumns } from "~/hooks/useCustomColumns";
-import type { WorkCellType } from "~/modules/resources";
-import { path } from "~/utils/path";
-
-type WorkCellTypesTableProps = {
- data: WorkCellType[];
- count: number;
-};
-
-const WorkCellTypesTable = memo(({ data, count }: WorkCellTypesTableProps) => {
- const navigate = useNavigate();
- const [params] = useUrlParams();
- const permissions = usePermissions();
- const deleteModal = useDisclosure();
- const [selectedType, setSelectedType] = useState<WorkCellType | undefined>();
-
- const onDelete = (data: WorkCellType) => {
- setSelectedType(data);
- deleteModal.onOpen();
- };
-
- const onDeleteCancel = () => {
- setSelectedType(undefined);
- deleteModal.onClose();
- };
-
- const customColumns = useCustomColumns<WorkCellType>("workCellType");
- const columns = useMemo<ColumnDef<WorkCellType>[]>(() => {
- const defaultColumns: ColumnDef<WorkCellType>[] = [
- {
- accessorKey: "name",
- header: "Work Cell Type",
- cell: ({ row }) => (
- <HStack>
- <Enumerable
- value={row.original.name}
- onClick={() => navigate(row.original.id)}
- className="cursor-pointer"
- />
-
- {row.original.requiredAbility && (
- <BsFillCheckCircleFill
- className="text-green-500"
- title="Requires ability"
- />
- )}
- </HStack>
- ),
- },
- {
- accessorKey: "description",
- header: "Description",
- cell: ({ row }) => (
- <span className="max-w-[300px] line-clamp-1">
- {row.original.description}
- </span>
- ),
- },
- {
- header: "Work Cells",
- cell: ({ row }) => (
- <Button
- variant="secondary"
- onClick={() => {
- navigate(
- `${path.to.workCellTypeList(
- row.original.id
- )}?${params?.toString()}`
- );
- }}
- >
- {Array.isArray(row.original.workCell)
- ? row.original.workCell.length
- : 0}{" "}
- Work Cells
- </Button>
- ),
- },
- ];
- return [...defaultColumns, ...customColumns];
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [params, customColumns]);
-
- const renderContextMenu = useCallback<(row: WorkCellType) => JSX.Element>(
- (row) => (
- <>
- <MenuItem
- onClick={() => {
- navigate(
- `${path.to.newWorkCellUnit(row.id)}?${params?.toString()}`
- );
- }}
- >
- <MenuIcon icon={<BiAddToQueue />} />
- New Unit
- </MenuItem>
- <MenuItem
- onClick={() => {
- navigate(
- `${path.to.workCellTypeList(row.id)}?${params?.toString()}`
- );
- }}
- >
- <MenuIcon icon={<BsListUl />} />
- Edit Work Cells
- </MenuItem>
- <MenuItem
- onClick={() => {
- navigate(`${path.to.workCellType(row.id)}?${params?.toString()}`);
- }}
- >
- <MenuIcon icon={<LuPencil />} />
- Edit Work Cell Type
- </MenuItem>
- <MenuItem
- disabled={!permissions.can("delete", "users")}
- onClick={() => onDelete(row)}
- >
- <MenuIcon icon={<LuTrash />} />
- Delete Work Cell Type
- </MenuItem>
- </>
- ),
- // eslint-disable-next-line react-hooks/exhaustive-deps
- [navigate, params, permissions]
- );
-
- return (
- <>
- <Table<WorkCellType>
- data={data}
- columns={columns}
- count={count ?? 0}
- primaryAction={
- permissions.can("update", "resources") && (
- <New label="Work Cell Type" to={`new?${params.toString()}`} />
- )
- }
- renderContextMenu={renderContextMenu}
- />
-
- {selectedType && selectedType.id && (
- <ConfirmDelete
- action={path.to.deleteWorkCellType(selectedType.id)}
- name={selectedType?.name ?? ""}
- text={`Are you sure you want to deactivate the ${selectedType?.name} work cell type?`}
- isOpen={deleteModal.isOpen}
- onCancel={onDeleteCancel}
- onSubmit={onDeleteCancel}
- />
- )}
- </>
- );
-});
-
-WorkCellTypesTable.displayName = "WorkCellTypesTable";
-export default WorkCellTypesTable;
diff --git a/apps/carbon/app/modules/resources/ui/WorkCells/index.ts b/apps/carbon/app/modules/resources/ui/WorkCells/index.ts
deleted file mode 100644
index eb6814af71..0000000000
--- a/apps/carbon/app/modules/resources/ui/WorkCells/index.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import WorkCellForm from "./WorkCellForm";
-import WorkCellTypeDetail from "./WorkCellTypeDetail";
-import WorkCellTypeForm from "./WorkCellTypeForm";
-import WorkCellTypesTable from "./WorkCellTypesTable";
-
-export {
- WorkCellForm,
- WorkCellTypeDetail,
- WorkCellTypeForm,
- WorkCellTypesTable,
-};
diff --git a/apps/carbon/app/modules/resources/ui/WorkCells/WorkCellTypeForm.tsx b/apps/carbon/app/modules/resources/ui/WorkCenters/WorkCenterForm.tsx
similarity index 84%
rename from apps/carbon/app/modules/resources/ui/WorkCells/WorkCellTypeForm.tsx
rename to apps/carbon/app/modules/resources/ui/WorkCenters/WorkCenterForm.tsx
index 7503ba4b5a..1472016b15 100644
--- a/apps/carbon/app/modules/resources/ui/WorkCells/WorkCellTypeForm.tsx
+++ b/apps/carbon/app/modules/resources/ui/WorkCenters/WorkCenterForm.tsx
@@ -22,27 +22,28 @@ import {
Hidden,
Input,
Number,
+ Processes,
StandardFactor,
Submit,
TextArea,
} from "~/components/Form";
import { usePermissions } from "~/hooks";
-import { workCellTypeValidator } from "~/modules/resources";
+import { workCenterValidator } from "~/modules/resources";
import { path } from "~/utils/path";
-type WorkCellTypeFormProps = {
- initialValues: z.infer<typeof workCellTypeValidator>;
+type WorkCenterFormProps = {
+ initialValues: z.infer<typeof workCenterValidator>;
type?: "modal" | "drawer";
open?: boolean;
onClose: () => void;
};
-const WorkCellTypeForm = ({
+const WorkCenterForm = ({
initialValues,
open = true,
type = "drawer",
onClose,
-}: WorkCellTypeFormProps) => {
+}: WorkCenterFormProps) => {
const permissions = usePermissions();
const fetcher = useFetcher<PostgrestResponse<{ id: string }>>();
@@ -74,12 +75,12 @@ const WorkCellTypeForm = ({
>
<ModalDrawerContent>
<ValidatedForm
- validator={workCellTypeValidator}
+ validator={workCenterValidator}
method="post"
action={
isEditing
- ? path.to.workCellType(initialValues.id!)
- : path.to.newWorkCellType
+ ? path.to.workCenter(initialValues.id!)
+ : path.to.newWorkCenter
}
defaultValues={initialValues}
fetcher={fetcher}
@@ -87,7 +88,7 @@ const WorkCellTypeForm = ({
>
<ModalDrawerHeader>
<ModalDrawerTitle>
- {isEditing ? "Edit" : "New"} Work Cell Type
+ {isEditing ? "Edit" : "New"} Work Center
</ModalDrawerTitle>
</ModalDrawerHeader>
<ModalDrawerBody>
@@ -95,20 +96,22 @@ const WorkCellTypeForm = ({
<Hidden name="type" value={type} />
<VStack spacing={4}>
<Input name="name" label="Name" />
+ <Processes name="processes" label="Processes" />
<TextArea name="description" label="Description" />
- <Ability
- name="requiredAbility"
- label="Required Ability"
- isClearable
- />
+
<Number name="quotingRate" label="Quoting Rate" />
<Number name="laborRate" label="Labor Rate" />
- <Number name="overheadRate" label="Overhead Rate" />
+
<StandardFactor
name="defaultStandardFactor"
- label="Default Standard Factor"
+ label="Default Unit"
value={initialValues.defaultStandardFactor}
/>
+ <Ability
+ name="requiredAbilityId"
+ label="Required Ability"
+ isClearable
+ />
<CustomFormFields table="workCellType" />
</VStack>
</ModalDrawerBody>
@@ -127,4 +130,4 @@ const WorkCellTypeForm = ({
);
};
-export default WorkCellTypeForm;
+export default WorkCenterForm;
diff --git a/apps/carbon/app/modules/resources/ui/WorkCenters/WorkCentersTable.tsx b/apps/carbon/app/modules/resources/ui/WorkCenters/WorkCentersTable.tsx
new file mode 100644
index 0000000000..08e0f2ff4d
--- /dev/null
+++ b/apps/carbon/app/modules/resources/ui/WorkCenters/WorkCentersTable.tsx
@@ -0,0 +1,181 @@
+import {
+ Enumerable,
+ HStack,
+ MenuIcon,
+ MenuItem,
+ useDisclosure,
+} from "@carbon/react";
+import { useNavigate } from "@remix-run/react";
+import type { ColumnDef } from "@tanstack/react-table";
+import { memo, useCallback, useMemo, useState } from "react";
+import { BsFillCheckCircleFill } from "react-icons/bs";
+import { LuPencil, LuTrash } from "react-icons/lu";
+import { EmployeeAvatar, New, Table } from "~/components";
+import { ConfirmDelete } from "~/components/Modals";
+import { usePermissions, useUrlParams } from "~/hooks";
+import { useCustomColumns } from "~/hooks/useCustomColumns";
+import type { WorkCenter } from "~/modules/resources";
+import { usePeople } from "~/stores";
+import { path } from "~/utils/path";
+
+type WorkCentersTableProps = {
+ data: WorkCenter[];
+ count: number;
+};
+
+const WorkCentersTable = memo(({ data, count }: WorkCentersTableProps) => {
+ const navigate = useNavigate();
+ const [params] = useUrlParams();
+ const [people] = usePeople();
+
+ const permissions = usePermissions();
+ const deleteModal = useDisclosure();
+ const [selectedWorkCenter, setSelectedWorkCenter] =
+ useState<WorkCenter | null>(null);
+
+ const onDelete = (data: WorkCenter) => {
+ setSelectedWorkCenter(data);
+ deleteModal.onOpen();
+ };
+
+ const onDeleteCancel = () => {
+ setSelectedWorkCenter(null);
+ deleteModal.onClose();
+ };
+
+ const customColumns = useCustomColumns<WorkCenter>("workCenter");
+ const columns = useMemo<ColumnDef<WorkCenter>[]>(() => {
+ const defaultColumns: ColumnDef<WorkCenter>[] = [
+ {
+ accessorKey: "name",
+ header: "Work Center",
+ cell: ({ row }) => (
+ <HStack>
+ <Enumerable
+ value={row.original.name}
+ onClick={() => navigate(row.original.id!)}
+ className="cursor-pointer"
+ />
+
+ {row.original.requiredAbilityId && (
+ <BsFillCheckCircleFill
+ className="text-green-500"
+ title="Requires ability"
+ />
+ )}
+ </HStack>
+ ),
+ },
+ {
+ id: "processes",
+ header: "Processes",
+ cell: ({ row }) => (
+ <span className="flex gap-2 items-center flex-wrap py-2">
+ {((row.original.processes ?? []) as Array<{ name: string }>).map(
+ (process) => (
+ <Enumerable key={process.name} value={process.name} />
+ )
+ )}
+ </span>
+ ),
+ },
+ {
+ accessorKey: "description",
+ header: "Description",
+ cell: ({ row }) => (
+ <span className="max-w-[300px] line-clamp-1">
+ {row.original.description}
+ </span>
+ ),
+ },
+ {
+ id: "createdBy",
+ header: "Created By",
+ cell: ({ row }) => (
+ <EmployeeAvatar employeeId={row.original.createdBy} />
+ ),
+ meta: {
+ filter: {
+ type: "static",
+ options: people.map((employee) => ({
+ value: employee.id,
+ label: employee.name,
+ })),
+ },
+ },
+ },
+ {
+ id: "updatedBy",
+ header: "Updated By",
+ cell: ({ row }) => (
+ <EmployeeAvatar employeeId={row.original.updatedBy} />
+ ),
+ meta: {
+ filter: {
+ type: "static",
+ options: people.map((employee) => ({
+ value: employee.id,
+ label: employee.name,
+ })),
+ },
+ },
+ },
+ ];
+ return [...defaultColumns, ...customColumns];
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [params, customColumns]);
+
+ const renderContextMenu = useCallback<(row: WorkCenter) => JSX.Element>(
+ (row) => (
+ <>
+ <MenuItem
+ onClick={() => {
+ navigate(`${path.to.workCenter(row.id!)}?${params?.toString()}`);
+ }}
+ >
+ <MenuIcon icon={<LuPencil />} />
+ Edit Work Center
+ </MenuItem>
+ <MenuItem
+ disabled={!permissions.can("delete", "users")}
+ onClick={() => onDelete(row)}
+ >
+ <MenuIcon icon={<LuTrash />} />
+ Delete Work Center
+ </MenuItem>
+ </>
+ ),
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ [navigate, params, permissions]
+ );
+
+ return (
+ <>
+ <Table<WorkCenter>
+ data={data}
+ columns={columns}
+ count={count ?? 0}
+ primaryAction={
+ permissions.can("update", "resources") && (
+ <New label="Work Center" to={`new?${params.toString()}`} />
+ )
+ }
+ renderContextMenu={renderContextMenu}
+ />
+
+ {selectedWorkCenter && selectedWorkCenter.id && (
+ <ConfirmDelete
+ action={path.to.deleteWorkCenter(selectedWorkCenter.id)}
+ name={selectedWorkCenter?.name ?? ""}
+ text={`Are you sure you want to deactivate the ${selectedWorkCenter?.name} work cell type?`}
+ isOpen={deleteModal.isOpen}
+ onCancel={onDeleteCancel}
+ onSubmit={onDeleteCancel}
+ />
+ )}
+ </>
+ );
+});
+
+WorkCentersTable.displayName = "WorkCentersTable";
+export default WorkCentersTable;
diff --git a/apps/carbon/app/modules/resources/ui/WorkCenters/index.ts b/apps/carbon/app/modules/resources/ui/WorkCenters/index.ts
new file mode 100644
index 0000000000..31c152ec03
--- /dev/null
+++ b/apps/carbon/app/modules/resources/ui/WorkCenters/index.ts
@@ -0,0 +1,4 @@
+import WorkCenterForm from "./WorkCenterForm";
+import WorkCentersTable from "./WorkCentersTable";
+
+export { WorkCenterForm, WorkCentersTable };
diff --git a/apps/carbon/app/modules/resources/ui/index.ts b/apps/carbon/app/modules/resources/ui/index.ts
index dbd82d28f3..28734dd751 100644
--- a/apps/carbon/app/modules/resources/ui/index.ts
+++ b/apps/carbon/app/modules/resources/ui/index.ts
@@ -2,9 +2,8 @@ import useResourcesSubmodules from "./useResourcesSubmodules";
export * from "./Abilities";
export * from "./Contractors";
-export * from "./Equipment";
export * from "./Locations";
export * from "./Partners";
export * from "./Processes";
-export * from "./WorkCells";
+export * from "./WorkCenters";
export { useResourcesSubmodules };
diff --git a/apps/carbon/app/modules/resources/ui/useResourcesSubmodules.tsx b/apps/carbon/app/modules/resources/ui/useResourcesSubmodules.tsx
index 828a9a6e9b..7c83b039fa 100644
--- a/apps/carbon/app/modules/resources/ui/useResourcesSubmodules.tsx
+++ b/apps/carbon/app/modules/resources/ui/useResourcesSubmodules.tsx
@@ -1,4 +1,4 @@
-import { LuGroup, LuHammer, LuMapPin, LuShapes } from "react-icons/lu";
+import { LuGroup, LuHammer, LuMapPin } from "react-icons/lu";
import { TbRoute } from "react-icons/tb";
import type { RouteGroup } from "~/types";
import { path } from "~/utils/path";
@@ -7,46 +7,31 @@ const resourcesRoutes: RouteGroup[] = [
{
name: "Manage",
routes: [
- // {
- // name: "Contractors",
- // to: path.to.contractors,
- // icon: <LuHardHat />,
- // },
- // {
- // name: "Partners",
- // to: path.to.partners,
- // icon: <FaPeopleArrows />,
- // },
{
name: "Abilities",
to: path.to.abilities,
icon: <LuHammer />,
},
{
- name: "Work Cells",
- to: path.to.workCells,
+ name: "Work Centers",
+ to: path.to.workCenters,
icon: <LuGroup />,
},
- {
- name: "Equipment",
- to: path.to.equipment,
- icon: <LuShapes />,
- },
],
},
{
name: "Configure",
routes: [
- {
- name: "Processes",
- to: path.to.processes,
- icon: <TbRoute />,
- },
{
name: "Locations",
to: path.to.locations,
icon: <LuMapPin />,
},
+ {
+ name: "Processes",
+ to: path.to.processes,
+ icon: <TbRoute />,
+ },
],
},
];
diff --git a/apps/carbon/app/modules/sales/sales.models.ts b/apps/carbon/app/modules/sales/sales.models.ts
index 72341be86b..a78c018c31 100644
--- a/apps/carbon/app/modules/sales/sales.models.ts
+++ b/apps/carbon/app/modules/sales/sales.models.ts
@@ -254,14 +254,20 @@ export const quoteOperationValidator = z.object({
description: zfd.text(
z.string().min(0, { message: "Description is required" })
),
- setupHours: zfd.numeric(z.number().min(0)),
- standardFactor: z.enum(standardFactorType, {
- errorMap: () => ({ message: "Standard factor is required" }),
+ setupUnit: z.enum(standardFactorType, {
+ errorMap: () => ({ message: "Setup unit is required" }),
}),
- productionStandard: zfd.numeric(z.number().min(0)),
+ setupTime: zfd.numeric(z.number().min(0)),
+ laborUnit: z.enum(standardFactorType, {
+ errorMap: () => ({ message: "Labor unit is required" }),
+ }),
+ laborTime: zfd.numeric(z.number().min(0)),
+ machineUnit: z.enum(standardFactorType, {
+ errorMap: () => ({ message: "Machine unit is required" }),
+ }),
+ machineTime: zfd.numeric(z.number().min(0)),
quotingRate: zfd.numeric(z.number().min(0)),
laborRate: zfd.numeric(z.number().min(0)),
- overheadRate: zfd.numeric(z.number().min(0)),
});
export const quoteFinalizeValidator = z
diff --git a/apps/carbon/app/modules/sales/ui/Quotes/QuoteBillOfProcess.tsx b/apps/carbon/app/modules/sales/ui/Quotes/QuoteBillOfProcess.tsx
index 0b55ca8dc2..7da99ac789 100644
--- a/apps/carbon/app/modules/sales/ui/Quotes/QuoteBillOfProcess.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotes/QuoteBillOfProcess.tsx
@@ -20,7 +20,6 @@ import { flushSync } from "react-dom";
import { LuSettings2, LuX } from "react-icons/lu";
import type { z } from "zod";
import {
- EquipmentType,
Hidden,
InputControlled,
Number,
@@ -28,7 +27,7 @@ import {
Select,
StandardFactor,
Submit,
- WorkCellType,
+ WorkCenter,
} from "~/components/Form";
import type { Item, SortableItemRenderProps } from "~/components/SortableList";
import { SortableList, SortableListItem } from "~/components/SortableList";
@@ -461,22 +460,6 @@ function OperationForm({
setupHours: item.data.setupHours ?? 0,
});
- const onEquipmentChange = async (equipmentTypeId: string) => {
- if (!supabase || !equipmentTypeId) return;
- const { data, error } = await supabase
- .from("equipmentType")
- .select("*")
- .eq("id", equipmentTypeId)
- .single();
-
- if (error) throw new Error(error.message);
-
- setEquipmentData({
- equipmentTypeId,
- setupHours: data?.setupHours ?? 0,
- });
- };
-
return (
<ValidatedForm
action={
@@ -505,7 +488,7 @@ function OperationForm({
<Hidden name="quoteMakeMethodId" />
<Hidden name="order" />
<div className="grid w-full gap-x-8 gap-y-4 grid-cols-1 lg:grid-cols-3">
- <WorkCellType
+ <WorkCenter
name="workCellTypeId"
label="Work Cell"
isReadOnly={isDisabled}
@@ -513,12 +496,6 @@ function OperationForm({
onWorkCellChange(value?.value as string);
}}
/>
- <EquipmentType
- name="equipmentTypeId"
- label="Equipment"
- isReadOnly={isDisabled}
- onChange={(value) => onEquipmentChange(value?.value as string)}
- />
<Select
name="operationOrder"
label="Operation Order"
@@ -540,7 +517,7 @@ function OperationForm({
<div className="grid w-full gap-x-8 gap-y-4 grid-cols-1 lg:grid-cols-3">
<NumberControlled
name="setupHours"
- label="Setup Time (hours)"
+ label="Setup Time"
minValue={0}
value={equipmentData.setupHours}
onChange={(newValue) => {
diff --git a/apps/carbon/app/routes/api+/resources.work-cell-types.tsx b/apps/carbon/app/routes/api+/resources.processes.tsx
similarity index 71%
rename from apps/carbon/app/routes/api+/resources.work-cell-types.tsx
rename to apps/carbon/app/routes/api+/resources.processes.tsx
index ea5cdbfba2..56acbf9415 100644
--- a/apps/carbon/app/routes/api+/resources.work-cell-types.tsx
+++ b/apps/carbon/app/routes/api+/resources.processes.tsx
@@ -1,10 +1,10 @@
import type { LoaderFunctionArgs } from "@remix-run/node";
import { json } from "@remix-run/node";
-import { getWorkCellTypesList } from "~/modules/resources";
+import { getProcessesList } from "~/modules/resources";
import { requirePermissions } from "~/services/auth/auth.server";
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {});
- return json(await getWorkCellTypesList(client, companyId));
+ return json(await getProcessesList(client, companyId));
}
diff --git a/apps/carbon/app/routes/api+/resources.work-cells.ts b/apps/carbon/app/routes/api+/resources.work-cells.ts
deleted file mode 100644
index f8dab1036c..0000000000
--- a/apps/carbon/app/routes/api+/resources.work-cells.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import type { LoaderFunctionArgs } from "@remix-run/node";
-import { json } from "@remix-run/node";
-import { getWorkCellList } from "~/modules/resources";
-import { requirePermissions } from "~/services/auth/auth.server";
-
-export async function loader({ request }: LoaderFunctionArgs) {
- const authorized = await requirePermissions(request, {
- view: "resources",
- });
-
- const url = new URL(request.url);
- const location = url.searchParams.get("location");
- const workCellType = url.searchParams.get("workCellType");
-
- return json(await getWorkCellList(authorized.client, location, workCellType));
-}
diff --git a/apps/carbon/app/routes/api+/resources.equipment-types.ts b/apps/carbon/app/routes/api+/resources.work-centers.tsx
similarity index 71%
rename from apps/carbon/app/routes/api+/resources.equipment-types.ts
rename to apps/carbon/app/routes/api+/resources.work-centers.tsx
index 1d39e0dc97..b2121eb467 100644
--- a/apps/carbon/app/routes/api+/resources.equipment-types.ts
+++ b/apps/carbon/app/routes/api+/resources.work-centers.tsx
@@ -1,10 +1,10 @@
import type { LoaderFunctionArgs } from "@remix-run/node";
import { json } from "@remix-run/node";
-import { getEquipmentTypesList } from "~/modules/resources";
+import { getWorkCentersList } from "~/modules/resources";
import { requirePermissions } from "~/services/auth/auth.server";
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {});
- return json(await getEquipmentTypesList(client, companyId));
+ return json(await getWorkCentersList(client, companyId));
}
diff --git a/apps/carbon/app/routes/x+/resources+/_index.tsx b/apps/carbon/app/routes/x+/resources+/_index.tsx
index 0609d5daef..39cf4e82ba 100644
--- a/apps/carbon/app/routes/x+/resources+/_index.tsx
+++ b/apps/carbon/app/routes/x+/resources+/_index.tsx
@@ -2,5 +2,5 @@ import { redirect } from "@remix-run/node";
import { path } from "~/utils/path";
export async function loader() {
- throw redirect(path.to.workCells);
+ throw redirect(path.to.workCenters);
}
diff --git a/apps/carbon/app/routes/x+/resources+/work-cells.cell.$workCellId.tsx b/apps/carbon/app/routes/x+/resources+/work-cells.cell.$workCellId.tsx
deleted file mode 100644
index 47635b74a1..0000000000
--- a/apps/carbon/app/routes/x+/resources+/work-cells.cell.$workCellId.tsx
+++ /dev/null
@@ -1,57 +0,0 @@
-import { validationError, validator } from "@carbon/remix-validated-form";
-import type { ActionFunctionArgs } from "@remix-run/node";
-import { redirect } from "@remix-run/node";
-import { upsertWorkCell, workCellValidator } from "~/modules/resources";
-import { requirePermissions } from "~/services/auth/auth.server";
-import { flash } from "~/services/session.server";
-import { setCustomFields } from "~/utils/form";
-import { assertIsPost } from "~/utils/http";
-import { path } from "~/utils/path";
-import { error, success } from "~/utils/result";
-
-export async function action({ request, params }: ActionFunctionArgs) {
- assertIsPost(request);
- const { client, userId } = await requirePermissions(request, {
- update: "resources",
- });
-
- const formData = await request.formData();
- const validation = await validator(workCellValidator).validate(formData);
-
- if (validation.error) {
- return validationError(validation.error);
- }
-
- const { workCellId } = params;
- if (!workCellId) {
- throw redirect(
- path.to.workCells,
- await flash(
- request,
- error("No work cell id provided", "Failed to update work cell")
- )
- );
- }
-
- const { id, ...data } = validation.data;
-
- const updateWorkCell = await upsertWorkCell(client, {
- id: workCellId,
- ...data,
- updatedBy: userId,
- customFields: setCustomFields(formData),
- });
- if (updateWorkCell.error)
- redirect(
- path.to.workCells,
- await flash(
- request,
- error(updateWorkCell.error, "Failed to update work cell")
- )
- );
-
- throw redirect(
- path.to.workCellTypeList(validation.data.workCellTypeId),
- await flash(request, success("Successfully updated workCell"))
- );
-}
diff --git a/apps/carbon/app/routes/x+/resources+/work-cells.cell.delete.$workCellId.tsx b/apps/carbon/app/routes/x+/resources+/work-cells.cell.delete.$workCellId.tsx
deleted file mode 100644
index f2af9e63fc..0000000000
--- a/apps/carbon/app/routes/x+/resources+/work-cells.cell.delete.$workCellId.tsx
+++ /dev/null
@@ -1,75 +0,0 @@
-import type { ActionFunctionArgs } from "@remix-run/node";
-import { json, redirect } from "@remix-run/node";
-import { useLoaderData, useNavigate, useParams } from "@remix-run/react";
-import { ConfirmDelete } from "~/components/Modals";
-import { deleteWorkCell, getWorkCell } from "~/modules/resources";
-import { requirePermissions } from "~/services/auth/auth.server";
-import { flash } from "~/services/session.server";
-import { path } from "~/utils/path";
-import { error, success } from "~/utils/result";
-
-export async function loader({ request, params }: ActionFunctionArgs) {
- const { client } = await requirePermissions(request, {
- delete: "resources",
- });
-
- const { workCellId } = params;
- if (!workCellId) throw new Error("No work cell id provided");
-
- const workCell = await getWorkCell(client, workCellId);
- if (workCell.error) {
- throw redirect(
- path.to.workCells,
- await flash(request, error(workCell.error, "Failed to get work cell"))
- );
- }
-
- return json({
- workCell: workCell.data,
- });
-}
-
-export async function action({ request, params }: ActionFunctionArgs) {
- const { client } = await requirePermissions(request, {
- delete: "resources",
- });
-
- const { workCellId } = params;
- if (!workCellId) throw new Error("No work cell id provided");
-
- const deactivateWorkCell = await deleteWorkCell(client, workCellId);
- if (deactivateWorkCell.error) {
- throw redirect(
- path.to.workCells,
- await flash(
- request,
- error(deactivateWorkCell.error, "Failed to delete work cell")
- )
- );
- }
-
- throw redirect(
- path.to.workCells,
- await flash(request, success("Successfully deleted work cell"))
- );
-}
-
-export default function DeleteWorkCellRoute() {
- const { workCell } = useLoaderData<typeof loader>();
- const navigate = useNavigate();
- const { workCellId } = useParams();
-
- if (!workCell) return null;
- if (!workCellId) throw new Error("workCellId not found");
-
- const onCancel = () => navigate(path.to.workCells);
-
- return (
- <ConfirmDelete
- action={path.to.deleteWorkCell(workCellId)}
- name={workCell.name}
- text={`Are you sure you want remove delete ${workCell.name}? This cannot be undone.`}
- onCancel={onCancel}
- />
- );
-}
diff --git a/apps/carbon/app/routes/x+/resources+/work-cells.cell.new.tsx b/apps/carbon/app/routes/x+/resources+/work-cells.cell.new.tsx
deleted file mode 100644
index e37d115894..0000000000
--- a/apps/carbon/app/routes/x+/resources+/work-cells.cell.new.tsx
+++ /dev/null
@@ -1,44 +0,0 @@
-import { validationError, validator } from "@carbon/remix-validated-form";
-import type { ActionFunctionArgs } from "@remix-run/node";
-import { json, redirect } from "@remix-run/node";
-import { upsertWorkCell, workCellValidator } from "~/modules/resources";
-import { requirePermissions } from "~/services/auth/auth.server";
-import { flash } from "~/services/session.server";
-import { setCustomFields } from "~/utils/form";
-import { assertIsPost } from "~/utils/http";
-import { path } from "~/utils/path";
-import { error } from "~/utils/result";
-
-export async function action({ request }: ActionFunctionArgs) {
- assertIsPost(request);
- const { client, companyId, userId } = await requirePermissions(request, {
- create: "resources",
- });
-
- const formData = await request.formData();
- const validation = await validator(workCellValidator).validate(formData);
-
- if (validation.error) {
- return validationError(validation.error);
- }
-
- const { id, ...data } = validation.data;
-
- const insertWorkCell = await upsertWorkCell(client, {
- ...data,
- companyId,
- createdBy: userId,
- customFields: setCustomFields(formData),
- });
- if (insertWorkCell.error) {
- return json(
- {},
- await flash(
- request,
- error(insertWorkCell.error, "Failed to create work cell")
- )
- );
- }
-
- throw redirect(path.to.workCells);
-}
diff --git a/apps/carbon/app/routes/x+/resources+/work-cells.list.$typeId.$workCellId.tsx b/apps/carbon/app/routes/x+/resources+/work-cells.list.$typeId.$workCellId.tsx
deleted file mode 100644
index bc72e6c3e6..0000000000
--- a/apps/carbon/app/routes/x+/resources+/work-cells.list.$typeId.$workCellId.tsx
+++ /dev/null
@@ -1,75 +0,0 @@
-import type { LoaderFunctionArgs } from "@remix-run/node";
-import { json, redirect } from "@remix-run/node";
-import { useLoaderData, useNavigate, useParams } from "@remix-run/react";
-import { useRouteData } from "~/hooks";
-import type { WorkCellType } from "~/modules/resources";
-import { WorkCellForm, getWorkCell } from "~/modules/resources";
-import { requirePermissions } from "~/services/auth/auth.server";
-import { flash } from "~/services/session.server";
-import { getCustomFields } from "~/utils/form";
-import { notFound } from "~/utils/http";
-import { path } from "~/utils/path";
-import { error } from "~/utils/result";
-
-export async function loader({ request, params }: LoaderFunctionArgs) {
- const { client } = await requirePermissions(request, {
- view: "resources",
- role: "employee",
- });
-
- const { typeId, workCellId } = params;
- if (!typeId) throw notFound("typeId not found");
- if (!workCellId) throw notFound("workCellId not found");
-
- const workCell = await getWorkCell(client, workCellId);
- if (workCell.error) {
- throw redirect(
- path.to.workCellTypeList(typeId),
- await flash(request, error(workCell.error, "Failed to fetch work cell"))
- );
- }
-
- return json({
- workCell: workCell.data,
- });
-}
-
-export default function EditWorkCellRoute() {
- const { workCell } = useLoaderData<typeof loader>();
- const { typeId } = useParams();
- if (!typeId) throw new Error("typeId not found");
-
- const navigate = useNavigate();
- const onClose = () => navigate(path.to.workCellTypeList(typeId));
- const workCellRouteData = useRouteData<{
- workCellTypes: WorkCellType[];
- }>(path.to.workCells);
-
- if (
- !workCell ||
- !typeId ||
- Array.isArray(workCell.workCellType) ||
- Array.isArray(workCell.location) ||
- Array.isArray(workCell.department)
- ) {
- return null;
- }
-
- return (
- <WorkCellForm
- key={`${workCell?.id}${typeId}`}
- initialValues={{
- id: workCell?.id,
- name: workCell?.name ?? "",
- description: workCell?.description ?? "",
- workCellTypeId: workCell?.workCellType?.id ?? typeId,
- locationId: workCell?.location?.id ?? "",
- departmentId: workCell?.department?.id ?? "",
- activeDate: workCell?.activeDate ?? "",
- ...getCustomFields(workCell?.customFields),
- }}
- workCellTypes={workCellRouteData?.workCellTypes ?? []}
- onClose={onClose}
- />
- );
-}
diff --git a/apps/carbon/app/routes/x+/resources+/work-cells.list.$typeId.new.tsx b/apps/carbon/app/routes/x+/resources+/work-cells.list.$typeId.new.tsx
deleted file mode 100644
index 69ba1e4d34..0000000000
--- a/apps/carbon/app/routes/x+/resources+/work-cells.list.$typeId.new.tsx
+++ /dev/null
@@ -1,30 +0,0 @@
-import { useNavigate, useParams } from "@remix-run/react";
-import { useRouteData } from "~/hooks";
-import type { WorkCellType } from "~/modules/resources";
-import { WorkCellForm } from "~/modules/resources";
-import { path } from "~/utils/path";
-
-export default function NewWorkCellRoute() {
- const { typeId } = useParams();
- if (!typeId) throw new Error("typeId not found");
-
- const navigate = useNavigate();
- const onClose = () => navigate(-1);
- const workCellRouteData = useRouteData<{
- workCellTypes: WorkCellType[];
- }>(path.to.workCells);
-
- return (
- <WorkCellForm
- initialValues={{
- name: "",
- description: "",
- locationId: "",
- departmentId: "",
- workCellTypeId: typeId,
- }}
- workCellTypes={workCellRouteData?.workCellTypes ?? []}
- onClose={onClose}
- />
- );
-}
diff --git a/apps/carbon/app/routes/x+/resources+/work-cells.list.$typeId.tsx b/apps/carbon/app/routes/x+/resources+/work-cells.list.$typeId.tsx
deleted file mode 100644
index eaf0c7dc93..0000000000
--- a/apps/carbon/app/routes/x+/resources+/work-cells.list.$typeId.tsx
+++ /dev/null
@@ -1,47 +0,0 @@
-import type { LoaderFunctionArgs } from "@remix-run/node";
-import { json, redirect } from "@remix-run/node";
-import { Outlet, useLoaderData, useNavigate } from "@remix-run/react";
-import { useUrlParams } from "~/hooks";
-import { WorkCellTypeDetail, getWorkCellType } from "~/modules/resources";
-import { requirePermissions } from "~/services/auth/auth.server";
-import { flash } from "~/services/session.server";
-import { notFound } from "~/utils/http";
-import { path } from "~/utils/path";
-import { error } from "~/utils/result";
-
-export async function loader({ request, params }: LoaderFunctionArgs) {
- const { client } = await requirePermissions(request, {
- view: "resources",
- role: "employee",
- });
-
- const { typeId } = params;
- if (!typeId) throw notFound("Invalid workCellTypeId");
-
- const workCellType = await getWorkCellType(client, typeId);
- if (workCellType.error) {
- throw redirect(
- path.to.workCells,
- await flash(
- request,
- error(workCellType.error, "Failed to fetch work cell type")
- )
- );
- }
-
- return json({ workCellType: workCellType.data });
-}
-
-export default function WorkCellTypeListRoute() {
- const { workCellType } = useLoaderData<typeof loader>();
- const [params] = useUrlParams();
- const navigate = useNavigate();
- const onClose = () => navigate(`${path.to.workCells}?${params.toString()}`);
-
- return (
- <>
- <WorkCellTypeDetail workCellType={workCellType} onClose={onClose} />
- <Outlet />
- </>
- );
-}
diff --git a/apps/carbon/app/routes/x+/resources+/work-cells.$typeId.tsx b/apps/carbon/app/routes/x+/resources+/work-centers.$id.tsx
similarity index 52%
rename from apps/carbon/app/routes/x+/resources+/work-cells.$typeId.tsx
rename to apps/carbon/app/routes/x+/resources+/work-centers.$id.tsx
index a70924d123..d246933c88 100644
--- a/apps/carbon/app/routes/x+/resources+/work-cells.$typeId.tsx
+++ b/apps/carbon/app/routes/x+/resources+/work-centers.$id.tsx
@@ -3,10 +3,10 @@ import type { ActionFunctionArgs, LoaderFunctionArgs } from "@remix-run/node";
import { json, redirect } from "@remix-run/node";
import { useLoaderData, useNavigate } from "@remix-run/react";
import {
- WorkCellTypeForm,
- getWorkCellType,
- upsertWorkCellType,
- workCellTypeValidator,
+ WorkCenterForm,
+ getWorkCenter,
+ upsertWorkCenter,
+ workCenterValidator,
} from "~/modules/resources";
import { requirePermissions } from "~/services/auth/auth.server";
import { flash } from "~/services/session.server";
@@ -21,31 +21,31 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
role: "employee",
});
- const { typeId } = params;
- if (!typeId) throw notFound("Invalid work cell type id");
+ const { id } = params;
+ if (!id) throw notFound("Invalid work center id");
- const workCellType = await getWorkCellType(client, typeId);
- if (workCellType.error) {
+ const workCenter = await getWorkCenter(client, id);
+ if (workCenter.error) {
throw redirect(
- path.to.workCells,
+ path.to.workCenters,
await flash(
request,
- error(workCellType.error, "Failed to fetch work cell type")
+ error(workCenter.error, "Failed to fetch work center")
)
);
}
- return json({ workCellType: workCellType.data });
+ return json({ workCenter: workCenter.data });
}
export async function action({ request }: ActionFunctionArgs) {
assertIsPost(request);
- const { client, userId } = await requirePermissions(request, {
+ const { client, companyId, userId } = await requirePermissions(request, {
update: "resources",
});
const formData = await request.formData();
- const validation = await validator(workCellTypeValidator).validate(formData);
+ const validation = await validator(workCenterValidator).validate(formData);
if (validation.error) {
return validationError(validation.error);
@@ -54,48 +54,50 @@ export async function action({ request }: ActionFunctionArgs) {
const { id, ...data } = validation.data;
if (!id) throw new Error("ID is was not found");
- const updateCategory = await upsertWorkCellType(client, {
+ const updateCategory = await upsertWorkCenter(client, {
id,
...data,
+ companyId,
updatedBy: userId,
customFields: setCustomFields(formData),
});
if (updateCategory.error) {
throw redirect(
- path.to.workCells,
+ path.to.workCenters,
await flash(
request,
- error(updateCategory.error, "Failed to update work cell type")
+ error(updateCategory.error, "Failed to update work center")
)
);
}
throw redirect(
- path.to.workCells,
- await flash(request, success("Updated work cell type "))
+ path.to.workCenters,
+ await flash(request, success("Updated work center "))
);
}
-export default function EditAttributeCategoryRoute() {
- const { workCellType } = useLoaderData<typeof loader>();
+export default function WorkCenterRoute() {
+ const { workCenter } = useLoaderData<typeof loader>();
const navigate = useNavigate();
- const onClose = () => navigate(path.to.workCells);
+ const onClose = () => navigate(path.to.workCenters);
const initialValues = {
- id: workCellType?.id,
- name: workCellType?.name ?? "",
- description: workCellType?.description ?? "",
- requiredAbility: workCellType?.requiredAbility ?? undefined,
- quotingRate: workCellType?.quotingRate ?? 0,
- laborRate: workCellType?.laborRate ?? 0,
- overheadRate: workCellType?.overheadRate ?? 0,
- defaultStandardFactor:
- workCellType?.defaultStandardFactor ?? "Minutes/Piece",
- ...getCustomFields(workCellType?.customFields),
+ id: workCenter?.id ?? undefined,
+ name: workCenter?.name ?? "",
+ description: workCenter?.description ?? "",
+ requiredAbilityId: workCenter?.requiredAbilityId ?? undefined,
+ quotingRate: workCenter?.quotingRate ?? 0,
+ laborRate: workCenter?.laborRate ?? 0,
+ overheadRate: workCenter?.overheadRate ?? 0,
+ defaultStandardFactor: workCenter?.defaultStandardFactor ?? "Minutes/Piece",
+ // @ts-ignore
+ processes: (workCenter?.processes ?? []).map((p) => p.id) ?? [],
+ ...getCustomFields(workCenter?.customFields),
};
return (
- <WorkCellTypeForm
+ <WorkCenterForm
key={initialValues.id}
onClose={onClose}
initialValues={initialValues}
diff --git a/apps/carbon/app/routes/x+/resources+/work-cells.delete.$typeId.tsx b/apps/carbon/app/routes/x+/resources+/work-centers.delete.$id.tsx
similarity index 66%
rename from apps/carbon/app/routes/x+/resources+/work-cells.delete.$typeId.tsx
rename to apps/carbon/app/routes/x+/resources+/work-centers.delete.$id.tsx
index ad8bb7de6c..6e91d7ae4f 100644
--- a/apps/carbon/app/routes/x+/resources+/work-cells.delete.$typeId.tsx
+++ b/apps/carbon/app/routes/x+/resources+/work-centers.delete.$id.tsx
@@ -1,6 +1,6 @@
import type { LoaderFunctionArgs } from "@remix-run/node";
import { redirect } from "@remix-run/node";
-import { deleteWorkCellType } from "~/modules/resources";
+import { deleteWorkCenter } from "~/modules/resources";
import { requirePermissions } from "~/services/auth/auth.server";
import { flash } from "~/services/session.server";
import { path } from "~/utils/path";
@@ -14,27 +14,24 @@ export async function action({ request, params }: LoaderFunctionArgs) {
const { typeId } = params;
if (!typeId) {
throw redirect(
- path.to.workCells,
- await flash(request, error(params, "Failed to get a work cell type id"))
+ path.to.workCenters,
+ await flash(request, error(params, "Failed to get a work center id"))
);
}
- const deactivateWorkCellType = await deleteWorkCellType(client, typeId);
- if (deactivateWorkCellType.error) {
+ const deactivateWorkCenter = await deleteWorkCenter(client, typeId);
+ if (deactivateWorkCenter.error) {
throw redirect(
- path.to.workCells,
+ path.to.workCenters,
await flash(
request,
- error(
- deactivateWorkCellType.error,
- "Failed to deactivate work cell type"
- )
+ error(deactivateWorkCenter.error, "Failed to deactivate work center")
)
);
}
throw redirect(
- path.to.workCells,
- await flash(request, success("Successfully deactivated work cell type"))
+ path.to.workCenters,
+ await flash(request, success("Successfully deactivated work center"))
);
}
diff --git a/apps/carbon/app/routes/x+/resources+/work-cells.new.tsx b/apps/carbon/app/routes/x+/resources+/work-centers.new.tsx
similarity index 68%
rename from apps/carbon/app/routes/x+/resources+/work-cells.new.tsx
rename to apps/carbon/app/routes/x+/resources+/work-centers.new.tsx
index e8f4ce9037..326d9b7648 100644
--- a/apps/carbon/app/routes/x+/resources+/work-cells.new.tsx
+++ b/apps/carbon/app/routes/x+/resources+/work-centers.new.tsx
@@ -3,9 +3,9 @@ import type { ActionFunctionArgs } from "@remix-run/node";
import { json, redirect } from "@remix-run/node";
import { useNavigate } from "@remix-run/react";
import {
- WorkCellTypeForm,
- upsertWorkCellType,
- workCellTypeValidator,
+ WorkCenterForm,
+ upsertWorkCenter,
+ workCenterValidator,
} from "~/modules/resources";
import { requirePermissions } from "~/services/auth/auth.server";
import { flash } from "~/services/session.server";
@@ -23,7 +23,7 @@ export async function action({ request }: ActionFunctionArgs) {
const formData = await request.formData();
const modal = formData.get("type") === "modal";
- const validation = await validator(workCellTypeValidator).validate(formData);
+ const validation = await validator(workCenterValidator).validate(formData);
if (validation.error) {
return validationError(validation.error);
@@ -31,30 +31,30 @@ export async function action({ request }: ActionFunctionArgs) {
const { id, ...data } = validation.data;
- const createWorkCellType = await upsertWorkCellType(client, {
+ const createWorkCenter = await upsertWorkCenter(client, {
...data,
companyId,
createdBy: userId,
customFields: setCustomFields(formData),
});
- if (createWorkCellType.error) {
+ if (createWorkCenter.error) {
return modal
- ? json(createWorkCellType)
+ ? json(createWorkCenter)
: redirect(
- path.to.workCells,
+ path.to.workCenters,
await flash(
request,
- error(createWorkCellType.error, "Failed to create work cell type")
+ error(createWorkCenter.error, "Failed to create work cell type")
)
);
}
- return modal ? json(createWorkCellType) : redirect(path.to.workCells);
+ return modal ? json(createWorkCenter) : redirect(path.to.workCenters);
}
-export default function NewWorkCellTypeRoute() {
+export default function NewWorkCenterRoute() {
const navigate = useNavigate();
- const onClose = () => navigate(path.to.workCells);
+ const onClose = () => navigate(path.to.workCenters);
const initialValues = {
name: "",
@@ -63,7 +63,8 @@ export default function NewWorkCellTypeRoute() {
laborRate: 0,
overheadRate: 0,
defaultStandardFactor: "Minutes/Piece" as "Minutes/Piece",
+ processes: [],
};
- return <WorkCellTypeForm onClose={onClose} initialValues={initialValues} />;
+ return <WorkCenterForm onClose={onClose} initialValues={initialValues} />;
}
diff --git a/apps/carbon/app/routes/x+/resources+/work-cells.tsx b/apps/carbon/app/routes/x+/resources+/work-centers.tsx
similarity index 68%
rename from apps/carbon/app/routes/x+/resources+/work-cells.tsx
rename to apps/carbon/app/routes/x+/resources+/work-centers.tsx
index c16014b7ea..12d3fe2afc 100644
--- a/apps/carbon/app/routes/x+/resources+/work-cells.tsx
+++ b/apps/carbon/app/routes/x+/resources+/work-centers.tsx
@@ -2,7 +2,7 @@ import { VStack } from "@carbon/react";
import type { LoaderFunctionArgs } from "@remix-run/node";
import { json, redirect } from "@remix-run/node";
import { Outlet, useLoaderData } from "@remix-run/react";
-import { WorkCellTypesTable, getWorkCellTypes } from "~/modules/resources";
+import { WorkCentersTable, getWorkCenters } from "~/modules/resources";
import { requirePermissions } from "~/services/auth/auth.server";
import { flash } from "~/services/session.server";
import type { Handle } from "~/utils/handle";
@@ -11,8 +11,8 @@ import { getGenericQueryFilters } from "~/utils/query";
import { error } from "~/utils/result";
export const handle: Handle = {
- breadcrumb: "Work Cells",
- to: path.to.workCells,
+ breadcrumb: "Work Centers",
+ to: path.to.workCenters,
};
export async function loader({ request }: LoaderFunctionArgs) {
@@ -27,7 +27,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
const { limit, offset, sorts, filters } =
getGenericQueryFilters(searchParams);
- const workCellTypes = await getWorkCellTypes(client, companyId, {
+ const workCenters = await getWorkCenters(client, companyId, {
search,
limit,
offset,
@@ -35,28 +35,29 @@ export async function loader({ request }: LoaderFunctionArgs) {
filters,
});
- if (workCellTypes.error) {
+ if (workCenters.error) {
redirect(
path.to.resources,
await flash(
request,
- error(workCellTypes.error, "Failed to fetch equipment types")
+ error(workCenters.error, "Failed to fetch work centers")
)
);
}
return json({
- count: workCellTypes.count ?? 0,
- workCellTypes: workCellTypes.data ?? [],
+ count: workCenters.count ?? 0,
+ workCenters: workCenters.data ?? [],
});
}
-export default function UserAttributesRoute() {
- const { count, workCellTypes } = useLoaderData<typeof loader>();
+export default function WorkCentersRoute() {
+ const { count, workCenters } = useLoaderData<typeof loader>();
+ console.log({ workCenters });
return (
<VStack spacing={0} className="h-full">
- <WorkCellTypesTable data={workCellTypes} count={count} />
+ <WorkCentersTable data={workCenters} count={count} />
<Outlet />
</VStack>
);
diff --git a/apps/carbon/app/utils/path.ts b/apps/carbon/app/utils/path.ts
index 42db9db592..a55b28e885 100644
--- a/apps/carbon/app/utils/path.ts
+++ b/apps/carbon/app/utils/path.ts
@@ -27,7 +27,6 @@ export const path = {
departments: `${api}/people/departments`,
employeeTypes: `${api}/users/employee-types`,
emptyPermissions: `${api}/users/empty-permissions`,
- equipmentTypes: `${api}/resources/equipment-types`,
groupsByType: (type?: string) =>
generatePath(`${api}/users/groups?type=${type}`),
item: (type: string) => generatePath(`${api}/item/${type}`),
@@ -35,6 +34,7 @@ export const path = {
itemPostingGroups: `${api}/items/groups`,
materialForms: `${api}/items/forms`,
materialSubstances: `${api}/items/substances`,
+ processes: `${api}/resources/processes`,
rollback: (table: string, id: string) =>
generatePath(
`${api}/settings/sequence/rollback?table=${table}&currentSequence=${id}`
@@ -52,9 +52,9 @@ export const path = {
supplierStatuses: `${api}/purchasing/supplier-statuses`,
supplierTypes: `${api}/purchasing/supplier-types`,
unitOfMeasures: `${api}/items/uoms`,
- workCells: (id: string) =>
- generatePath(`${api}/resources/work-cells?location=${id}`),
- workCellTypes: `${api}/resources/work-cell-types`,
+ workCentersByLocation: (id: string) =>
+ generatePath(`${api}/resources/work-centers?location=${id}`),
+ workCenters: `${api}/resources/work-centers`,
},
file: {
cadModel: (urn: string) => generatePath(`${file}/autodesk/${urn}`),
@@ -211,10 +211,6 @@ export const path = {
generatePath(`${x}/resources/ability/${abilityId}/employee/delete/${id}`),
deleteEmployeeType: (id: string) =>
generatePath(`${x}/users/employee-types/delete/${id}`),
- deleteEquipment: (id: string) =>
- generatePath(`${x}/resources/equipment/unit/delete/${id}`),
- deleteEquipmentType: (id: string) =>
- generatePath(`${x}/resources/equipment/delete/${id}`),
deleteGroup: (id: string) => generatePath(`${x}/users/groups/delete/${id}`),
deleteHoliday: (id: string) =>
generatePath(`${x}/people/holidays/delete/${id}`),
@@ -276,10 +272,8 @@ export const path = {
deleteUom: (id: string) => generatePath(`${x}/items/uom/delete/${id}`),
deleteUserAttribute: (id: string) =>
generatePath(`${x}/account/${id}/delete/attribute`),
- deleteWorkCell: (id: string) =>
- generatePath(`${x}/resources/work-cells/cell/delete/${id}`),
- deleteWorkCellType: (id: string) =>
- generatePath(`${x}/resources/work-cells/delete/${id}`),
+ deleteWorkCenter: (id: string) =>
+ generatePath(`${x}/resources/work-centers/delete/${id}`),
department: (id: string) => generatePath(`${x}/people/departments/${id}`),
departments: `${x}/people/departments`,
document: (id: string) => generatePath(`${x}/documents/search/${id}`),
@@ -297,13 +291,6 @@ export const path = {
employeeType: (id: string) =>
generatePath(`${x}/users/employee-types/${id}`),
employeeTypes: `${x}/users/employee-types`,
- equipment: `${x}/resources/equipment`,
- equipmentType: (id: string) =>
- generatePath(`${x}/resources/equipment/${id}`),
- equipmentTypeList: (id: string) =>
- generatePath(`${x}/resources/equipment/list/${id}`),
- equipmentUnit: (id: string) =>
- generatePath(`${x}/resources/equipment/unit/${id}`),
fiscalYears: `${x}/accounting/years`,
fixture: (id: string) => generatePath(`${x}/fixture/${id}`),
fixtures: `${x}/items/fixtures`,
@@ -422,10 +409,6 @@ export const path = {
newEmployeeAbility: (id: string) =>
generatePath(`${x}/resources/ability/${id}/employee/new`),
newEmployeeType: `${x}/users/employee-types/new`,
- newEquipment: (id: string) =>
- generatePath(`${x}/resources/equipment/list/${id}/new`),
- newEquipmentUnit: `${x}/resources/equipment/unit/new`,
- newEquipmentType: `${x}/resources/equipment/new`,
newFixture: `${x}/fixture/new`,
newFixtureSupplier: (id: string) =>
generatePath(`${x}/fixture/${id}/purchasing/new`),
@@ -484,10 +467,7 @@ export const path = {
newToolSupplier: (id: string) =>
generatePath(`${x}/tool/${id}/purchasing/new`),
newUom: `${x}/items/uom/new`,
- newWorkCell: `${x}/resources/work-cells/cell/new`,
- newWorkCellUnit: (id: string) =>
- generatePath(`${x}/resources/work-cells/list/${id}/new`),
- newWorkCellType: `${x}/resources/work-cells/new`,
+ newWorkCenter: `${x}/resources/work-centers/new`,
part: (id: string) => generatePath(`${x}/part/${id}`),
partCosting: (id: string) => generatePath(`${x}/part/${id}/costing`),
partDetails: (id: string) => generatePath(`${x}/part/${id}/details`),
@@ -726,13 +706,9 @@ export const path = {
uoms: `${x}/items/uom`,
userAttribute: (id: string) => generatePath(`${x}/account/${id}/attribute`),
users: `${x}/users`,
- workCell: (id: string) =>
- generatePath(`${x}/resources/work-cells/cell/${id}`),
- workCells: `${x}/resources/work-cells`,
- workCellType: (id: string) =>
- generatePath(`${x}/resources/work-cells/${id}`),
- workCellTypeList: (id: string) =>
- generatePath(`/${x}/resources/work-cells/list/${id}`),
+ workCenters: `${x}/resources/work-centers`,
+ workCenter: (id: string) =>
+ generatePath(`${x}/resources/work-centers/${id}`),
},
} as const;
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index e35eab859e..58b5c52cf4 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -2575,204 +2575,6 @@ export type Database = {
}
Relationships: []
}
- crew: {
- Row: {
- companyId: string
- createdAt: string
- createdBy: string
- crewLeaderId: string | null
- description: string | null
- groupId: string
- id: string
- name: string
- updatedAt: string | null
- updatedBy: string | null
- workCellId: string | null
- }
- Insert: {
- companyId: string
- createdAt?: string
- createdBy: string
- crewLeaderId?: string | null
- description?: string | null
- groupId: string
- id?: string
- name: string
- updatedAt?: string | null
- updatedBy?: string | null
- workCellId?: string | null
- }
- Update: {
- companyId?: string
- createdAt?: string
- createdBy?: string
- crewLeaderId?: string | null
- description?: string | null
- groupId?: string
- id?: string
- name?: string
- updatedAt?: string | null
- updatedBy?: string | null
- workCellId?: string | null
- }
- Relationships: [
- {
- foreignKeyName: "crew_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "crew_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "crew_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "crew_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "crew_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
- {
- foreignKeyName: "crew_crewLeaderId_fkey"
- columns: ["crewLeaderId"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "crew_crewLeaderId_fkey"
- columns: ["crewLeaderId"]
- isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "crew_crewLeaderId_fkey"
- columns: ["crewLeaderId"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "crew_crewLeaderId_fkey"
- columns: ["crewLeaderId"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "crew_crewLeaderId_fkey"
- columns: ["crewLeaderId"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
- {
- foreignKeyName: "crew_groupId_fkey"
- columns: ["groupId"]
- isOneToOne: false
- referencedRelation: "group"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "crew_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "crew_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "crew_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "crew_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "crew_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
- {
- foreignKeyName: "crew_workCellId_fkey"
- columns: ["workCellId"]
- isOneToOne: false
- referencedRelation: "workCell"
- referencedColumns: ["id"]
- },
- ]
- }
- crewAbility: {
- Row: {
- abilityId: string
- active: boolean
- crewId: string
- id: string
- }
- Insert: {
- abilityId: string
- active?: boolean
- crewId: string
- id?: string
- }
- Update: {
- abilityId?: string
- active?: boolean
- crewId?: string
- id?: string
- }
- Relationships: [
- {
- foreignKeyName: "crewAbility_abilityId_fkey"
- columns: ["abilityId"]
- isOneToOne: false
- referencedRelation: "ability"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "crewAbility_crewId_fkey"
- columns: ["crewId"]
- isOneToOne: false
- referencedRelation: "crew"
- referencedColumns: ["id"]
- },
- ]
- }
currency: {
Row: {
active: boolean
@@ -4813,7 +4615,6 @@ export type Database = {
title: string | null
updatedAt: string | null
updatedBy: string | null
- workCellId: string | null
}
Insert: {
companyId: string
@@ -4827,7 +4628,6 @@ export type Database = {
title?: string | null
updatedAt?: string | null
updatedBy?: string | null
- workCellId?: string | null
}
Update: {
companyId?: string
@@ -4841,7 +4641,6 @@ export type Database = {
title?: string | null
updatedAt?: string | null
updatedBy?: string | null
- workCellId?: string | null
}
Relationships: [
{
@@ -5026,13 +4825,6 @@ export type Database = {
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
- {
- foreignKeyName: "employeeJob_workCellId_fkey"
- columns: ["workCellId"]
- isOneToOne: false
- referencedRelation: "workCell"
- referencedColumns: ["id"]
- },
]
}
employeeShift: {
@@ -5200,437 +4992,85 @@ export type Database = {
},
]
}
- equipment: {
+ fiscalYearSettings: {
Row: {
- active: boolean
- activeDate: string | null
companyId: string
- createdAt: string
- createdBy: string
- customFields: Json | null
- description: string | null
- equipmentId: string | null
- equipmentTypeId: string
- id: string
- locationId: string
- name: string
- operatorsRequired: number
- setupHours: number
- updatedAt: string | null
- updatedBy: string | null
- workCellId: string | null
+ startMonth: Database["public"]["Enums"]["month"]
+ taxStartMonth: Database["public"]["Enums"]["month"]
+ updatedBy: string
}
Insert: {
- active?: boolean
- activeDate?: string | null
companyId: string
- createdAt?: string
- createdBy: string
- customFields?: Json | null
- description?: string | null
- equipmentId?: string | null
- equipmentTypeId: string
- id?: string
- locationId: string
- name: string
- operatorsRequired?: number
- setupHours?: number
- updatedAt?: string | null
- updatedBy?: string | null
- workCellId?: string | null
+ startMonth?: Database["public"]["Enums"]["month"]
+ taxStartMonth?: Database["public"]["Enums"]["month"]
+ updatedBy: string
}
Update: {
- active?: boolean
- activeDate?: string | null
companyId?: string
- createdAt?: string
- createdBy?: string
- customFields?: Json | null
- description?: string | null
- equipmentId?: string | null
- equipmentTypeId?: string
- id?: string
- locationId?: string
- name?: string
- operatorsRequired?: number
- setupHours?: number
- updatedAt?: string | null
- updatedBy?: string | null
- workCellId?: string | null
+ startMonth?: Database["public"]["Enums"]["month"]
+ taxStartMonth?: Database["public"]["Enums"]["month"]
+ updatedBy?: string
}
Relationships: [
{
- foreignKeyName: "equipment_companyId_fkey"
+ foreignKeyName: "fiscalYearSettings_companyId_fkey"
columns: ["companyId"]
- isOneToOne: false
+ isOneToOne: true
referencedRelation: "companies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "equipment_companyId_fkey"
+ foreignKeyName: "fiscalYearSettings_companyId_fkey"
columns: ["companyId"]
- isOneToOne: false
+ isOneToOne: true
referencedRelation: "company"
referencedColumns: ["id"]
},
{
- foreignKeyName: "equipment_companyId_fkey"
+ foreignKeyName: "fiscalYearSettings_companyId_fkey"
columns: ["companyId"]
- isOneToOne: false
+ isOneToOne: true
referencedRelation: "customFieldTables"
referencedColumns: ["companyId"]
},
{
- foreignKeyName: "equipment_companyId_fkey"
+ foreignKeyName: "fiscalYearSettings_companyId_fkey"
columns: ["companyId"]
- isOneToOne: false
+ isOneToOne: true
referencedRelation: "integrations"
referencedColumns: ["companyId"]
},
{
- foreignKeyName: "equipment_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "fiscalYearSettings_updatedBy_fkey"
+ columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "equipment_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "fiscalYearSettings_updatedBy_fkey"
+ columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "equipment_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "fiscalYearSettings_updatedBy_fkey"
+ columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "equipment_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "fiscalYearSettings_updatedBy_fkey"
+ columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "equipment_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
- {
- foreignKeyName: "equipment_equipmentTypeId_fkey"
- columns: ["equipmentTypeId"]
- isOneToOne: false
- referencedRelation: "equipmentType"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "equipment_locationId_fkey"
- columns: ["locationId"]
- isOneToOne: false
- referencedRelation: "itemQuantities"
- referencedColumns: ["locationId"]
- },
- {
- foreignKeyName: "equipment_locationId_fkey"
- columns: ["locationId"]
- isOneToOne: false
- referencedRelation: "location"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "equipment_locationId_fkey"
- columns: ["locationId"]
- isOneToOne: false
- referencedRelation: "purchaseOrders"
- referencedColumns: ["locationId"]
- },
- {
- foreignKeyName: "equipment_locationId_fkey"
- columns: ["locationId"]
- isOneToOne: false
- referencedRelation: "salesOrders"
- referencedColumns: ["locationId"]
- },
- {
- foreignKeyName: "equipment_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "equipment_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "equipment_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "equipment_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "equipment_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
- {
- foreignKeyName: "equipment_workCellId_fkey"
- columns: ["workCellId"]
- isOneToOne: false
- referencedRelation: "workCell"
- referencedColumns: ["id"]
- },
- ]
- }
- equipmentType: {
- Row: {
- active: boolean
- companyId: string
- createdAt: string
- createdBy: string
- customFields: Json | null
- description: string | null
- id: string
- name: string
- requiredAbility: string | null
- setupHours: number
- updatedAt: string | null
- updatedBy: string | null
- }
- Insert: {
- active?: boolean
- companyId: string
- createdAt?: string
- createdBy: string
- customFields?: Json | null
- description?: string | null
- id?: string
- name: string
- requiredAbility?: string | null
- setupHours?: number
- updatedAt?: string | null
- updatedBy?: string | null
- }
- Update: {
- active?: boolean
- companyId?: string
- createdAt?: string
- createdBy?: string
- customFields?: Json | null
- description?: string | null
- id?: string
- name?: string
- requiredAbility?: string | null
- setupHours?: number
- updatedAt?: string | null
- updatedBy?: string | null
- }
- Relationships: [
- {
- foreignKeyName: "equipmentType_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "companies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "equipmentType_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "company"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "equipmentType_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "customFieldTables"
- referencedColumns: ["companyId"]
- },
- {
- foreignKeyName: "equipmentType_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "integrations"
- referencedColumns: ["companyId"]
- },
- {
- foreignKeyName: "equipmentType_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "equipmentType_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "equipmentType_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "equipmentType_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "equipmentType_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
- {
- foreignKeyName: "equipmentType_requiredAbility_fkey"
- columns: ["requiredAbility"]
- isOneToOne: false
- referencedRelation: "ability"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "equipmentType_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "equipmentType_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "equipmentType_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "equipmentType_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "equipmentType_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
- ]
- }
- fiscalYearSettings: {
- Row: {
- companyId: string
- startMonth: Database["public"]["Enums"]["month"]
- taxStartMonth: Database["public"]["Enums"]["month"]
- updatedBy: string
- }
- Insert: {
- companyId: string
- startMonth?: Database["public"]["Enums"]["month"]
- taxStartMonth?: Database["public"]["Enums"]["month"]
- updatedBy: string
- }
- Update: {
- companyId?: string
- startMonth?: Database["public"]["Enums"]["month"]
- taxStartMonth?: Database["public"]["Enums"]["month"]
- updatedBy?: string
- }
- Relationships: [
- {
- foreignKeyName: "fiscalYearSettings_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: true
- referencedRelation: "companies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "fiscalYearSettings_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: true
- referencedRelation: "company"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "fiscalYearSettings_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: true
- referencedRelation: "customFieldTables"
- referencedColumns: ["companyId"]
- },
- {
- foreignKeyName: "fiscalYearSettings_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: true
- referencedRelation: "integrations"
- referencedColumns: ["companyId"]
- },
- {
- foreignKeyName: "fiscalYearSettings_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "fiscalYearSettings_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "fiscalYearSettings_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "fiscalYearSettings_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "fiscalYearSettings_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "fiscalYearSettings_updatedBy_fkey"
+ columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
@@ -8462,17 +7902,20 @@ export type Database = {
createdBy: string
customFields: Json | null
description: string
- equipmentTypeId: string | null
id: string
+ laborTime: number
+ laborUnit: Database["public"]["Enums"]["factor"]
+ machineTime: number
+ machineUnit: Database["public"]["Enums"]["factor"]
makeMethodId: string
operationOrder: Database["public"]["Enums"]["methodOperationOrder"]
order: number
- productionStandard: number
- setupHours: number
- standardFactor: Database["public"]["Enums"]["factor"]
+ processId: string
+ setupTime: number
+ setupUnit: Database["public"]["Enums"]["factor"]
updatedAt: string | null
updatedBy: string | null
- workCellTypeId: string
+ workCenterId: string | null
}
Insert: {
companyId: string
@@ -8480,17 +7923,20 @@ export type Database = {
createdBy: string
customFields?: Json | null
description: string
- equipmentTypeId?: string | null
id?: string
+ laborTime?: number
+ laborUnit?: Database["public"]["Enums"]["factor"]
+ machineTime?: number
+ machineUnit?: Database["public"]["Enums"]["factor"]
makeMethodId: string
operationOrder?: Database["public"]["Enums"]["methodOperationOrder"]
order?: number
- productionStandard?: number
- setupHours?: number
- standardFactor?: Database["public"]["Enums"]["factor"]
+ processId: string
+ setupTime?: number
+ setupUnit?: Database["public"]["Enums"]["factor"]
updatedAt?: string | null
updatedBy?: string | null
- workCellTypeId: string
+ workCenterId?: string | null
}
Update: {
companyId?: string
@@ -8498,17 +7944,20 @@ export type Database = {
createdBy?: string
customFields?: Json | null
description?: string
- equipmentTypeId?: string | null
id?: string
+ laborTime?: number
+ laborUnit?: Database["public"]["Enums"]["factor"]
+ machineTime?: number
+ machineUnit?: Database["public"]["Enums"]["factor"]
makeMethodId?: string
operationOrder?: Database["public"]["Enums"]["methodOperationOrder"]
order?: number
- productionStandard?: number
- setupHours?: number
- standardFactor?: Database["public"]["Enums"]["factor"]
+ processId?: string
+ setupTime?: number
+ setupUnit?: Database["public"]["Enums"]["factor"]
updatedAt?: string | null
updatedBy?: string | null
- workCellTypeId?: string
+ workCenterId?: string | null
}
Relationships: [
{
@@ -8574,13 +8023,6 @@ export type Database = {
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
- {
- foreignKeyName: "methodOperation_equipmentTypeId_fkey"
- columns: ["equipmentTypeId"]
- isOneToOne: false
- referencedRelation: "equipmentType"
- referencedColumns: ["id"]
- },
{
foreignKeyName: "methodOperation_methodId_fkey"
columns: ["makeMethodId"]
@@ -8595,6 +8037,13 @@ export type Database = {
referencedRelation: "quoteOperationsWithMakeMethods"
referencedColumns: ["makeMethodId"]
},
+ {
+ foreignKeyName: "methodOperation_processId_fkey"
+ columns: ["processId"]
+ isOneToOne: false
+ referencedRelation: "process"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "methodOperation_updatedBy_fkey"
columns: ["updatedBy"]
@@ -8631,10 +8080,17 @@ export type Database = {
referencedColumns: ["userId"]
},
{
- foreignKeyName: "methodOperation_workCellTypeId_fkey"
- columns: ["workCellTypeId"]
+ foreignKeyName: "methodOperation_workCenterId_fkey"
+ columns: ["workCenterId"]
isOneToOne: false
- referencedRelation: "workCellType"
+ referencedRelation: "workCenter"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "methodOperation_workCenterId_fkey"
+ columns: ["workCenterId"]
+ isOneToOne: false
+ referencedRelation: "workCenters"
referencedColumns: ["id"]
},
]
@@ -13983,22 +13439,25 @@ export type Database = {
createdBy: string
customFields: Json | null
description: string | null
- equipmentTypeId: string | null
id: string
laborRate: number
+ laborTime: number
+ laborUnit: Database["public"]["Enums"]["factor"]
+ machineTime: number
+ machineUnit: Database["public"]["Enums"]["factor"]
operationOrder: Database["public"]["Enums"]["methodOperationOrder"]
order: number
overheadRate: number
- productionStandard: number
+ processId: string
quoteId: string
quoteLineId: string
quoteMakeMethodId: string | null
quotingRate: number
- setupHours: number
- standardFactor: Database["public"]["Enums"]["factor"]
+ setupTime: number
+ setupUnit: Database["public"]["Enums"]["factor"]
updatedAt: string | null
updatedBy: string | null
- workCellTypeId: string
+ workCenterId: string | null
}
Insert: {
companyId: string
@@ -14006,22 +13465,25 @@ export type Database = {
createdBy: string
customFields?: Json | null
description?: string | null
- equipmentTypeId?: string | null
id?: string
laborRate?: number
+ laborTime?: number
+ laborUnit?: Database["public"]["Enums"]["factor"]
+ machineTime?: number
+ machineUnit?: Database["public"]["Enums"]["factor"]
operationOrder?: Database["public"]["Enums"]["methodOperationOrder"]
order?: number
overheadRate?: number
- productionStandard?: number
+ processId: string
quoteId: string
quoteLineId: string
quoteMakeMethodId?: string | null
quotingRate?: number
- setupHours?: number
- standardFactor?: Database["public"]["Enums"]["factor"]
+ setupTime?: number
+ setupUnit?: Database["public"]["Enums"]["factor"]
updatedAt?: string | null
updatedBy?: string | null
- workCellTypeId: string
+ workCenterId?: string | null
}
Update: {
companyId?: string
@@ -14029,22 +13491,25 @@ export type Database = {
createdBy?: string
customFields?: Json | null
description?: string | null
- equipmentTypeId?: string | null
id?: string
laborRate?: number
+ laborTime?: number
+ laborUnit?: Database["public"]["Enums"]["factor"]
+ machineTime?: number
+ machineUnit?: Database["public"]["Enums"]["factor"]
operationOrder?: Database["public"]["Enums"]["methodOperationOrder"]
order?: number
overheadRate?: number
- productionStandard?: number
+ processId?: string
quoteId?: string
quoteLineId?: string
quoteMakeMethodId?: string | null
quotingRate?: number
- setupHours?: number
- standardFactor?: Database["public"]["Enums"]["factor"]
+ setupTime?: number
+ setupUnit?: Database["public"]["Enums"]["factor"]
updatedAt?: string | null
updatedBy?: string | null
- workCellTypeId?: string
+ workCenterId?: string | null
}
Relationships: [
{
@@ -14111,10 +13576,10 @@ export type Database = {
referencedColumns: ["userId"]
},
{
- foreignKeyName: "quoteOperation_equipmentTypeId_fkey"
- columns: ["equipmentTypeId"]
+ foreignKeyName: "quoteOperation_processId_fkey"
+ columns: ["processId"]
isOneToOne: false
- referencedRelation: "equipmentType"
+ referencedRelation: "process"
referencedColumns: ["id"]
},
{
@@ -14202,10 +13667,17 @@ export type Database = {
referencedColumns: ["userId"]
},
{
- foreignKeyName: "quoteOperation_workCellTypeId_fkey"
- columns: ["workCellTypeId"]
+ foreignKeyName: "quoteOperation_workCenterId_fkey"
+ columns: ["workCenterId"]
+ isOneToOne: false
+ referencedRelation: "workCenter"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteOperation_workCenterId_fkey"
+ columns: ["workCenterId"]
isOneToOne: false
- referencedRelation: "workCellType"
+ referencedRelation: "workCenters"
referencedColumns: ["id"]
},
]
@@ -19622,402 +19094,28 @@ export type Database = {
referencedColumns: ["id"]
},
{
- foreignKeyName: "userToCompany_userId_fkey"
- columns: ["userId"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
- ]
- }
- warehouse: {
- Row: {
- active: boolean
- companyId: string
- createdAt: string
- createdBy: string
- id: string
- locationId: string
- name: string
- requiresBin: boolean
- requiresPick: boolean
- requiresPutAway: boolean
- requiresReceive: boolean
- requiresShipment: boolean
- updatedAt: string | null
- updatedBy: string | null
- }
- Insert: {
- active?: boolean
- companyId: string
- createdAt?: string
- createdBy: string
- id?: string
- locationId: string
- name: string
- requiresBin?: boolean
- requiresPick?: boolean
- requiresPutAway?: boolean
- requiresReceive?: boolean
- requiresShipment?: boolean
- updatedAt?: string | null
- updatedBy?: string | null
- }
- Update: {
- active?: boolean
- companyId?: string
- createdAt?: string
- createdBy?: string
- id?: string
- locationId?: string
- name?: string
- requiresBin?: boolean
- requiresPick?: boolean
- requiresPutAway?: boolean
- requiresReceive?: boolean
- requiresShipment?: boolean
- updatedAt?: string | null
- updatedBy?: string | null
- }
- Relationships: [
- {
- foreignKeyName: "warehouse_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "companies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "warehouse_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "company"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "warehouse_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "customFieldTables"
- referencedColumns: ["companyId"]
- },
- {
- foreignKeyName: "warehouse_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "integrations"
- referencedColumns: ["companyId"]
- },
- {
- foreignKeyName: "warehouse_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "warehouse_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "warehouse_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "warehouse_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "warehouse_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
- {
- foreignKeyName: "warehouse_locationId_fkey"
- columns: ["locationId"]
- isOneToOne: false
- referencedRelation: "itemQuantities"
- referencedColumns: ["locationId"]
- },
- {
- foreignKeyName: "warehouse_locationId_fkey"
- columns: ["locationId"]
- isOneToOne: false
- referencedRelation: "location"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "warehouse_locationId_fkey"
- columns: ["locationId"]
- isOneToOne: false
- referencedRelation: "purchaseOrders"
- referencedColumns: ["locationId"]
- },
- {
- foreignKeyName: "warehouse_locationId_fkey"
- columns: ["locationId"]
- isOneToOne: false
- referencedRelation: "salesOrders"
- referencedColumns: ["locationId"]
- },
- {
- foreignKeyName: "warehouse_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "warehouse_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "warehouse_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "warehouse_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "warehouse_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
- ]
- }
- workCell: {
- Row: {
- active: boolean
- activeDate: string | null
- companyId: string
- createdAt: string
- createdBy: string
- customFields: Json | null
- defaultStandardFactor: Database["public"]["Enums"]["factor"]
- departmentId: string
- description: string | null
- id: string
- locationId: string | null
- name: string
- updatedAt: string | null
- updatedBy: string | null
- workCellTypeId: string
- }
- Insert: {
- active?: boolean
- activeDate?: string | null
- companyId: string
- createdAt?: string
- createdBy: string
- customFields?: Json | null
- defaultStandardFactor?: Database["public"]["Enums"]["factor"]
- departmentId: string
- description?: string | null
- id?: string
- locationId?: string | null
- name: string
- updatedAt?: string | null
- updatedBy?: string | null
- workCellTypeId: string
- }
- Update: {
- active?: boolean
- activeDate?: string | null
- companyId?: string
- createdAt?: string
- createdBy?: string
- customFields?: Json | null
- defaultStandardFactor?: Database["public"]["Enums"]["factor"]
- departmentId?: string
- description?: string | null
- id?: string
- locationId?: string | null
- name?: string
- updatedAt?: string | null
- updatedBy?: string | null
- workCellTypeId?: string
- }
- Relationships: [
- {
- foreignKeyName: "workCell_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "companies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "workCell_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "company"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "workCell_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "customFieldTables"
- referencedColumns: ["companyId"]
- },
- {
- foreignKeyName: "workCell_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "integrations"
- referencedColumns: ["companyId"]
- },
- {
- foreignKeyName: "workCell_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "workCell_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "workCell_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "workCell_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "workCell_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
- {
- foreignKeyName: "workCell_departmentId_fkey"
- columns: ["departmentId"]
- isOneToOne: false
- referencedRelation: "department"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "workCell_locationId_fkey"
- columns: ["locationId"]
- isOneToOne: false
- referencedRelation: "itemQuantities"
- referencedColumns: ["locationId"]
- },
- {
- foreignKeyName: "workCell_locationId_fkey"
- columns: ["locationId"]
- isOneToOne: false
- referencedRelation: "location"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "workCell_locationId_fkey"
- columns: ["locationId"]
- isOneToOne: false
- referencedRelation: "purchaseOrders"
- referencedColumns: ["locationId"]
- },
- {
- foreignKeyName: "workCell_locationId_fkey"
- columns: ["locationId"]
- isOneToOne: false
- referencedRelation: "salesOrders"
- referencedColumns: ["locationId"]
- },
- {
- foreignKeyName: "workCell_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "workCell_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "workCell_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "workCell_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "workCell_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "userToCompany_userId_fkey"
+ columns: ["userId"]
isOneToOne: false
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
- {
- foreignKeyName: "workCell_workCellTypeId_fkey"
- columns: ["workCellTypeId"]
- isOneToOne: false
- referencedRelation: "workCellType"
- referencedColumns: ["id"]
- },
]
}
- workCellType: {
+ warehouse: {
Row: {
active: boolean
companyId: string
createdAt: string
createdBy: string
- customFields: Json | null
- defaultStandardFactor: Database["public"]["Enums"]["factor"]
- description: string | null
id: string
- laborRate: number
+ locationId: string
name: string
- overheadRate: number
- quotingRate: number
- requiredAbility: string | null
+ requiresBin: boolean
+ requiresPick: boolean
+ requiresPutAway: boolean
+ requiresReceive: boolean
+ requiresShipment: boolean
updatedAt: string | null
updatedBy: string | null
}
@@ -20026,15 +19124,14 @@ export type Database = {
companyId: string
createdAt?: string
createdBy: string
- customFields?: Json | null
- defaultStandardFactor?: Database["public"]["Enums"]["factor"]
- description?: string | null
id?: string
- laborRate?: number
+ locationId: string
name: string
- overheadRate?: number
- quotingRate?: number
- requiredAbility?: string | null
+ requiresBin?: boolean
+ requiresPick?: boolean
+ requiresPutAway?: boolean
+ requiresReceive?: boolean
+ requiresShipment?: boolean
updatedAt?: string | null
updatedBy?: string | null
}
@@ -20043,119 +19140,139 @@ export type Database = {
companyId?: string
createdAt?: string
createdBy?: string
- customFields?: Json | null
- defaultStandardFactor?: Database["public"]["Enums"]["factor"]
- description?: string | null
id?: string
- laborRate?: number
+ locationId?: string
name?: string
- overheadRate?: number
- quotingRate?: number
- requiredAbility?: string | null
+ requiresBin?: boolean
+ requiresPick?: boolean
+ requiresPutAway?: boolean
+ requiresReceive?: boolean
+ requiresShipment?: boolean
updatedAt?: string | null
updatedBy?: string | null
}
Relationships: [
{
- foreignKeyName: "workCellType_companyId_fkey"
+ foreignKeyName: "warehouse_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "companies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "workCellType_companyId_fkey"
+ foreignKeyName: "warehouse_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "company"
referencedColumns: ["id"]
},
{
- foreignKeyName: "workCellType_companyId_fkey"
+ foreignKeyName: "warehouse_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "customFieldTables"
referencedColumns: ["companyId"]
},
{
- foreignKeyName: "workCellType_companyId_fkey"
+ foreignKeyName: "warehouse_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "integrations"
referencedColumns: ["companyId"]
},
{
- foreignKeyName: "workCellType_createdBy_fkey"
+ foreignKeyName: "warehouse_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "workCellType_createdBy_fkey"
+ foreignKeyName: "warehouse_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "workCellType_createdBy_fkey"
+ foreignKeyName: "warehouse_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "workCellType_createdBy_fkey"
+ foreignKeyName: "warehouse_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "workCellType_createdBy_fkey"
+ foreignKeyName: "warehouse_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
{
- foreignKeyName: "workCellType_requiredAbility_fkey"
- columns: ["requiredAbility"]
+ foreignKeyName: "warehouse_locationId_fkey"
+ columns: ["locationId"]
isOneToOne: false
- referencedRelation: "ability"
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["locationId"]
+ },
+ {
+ foreignKeyName: "warehouse_locationId_fkey"
+ columns: ["locationId"]
+ isOneToOne: false
+ referencedRelation: "location"
referencedColumns: ["id"]
},
{
- foreignKeyName: "workCellType_updatedBy_fkey"
+ foreignKeyName: "warehouse_locationId_fkey"
+ columns: ["locationId"]
+ isOneToOne: false
+ referencedRelation: "purchaseOrders"
+ referencedColumns: ["locationId"]
+ },
+ {
+ foreignKeyName: "warehouse_locationId_fkey"
+ columns: ["locationId"]
+ isOneToOne: false
+ referencedRelation: "salesOrders"
+ referencedColumns: ["locationId"]
+ },
+ {
+ foreignKeyName: "warehouse_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "workCellType_updatedBy_fkey"
+ foreignKeyName: "warehouse_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "workCellType_updatedBy_fkey"
+ foreignKeyName: "warehouse_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "workCellType_updatedBy_fkey"
+ foreignKeyName: "warehouse_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "workCellType_updatedBy_fkey"
+ foreignKeyName: "warehouse_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "userDefaults"
@@ -20165,6 +19282,7 @@ export type Database = {
}
workCenter: {
Row: {
+ active: boolean
companyId: string
createdAt: string
createdBy: string
@@ -20177,10 +19295,12 @@ export type Database = {
name: string
overheadRate: number | null
quotingRate: number
+ requiredAbilityId: string | null
updatedAt: string | null
updatedBy: string | null
}
Insert: {
+ active?: boolean
companyId: string
createdAt?: string
createdBy: string
@@ -20193,10 +19313,12 @@ export type Database = {
name: string
overheadRate?: number | null
quotingRate?: number
+ requiredAbilityId?: string | null
updatedAt?: string | null
updatedBy?: string | null
}
Update: {
+ active?: boolean
companyId?: string
createdAt?: string
createdBy?: string
@@ -20209,6 +19331,7 @@ export type Database = {
name?: string
overheadRate?: number | null
quotingRate?: number
+ requiredAbilityId?: string | null
updatedAt?: string | null
updatedBy?: string | null
}
@@ -20304,6 +19427,13 @@ export type Database = {
referencedRelation: "salesOrders"
referencedColumns: ["locationId"]
},
+ {
+ foreignKeyName: "workCenter_requiredAbilityId_fkey"
+ columns: ["requiredAbilityId"]
+ isOneToOne: false
+ referencedRelation: "ability"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "workCenter_updatedBy_fkey"
columns: ["updatedBy"]
@@ -20482,6 +19612,13 @@ export type Database = {
referencedRelation: "workCenter"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "workCenterProcess_workCenterId_fkey"
+ columns: ["workCenterId"]
+ isOneToOne: false
+ referencedRelation: "workCenters"
+ referencedColumns: ["id"]
+ },
]
}
}
@@ -23969,25 +23106,28 @@ export type Database = {
createdBy: string | null
customFields: Json | null
description: string | null
- equipmentTypeId: string | null
id: string | null
laborRate: number | null
+ laborTime: number | null
+ laborUnit: Database["public"]["Enums"]["factor"] | null
+ machineTime: number | null
+ machineUnit: Database["public"]["Enums"]["factor"] | null
makeMethodId: string | null
operationOrder:
| Database["public"]["Enums"]["methodOperationOrder"]
| null
order: number | null
overheadRate: number | null
- productionStandard: number | null
+ processId: string | null
quoteId: string | null
quoteLineId: string | null
quoteMakeMethodId: string | null
quotingRate: number | null
- setupHours: number | null
- standardFactor: Database["public"]["Enums"]["factor"] | null
+ setupTime: number | null
+ setupUnit: Database["public"]["Enums"]["factor"] | null
updatedAt: string | null
updatedBy: string | null
- workCellTypeId: string | null
+ workCenterId: string | null
}
Relationships: [
{
@@ -24054,10 +23194,10 @@ export type Database = {
referencedColumns: ["userId"]
},
{
- foreignKeyName: "quoteOperation_equipmentTypeId_fkey"
- columns: ["equipmentTypeId"]
+ foreignKeyName: "quoteOperation_processId_fkey"
+ columns: ["processId"]
isOneToOne: false
- referencedRelation: "equipmentType"
+ referencedRelation: "process"
referencedColumns: ["id"]
},
{
@@ -24145,10 +23285,17 @@ export type Database = {
referencedColumns: ["userId"]
},
{
- foreignKeyName: "quoteOperation_workCellTypeId_fkey"
- columns: ["workCellTypeId"]
+ foreignKeyName: "quoteOperation_workCenterId_fkey"
+ columns: ["workCenterId"]
+ isOneToOne: false
+ referencedRelation: "workCenter"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteOperation_workCenterId_fkey"
+ columns: ["workCenterId"]
isOneToOne: false
- referencedRelation: "workCellType"
+ referencedRelation: "workCenters"
referencedColumns: ["id"]
},
]
@@ -26486,6 +25633,162 @@ export type Database = {
},
]
}
+ workCenters: {
+ Row: {
+ active: boolean | null
+ companyId: string | null
+ createdAt: string | null
+ createdBy: string | null
+ customFields: Json | null
+ defaultStandardFactor: Database["public"]["Enums"]["factor"] | null
+ description: string | null
+ id: string | null
+ laborRate: number | null
+ locationId: string | null
+ name: string | null
+ overheadRate: number | null
+ processes: Json | null
+ quotingRate: number | null
+ requiredAbilityId: string | null
+ updatedAt: string | null
+ updatedBy: string | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "workCenter_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "workCenter_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "workCenter_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "workCenter_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "workCenter_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "workCenter_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "workCenter_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "workCenter_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "workCenter_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "workCenter_locationId_fkey"
+ columns: ["locationId"]
+ isOneToOne: false
+ referencedRelation: "location"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "workCenter_locationId_fkey"
+ columns: ["locationId"]
+ isOneToOne: false
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["locationId"]
+ },
+ {
+ foreignKeyName: "workCenter_locationId_fkey"
+ columns: ["locationId"]
+ isOneToOne: false
+ referencedRelation: "purchaseOrders"
+ referencedColumns: ["locationId"]
+ },
+ {
+ foreignKeyName: "workCenter_locationId_fkey"
+ columns: ["locationId"]
+ isOneToOne: false
+ referencedRelation: "salesOrders"
+ referencedColumns: ["locationId"]
+ },
+ {
+ foreignKeyName: "workCenter_requiredAbilityId_fkey"
+ columns: ["requiredAbilityId"]
+ isOneToOne: false
+ referencedRelation: "ability"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "workCenter_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "workCenter_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "workCenter_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "workCenter_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "workCenter_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ ]
+ }
}
Functions: {
_xid_machine_id: {
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index e35eab859e..58b5c52cf4 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -2575,204 +2575,6 @@ export type Database = {
}
Relationships: []
}
- crew: {
- Row: {
- companyId: string
- createdAt: string
- createdBy: string
- crewLeaderId: string | null
- description: string | null
- groupId: string
- id: string
- name: string
- updatedAt: string | null
- updatedBy: string | null
- workCellId: string | null
- }
- Insert: {
- companyId: string
- createdAt?: string
- createdBy: string
- crewLeaderId?: string | null
- description?: string | null
- groupId: string
- id?: string
- name: string
- updatedAt?: string | null
- updatedBy?: string | null
- workCellId?: string | null
- }
- Update: {
- companyId?: string
- createdAt?: string
- createdBy?: string
- crewLeaderId?: string | null
- description?: string | null
- groupId?: string
- id?: string
- name?: string
- updatedAt?: string | null
- updatedBy?: string | null
- workCellId?: string | null
- }
- Relationships: [
- {
- foreignKeyName: "crew_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "crew_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "crew_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "crew_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "crew_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
- {
- foreignKeyName: "crew_crewLeaderId_fkey"
- columns: ["crewLeaderId"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "crew_crewLeaderId_fkey"
- columns: ["crewLeaderId"]
- isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "crew_crewLeaderId_fkey"
- columns: ["crewLeaderId"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "crew_crewLeaderId_fkey"
- columns: ["crewLeaderId"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "crew_crewLeaderId_fkey"
- columns: ["crewLeaderId"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
- {
- foreignKeyName: "crew_groupId_fkey"
- columns: ["groupId"]
- isOneToOne: false
- referencedRelation: "group"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "crew_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "crew_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "crew_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "crew_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "crew_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
- {
- foreignKeyName: "crew_workCellId_fkey"
- columns: ["workCellId"]
- isOneToOne: false
- referencedRelation: "workCell"
- referencedColumns: ["id"]
- },
- ]
- }
- crewAbility: {
- Row: {
- abilityId: string
- active: boolean
- crewId: string
- id: string
- }
- Insert: {
- abilityId: string
- active?: boolean
- crewId: string
- id?: string
- }
- Update: {
- abilityId?: string
- active?: boolean
- crewId?: string
- id?: string
- }
- Relationships: [
- {
- foreignKeyName: "crewAbility_abilityId_fkey"
- columns: ["abilityId"]
- isOneToOne: false
- referencedRelation: "ability"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "crewAbility_crewId_fkey"
- columns: ["crewId"]
- isOneToOne: false
- referencedRelation: "crew"
- referencedColumns: ["id"]
- },
- ]
- }
currency: {
Row: {
active: boolean
@@ -4813,7 +4615,6 @@ export type Database = {
title: string | null
updatedAt: string | null
updatedBy: string | null
- workCellId: string | null
}
Insert: {
companyId: string
@@ -4827,7 +4628,6 @@ export type Database = {
title?: string | null
updatedAt?: string | null
updatedBy?: string | null
- workCellId?: string | null
}
Update: {
companyId?: string
@@ -4841,7 +4641,6 @@ export type Database = {
title?: string | null
updatedAt?: string | null
updatedBy?: string | null
- workCellId?: string | null
}
Relationships: [
{
@@ -5026,13 +4825,6 @@ export type Database = {
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
- {
- foreignKeyName: "employeeJob_workCellId_fkey"
- columns: ["workCellId"]
- isOneToOne: false
- referencedRelation: "workCell"
- referencedColumns: ["id"]
- },
]
}
employeeShift: {
@@ -5200,437 +4992,85 @@ export type Database = {
},
]
}
- equipment: {
+ fiscalYearSettings: {
Row: {
- active: boolean
- activeDate: string | null
companyId: string
- createdAt: string
- createdBy: string
- customFields: Json | null
- description: string | null
- equipmentId: string | null
- equipmentTypeId: string
- id: string
- locationId: string
- name: string
- operatorsRequired: number
- setupHours: number
- updatedAt: string | null
- updatedBy: string | null
- workCellId: string | null
+ startMonth: Database["public"]["Enums"]["month"]
+ taxStartMonth: Database["public"]["Enums"]["month"]
+ updatedBy: string
}
Insert: {
- active?: boolean
- activeDate?: string | null
companyId: string
- createdAt?: string
- createdBy: string
- customFields?: Json | null
- description?: string | null
- equipmentId?: string | null
- equipmentTypeId: string
- id?: string
- locationId: string
- name: string
- operatorsRequired?: number
- setupHours?: number
- updatedAt?: string | null
- updatedBy?: string | null
- workCellId?: string | null
+ startMonth?: Database["public"]["Enums"]["month"]
+ taxStartMonth?: Database["public"]["Enums"]["month"]
+ updatedBy: string
}
Update: {
- active?: boolean
- activeDate?: string | null
companyId?: string
- createdAt?: string
- createdBy?: string
- customFields?: Json | null
- description?: string | null
- equipmentId?: string | null
- equipmentTypeId?: string
- id?: string
- locationId?: string
- name?: string
- operatorsRequired?: number
- setupHours?: number
- updatedAt?: string | null
- updatedBy?: string | null
- workCellId?: string | null
+ startMonth?: Database["public"]["Enums"]["month"]
+ taxStartMonth?: Database["public"]["Enums"]["month"]
+ updatedBy?: string
}
Relationships: [
{
- foreignKeyName: "equipment_companyId_fkey"
+ foreignKeyName: "fiscalYearSettings_companyId_fkey"
columns: ["companyId"]
- isOneToOne: false
+ isOneToOne: true
referencedRelation: "companies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "equipment_companyId_fkey"
+ foreignKeyName: "fiscalYearSettings_companyId_fkey"
columns: ["companyId"]
- isOneToOne: false
+ isOneToOne: true
referencedRelation: "company"
referencedColumns: ["id"]
},
{
- foreignKeyName: "equipment_companyId_fkey"
+ foreignKeyName: "fiscalYearSettings_companyId_fkey"
columns: ["companyId"]
- isOneToOne: false
+ isOneToOne: true
referencedRelation: "customFieldTables"
referencedColumns: ["companyId"]
},
{
- foreignKeyName: "equipment_companyId_fkey"
+ foreignKeyName: "fiscalYearSettings_companyId_fkey"
columns: ["companyId"]
- isOneToOne: false
+ isOneToOne: true
referencedRelation: "integrations"
referencedColumns: ["companyId"]
},
{
- foreignKeyName: "equipment_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "fiscalYearSettings_updatedBy_fkey"
+ columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "equipment_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "fiscalYearSettings_updatedBy_fkey"
+ columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "equipment_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "fiscalYearSettings_updatedBy_fkey"
+ columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "equipment_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "fiscalYearSettings_updatedBy_fkey"
+ columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "equipment_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
- {
- foreignKeyName: "equipment_equipmentTypeId_fkey"
- columns: ["equipmentTypeId"]
- isOneToOne: false
- referencedRelation: "equipmentType"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "equipment_locationId_fkey"
- columns: ["locationId"]
- isOneToOne: false
- referencedRelation: "itemQuantities"
- referencedColumns: ["locationId"]
- },
- {
- foreignKeyName: "equipment_locationId_fkey"
- columns: ["locationId"]
- isOneToOne: false
- referencedRelation: "location"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "equipment_locationId_fkey"
- columns: ["locationId"]
- isOneToOne: false
- referencedRelation: "purchaseOrders"
- referencedColumns: ["locationId"]
- },
- {
- foreignKeyName: "equipment_locationId_fkey"
- columns: ["locationId"]
- isOneToOne: false
- referencedRelation: "salesOrders"
- referencedColumns: ["locationId"]
- },
- {
- foreignKeyName: "equipment_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "equipment_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "equipment_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "equipment_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "equipment_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
- {
- foreignKeyName: "equipment_workCellId_fkey"
- columns: ["workCellId"]
- isOneToOne: false
- referencedRelation: "workCell"
- referencedColumns: ["id"]
- },
- ]
- }
- equipmentType: {
- Row: {
- active: boolean
- companyId: string
- createdAt: string
- createdBy: string
- customFields: Json | null
- description: string | null
- id: string
- name: string
- requiredAbility: string | null
- setupHours: number
- updatedAt: string | null
- updatedBy: string | null
- }
- Insert: {
- active?: boolean
- companyId: string
- createdAt?: string
- createdBy: string
- customFields?: Json | null
- description?: string | null
- id?: string
- name: string
- requiredAbility?: string | null
- setupHours?: number
- updatedAt?: string | null
- updatedBy?: string | null
- }
- Update: {
- active?: boolean
- companyId?: string
- createdAt?: string
- createdBy?: string
- customFields?: Json | null
- description?: string | null
- id?: string
- name?: string
- requiredAbility?: string | null
- setupHours?: number
- updatedAt?: string | null
- updatedBy?: string | null
- }
- Relationships: [
- {
- foreignKeyName: "equipmentType_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "companies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "equipmentType_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "company"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "equipmentType_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "customFieldTables"
- referencedColumns: ["companyId"]
- },
- {
- foreignKeyName: "equipmentType_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "integrations"
- referencedColumns: ["companyId"]
- },
- {
- foreignKeyName: "equipmentType_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "equipmentType_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "equipmentType_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "equipmentType_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "equipmentType_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
- {
- foreignKeyName: "equipmentType_requiredAbility_fkey"
- columns: ["requiredAbility"]
- isOneToOne: false
- referencedRelation: "ability"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "equipmentType_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "equipmentType_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "equipmentType_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "equipmentType_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "equipmentType_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
- ]
- }
- fiscalYearSettings: {
- Row: {
- companyId: string
- startMonth: Database["public"]["Enums"]["month"]
- taxStartMonth: Database["public"]["Enums"]["month"]
- updatedBy: string
- }
- Insert: {
- companyId: string
- startMonth?: Database["public"]["Enums"]["month"]
- taxStartMonth?: Database["public"]["Enums"]["month"]
- updatedBy: string
- }
- Update: {
- companyId?: string
- startMonth?: Database["public"]["Enums"]["month"]
- taxStartMonth?: Database["public"]["Enums"]["month"]
- updatedBy?: string
- }
- Relationships: [
- {
- foreignKeyName: "fiscalYearSettings_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: true
- referencedRelation: "companies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "fiscalYearSettings_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: true
- referencedRelation: "company"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "fiscalYearSettings_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: true
- referencedRelation: "customFieldTables"
- referencedColumns: ["companyId"]
- },
- {
- foreignKeyName: "fiscalYearSettings_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: true
- referencedRelation: "integrations"
- referencedColumns: ["companyId"]
- },
- {
- foreignKeyName: "fiscalYearSettings_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "fiscalYearSettings_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "fiscalYearSettings_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "fiscalYearSettings_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "fiscalYearSettings_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "fiscalYearSettings_updatedBy_fkey"
+ columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
@@ -8462,17 +7902,20 @@ export type Database = {
createdBy: string
customFields: Json | null
description: string
- equipmentTypeId: string | null
id: string
+ laborTime: number
+ laborUnit: Database["public"]["Enums"]["factor"]
+ machineTime: number
+ machineUnit: Database["public"]["Enums"]["factor"]
makeMethodId: string
operationOrder: Database["public"]["Enums"]["methodOperationOrder"]
order: number
- productionStandard: number
- setupHours: number
- standardFactor: Database["public"]["Enums"]["factor"]
+ processId: string
+ setupTime: number
+ setupUnit: Database["public"]["Enums"]["factor"]
updatedAt: string | null
updatedBy: string | null
- workCellTypeId: string
+ workCenterId: string | null
}
Insert: {
companyId: string
@@ -8480,17 +7923,20 @@ export type Database = {
createdBy: string
customFields?: Json | null
description: string
- equipmentTypeId?: string | null
id?: string
+ laborTime?: number
+ laborUnit?: Database["public"]["Enums"]["factor"]
+ machineTime?: number
+ machineUnit?: Database["public"]["Enums"]["factor"]
makeMethodId: string
operationOrder?: Database["public"]["Enums"]["methodOperationOrder"]
order?: number
- productionStandard?: number
- setupHours?: number
- standardFactor?: Database["public"]["Enums"]["factor"]
+ processId: string
+ setupTime?: number
+ setupUnit?: Database["public"]["Enums"]["factor"]
updatedAt?: string | null
updatedBy?: string | null
- workCellTypeId: string
+ workCenterId?: string | null
}
Update: {
companyId?: string
@@ -8498,17 +7944,20 @@ export type Database = {
createdBy?: string
customFields?: Json | null
description?: string
- equipmentTypeId?: string | null
id?: string
+ laborTime?: number
+ laborUnit?: Database["public"]["Enums"]["factor"]
+ machineTime?: number
+ machineUnit?: Database["public"]["Enums"]["factor"]
makeMethodId?: string
operationOrder?: Database["public"]["Enums"]["methodOperationOrder"]
order?: number
- productionStandard?: number
- setupHours?: number
- standardFactor?: Database["public"]["Enums"]["factor"]
+ processId?: string
+ setupTime?: number
+ setupUnit?: Database["public"]["Enums"]["factor"]
updatedAt?: string | null
updatedBy?: string | null
- workCellTypeId?: string
+ workCenterId?: string | null
}
Relationships: [
{
@@ -8574,13 +8023,6 @@ export type Database = {
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
- {
- foreignKeyName: "methodOperation_equipmentTypeId_fkey"
- columns: ["equipmentTypeId"]
- isOneToOne: false
- referencedRelation: "equipmentType"
- referencedColumns: ["id"]
- },
{
foreignKeyName: "methodOperation_methodId_fkey"
columns: ["makeMethodId"]
@@ -8595,6 +8037,13 @@ export type Database = {
referencedRelation: "quoteOperationsWithMakeMethods"
referencedColumns: ["makeMethodId"]
},
+ {
+ foreignKeyName: "methodOperation_processId_fkey"
+ columns: ["processId"]
+ isOneToOne: false
+ referencedRelation: "process"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "methodOperation_updatedBy_fkey"
columns: ["updatedBy"]
@@ -8631,10 +8080,17 @@ export type Database = {
referencedColumns: ["userId"]
},
{
- foreignKeyName: "methodOperation_workCellTypeId_fkey"
- columns: ["workCellTypeId"]
+ foreignKeyName: "methodOperation_workCenterId_fkey"
+ columns: ["workCenterId"]
isOneToOne: false
- referencedRelation: "workCellType"
+ referencedRelation: "workCenter"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "methodOperation_workCenterId_fkey"
+ columns: ["workCenterId"]
+ isOneToOne: false
+ referencedRelation: "workCenters"
referencedColumns: ["id"]
},
]
@@ -13983,22 +13439,25 @@ export type Database = {
createdBy: string
customFields: Json | null
description: string | null
- equipmentTypeId: string | null
id: string
laborRate: number
+ laborTime: number
+ laborUnit: Database["public"]["Enums"]["factor"]
+ machineTime: number
+ machineUnit: Database["public"]["Enums"]["factor"]
operationOrder: Database["public"]["Enums"]["methodOperationOrder"]
order: number
overheadRate: number
- productionStandard: number
+ processId: string
quoteId: string
quoteLineId: string
quoteMakeMethodId: string | null
quotingRate: number
- setupHours: number
- standardFactor: Database["public"]["Enums"]["factor"]
+ setupTime: number
+ setupUnit: Database["public"]["Enums"]["factor"]
updatedAt: string | null
updatedBy: string | null
- workCellTypeId: string
+ workCenterId: string | null
}
Insert: {
companyId: string
@@ -14006,22 +13465,25 @@ export type Database = {
createdBy: string
customFields?: Json | null
description?: string | null
- equipmentTypeId?: string | null
id?: string
laborRate?: number
+ laborTime?: number
+ laborUnit?: Database["public"]["Enums"]["factor"]
+ machineTime?: number
+ machineUnit?: Database["public"]["Enums"]["factor"]
operationOrder?: Database["public"]["Enums"]["methodOperationOrder"]
order?: number
overheadRate?: number
- productionStandard?: number
+ processId: string
quoteId: string
quoteLineId: string
quoteMakeMethodId?: string | null
quotingRate?: number
- setupHours?: number
- standardFactor?: Database["public"]["Enums"]["factor"]
+ setupTime?: number
+ setupUnit?: Database["public"]["Enums"]["factor"]
updatedAt?: string | null
updatedBy?: string | null
- workCellTypeId: string
+ workCenterId?: string | null
}
Update: {
companyId?: string
@@ -14029,22 +13491,25 @@ export type Database = {
createdBy?: string
customFields?: Json | null
description?: string | null
- equipmentTypeId?: string | null
id?: string
laborRate?: number
+ laborTime?: number
+ laborUnit?: Database["public"]["Enums"]["factor"]
+ machineTime?: number
+ machineUnit?: Database["public"]["Enums"]["factor"]
operationOrder?: Database["public"]["Enums"]["methodOperationOrder"]
order?: number
overheadRate?: number
- productionStandard?: number
+ processId?: string
quoteId?: string
quoteLineId?: string
quoteMakeMethodId?: string | null
quotingRate?: number
- setupHours?: number
- standardFactor?: Database["public"]["Enums"]["factor"]
+ setupTime?: number
+ setupUnit?: Database["public"]["Enums"]["factor"]
updatedAt?: string | null
updatedBy?: string | null
- workCellTypeId?: string
+ workCenterId?: string | null
}
Relationships: [
{
@@ -14111,10 +13576,10 @@ export type Database = {
referencedColumns: ["userId"]
},
{
- foreignKeyName: "quoteOperation_equipmentTypeId_fkey"
- columns: ["equipmentTypeId"]
+ foreignKeyName: "quoteOperation_processId_fkey"
+ columns: ["processId"]
isOneToOne: false
- referencedRelation: "equipmentType"
+ referencedRelation: "process"
referencedColumns: ["id"]
},
{
@@ -14202,10 +13667,17 @@ export type Database = {
referencedColumns: ["userId"]
},
{
- foreignKeyName: "quoteOperation_workCellTypeId_fkey"
- columns: ["workCellTypeId"]
+ foreignKeyName: "quoteOperation_workCenterId_fkey"
+ columns: ["workCenterId"]
+ isOneToOne: false
+ referencedRelation: "workCenter"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteOperation_workCenterId_fkey"
+ columns: ["workCenterId"]
isOneToOne: false
- referencedRelation: "workCellType"
+ referencedRelation: "workCenters"
referencedColumns: ["id"]
},
]
@@ -19622,402 +19094,28 @@ export type Database = {
referencedColumns: ["id"]
},
{
- foreignKeyName: "userToCompany_userId_fkey"
- columns: ["userId"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
- ]
- }
- warehouse: {
- Row: {
- active: boolean
- companyId: string
- createdAt: string
- createdBy: string
- id: string
- locationId: string
- name: string
- requiresBin: boolean
- requiresPick: boolean
- requiresPutAway: boolean
- requiresReceive: boolean
- requiresShipment: boolean
- updatedAt: string | null
- updatedBy: string | null
- }
- Insert: {
- active?: boolean
- companyId: string
- createdAt?: string
- createdBy: string
- id?: string
- locationId: string
- name: string
- requiresBin?: boolean
- requiresPick?: boolean
- requiresPutAway?: boolean
- requiresReceive?: boolean
- requiresShipment?: boolean
- updatedAt?: string | null
- updatedBy?: string | null
- }
- Update: {
- active?: boolean
- companyId?: string
- createdAt?: string
- createdBy?: string
- id?: string
- locationId?: string
- name?: string
- requiresBin?: boolean
- requiresPick?: boolean
- requiresPutAway?: boolean
- requiresReceive?: boolean
- requiresShipment?: boolean
- updatedAt?: string | null
- updatedBy?: string | null
- }
- Relationships: [
- {
- foreignKeyName: "warehouse_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "companies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "warehouse_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "company"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "warehouse_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "customFieldTables"
- referencedColumns: ["companyId"]
- },
- {
- foreignKeyName: "warehouse_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "integrations"
- referencedColumns: ["companyId"]
- },
- {
- foreignKeyName: "warehouse_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "warehouse_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "warehouse_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "warehouse_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "warehouse_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
- {
- foreignKeyName: "warehouse_locationId_fkey"
- columns: ["locationId"]
- isOneToOne: false
- referencedRelation: "itemQuantities"
- referencedColumns: ["locationId"]
- },
- {
- foreignKeyName: "warehouse_locationId_fkey"
- columns: ["locationId"]
- isOneToOne: false
- referencedRelation: "location"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "warehouse_locationId_fkey"
- columns: ["locationId"]
- isOneToOne: false
- referencedRelation: "purchaseOrders"
- referencedColumns: ["locationId"]
- },
- {
- foreignKeyName: "warehouse_locationId_fkey"
- columns: ["locationId"]
- isOneToOne: false
- referencedRelation: "salesOrders"
- referencedColumns: ["locationId"]
- },
- {
- foreignKeyName: "warehouse_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "warehouse_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "warehouse_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "warehouse_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "warehouse_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
- ]
- }
- workCell: {
- Row: {
- active: boolean
- activeDate: string | null
- companyId: string
- createdAt: string
- createdBy: string
- customFields: Json | null
- defaultStandardFactor: Database["public"]["Enums"]["factor"]
- departmentId: string
- description: string | null
- id: string
- locationId: string | null
- name: string
- updatedAt: string | null
- updatedBy: string | null
- workCellTypeId: string
- }
- Insert: {
- active?: boolean
- activeDate?: string | null
- companyId: string
- createdAt?: string
- createdBy: string
- customFields?: Json | null
- defaultStandardFactor?: Database["public"]["Enums"]["factor"]
- departmentId: string
- description?: string | null
- id?: string
- locationId?: string | null
- name: string
- updatedAt?: string | null
- updatedBy?: string | null
- workCellTypeId: string
- }
- Update: {
- active?: boolean
- activeDate?: string | null
- companyId?: string
- createdAt?: string
- createdBy?: string
- customFields?: Json | null
- defaultStandardFactor?: Database["public"]["Enums"]["factor"]
- departmentId?: string
- description?: string | null
- id?: string
- locationId?: string | null
- name?: string
- updatedAt?: string | null
- updatedBy?: string | null
- workCellTypeId?: string
- }
- Relationships: [
- {
- foreignKeyName: "workCell_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "companies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "workCell_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "company"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "workCell_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "customFieldTables"
- referencedColumns: ["companyId"]
- },
- {
- foreignKeyName: "workCell_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "integrations"
- referencedColumns: ["companyId"]
- },
- {
- foreignKeyName: "workCell_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "workCell_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "workCell_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "workCell_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "workCell_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
- {
- foreignKeyName: "workCell_departmentId_fkey"
- columns: ["departmentId"]
- isOneToOne: false
- referencedRelation: "department"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "workCell_locationId_fkey"
- columns: ["locationId"]
- isOneToOne: false
- referencedRelation: "itemQuantities"
- referencedColumns: ["locationId"]
- },
- {
- foreignKeyName: "workCell_locationId_fkey"
- columns: ["locationId"]
- isOneToOne: false
- referencedRelation: "location"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "workCell_locationId_fkey"
- columns: ["locationId"]
- isOneToOne: false
- referencedRelation: "purchaseOrders"
- referencedColumns: ["locationId"]
- },
- {
- foreignKeyName: "workCell_locationId_fkey"
- columns: ["locationId"]
- isOneToOne: false
- referencedRelation: "salesOrders"
- referencedColumns: ["locationId"]
- },
- {
- foreignKeyName: "workCell_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "workCell_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "workCell_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "workCell_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "workCell_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "userToCompany_userId_fkey"
+ columns: ["userId"]
isOneToOne: false
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
- {
- foreignKeyName: "workCell_workCellTypeId_fkey"
- columns: ["workCellTypeId"]
- isOneToOne: false
- referencedRelation: "workCellType"
- referencedColumns: ["id"]
- },
]
}
- workCellType: {
+ warehouse: {
Row: {
active: boolean
companyId: string
createdAt: string
createdBy: string
- customFields: Json | null
- defaultStandardFactor: Database["public"]["Enums"]["factor"]
- description: string | null
id: string
- laborRate: number
+ locationId: string
name: string
- overheadRate: number
- quotingRate: number
- requiredAbility: string | null
+ requiresBin: boolean
+ requiresPick: boolean
+ requiresPutAway: boolean
+ requiresReceive: boolean
+ requiresShipment: boolean
updatedAt: string | null
updatedBy: string | null
}
@@ -20026,15 +19124,14 @@ export type Database = {
companyId: string
createdAt?: string
createdBy: string
- customFields?: Json | null
- defaultStandardFactor?: Database["public"]["Enums"]["factor"]
- description?: string | null
id?: string
- laborRate?: number
+ locationId: string
name: string
- overheadRate?: number
- quotingRate?: number
- requiredAbility?: string | null
+ requiresBin?: boolean
+ requiresPick?: boolean
+ requiresPutAway?: boolean
+ requiresReceive?: boolean
+ requiresShipment?: boolean
updatedAt?: string | null
updatedBy?: string | null
}
@@ -20043,119 +19140,139 @@ export type Database = {
companyId?: string
createdAt?: string
createdBy?: string
- customFields?: Json | null
- defaultStandardFactor?: Database["public"]["Enums"]["factor"]
- description?: string | null
id?: string
- laborRate?: number
+ locationId?: string
name?: string
- overheadRate?: number
- quotingRate?: number
- requiredAbility?: string | null
+ requiresBin?: boolean
+ requiresPick?: boolean
+ requiresPutAway?: boolean
+ requiresReceive?: boolean
+ requiresShipment?: boolean
updatedAt?: string | null
updatedBy?: string | null
}
Relationships: [
{
- foreignKeyName: "workCellType_companyId_fkey"
+ foreignKeyName: "warehouse_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "companies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "workCellType_companyId_fkey"
+ foreignKeyName: "warehouse_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "company"
referencedColumns: ["id"]
},
{
- foreignKeyName: "workCellType_companyId_fkey"
+ foreignKeyName: "warehouse_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "customFieldTables"
referencedColumns: ["companyId"]
},
{
- foreignKeyName: "workCellType_companyId_fkey"
+ foreignKeyName: "warehouse_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "integrations"
referencedColumns: ["companyId"]
},
{
- foreignKeyName: "workCellType_createdBy_fkey"
+ foreignKeyName: "warehouse_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "workCellType_createdBy_fkey"
+ foreignKeyName: "warehouse_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "workCellType_createdBy_fkey"
+ foreignKeyName: "warehouse_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "workCellType_createdBy_fkey"
+ foreignKeyName: "warehouse_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "workCellType_createdBy_fkey"
+ foreignKeyName: "warehouse_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
{
- foreignKeyName: "workCellType_requiredAbility_fkey"
- columns: ["requiredAbility"]
+ foreignKeyName: "warehouse_locationId_fkey"
+ columns: ["locationId"]
isOneToOne: false
- referencedRelation: "ability"
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["locationId"]
+ },
+ {
+ foreignKeyName: "warehouse_locationId_fkey"
+ columns: ["locationId"]
+ isOneToOne: false
+ referencedRelation: "location"
referencedColumns: ["id"]
},
{
- foreignKeyName: "workCellType_updatedBy_fkey"
+ foreignKeyName: "warehouse_locationId_fkey"
+ columns: ["locationId"]
+ isOneToOne: false
+ referencedRelation: "purchaseOrders"
+ referencedColumns: ["locationId"]
+ },
+ {
+ foreignKeyName: "warehouse_locationId_fkey"
+ columns: ["locationId"]
+ isOneToOne: false
+ referencedRelation: "salesOrders"
+ referencedColumns: ["locationId"]
+ },
+ {
+ foreignKeyName: "warehouse_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "workCellType_updatedBy_fkey"
+ foreignKeyName: "warehouse_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "workCellType_updatedBy_fkey"
+ foreignKeyName: "warehouse_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "workCellType_updatedBy_fkey"
+ foreignKeyName: "warehouse_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "workCellType_updatedBy_fkey"
+ foreignKeyName: "warehouse_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "userDefaults"
@@ -20165,6 +19282,7 @@ export type Database = {
}
workCenter: {
Row: {
+ active: boolean
companyId: string
createdAt: string
createdBy: string
@@ -20177,10 +19295,12 @@ export type Database = {
name: string
overheadRate: number | null
quotingRate: number
+ requiredAbilityId: string | null
updatedAt: string | null
updatedBy: string | null
}
Insert: {
+ active?: boolean
companyId: string
createdAt?: string
createdBy: string
@@ -20193,10 +19313,12 @@ export type Database = {
name: string
overheadRate?: number | null
quotingRate?: number
+ requiredAbilityId?: string | null
updatedAt?: string | null
updatedBy?: string | null
}
Update: {
+ active?: boolean
companyId?: string
createdAt?: string
createdBy?: string
@@ -20209,6 +19331,7 @@ export type Database = {
name?: string
overheadRate?: number | null
quotingRate?: number
+ requiredAbilityId?: string | null
updatedAt?: string | null
updatedBy?: string | null
}
@@ -20304,6 +19427,13 @@ export type Database = {
referencedRelation: "salesOrders"
referencedColumns: ["locationId"]
},
+ {
+ foreignKeyName: "workCenter_requiredAbilityId_fkey"
+ columns: ["requiredAbilityId"]
+ isOneToOne: false
+ referencedRelation: "ability"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "workCenter_updatedBy_fkey"
columns: ["updatedBy"]
@@ -20482,6 +19612,13 @@ export type Database = {
referencedRelation: "workCenter"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "workCenterProcess_workCenterId_fkey"
+ columns: ["workCenterId"]
+ isOneToOne: false
+ referencedRelation: "workCenters"
+ referencedColumns: ["id"]
+ },
]
}
}
@@ -23969,25 +23106,28 @@ export type Database = {
createdBy: string | null
customFields: Json | null
description: string | null
- equipmentTypeId: string | null
id: string | null
laborRate: number | null
+ laborTime: number | null
+ laborUnit: Database["public"]["Enums"]["factor"] | null
+ machineTime: number | null
+ machineUnit: Database["public"]["Enums"]["factor"] | null
makeMethodId: string | null
operationOrder:
| Database["public"]["Enums"]["methodOperationOrder"]
| null
order: number | null
overheadRate: number | null
- productionStandard: number | null
+ processId: string | null
quoteId: string | null
quoteLineId: string | null
quoteMakeMethodId: string | null
quotingRate: number | null
- setupHours: number | null
- standardFactor: Database["public"]["Enums"]["factor"] | null
+ setupTime: number | null
+ setupUnit: Database["public"]["Enums"]["factor"] | null
updatedAt: string | null
updatedBy: string | null
- workCellTypeId: string | null
+ workCenterId: string | null
}
Relationships: [
{
@@ -24054,10 +23194,10 @@ export type Database = {
referencedColumns: ["userId"]
},
{
- foreignKeyName: "quoteOperation_equipmentTypeId_fkey"
- columns: ["equipmentTypeId"]
+ foreignKeyName: "quoteOperation_processId_fkey"
+ columns: ["processId"]
isOneToOne: false
- referencedRelation: "equipmentType"
+ referencedRelation: "process"
referencedColumns: ["id"]
},
{
@@ -24145,10 +23285,17 @@ export type Database = {
referencedColumns: ["userId"]
},
{
- foreignKeyName: "quoteOperation_workCellTypeId_fkey"
- columns: ["workCellTypeId"]
+ foreignKeyName: "quoteOperation_workCenterId_fkey"
+ columns: ["workCenterId"]
+ isOneToOne: false
+ referencedRelation: "workCenter"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteOperation_workCenterId_fkey"
+ columns: ["workCenterId"]
isOneToOne: false
- referencedRelation: "workCellType"
+ referencedRelation: "workCenters"
referencedColumns: ["id"]
},
]
@@ -26486,6 +25633,162 @@ export type Database = {
},
]
}
+ workCenters: {
+ Row: {
+ active: boolean | null
+ companyId: string | null
+ createdAt: string | null
+ createdBy: string | null
+ customFields: Json | null
+ defaultStandardFactor: Database["public"]["Enums"]["factor"] | null
+ description: string | null
+ id: string | null
+ laborRate: number | null
+ locationId: string | null
+ name: string | null
+ overheadRate: number | null
+ processes: Json | null
+ quotingRate: number | null
+ requiredAbilityId: string | null
+ updatedAt: string | null
+ updatedBy: string | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "workCenter_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "workCenter_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "workCenter_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "workCenter_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "workCenter_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "workCenter_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "workCenter_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "workCenter_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "workCenter_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "workCenter_locationId_fkey"
+ columns: ["locationId"]
+ isOneToOne: false
+ referencedRelation: "location"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "workCenter_locationId_fkey"
+ columns: ["locationId"]
+ isOneToOne: false
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["locationId"]
+ },
+ {
+ foreignKeyName: "workCenter_locationId_fkey"
+ columns: ["locationId"]
+ isOneToOne: false
+ referencedRelation: "purchaseOrders"
+ referencedColumns: ["locationId"]
+ },
+ {
+ foreignKeyName: "workCenter_locationId_fkey"
+ columns: ["locationId"]
+ isOneToOne: false
+ referencedRelation: "salesOrders"
+ referencedColumns: ["locationId"]
+ },
+ {
+ foreignKeyName: "workCenter_requiredAbilityId_fkey"
+ columns: ["requiredAbilityId"]
+ isOneToOne: false
+ referencedRelation: "ability"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "workCenter_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "workCenter_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "workCenter_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "workCenter_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "workCenter_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ ]
+ }
}
Functions: {
_xid_machine_id: {
diff --git a/packages/database/supabase/migrations/20240511125727_seed_custom_fields.sql b/packages/database/supabase/migrations/20240511125727_seed_custom_fields.sql
index 1771c746e5..1a67782641 100644
--- a/packages/database/supabase/migrations/20240511125727_seed_custom_fields.sql
+++ b/packages/database/supabase/migrations/20240511125727_seed_custom_fields.sql
@@ -60,3 +60,4 @@ VALUES
('workCell', 'Work Cell', 'Resources'),
('workCellType', 'Work Cell Type', 'Resources');
+
diff --git a/packages/database/supabase/migrations/20240819115702_work-centers.sql b/packages/database/supabase/migrations/20240819115702_work-centers.sql
index a17da00986..458e7afb90 100644
--- a/packages/database/supabase/migrations/20240819115702_work-centers.sql
+++ b/packages/database/supabase/migrations/20240819115702_work-centers.sql
@@ -57,6 +57,8 @@ CREATE TABLE "workCenter" (
"overheadRate" NUMERIC GENERATED ALWAYS AS ("quotingRate" - "laborRate") STORED,
"defaultStandardFactor" factor NOT NULL DEFAULT 'Minutes/Piece',
"locationId" TEXT,
+ "requiredAbilityId" TEXT,
+ "active" BOOLEAN NOT NULL DEFAULT true,
"companyId" TEXT NOT NULL,
"customFields" JSONB,
"createdBy" TEXT NOT NULL,
@@ -66,6 +68,7 @@ CREATE TABLE "workCenter" (
CONSTRAINT "workCenter_pkey" PRIMARY KEY ("id"),
CONSTRAINT "workCenter_locationId_fkey" FOREIGN KEY ("locationId") REFERENCES "location" ("id") ON DELETE CASCADE,
+ CONSTRAINT "workCenter_requiredAbilityId_fkey" FOREIGN KEY ("requiredAbilityId") REFERENCES "ability" ("id") ON DELETE CASCADE,
CONSTRAINT "workCenter_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company" ("id") ON DELETE CASCADE,
CONSTRAINT "workCenter_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user" ("id") ON DELETE RESTRICT,
CONSTRAINT "workCenter_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user" ("id") ON DELETE SET NULL
@@ -151,4 +154,91 @@ CREATE POLICY "Employees with resources_delete can delete work center/processes"
USING (
has_role('employee', "companyId") AND
has_company_permission('resources_delete', "companyId")
- );
\ No newline at end of file
+ );
+
+CREATE OR REPLACE VIEW "workCenters" WITH(SECURITY_INVOKER=true) AS
+ SELECT
+ wc.*,
+ wcp.processes
+ FROM "workCenter" wc
+ LEFT JOIN (
+ SELECT
+ "workCenterId",
+ jsonb_agg(jsonb_build_object('id', "processId", 'name', p.name)) as processes
+ FROM "workCenterProcess" wcp
+ INNER JOIN "process" p ON wcp."processId" = p.id
+ GROUP BY "workCenterId"
+ ) wcp ON wc.id = wcp."workCenterId";
+
+
+DELETE FROM "customFieldTable" WHERE "table" = 'workCell';
+DELETE FROM "customFieldTable" WHERE "table" = 'workCellType';
+DELETE FROM "customFieldTable" WHERE "table" = 'equipmentType';
+DELETE FROM "customFieldTable" WHERE "table" = 'equipment';
+
+INSERT INTO "customFieldTable" ("table", "name", "module")
+VALUES
+('process', 'Process', 'Resources'),
+('workCenter', 'Work Center', 'Resources');
+
+ALTER TABLE "methodOperation"
+ DROP COLUMN "workCellTypeId",
+ DROP COLUMN "equipmentTypeId",
+ DROP COLUMN "setupHours",
+ DROP COLUMN "standardFactor",
+ DROP COLUMN "productionStandard";
+
+DROP VIEW "quoteOperationsWithMakeMethods";
+
+COMMIT;
+
+ALTER TABLE "quoteOperation"
+ DROP COLUMN "workCellTypeId",
+ DROP COLUMN "equipmentTypeId",
+ DROP COLUMN "setupHours",
+ DROP COLUMN "standardFactor",
+ DROP COLUMN "productionStandard";
+
+ALTER TABLE "employeeJob" DROP COLUMN "workCellId";
+
+DROP TABLE "equipment";
+DROP TABLE "equipmentType";
+DROP TABLE "crewAbility";
+DROP TABLE "crew";
+DROP TABLE "workCell";
+DROP TABLE "workCellType";
+
+ALTER TABLE "methodOperation"
+ ADD COLUMN "processId" TEXT NOT NULL,
+ ADD CONSTRAINT "methodOperation_processId_fkey" FOREIGN KEY ("processId") REFERENCES "process" ("id") ON DELETE RESTRICT,
+ ADD COLUMN "workCenterId" TEXT,
+ ADD CONSTRAINT "methodOperation_workCenterId_fkey" FOREIGN KEY ("workCenterId") REFERENCES "workCenter" ("id") ON DELETE RESTRICT,
+ ADD COLUMN "setupTime" NUMERIC(10,2) NOT NULL DEFAULT 0,
+ ADD COLUMN "setupUnit" factor NOT NULL DEFAULT 'Total Hours',
+ ADD COLUMN "laborTime" NUMERIC(10,2) NOT NULL DEFAULT 0,
+ ADD COLUMN "laborUnit" factor NOT NULL DEFAULT 'Hours/Piece',
+ ADD COLUMN "machineTime" NUMERIC(10,2) NOT NULL DEFAULT 0,
+ ADD COLUMN "machineUnit" factor NOT NULL DEFAULT 'Hours/Piece';
+
+ALTER TABLE "quoteOperation"
+ ADD COLUMN "processId" TEXT NOT NULL,
+ ADD CONSTRAINT "quoteOperation_processId_fkey" FOREIGN KEY ("processId") REFERENCES "process" ("id") ON DELETE RESTRICT,
+ ADD COLUMN "workCenterId" TEXT,
+ ADD CONSTRAINT "quoteOperation_workCenterId_fkey" FOREIGN KEY ("workCenterId") REFERENCES "workCenter" ("id") ON DELETE RESTRICT,
+ ADD COLUMN "setupTime" NUMERIC(10,2) NOT NULL DEFAULT 0,
+ ADD COLUMN "setupUnit" factor NOT NULL DEFAULT 'Total Hours',
+ ADD COLUMN "laborTime" NUMERIC(10,2) NOT NULL DEFAULT 0,
+ ADD COLUMN "laborUnit" factor NOT NULL DEFAULT 'Hours/Piece',
+ ADD COLUMN "machineTime" NUMERIC(10,2) NOT NULL DEFAULT 0,
+ ADD COLUMN "machineUnit" factor NOT NULL DEFAULT 'Hours/Piece';
+
+
+CREATE OR REPLACE VIEW "quoteOperationsWithMakeMethods" WITH(SECURITY_INVOKER=true) AS
+ SELECT
+ mm.id AS "makeMethodId",
+ qo.*
+ FROM "quoteOperation" qo
+ INNER JOIN "quoteMakeMethod" qmm
+ ON qo."quoteMakeMethodId" = qmm.id
+ LEFT JOIN "makeMethod" mm
+ ON qmm."itemId" = mm."itemId";
\ No newline at end of file
diff --git a/packages/react/src/Badge.tsx b/packages/react/src/Badge.tsx
index 7ba91fc3c0..99b8464a6e 100644
--- a/packages/react/src/Badge.tsx
+++ b/packages/react/src/Badge.tsx
@@ -51,12 +51,12 @@ const BadgeCloseButton = forwardRef<
>(({ className, ...props }, ref) => (
<button
className={cn(
- "ml-1 ring-offset-background rounded-full outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
+ "ml-1 ring-offset-background rounded-full outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 text-muted-foreground hover:text-foreground",
className
)}
{...props}
>
- <MdClose className="h-3 w-3 text-muted-foreground hover:text-foreground" />
+ <MdClose className="h-3 w-3 " />
</button>
));
BadgeCloseButton.displayName = "BadgeCloseButton";
diff --git a/packages/react/src/Form/FormLabel.tsx b/packages/react/src/Form/FormLabel.tsx
index e6c46c4d40..2eb5032cd9 100644
--- a/packages/react/src/Form/FormLabel.tsx
+++ b/packages/react/src/Form/FormLabel.tsx
@@ -7,9 +7,11 @@ import { cn } from "../utils/cn";
export const FormLabel = forwardRef<
ElementRef<typeof ReactAria.Label>,
- ComponentPropsWithoutRef<typeof ReactAria.Label>
+ ComponentPropsWithoutRef<typeof ReactAria.Label> & {
+ isOptional?: boolean;
+ }
>((props, ref) => {
- const { className, children, ...rest } = props;
+ const { className, children, isOptional = false, ...rest } = props;
const field = useFormControlContext();
const labelProps = field?.getLabelProps(rest, ref) ?? { ref, ...rest };
@@ -18,11 +20,17 @@ export const FormLabel = forwardRef<
<ReactAria.Label
{...labelProps}
ref={ref}
- className={cn("text-xs text-muted-foreground", className)}
+ className="flex items-center justify-between"
{...props}
>
- {children}
- {field?.isRequired && <span className="text-destructive"> *</span>}
+ <span className={cn("text-xs text-muted-foreground", className)}>
+ {children}
+ </span>
+ {isOptional && (
+ <span className="text-muted-foreground font-light text-xxs">
+ Optional
+ </span>
+ )}
</ReactAria.Label>
);
});