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.

refactor: rename part group to item group

Brad Barbin4d9ce5a17c8a
diff --git a/apps/carbon/app/components/Form/PartGroup.tsx b/apps/carbon/app/components/Form/ItemGroup.tsx
similarity index 56%
rename from apps/carbon/app/components/Form/PartGroup.tsx
rename to apps/carbon/app/components/Form/ItemGroup.tsx
index 7357615ac8..c8793a87a3 100644
--- a/apps/carbon/app/components/Form/PartGroup.tsx
+++ b/apps/carbon/app/components/Form/ItemGroup.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 { getPartGroupsList } from "~/modules/parts";
-import { PartGroupForm } from "~/modules/parts";
+import type { getItemGroupsList } from "~/modules/parts";
+import { ItemGroupForm } from "~/modules/parts";
import { path } from "~/utils/path";
import type { ComboboxProps } from "./Combobox";
import CreatableCombobox from "./CreatableCombobox";
-type PartGroupSelectProps = Omit<ComboboxProps, "options">;
+type ItemGroupSelectProps = Omit<ComboboxProps, "options">;
-const PartGroup = (props: PartGroupSelectProps) => {
- const newPartGroupModal = useDisclosure();
+const ItemGroup = (props: ItemGroupSelectProps) => {
+ const newItemGroupModal = useDisclosure();
const [created, setCreated] = useState<string>("");
const triggerRef = useRef<HTMLButtonElement>(null);
- const options = usePartGroups();
+ const options = useItemGroups();
return (
<>
@@ -22,18 +22,18 @@ const PartGroup = (props: PartGroupSelectProps) => {
ref={triggerRef}
options={options}
{...props}
- label={props?.label ?? "Part Group"}
+ label={props?.label ?? "Item Group"}
onCreateOption={(option) => {
- newPartGroupModal.onOpen();
+ newItemGroupModal.onOpen();
setCreated(option);
}}
/>
- {newPartGroupModal.isOpen && (
- <PartGroupForm
+ {newItemGroupModal.isOpen && (
+ <ItemGroupForm
type="modal"
onClose={() => {
setCreated("");
- newPartGroupModal.onClose();
+ newItemGroupModal.onClose();
triggerRef.current?.click();
}}
initialValues={{
@@ -45,27 +45,27 @@ const PartGroup = (props: PartGroupSelectProps) => {
);
};
-PartGroup.displayName = "PartGroup";
+ItemGroup.displayName = "ItemGroup";
-export default PartGroup;
+export default ItemGroup;
-export const usePartGroups = () => {
- const partGroupFetcher =
- useFetcher<Awaited<ReturnType<typeof getPartGroupsList>>>();
+export const useItemGroups = () => {
+ const itemGroupFetcher =
+ useFetcher<Awaited<ReturnType<typeof getItemGroupsList>>>();
useMount(() => {
- partGroupFetcher.load(path.to.api.partGroups);
+ itemGroupFetcher.load(path.to.api.itemGroups);
});
const options = useMemo(
() =>
- partGroupFetcher.data?.data
- ? partGroupFetcher.data?.data.map((c) => ({
+ itemGroupFetcher.data?.data
+ ? itemGroupFetcher.data?.data.map((c) => ({
value: c.id,
label: c.name,
}))
: [],
- [partGroupFetcher.data]
+ [itemGroupFetcher.data]
);
return options;
diff --git a/apps/carbon/app/components/Form/UnitOfMeasure.tsx b/apps/carbon/app/components/Form/UnitOfMeasure.tsx
index dab5684e63..5e65423c1f 100644
--- a/apps/carbon/app/components/Form/UnitOfMeasure.tsx
+++ b/apps/carbon/app/components/Form/UnitOfMeasure.tsx
@@ -26,7 +26,7 @@ const UnitOfMeasure = (props: UnitOfMeasureSelectProps) => {
ref={triggerRef}
options={options}
{...props}
- label={props?.label ?? "Part Group"}
+ label={props?.label ?? "Item Group"}
onCreateOption={(option) => {
newUnitOfMeasureModal.onOpen();
setCreated(option);
diff --git a/apps/carbon/app/components/Form/index.ts b/apps/carbon/app/components/Form/index.ts
index b70c59b7b4..59eea02d7e 100644
--- a/apps/carbon/app/components/Form/index.ts
+++ b/apps/carbon/app/components/Form/index.ts
@@ -25,11 +25,11 @@ import EquipmentType from "./EquipmentType";
import Hidden from "./Hidden";
import Input from "./Input";
import InputControlled from "./InputControlled";
+import ItemGroup from "./ItemGroup";
import Location from "./Location";
import Number from "./Number";
import NumberControlled from "./NumberControlled";
import Part from "./Part";
-import PartGroup from "./PartGroup";
import Password from "./Password";
import PhoneInput from "./PhoneInput";
import Radios from "./Radios";
@@ -82,11 +82,11 @@ export {
Hidden,
Input,
InputControlled,
+ ItemGroup,
Location,
Number,
NumberControlled,
Part,
- PartGroup,
Password,
PhoneInput,
Radios,
diff --git a/apps/carbon/app/modules/accounting/accounting.service.ts b/apps/carbon/app/modules/accounting/accounting.service.ts
index 60f0ce67dc..13faf43740 100644
--- a/apps/carbon/app/modules/accounting/accounting.service.ts
+++ b/apps/carbon/app/modules/accounting/accounting.service.ts
@@ -472,16 +472,16 @@ export async function getFiscalYearSettings(
export async function getInventoryPostingGroup(
client: SupabaseClient<Database>,
args: {
- partGroupId: string | null;
+ itemGroupId: string | null;
locationId: string | null;
}
) {
let query = client.from("postingGroupInventory").select("*");
- if (args.partGroupId === null) {
- query = query.is("partGroupId", null);
+ if (args.itemGroupId === null) {
+ query = query.is("itemGroupId", null);
} else {
- query = query.eq("partGroupId", args.partGroupId);
+ query = query.eq("itemGroupId", args.itemGroupId);
}
if (args.locationId === null) {
@@ -506,7 +506,7 @@ export async function getInventoryPostingGroups(
.eq("companyId", companyId);
query = setGenericQueryFilters(query, args, [
- { column: "partGroupId", ascending: false },
+ { column: "itemGroupId", ascending: false },
]);
return query;
}
@@ -562,16 +562,16 @@ export async function getPaymentTermsList(
export async function getPurchasingPostingGroup(
client: SupabaseClient<Database>,
args: {
- partGroupId: string | null;
+ itemGroupId: string | null;
supplierTypeId: string | null;
}
) {
let query = client.from("postingGroupInventory").select("*");
- if (args.partGroupId === null) {
- query = query.is("partGroupId", null);
+ if (args.itemGroupId === null) {
+ query = query.is("itemGroupId", null);
} else {
- query = query.eq("partGroupId", args.partGroupId);
+ query = query.eq("itemGroupId", args.itemGroupId);
}
if (args.supplierTypeId === null) {
@@ -596,7 +596,7 @@ export async function getPurchasingPostingGroups(
.eq("companyId", companyId);
query = setGenericQueryFilters(query, args, [
- { column: "partGroupId", ascending: false },
+ { column: "itemGroupId", ascending: false },
]);
return query;
}
@@ -604,16 +604,16 @@ export async function getPurchasingPostingGroups(
export async function getPurchasingSalesGroup(
client: SupabaseClient<Database>,
args: {
- partGroupId: string | null;
+ itemGroupId: string | null;
customerTypeId: string | null;
}
) {
let query = client.from("postingGroupInventory").select("*");
- if (args.partGroupId === null) {
- query = query.is("partGroupId", null);
+ if (args.itemGroupId === null) {
+ query = query.is("itemGroupId", null);
} else {
- query = query.eq("partGroupId", args.partGroupId);
+ query = query.eq("itemGroupId", args.itemGroupId);
}
if (args.customerTypeId === null) {
@@ -638,7 +638,7 @@ export async function getSalesPostingGroups(
.eq("companyId", companyId);
query = setGenericQueryFilters(query, args, [
- { column: "partGroupId", ascending: false },
+ { column: "itemGroupId", ascending: false },
]);
return query;
}
diff --git a/apps/carbon/app/modules/accounting/ui/PostingGroups/InventoryPostingGroupsTable.tsx b/apps/carbon/app/modules/accounting/ui/PostingGroups/InventoryPostingGroupsTable.tsx
index e3e11e53f8..e829e0d668 100644
--- a/apps/carbon/app/modules/accounting/ui/PostingGroups/InventoryPostingGroupsTable.tsx
+++ b/apps/carbon/app/modules/accounting/ui/PostingGroups/InventoryPostingGroupsTable.tsx
@@ -13,7 +13,7 @@ import usePostingGroups from "./usePostingGroups";
type InventoryPostingGroupsTableProps = {
data: InventoryPostingGroup[];
count: number;
- partGroups: ListItem[];
+ itemGroups: ListItem[];
locations: ListItem[];
balanceSheetAccounts: AccountListItem[];
incomeStatementAccounts: AccountListItem[];
@@ -22,7 +22,7 @@ type InventoryPostingGroupsTableProps = {
const InventoryPostingGroupsTable = ({
data,
count,
- partGroups,
+ itemGroups,
locations,
balanceSheetAccounts,
incomeStatementAccounts,
@@ -46,12 +46,12 @@ const InventoryPostingGroupsTable = ({
const columns = useMemo<ColumnDef<InventoryPostingGroup>[]>(() => {
return [
{
- id: "partGroupId",
- header: "Part Group",
+ id: "itemGroupId",
+ header: "Item Group",
cell: ({ row }) => (
<Enumerable
value={
- partGroups.find((group) => group.id === row.original.partGroupId)
+ itemGroups.find((group) => group.id === row.original.itemGroupId)
?.name ?? null
}
/>
@@ -59,7 +59,7 @@ const InventoryPostingGroupsTable = ({
meta: {
filter: {
type: "static",
- options: partGroups.map((group) => ({
+ options: itemGroups.map((group) => ({
label: <Enumerable value={group.name} />,
value: group.id,
})),
@@ -158,7 +158,7 @@ const InventoryPostingGroupsTable = ({
cell: (item) => item.getValue(),
},
];
- }, [locations, partGroups]);
+ }, [locations, itemGroups]);
const editableComponents = useMemo(
() => ({
diff --git a/apps/carbon/app/modules/accounting/ui/PostingGroups/PurchasingPostingGroupsTable.tsx b/apps/carbon/app/modules/accounting/ui/PostingGroups/PurchasingPostingGroupsTable.tsx
index 4e8faf1636..5c2b03d508 100644
--- a/apps/carbon/app/modules/accounting/ui/PostingGroups/PurchasingPostingGroupsTable.tsx
+++ b/apps/carbon/app/modules/accounting/ui/PostingGroups/PurchasingPostingGroupsTable.tsx
@@ -13,7 +13,7 @@ import usePostingGroups from "./usePostingGroups";
type PurchasingPostingGroupsTableProps = {
data: PurchasingPostingGroup[];
count: number;
- partGroups: ListItem[];
+ itemGroups: ListItem[];
supplierTypes: ListItem[];
balanceSheetAccounts: AccountListItem[];
incomeStatementAccounts: AccountListItem[];
@@ -22,7 +22,7 @@ type PurchasingPostingGroupsTableProps = {
const PurchasingPostingGroupsTable = ({
data,
count,
- partGroups,
+ itemGroups,
supplierTypes,
balanceSheetAccounts,
incomeStatementAccounts,
@@ -46,12 +46,12 @@ const PurchasingPostingGroupsTable = ({
const columns = useMemo<ColumnDef<PurchasingPostingGroup>[]>(() => {
return [
{
- id: "partGroupId",
- header: "Part Group",
+ id: "itemGroupId",
+ header: "Item Group",
cell: ({ row }) => (
<Enumerable
value={
- partGroups.find((group) => group.id === row.original.partGroupId)
+ itemGroups.find((group) => group.id === row.original.itemGroupId)
?.name ?? null
}
/>
@@ -59,7 +59,7 @@ const PurchasingPostingGroupsTable = ({
meta: {
filter: {
type: "static",
- options: partGroups.map((group) => ({
+ options: itemGroups.map((group) => ({
label: <Enumerable value={group.name} />,
value: group.id,
})),
@@ -119,7 +119,7 @@ const PurchasingPostingGroupsTable = ({
cell: (item) => item.getValue(),
},
];
- }, [supplierTypes, partGroups]);
+ }, [supplierTypes, itemGroups]);
const editableComponents = useMemo(
() => ({
diff --git a/apps/carbon/app/modules/accounting/ui/PostingGroups/SalesPostingGroupsTable.tsx b/apps/carbon/app/modules/accounting/ui/PostingGroups/SalesPostingGroupsTable.tsx
index 48a1e5ead3..202d57b070 100644
--- a/apps/carbon/app/modules/accounting/ui/PostingGroups/SalesPostingGroupsTable.tsx
+++ b/apps/carbon/app/modules/accounting/ui/PostingGroups/SalesPostingGroupsTable.tsx
@@ -10,7 +10,7 @@ import usePostingGroups from "./usePostingGroups";
type SalesPostingGroupsTableProps = {
data: SalesPostingGroup[];
count: number;
- partGroups: ListItem[];
+ itemGroups: ListItem[];
customerTypes: ListItem[];
balanceSheetAccounts: AccountListItem[];
incomeStatementAccounts: AccountListItem[];
@@ -19,7 +19,7 @@ type SalesPostingGroupsTableProps = {
const SalesPostingGroupsTable = ({
data,
count,
- partGroups,
+ itemGroups,
customerTypes,
balanceSheetAccounts,
incomeStatementAccounts,
@@ -43,12 +43,12 @@ const SalesPostingGroupsTable = ({
const columns = useMemo<ColumnDef<SalesPostingGroup>[]>(() => {
return [
{
- id: "partGroupId",
- header: "Part Group",
+ id: "itemGroupId",
+ header: "Item Group",
cell: ({ row }) => (
<Enumerable
value={
- partGroups.find((group) => group.id === row.original.partGroupId)
+ itemGroups.find((group) => group.id === row.original.itemGroupId)
?.name ?? null
}
/>
@@ -56,7 +56,7 @@ const SalesPostingGroupsTable = ({
meta: {
filter: {
type: "static",
- options: partGroups.map((group) => ({
+ options: itemGroups.map((group) => ({
label: <Enumerable value={group.name} />,
value: group.id,
})),
@@ -116,7 +116,7 @@ const SalesPostingGroupsTable = ({
cell: (item) => item.getValue(),
},
];
- }, [customerTypes, partGroups]);
+ }, [customerTypes, itemGroups]);
const editableComponents = useMemo(
() => ({
diff --git a/apps/carbon/app/modules/parts/parts.models.ts b/apps/carbon/app/modules/parts/parts.models.ts
index cbeadc1f82..3e2ff0e312 100644
--- a/apps/carbon/app/modules/parts/parts.models.ts
+++ b/apps/carbon/app/modules/parts/parts.models.ts
@@ -31,7 +31,7 @@ export const itemValidator = z.object({
id: z.string().min(1, { message: "Item ID is required" }).max(255),
name: z.string().min(1, { message: "Name is required" }).max(255),
description: zfd.text(z.string().optional()),
- partGroupId: zfd.text(z.string().optional()),
+ itemGroupId: zfd.text(z.string().optional()),
blocked: zfd.checkbox(),
active: zfd.checkbox(),
});
@@ -67,7 +67,7 @@ export const partCostValidator = z.object({
costIsAdjusted: zfd.checkbox(),
});
-export const partGroupValidator = z.object({
+export const itemGroupValidator = z.object({
id: zfd.text(z.string().optional()),
name: z.string().min(1, { message: "Name is required" }).max(255),
description: z.string().optional(),
diff --git a/apps/carbon/app/modules/parts/parts.service.ts b/apps/carbon/app/modules/parts/parts.service.ts
index bfc2aa9b2d..5750c98754 100644
--- a/apps/carbon/app/modules/parts/parts.service.ts
+++ b/apps/carbon/app/modules/parts/parts.service.ts
@@ -6,9 +6,9 @@ import type { GenericQueryFilters } from "~/utils/query";
import { setGenericQueryFilters } from "~/utils/query";
import { sanitize } from "~/utils/supabase";
import type {
+ itemGroupValidator,
itemValidator,
partCostValidator,
- partGroupValidator,
partInventoryValidator,
partManufacturingValidator,
partPlanningValidator,
@@ -22,11 +22,11 @@ import type {
} from "./parts.models";
import type { PartReplenishmentSystem, ServiceType } from "./types";
-export async function deletePartGroup(
+export async function deleteItemGroup(
client: SupabaseClient<Database>,
id: string
) {
- return client.from("partGroup").delete().eq("id", id);
+ return client.from("itemGroup").delete().eq("id", id);
}
export async function deleteUnitOfMeasure(
@@ -49,20 +49,20 @@ export async function getPartCost(
.single();
}
-export async function getPartGroup(
+export async function getItemGroup(
client: SupabaseClient<Database>,
id: string
) {
- return client.from("partGroup").select("*").eq("id", id).single();
+ return client.from("itemGroup").select("*").eq("id", id).single();
}
-export async function getPartGroups(
+export async function getItemGroups(
client: SupabaseClient<Database>,
companyId: string,
args?: GenericQueryFilters & { search: string | null }
) {
let query = client
- .from("partGroup")
+ .from("itemGroup")
.select("*", {
count: "exact",
})
@@ -81,12 +81,12 @@ export async function getPartGroups(
return query;
}
-export async function getPartGroupsList(
+export async function getItemGroupsList(
client: SupabaseClient<Database>,
companyId: string
) {
return client
- .from("partGroup")
+ .from("itemGroup")
.select("id, name", { count: "exact" })
.eq("companyId", companyId)
.order("name");
@@ -290,7 +290,7 @@ export async function getServices(
}
if (args.group) {
- query = query.eq("partGroupId", args.group);
+ query = query.eq("itemGroupId", args.group);
}
if (args.supplierId) {
@@ -490,7 +490,7 @@ export async function upsertPart(
id: part.id,
name: part.name,
description: part.description,
- partGroupId: part.partGroupId,
+ itemGroupId: part.itemGroupId,
active: part.active,
blocked: part.blocked,
};
@@ -622,29 +622,29 @@ export async function upsertPartPurchasing(
.eq("partId", partPurchasing.partId);
}
-export async function upsertPartGroup(
+export async function upsertItemGroup(
client: SupabaseClient<Database>,
- partGroup:
- | (Omit<z.infer<typeof partGroupValidator>, "id"> & {
+ itemGroup:
+ | (Omit<z.infer<typeof itemGroupValidator>, "id"> & {
companyId: string;
createdBy: string;
customFields?: Json;
})
- | (Omit<z.infer<typeof partGroupValidator>, "id"> & {
+ | (Omit<z.infer<typeof itemGroupValidator>, "id"> & {
id: string;
updatedBy: string;
customFields?: Json;
})
) {
- if ("createdBy" in partGroup) {
- return client.from("partGroup").insert([partGroup]).select("*").single();
+ if ("createdBy" in itemGroup) {
+ return client.from("itemGroup").insert([itemGroup]).select("*").single();
}
return (
client
- .from("partGroup")
- .update(sanitize(partGroup))
+ .from("itemGroup")
+ .update(sanitize(itemGroup))
// @ts-ignore
- .eq("id", partGroup.id)
+ .eq("id", itemGroup.id)
.select("id")
.single()
);
@@ -737,7 +737,7 @@ export async function upsertService(
id: service.id,
name: service.name,
description: service.description,
- partGroupId: service.partGroupId,
+ itemGroupId: service.itemGroupId,
active: service.active,
blocked: service.blocked,
};
diff --git a/apps/carbon/app/modules/parts/types.ts b/apps/carbon/app/modules/parts/types.ts
index 7e6ce22bef..a2a0f71da4 100644
--- a/apps/carbon/app/modules/parts/types.ts
+++ b/apps/carbon/app/modules/parts/types.ts
@@ -1,9 +1,9 @@
import type { Database } from "@carbon/database";
import type {
+ getItemGroups,
+ getItemGroupsList,
getPart,
getPartCost,
- getPartGroups,
- getPartGroupsList,
getPartQuantities,
getPartSuppliers,
getParts,
@@ -20,12 +20,12 @@ export type PartCost = NonNullable<
export type PartCostingMethod =
Database["public"]["Enums"]["partCostingMethod"];
-export type PartGroup = NonNullable<
- Awaited<ReturnType<typeof getPartGroups>>["data"]
+export type ItemGroup = NonNullable<
+ Awaited<ReturnType<typeof getItemGroups>>["data"]
>[number];
-export type PartGroupListItem = NonNullable<
- Awaited<ReturnType<typeof getPartGroupsList>>["data"]
+export type ItemGroupListItem = NonNullable<
+ Awaited<ReturnType<typeof getItemGroupsList>>["data"]
>[number];
export type PartQuantities = NonNullable<
diff --git a/apps/carbon/app/modules/parts/ui/Item/ItemForm.tsx b/apps/carbon/app/modules/parts/ui/Item/ItemForm.tsx
index 960a58cf96..96aeef084f 100644
--- a/apps/carbon/app/modules/parts/ui/Item/ItemForm.tsx
+++ b/apps/carbon/app/modules/parts/ui/Item/ItemForm.tsx
@@ -14,7 +14,7 @@ import {
CustomFormFields,
Hidden,
Input,
- PartGroup,
+ ItemGroup,
Submit,
} from "~/components/Form";
import { usePermissions } from "~/hooks";
@@ -57,7 +57,7 @@ const ItemForm = ({ initialValues, type }: ItemFormProps) => {
/>
<Input name="name" label="Name" />
- <PartGroup name="partGroupId" label="Part Group" />
+ <ItemGroup name="itemGroupId" label="Item Group" />
<Boolean name="active" label="Active" />
<Boolean name="blocked" label="Blocked" />
diff --git a/apps/carbon/app/modules/parts/ui/PartGroups/PartGroupForm.tsx b/apps/carbon/app/modules/parts/ui/ItemGroups/ItemGroupForm.tsx
similarity index 82%
rename from apps/carbon/app/modules/parts/ui/PartGroups/PartGroupForm.tsx
rename to apps/carbon/app/modules/parts/ui/ItemGroups/ItemGroupForm.tsx
index 79557f78da..4c8fb6ffbf 100644
--- a/apps/carbon/app/modules/parts/ui/PartGroups/PartGroupForm.tsx
+++ b/apps/carbon/app/modules/parts/ui/ItemGroups/ItemGroupForm.tsx
@@ -24,22 +24,22 @@ import {
TextArea,
} from "~/components/Form";
import { usePermissions } from "~/hooks";
-import { partGroupValidator } from "~/modules/parts";
+import { itemGroupValidator } from "~/modules/parts";
import { path } from "~/utils/path";
-type PartGroupFormProps = {
- initialValues: z.infer<typeof partGroupValidator>;
+type ItemGroupFormProps = {
+ initialValues: z.infer<typeof itemGroupValidator>;
type?: "modal" | "drawer";
open?: boolean;
onClose: (data?: { id: string; name: string }) => void;
};
-const PartGroupForm = ({
+const ItemGroupForm = ({
initialValues,
open = true,
type = "drawer",
onClose,
-}: PartGroupFormProps) => {
+}: ItemGroupFormProps) => {
const permissions = usePermissions();
const fetcher = useFetcher<PostgrestResponse<{ id: string; name: string }>>();
@@ -53,9 +53,9 @@ const PartGroupForm = ({
if (fetcher.state === "loading" && fetcher.data?.data) {
onClose?.();
- toast.success(`Created part group`);
+ toast.success(`Created item group`);
} else if (fetcher.state === "idle" && fetcher.data?.error) {
- toast.error(`Failed to create part group: ${fetcher.data.error.message}`);
+ toast.error(`Failed to create item group: ${fetcher.data.error.message}`);
}
}, [fetcher.data, fetcher.state, onClose, type]);
@@ -69,12 +69,12 @@ const PartGroupForm = ({
>
<ModalDrawerContent>
<ValidatedForm
- validator={partGroupValidator}
+ validator={itemGroupValidator}
method="post"
action={
isEditing
- ? path.to.partGroup(initialValues.id!)
- : path.to.newPartGroup
+ ? path.to.itemGroup(initialValues.id!)
+ : path.to.newItemGroup
}
defaultValues={initialValues}
fetcher={fetcher}
@@ -82,7 +82,7 @@ const PartGroupForm = ({
>
<ModalDrawerHeader>
<ModalDrawerTitle>
- {isEditing ? "Edit" : "New"} Part Group
+ {isEditing ? "Edit" : "New"} Item Group
</ModalDrawerTitle>
</ModalDrawerHeader>
<ModalDrawerBody>
@@ -91,7 +91,7 @@ const PartGroupForm = ({
<VStack spacing={4}>
<Input name="name" label="Name" />
<TextArea name="description" label="Description" />
- <CustomFormFields table="partGroup" />
+ <CustomFormFields table="itemGroup" />
</VStack>
</ModalDrawerBody>
<ModalDrawerFooter>
@@ -109,4 +109,4 @@ const PartGroupForm = ({
);
};
-export default PartGroupForm;
+export default ItemGroupForm;
diff --git a/apps/carbon/app/modules/parts/ui/PartGroups/PartGroupsTable.tsx b/apps/carbon/app/modules/parts/ui/ItemGroups/ItemGroupsTable.tsx
similarity index 77%
rename from apps/carbon/app/modules/parts/ui/PartGroups/PartGroupsTable.tsx
rename to apps/carbon/app/modules/parts/ui/ItemGroups/ItemGroupsTable.tsx
index f3fd54e47b..ad925d9150 100644
--- a/apps/carbon/app/modules/parts/ui/PartGroups/PartGroupsTable.tsx
+++ b/apps/carbon/app/modules/parts/ui/ItemGroups/ItemGroupsTable.tsx
@@ -6,21 +6,21 @@ import { LuPencil, LuTrash } from "react-icons/lu";
import { New, Table } from "~/components";
import { usePermissions, useUrlParams } from "~/hooks";
import { useCustomColumns } from "~/hooks/useCustomColumns";
-import type { PartGroup } from "~/modules/parts";
+import type { ItemGroup } from "~/modules/parts";
import { path } from "~/utils/path";
-type PartGroupsTableProps = {
- data: PartGroup[];
+type ItemGroupsTableProps = {
+ data: ItemGroup[];
count: number;
};
-const PartGroupsTable = memo(({ data, count }: PartGroupsTableProps) => {
+const ItemGroupsTable = memo(({ data, count }: ItemGroupsTableProps) => {
const [params] = useUrlParams();
const navigate = useNavigate();
const permissions = usePermissions();
const rows = useMemo(() => data, [data]);
- const customColumns = useCustomColumns<PartGroup>("partGroup");
+ const customColumns = useCustomColumns<ItemGroup>("itemGroup");
const columns = useMemo<ColumnDef<(typeof rows)[number]>[]>(() => {
const defaultColumns: ColumnDef<(typeof rows)[number]>[] = [
@@ -32,7 +32,7 @@ const PartGroupsTable = memo(({ data, count }: PartGroupsTableProps) => {
value={row.original.name}
onClick={() =>
navigate(
- `${path.to.partGroup(row.original.id)}?${params.toString()}`
+ `${path.to.itemGroup(row.original.id)}?${params.toString()}`
)
}
className="cursor-pointer"
@@ -55,22 +55,22 @@ const PartGroupsTable = memo(({ data, count }: PartGroupsTableProps) => {
<MenuItem
disabled={!permissions.can("update", "parts")}
onClick={() => {
- navigate(`${path.to.partGroup(row.id)}?${params.toString()}`);
+ navigate(`${path.to.itemGroup(row.id)}?${params.toString()}`);
}}
>
<MenuIcon icon={<LuPencil />} />
- Edit Part Group
+ Edit Item Group
</MenuItem>
<MenuItem
disabled={!permissions.can("delete", "parts")}
onClick={() => {
navigate(
- `${path.to.deletePartGroup(row.id)}?${params.toString()}`
+ `${path.to.deleteItemGroup(row.id)}?${params.toString()}`
);
}}
>
<MenuIcon icon={<LuTrash />} />
- Delete Part Group
+ Delete Item Group
</MenuItem>
</>
);
@@ -86,8 +86,8 @@ const PartGroupsTable = memo(({ data, count }: PartGroupsTableProps) => {
primaryAction={
permissions.can("create", "parts") && (
<New
- label="Part Group"
- to={`${path.to.newPartGroup}?${params.toString()}`}
+ label="Item Group"
+ to={`${path.to.newItemGroup}?${params.toString()}`}
/>
)
}
@@ -96,5 +96,5 @@ const PartGroupsTable = memo(({ data, count }: PartGroupsTableProps) => {
);
});
-PartGroupsTable.displayName = "PartGroupsTable";
-export default PartGroupsTable;
+ItemGroupsTable.displayName = "ItemGroupsTable";
+export default ItemGroupsTable;
diff --git a/apps/carbon/app/modules/parts/ui/ItemGroups/index.ts b/apps/carbon/app/modules/parts/ui/ItemGroups/index.ts
new file mode 100644
index 0000000000..025ed88462
--- /dev/null
+++ b/apps/carbon/app/modules/parts/ui/ItemGroups/index.ts
@@ -0,0 +1,4 @@
+import ItemGroupForm from "./ItemGroupForm";
+import ItemGroupsTable from "./ItemGroupsTable";
+
+export { ItemGroupForm, ItemGroupsTable };
diff --git a/apps/carbon/app/modules/parts/ui/Part/PartForm.tsx b/apps/carbon/app/modules/parts/ui/Part/PartForm.tsx
index ce0654420c..d004f4dfa7 100644
--- a/apps/carbon/app/modules/parts/ui/Part/PartForm.tsx
+++ b/apps/carbon/app/modules/parts/ui/Part/PartForm.tsx
@@ -21,7 +21,7 @@ import {
Hidden,
Input,
InputControlled,
- PartGroup,
+ ItemGroup,
Select,
Submit,
TextArea,
@@ -171,7 +171,7 @@ const PartForm = ({ initialValues, type = "card", onClose }: PartFormProps) => {
)}
<Input name="name" label="Name" />
- <PartGroup name="partGroupId" label="Part Group" />
+ <ItemGroup name="itemGroupId" label="Item Group" />
{isEditing && (
<TextArea name="description" label="Description" />
)}
diff --git a/apps/carbon/app/modules/parts/ui/PartGroups/index.ts b/apps/carbon/app/modules/parts/ui/PartGroups/index.ts
deleted file mode 100644
index f6a2612ff2..0000000000
--- a/apps/carbon/app/modules/parts/ui/PartGroups/index.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-import PartGroupForm from "./PartGroupForm";
-import PartGroupsTable from "./PartGroupsTable";
-
-export { PartGroupForm, PartGroupsTable };
diff --git a/apps/carbon/app/modules/parts/ui/Parts/PartsTable.tsx b/apps/carbon/app/modules/parts/ui/Parts/PartsTable.tsx
index dd5321ebd1..ceccadaff0 100644
--- a/apps/carbon/app/modules/parts/ui/Parts/PartsTable.tsx
+++ b/apps/carbon/app/modules/parts/ui/Parts/PartsTable.tsx
@@ -15,11 +15,11 @@ import { path } from "~/utils/path";
type PartsTableProps = {
data: Part[];
- partGroups: ListItem[];
+ itemGroups: ListItem[];
count: number;
};
-const PartsTable = memo(({ data, count, partGroups }: PartsTableProps) => {
+const PartsTable = memo(({ data, count, itemGroups }: PartsTableProps) => {
const navigate = useNavigate();
const [params] = useUrlParams();
const permissions = usePermissions();
@@ -76,13 +76,13 @@ const PartsTable = memo(({ data, count, partGroups }: PartsTableProps) => {
},
},
{
- accessorKey: "partGroup",
- header: "Part Group",
+ accessorKey: "itemGroup",
+ header: "Item Group",
cell: (item) => <Enumerable value={item.getValue<string>()} />,
meta: {
filter: {
type: "static",
- options: partGroups.map(({ name }) => ({
+ options: itemGroups.map(({ name }) => ({
value: name,
label: <Enumerable value={name} />,
})),
diff --git a/apps/carbon/app/modules/parts/ui/Service/ServiceForm.tsx b/apps/carbon/app/modules/parts/ui/Service/ServiceForm.tsx
index d987a6c985..52635bfa5c 100644
--- a/apps/carbon/app/modules/parts/ui/Service/ServiceForm.tsx
+++ b/apps/carbon/app/modules/parts/ui/Service/ServiceForm.tsx
@@ -15,7 +15,7 @@ import {
CustomFormFields,
Input,
InputControlled,
- PartGroup,
+ ItemGroup,
Select,
Submit,
TextArea,
@@ -124,7 +124,7 @@ const ServiceForm = ({ initialValues }: ServiceFormProps) => {
/>
)}
<Input name="name" label="Name" />
- <PartGroup name="partGroupId" label="Part Group" />
+ <ItemGroup name="itemGroupId" label="Item Group" />
<TextArea name="description" label="Description" />
<Select
diff --git a/apps/carbon/app/modules/parts/ui/Services/ServicesTable.tsx b/apps/carbon/app/modules/parts/ui/Services/ServicesTable.tsx
index f48435580e..f2d474d8b3 100644
--- a/apps/carbon/app/modules/parts/ui/Services/ServicesTable.tsx
+++ b/apps/carbon/app/modules/parts/ui/Services/ServicesTable.tsx
@@ -15,12 +15,12 @@ import { path } from "~/utils/path";
type ServicesTableProps = {
data: Service[];
- partGroups: ListItem[];
+ itemGroups: ListItem[];
count: number;
};
const ServicesTable = memo(
- ({ data, count, partGroups }: ServicesTableProps) => {
+ ({ data, count, itemGroups }: ServicesTableProps) => {
const navigate = useNavigate();
const permissions = usePermissions();
const customColumns = useCustomColumns<Service>("part");
@@ -62,13 +62,13 @@ const ServicesTable = memo(
},
},
{
- accessorKey: "partGroup",
- header: "Part Group",
+ accessorKey: "itemGroup",
+ header: "Item Group",
cell: (item) => <Enumerable value={item.getValue<string>()} />,
meta: {
filter: {
type: "static",
- options: partGroups.map(({ id, name }) => ({
+ options: itemGroups.map(({ id, name }) => ({
value: name,
label: <Enumerable value={name} />,
})),
@@ -165,7 +165,7 @@ const ServicesTable = memo(
},
];
return [...defaultColumns, ...customColumns];
- }, [customColumns, partGroups, people]);
+ }, [customColumns, itemGroups, people]);
const renderContextMenu = useMemo(() => {
// eslint-disable-next-line react/display-name
diff --git a/apps/carbon/app/modules/parts/ui/index.ts b/apps/carbon/app/modules/parts/ui/index.ts
index 9f9ba1951f..5494d77158 100644
--- a/apps/carbon/app/modules/parts/ui/index.ts
+++ b/apps/carbon/app/modules/parts/ui/index.ts
@@ -1,8 +1,8 @@
import usePartsSubmodules from "./usePartsSubmodules";
export * from "./Item";
+export * from "./ItemGroups";
export * from "./Part";
-export * from "./PartGroups";
export * from "./Parts";
export * from "./Routing";
export * from "./Service";
diff --git a/apps/carbon/app/modules/parts/ui/usePartsSubmodules.tsx b/apps/carbon/app/modules/parts/ui/usePartsSubmodules.tsx
index b024422162..d72ca4a44b 100644
--- a/apps/carbon/app/modules/parts/ui/usePartsSubmodules.tsx
+++ b/apps/carbon/app/modules/parts/ui/usePartsSubmodules.tsx
@@ -25,8 +25,8 @@ const partsRoutes: AuthenticatedRouteGroup[] = [
name: "Configure",
routes: [
{
- name: "Part Groups",
- to: path.to.partGroups,
+ name: "Item Groups",
+ to: path.to.itemGroups,
role: "employee",
},
{
diff --git a/apps/carbon/app/routes/api+/parts.groups.ts b/apps/carbon/app/routes/api+/parts.groups.ts
index 4cbdc23054..51638db9c9 100644
--- a/apps/carbon/app/routes/api+/parts.groups.ts
+++ b/apps/carbon/app/routes/api+/parts.groups.ts
@@ -1,10 +1,10 @@
import type { LoaderFunctionArgs } from "@remix-run/node";
import { json } from "@remix-run/node";
-import { getPartGroupsList } from "~/modules/parts";
+import { getItemGroupsList } from "~/modules/parts";
import { requirePermissions } from "~/services/auth/auth.server";
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {});
- return json(await getPartGroupsList(client, companyId));
+ return json(await getItemGroupsList(client, companyId));
}
diff --git a/apps/carbon/app/routes/x+/accounting+/groups.inventory.tsx b/apps/carbon/app/routes/x+/accounting+/groups.inventory.tsx
index 2fd8ac8175..e2d790c8c0 100644
--- a/apps/carbon/app/routes/x+/accounting+/groups.inventory.tsx
+++ b/apps/carbon/app/routes/x+/accounting+/groups.inventory.tsx
@@ -8,7 +8,7 @@ import {
InventoryPostingGroupsTable,
getInventoryPostingGroups,
} from "~/modules/accounting";
-import { getPartGroupsList } from "~/modules/parts";
+import { getItemGroupsList } from "~/modules/parts";
import { getLocationsList } from "~/modules/resources";
import { requirePermissions } from "~/services/auth/auth.server";
import { flash } from "~/services/session.server";
@@ -33,14 +33,14 @@ export async function loader({ request }: LoaderFunctionArgs) {
const { limit, offset, sorts, filters } =
getGenericQueryFilters(searchParams);
- const [inventoryGroups, partGroups, locations] = await Promise.all([
+ const [inventoryGroups, itemGroups, locations] = await Promise.all([
getInventoryPostingGroups(client, companyId, {
limit,
offset,
sorts,
filters,
}),
- getPartGroupsList(client, companyId),
+ getItemGroupsList(client, companyId),
getLocationsList(client, companyId),
]);
if (inventoryGroups.error) {
@@ -55,14 +55,14 @@ export async function loader({ request }: LoaderFunctionArgs) {
return json({
data: inventoryGroups.data ?? [],
- partGroups: partGroups.data ?? [],
+ itemGroups: itemGroups.data ?? [],
locations: locations.data ?? [],
count: inventoryGroups.count ?? 0,
});
}
export default function InventoryPostingGroupsRoute() {
- const { data, partGroups, locations, count } = useLoaderData<typeof loader>();
+ const { data, itemGroups, locations, count } = useLoaderData<typeof loader>();
const routeData = useRouteData<{
balanceSheetAccounts: AccountListItem[];
@@ -74,7 +74,7 @@ export default function InventoryPostingGroupsRoute() {
<InventoryPostingGroupsTable
data={data}
count={count}
- partGroups={partGroups}
+ itemGroups={itemGroups}
locations={locations}
balanceSheetAccounts={routeData?.balanceSheetAccounts ?? []}
incomeStatementAccounts={routeData?.incomeStatementAccounts ?? []}
diff --git a/apps/carbon/app/routes/x+/accounting+/groups.purchasing.tsx b/apps/carbon/app/routes/x+/accounting+/groups.purchasing.tsx
index b9087feb13..6e4226c8f0 100644
--- a/apps/carbon/app/routes/x+/accounting+/groups.purchasing.tsx
+++ b/apps/carbon/app/routes/x+/accounting+/groups.purchasing.tsx
@@ -8,7 +8,7 @@ import {
PurchasingPostingGroupsTable,
getPurchasingPostingGroups,
} from "~/modules/accounting";
-import { getPartGroupsList } from "~/modules/parts";
+import { getItemGroupsList } from "~/modules/parts";
import { getSupplierTypesList } from "~/modules/purchasing";
import { requirePermissions } from "~/services/auth/auth.server";
import { flash } from "~/services/session.server";
@@ -32,14 +32,14 @@ export async function loader({ request }: LoaderFunctionArgs) {
const { limit, offset, sorts, filters } =
getGenericQueryFilters(searchParams);
- const [purchasingGroups, partGroups, supplierTypes] = await Promise.all([
+ const [purchasingGroups, itemGroups, supplierTypes] = await Promise.all([
getPurchasingPostingGroups(client, companyId, {
limit,
offset,
sorts,
filters,
}),
- getPartGroupsList(client, companyId),
+ getItemGroupsList(client, companyId),
getSupplierTypesList(client, companyId),
]);
if (purchasingGroups.error) {
@@ -57,14 +57,14 @@ export async function loader({ request }: LoaderFunctionArgs) {
return json({
data: purchasingGroups.data ?? [],
- partGroups: partGroups.data ?? [],
+ itemGroups: itemGroups.data ?? [],
supplierTypes: supplierTypes.data ?? [],
count: purchasingGroups.count ?? 0,
});
}
export default function PurchasingPostingGroupsRoute() {
- const { data, partGroups, supplierTypes, count } =
+ const { data, itemGroups, supplierTypes, count } =
useLoaderData<typeof loader>();
const routeData = useRouteData<{
@@ -77,7 +77,7 @@ export default function PurchasingPostingGroupsRoute() {
<PurchasingPostingGroupsTable
data={data}
count={count}
- partGroups={partGroups}
+ itemGroups={itemGroups}
supplierTypes={supplierTypes}
balanceSheetAccounts={routeData?.balanceSheetAccounts ?? []}
incomeStatementAccounts={routeData?.incomeStatementAccounts ?? []}
diff --git a/apps/carbon/app/routes/x+/accounting+/groups.sales.tsx b/apps/carbon/app/routes/x+/accounting+/groups.sales.tsx
index 1d802a49ce..740b880542 100644
--- a/apps/carbon/app/routes/x+/accounting+/groups.sales.tsx
+++ b/apps/carbon/app/routes/x+/accounting+/groups.sales.tsx
@@ -8,7 +8,7 @@ import {
SalesPostingGroupsTable,
getSalesPostingGroups,
} from "~/modules/accounting";
-import { getPartGroupsList } from "~/modules/parts";
+import { getItemGroupsList } from "~/modules/parts";
import { getCustomerTypesList } from "~/modules/sales";
import { requirePermissions } from "~/services/auth/auth.server";
import { flash } from "~/services/session.server";
@@ -32,14 +32,14 @@ export async function loader({ request }: LoaderFunctionArgs) {
const { limit, offset, sorts, filters } =
getGenericQueryFilters(searchParams);
- const [salesGroups, partGroups, customerTypes] = await Promise.all([
+ const [salesGroups, itemGroups, customerTypes] = await Promise.all([
getSalesPostingGroups(client, companyId, {
limit,
offset,
sorts,
filters,
}),
- getPartGroupsList(client, companyId),
+ getItemGroupsList(client, companyId),
getCustomerTypesList(client, companyId),
]);
if (salesGroups.error) {
@@ -55,13 +55,13 @@ export async function loader({ request }: LoaderFunctionArgs) {
return json({
data: salesGroups.data ?? [],
count: salesGroups.count ?? 0,
- partGroups: partGroups.data ?? [],
+ itemGroups: itemGroups.data ?? [],
customerTypes: customerTypes.data ?? [],
});
}
export default function SalesPostingGroupsRoute() {
- const { data, count, partGroups, customerTypes } =
+ const { data, count, itemGroups, customerTypes } =
useLoaderData<typeof loader>();
const routeData = useRouteData<{
@@ -74,7 +74,7 @@ export default function SalesPostingGroupsRoute() {
<SalesPostingGroupsTable
data={data}
count={count}
- partGroups={partGroups}
+ itemGroups={itemGroups}
customerTypes={customerTypes}
balanceSheetAccounts={routeData?.balanceSheetAccounts ?? []}
incomeStatementAccounts={routeData?.incomeStatementAccounts ?? []}
diff --git a/apps/carbon/app/routes/x+/part+/$itemId.details.tsx b/apps/carbon/app/routes/x+/part+/$itemId.details.tsx
index 9da12be1ab..eda4f1d70f 100644
--- a/apps/carbon/app/routes/x+/part+/$itemId.details.tsx
+++ b/apps/carbon/app/routes/x+/part+/$itemId.details.tsx
@@ -61,7 +61,7 @@ export default function PartDetailsRoute() {
itemId: partData.partSummary?.itemId ?? "",
name: partData.partSummary?.name ?? "",
description: partData.partSummary?.description ?? "",
- partGroupId: partData.partSummary?.partGroupId ?? "",
+ itemGroupId: partData.partSummary?.itemGroupId ?? "",
active: partData.partSummary?.active ?? true,
blocked: partData.partSummary?.blocked ?? false,
partType: partData.partSummary?.partType ?? "Inventory",
diff --git a/apps/carbon/app/routes/x+/parts+/groups.$groupId.tsx b/apps/carbon/app/routes/x+/parts+/groups.$groupId.tsx
index 7882b96bef..6610ac0dd8 100644
--- a/apps/carbon/app/routes/x+/parts+/groups.$groupId.tsx
+++ b/apps/carbon/app/routes/x+/parts+/groups.$groupId.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 {
- PartGroupForm,
- getPartGroup,
- partGroupValidator,
- upsertPartGroup,
+ ItemGroupForm,
+ getItemGroup,
+ itemGroupValidator,
+ upsertItemGroup,
} from "~/modules/parts";
import { requirePermissions } from "~/services/auth/auth.server";
import { flash } from "~/services/session.server";
@@ -24,10 +24,10 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
const { groupId } = params;
if (!groupId) throw notFound("groupId not found");
- const partGroup = await getPartGroup(client, groupId);
+ const itemGroup = await getItemGroup(client, groupId);
return json({
- partGroup: partGroup?.data ?? null,
+ itemGroup: itemGroup?.data ?? null,
});
}
@@ -41,48 +41,48 @@ export async function action({ request, params }: ActionFunctionArgs) {
if (!groupId) throw new Error("Could not find groupId");
const formData = await request.formData();
- const validation = await validator(partGroupValidator).validate(formData);
+ const validation = await validator(itemGroupValidator).validate(formData);
if (validation.error) {
return validationError(validation.error);
}
- const updatePartGroup = await upsertPartGroup(client, {
+ const updateItemGroup = await upsertItemGroup(client, {
id: groupId,
...validation.data,
updatedBy: userId,
customFields: setCustomFields(formData),
});
- if (updatePartGroup.error) {
+ if (updateItemGroup.error) {
return json(
{},
await flash(
request,
- error(updatePartGroup.error, "Failed to update part group")
+ error(updateItemGroup.error, "Failed to update item group")
)
);
}
throw redirect(
- `${path.to.partGroups}?${getParams(request)}`,
- await flash(request, success("Updated part group"))
+ `${path.to.itemGroups}?${getParams(request)}`,
+ await flash(request, success("Updated item group"))
);
}
-export default function EditPartGroupsRoute() {
- const { partGroup } = useLoaderData<typeof loader>();
+export default function EditItemGroupsRoute() {
+ const { itemGroup } = useLoaderData<typeof loader>();
const navigate = useNavigate();
const initialValues = {
- id: partGroup?.id ?? undefined,
- name: partGroup?.name ?? "",
- description: partGroup?.description ?? "",
- ...getCustomFields(partGroup?.customFields),
+ id: itemGroup?.id ?? undefined,
+ name: itemGroup?.name ?? "",
+ description: itemGroup?.description ?? "",
+ ...getCustomFields(itemGroup?.customFields),
};
return (
- <PartGroupForm
+ <ItemGroupForm
key={initialValues.id}
initialValues={initialValues}
onClose={() => navigate(-1)}
diff --git a/apps/carbon/app/routes/x+/parts+/groups.delete.$groupId.tsx b/apps/carbon/app/routes/x+/parts+/groups.delete.$groupId.tsx
index 635067275e..aef7e5449b 100644
--- a/apps/carbon/app/routes/x+/parts+/groups.delete.$groupId.tsx
+++ b/apps/carbon/app/routes/x+/parts+/groups.delete.$groupId.tsx
@@ -2,7 +2,7 @@ import type { ActionFunctionArgs, LoaderFunctionArgs } 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 { deletePartGroup, getPartGroup } from "~/modules/parts";
+import { deleteItemGroup, getItemGroup } from "~/modules/parts";
import { requirePermissions } from "~/services/auth/auth.server";
import { flash } from "~/services/session.server";
import { notFound } from "~/utils/http";
@@ -16,15 +16,15 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
const { groupId } = params;
if (!groupId) throw notFound("groupId not found");
- const partGroup = await getPartGroup(client, groupId);
- if (partGroup.error) {
+ const itemGroup = await getItemGroup(client, groupId);
+ if (itemGroup.error) {
throw redirect(
- path.to.partGroups,
- await flash(request, error(partGroup.error, "Failed to get part group"))
+ path.to.itemGroups,
+ await flash(request, error(itemGroup.error, "Failed to get item group"))
);
}
- return json({ partGroup: partGroup.data });
+ return json({ itemGroup: itemGroup.data });
}
export async function action({ request, params }: ActionFunctionArgs) {
@@ -35,44 +35,44 @@ export async function action({ request, params }: ActionFunctionArgs) {
const { groupId } = params;
if (!groupId) {
throw redirect(
- path.to.partGroups,
- await flash(request, error(params, "Failed to get an part group id"))
+ path.to.itemGroups,
+ await flash(request, error(params, "Failed to get an item group id"))
);
}
- const { error: deleteTypeError } = await deletePartGroup(client, groupId);
+ const { error: deleteTypeError } = await deleteItemGroup(client, groupId);
if (deleteTypeError) {
throw redirect(
- `${path.to.partGroups}?${getParams(request)}`,
+ `${path.to.itemGroups}?${getParams(request)}`,
await flash(
request,
- error(deleteTypeError, "Failed to delete part group")
+ error(deleteTypeError, "Failed to delete item group")
)
);
}
throw redirect(
- path.to.partGroups,
- await flash(request, success("Successfully deleted part group"))
+ path.to.itemGroups,
+ await flash(request, success("Successfully deleted item group"))
);
}
-export default function DeletePartGroupRoute() {
+export default function DeleteItemGroupRoute() {
const { groupId } = useParams();
if (!groupId) throw new Error("groupId not found");
- const { partGroup } = useLoaderData<typeof loader>();
+ const { itemGroup } = useLoaderData<typeof loader>();
const navigate = useNavigate();
- if (!partGroup) return null;
+ if (!itemGroup) return null;
const onCancel = () => navigate(-1);
return (
<ConfirmDelete
- action={path.to.deletePartGroup(groupId)}
- name={partGroup.name}
- text={`Are you sure you want to delete the part group: ${partGroup.name}? This cannot be undone.`}
+ action={path.to.deleteItemGroup(groupId)}
+ name={itemGroup.name}
+ text={`Are you sure you want to delete the item group: ${itemGroup.name}? This cannot be undone.`}
onCancel={onCancel}
/>
);
diff --git a/apps/carbon/app/routes/x+/parts+/groups.new.tsx b/apps/carbon/app/routes/x+/parts+/groups.new.tsx
index e39d01cc2a..41e01a5e22 100644
--- a/apps/carbon/app/routes/x+/parts+/groups.new.tsx
+++ b/apps/carbon/app/routes/x+/parts+/groups.new.tsx
@@ -3,9 +3,9 @@ import type { ActionFunctionArgs, LoaderFunctionArgs } from "@remix-run/node";
import { json, redirect } from "@remix-run/node";
import { useNavigate } from "@remix-run/react";
import {
- PartGroupForm,
- partGroupValidator,
- upsertPartGroup,
+ ItemGroupForm,
+ itemGroupValidator,
+ upsertItemGroup,
} from "~/modules/parts";
import { requirePermissions } from "~/services/auth/auth.server";
import { flash } from "~/services/session.server";
@@ -31,7 +31,7 @@ export async function action({ request }: ActionFunctionArgs) {
const formData = await request.formData();
const modal = formData.get("type") == "modal";
- const validation = await validator(partGroupValidator).validate(formData);
+ const validation = await validator(itemGroupValidator).validate(formData);
if (validation.error) {
return validationError(validation.error);
@@ -39,42 +39,42 @@ export async function action({ request }: ActionFunctionArgs) {
const { id, ...data } = validation.data;
- const insertPartGroup = await upsertPartGroup(client, {
+ const insertItemGroup = await upsertItemGroup(client, {
...data,
companyId,
createdBy: userId,
customFields: setCustomFields(formData),
});
- if (insertPartGroup.error) {
+ if (insertItemGroup.error) {
return json(
{},
await flash(
request,
- error(insertPartGroup.error, "Failed to insert part group")
+ error(insertItemGroup.error, "Failed to insert item group")
)
);
}
- const partGroupId = insertPartGroup.data?.id;
- if (!partGroupId) {
+ const itemGroupId = insertItemGroup.data?.id;
+ if (!itemGroupId) {
return json(
{},
await flash(
request,
- error(insertPartGroup, "Failed to insert part group")
+ error(insertItemGroup, "Failed to insert item group")
)
);
}
return modal
- ? json(insertPartGroup, { status: 201 })
+ ? json(insertItemGroup, { status: 201 })
: redirect(
- `${path.to.partGroups}?${getParams(request)}`,
+ `${path.to.itemGroups}?${getParams(request)}`,
await flash(request, success("Part group created"))
);
}
-export default function NewPartGroupsRoute() {
+export default function NewItemGroupsRoute() {
const navigate = useNavigate();
const initialValues = {
name: "",
@@ -82,6 +82,6 @@ export default function NewPartGroupsRoute() {
};
return (
- <PartGroupForm onClose={() => navigate(-1)} initialValues={initialValues} />
+ <ItemGroupForm onClose={() => navigate(-1)} initialValues={initialValues} />
);
}
diff --git a/apps/carbon/app/routes/x+/parts+/groups.tsx b/apps/carbon/app/routes/x+/parts+/groups.tsx
index 993f79e014..c2ad9cbe99 100644
--- a/apps/carbon/app/routes/x+/parts+/groups.tsx
+++ b/apps/carbon/app/routes/x+/parts+/groups.tsx
@@ -3,7 +3,7 @@ import type { LoaderFunctionArgs } from "@remix-run/node";
import { json, redirect } from "@remix-run/node";
import { Outlet, useLoaderData } from "@remix-run/react";
import { getAccountsList } from "~/modules/accounting";
-import { PartGroupsTable, getPartGroups } from "~/modules/parts";
+import { ItemGroupsTable, getItemGroups } from "~/modules/parts";
import { requirePermissions } from "~/services/auth/auth.server";
import { flash } from "~/services/session.server";
import type { Handle } from "~/utils/handle";
@@ -12,8 +12,8 @@ import { getGenericQueryFilters } from "~/utils/query";
import { error } from "~/utils/result";
export const handle: Handle = {
- breadcrumb: "Part Groups",
- to: path.to.partGroups,
+ breadcrumb: "Item Groups",
+ to: path.to.itemGroups,
};
export async function loader({ request }: LoaderFunctionArgs) {
@@ -28,8 +28,8 @@ export async function loader({ request }: LoaderFunctionArgs) {
const { limit, offset, sorts, filters } =
getGenericQueryFilters(searchParams);
- const [partGroups, accounts] = await Promise.all([
- getPartGroups(client, companyId, {
+ const [itemGroups, accounts] = await Promise.all([
+ getItemGroups(client, companyId, {
limit,
offset,
sorts,
@@ -39,33 +39,33 @@ export async function loader({ request }: LoaderFunctionArgs) {
getAccountsList(client, companyId),
]);
- if (partGroups.error) {
+ if (itemGroups.error) {
throw redirect(
path.to.parts,
- await flash(request, error(null, "Error loading part groups"))
+ await flash(request, error(null, "Error loading item groups"))
);
}
if (accounts.error) {
throw redirect(
- path.to.partGroups,
+ path.to.itemGroups,
await flash(request, error(accounts.error, "Error loading accounts"))
);
}
return json({
- partGroups: partGroups.data ?? [],
- count: partGroups.count ?? 0,
+ itemGroups: itemGroups.data ?? [],
+ count: itemGroups.count ?? 0,
accounts: accounts.data ?? [],
});
}
-export default function PartGroupsRoute() {
- const { partGroups, count } = useLoaderData<typeof loader>();
+export default function ItemGroupsRoute() {
+ const { itemGroups, count } = useLoaderData<typeof loader>();
return (
<VStack spacing={0} className="h-full">
- <PartGroupsTable data={partGroups} count={count ?? 0} />
+ <ItemGroupsTable data={itemGroups} count={count ?? 0} />
<Outlet />
</VStack>
);
diff --git a/apps/carbon/app/routes/x+/parts+/search.tsx b/apps/carbon/app/routes/x+/parts+/search.tsx
index 6db2e69476..5068abec0b 100644
--- a/apps/carbon/app/routes/x+/parts+/search.tsx
+++ b/apps/carbon/app/routes/x+/parts+/search.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 { PartsTable, getPartGroupsList, getParts } from "~/modules/parts";
+import { PartsTable, getItemGroupsList, getParts } from "~/modules/parts";
import { requirePermissions } from "~/services/auth/auth.server";
import { flash } from "~/services/session.server";
import { path } from "~/utils/path";
@@ -22,7 +22,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
const { limit, offset, sorts, filters } =
getGenericQueryFilters(searchParams);
- const [parts, partGroups] = await Promise.all([
+ const [parts, itemGroups] = await Promise.all([
getParts(client, companyId, {
search,
supplierId,
@@ -31,7 +31,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
sorts,
filters,
}),
- getPartGroupsList(client, companyId),
+ getItemGroupsList(client, companyId),
]);
if (parts.error) {
@@ -44,16 +44,16 @@ export async function loader({ request }: LoaderFunctionArgs) {
return json({
count: parts.count ?? 0,
parts: parts.data ?? [],
- partGroups: partGroups.data ?? [],
+ itemGroups: itemGroups.data ?? [],
});
}
export default function PartsSearchRoute() {
- const { count, parts, partGroups } = useLoaderData<typeof loader>();
+ const { count, parts, itemGroups } = useLoaderData<typeof loader>();
return (
<VStack spacing={0} className="h-full">
- <PartsTable data={parts} count={count} partGroups={partGroups} />
+ <PartsTable data={parts} count={count} itemGroups={itemGroups} />
<Outlet />
</VStack>
);
diff --git a/apps/carbon/app/routes/x+/parts+/services.tsx b/apps/carbon/app/routes/x+/parts+/services.tsx
index 728320098f..879f678947 100644
--- a/apps/carbon/app/routes/x+/parts+/services.tsx
+++ b/apps/carbon/app/routes/x+/parts+/services.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 { ServicesTable, getPartGroupsList, getServices } from "~/modules/parts";
+import { ServicesTable, getItemGroupsList, getServices } from "~/modules/parts";
import { requirePermissions } from "~/services/auth/auth.server";
import { flash } from "~/services/session.server";
import type { Handle } from "~/utils/handle";
@@ -30,7 +30,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
const { limit, offset, sorts, filters } =
getGenericQueryFilters(searchParams);
- const [services, partGroups] = await Promise.all([
+ const [services, itemGroups] = await Promise.all([
getServices(client, companyId, {
search,
type,
@@ -41,7 +41,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
sorts,
filters,
}),
- getPartGroupsList(client, companyId),
+ getItemGroupsList(client, companyId),
]);
if (services.error) {
@@ -54,16 +54,16 @@ export async function loader({ request }: LoaderFunctionArgs) {
return json({
count: services.count ?? 0,
services: services.data ?? [],
- partGroups: partGroups.data ?? [],
+ itemGroups: itemGroups.data ?? [],
});
}
export default function ServicesSearchRoute() {
- const { count, services, partGroups } = useLoaderData<typeof loader>();
+ const { count, services, itemGroups } = useLoaderData<typeof loader>();
return (
<VStack spacing={0} className="h-full">
- <ServicesTable data={services} count={count} partGroups={partGroups} />
+ <ServicesTable data={services} count={count} itemGroups={itemGroups} />
<Outlet />
</VStack>
);
diff --git a/apps/carbon/app/routes/x+/service+/$itemId.details.tsx b/apps/carbon/app/routes/x+/service+/$itemId.details.tsx
index b2bd6ce35a..760340e2c2 100644
--- a/apps/carbon/app/routes/x+/service+/$itemId.details.tsx
+++ b/apps/carbon/app/routes/x+/service+/$itemId.details.tsx
@@ -60,7 +60,7 @@ export default function ServiceDetailsRoute() {
name: routeData.service?.name ?? "",
description: routeData.service?.description ?? undefined,
serviceType: routeData.service?.serviceType ?? "Internal",
- partGroupId: routeData.service?.partGroupId ?? undefined,
+ itemGroupId: routeData.service?.itemGroupId ?? undefined,
active: routeData.service?.active ?? true,
blocked: routeData.service?.blocked ?? false,
...getCustomFields(routeData.service?.customFields),
diff --git a/apps/carbon/app/routes/x+/service+/_layout.tsx b/apps/carbon/app/routes/x+/service+/_layout.tsx
index a01fa59836..576283f1c0 100644
--- a/apps/carbon/app/routes/x+/service+/_layout.tsx
+++ b/apps/carbon/app/routes/x+/service+/_layout.tsx
@@ -1,7 +1,7 @@
import { VStack } from "@carbon/react";
import type { LoaderFunctionArgs, MetaFunction } from "@remix-run/node";
import { Outlet } from "@remix-run/react";
-import { getPartGroupsList } from "~/modules/parts";
+import { getItemGroupsList } from "~/modules/parts";
import { getLocationsList } from "~/modules/resources";
import { requirePermissions } from "~/services/auth/auth.server";
import type { Handle } from "~/utils/handle";
@@ -22,14 +22,14 @@ export async function loader({ request }: LoaderFunctionArgs) {
view: "parts",
});
- const [partGroups, locations] = await Promise.all([
- getPartGroupsList(client, companyId),
+ const [itemGroups, locations] = await Promise.all([
+ getItemGroupsList(client, companyId),
getLocationsList(client, companyId),
]);
return {
locations: locations?.data ?? [],
- partGroups: partGroups?.data ?? [],
+ itemGroups: itemGroups?.data ?? [],
};
}
diff --git a/apps/carbon/app/utils/path.ts b/apps/carbon/app/utils/path.ts
index 0d95b4f1a9..a35505ef87 100644
--- a/apps/carbon/app/utils/path.ts
+++ b/apps/carbon/app/utils/path.ts
@@ -30,7 +30,7 @@ export const path = {
generatePath(`${api}/users/groups?type=${type}`),
item: (type: string) => generatePath(`${api}/item/${type}`),
locations: `${api}/resources/locations`,
- partGroups: `${api}/parts/groups`,
+ itemGroups: `${api}/parts/groups`,
rollback: (table: string, id: string) =>
generatePath(
`${api}/settings/sequence/rollback?table=${table}&currentSequence=${id}`
@@ -183,7 +183,7 @@ export const path = {
deleteLocation: (id: string) =>
generatePath(`${x}/resources/locations/delete/${id}`),
deleteNote: (id: string) => generatePath(`${x}/shared/notes/${id}/delete`),
- deletePartGroup: (id: string) =>
+ deleteItemGroup: (id: string) =>
generatePath(`${x}/parts/groups/delete/${id}`),
deletePartner: (id: string) =>
generatePath(`${x}/resources/partners/delete/${id}`),
@@ -313,7 +313,7 @@ export const path = {
newLocation: `${x}/resources/locations/new`,
newNote: `${x}/shared/notes/new`,
newPart: `${x}/part/new`,
- newPartGroup: `${x}/parts/groups/new`,
+ newItemGroup: `${x}/parts/groups/new`,
newPartSupplier: (id: string) =>
generatePath(`${x}/part/${id}/suppliers/new`),
newPartner: `${x}/resources/partners/new`,
@@ -370,8 +370,8 @@ export const path = {
part: (id: string) => generatePath(`${x}/part/${id}`),
partCosting: (id: string) => generatePath(`${x}/part/${id}/costing`),
partDetails: (id: string) => generatePath(`${x}/part/${id}/details`),
- partGroup: (id: string) => generatePath(`${x}/parts/groups/${id}`),
- partGroups: `${x}/parts/groups`,
+ itemGroup: (id: string) => generatePath(`${x}/parts/groups/${id}`),
+ itemGroups: `${x}/parts/groups`,
partInventory: (id: string) => generatePath(`${x}/part/${id}/inventory`),
partInventoryLocation: (id: string, locationId: string) =>
generatePath(`${x}/part/${id}/inventory?location=${locationId}`),
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index 57f902ced2..68a705ec68 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -5421,8 +5421,8 @@ export type Database = {
createdBy: string
description: string | null
id: string
+ itemGroupId: string | null
name: string
- partGroupId: string | null
readableId: string
type: Database["public"]["Enums"]["itemType"]
updatedAt: string | null
@@ -5436,8 +5436,8 @@ export type Database = {
createdBy: string
description?: string | null
id?: string
+ itemGroupId?: string | null
name: string
- partGroupId?: string | null
readableId: string
type: Database["public"]["Enums"]["itemType"]
updatedAt?: string | null
@@ -5451,8 +5451,8 @@ export type Database = {
createdBy?: string
description?: string | null
id?: string
+ itemGroupId?: string | null
name?: string
- partGroupId?: string | null
readableId?: string
type?: Database["public"]["Enums"]["itemType"]
updatedAt?: string | null
@@ -5523,10 +5523,10 @@ export type Database = {
referencedColumns: ["userId"]
},
{
- foreignKeyName: "item_partGroupId_fkey"
- columns: ["partGroupId"]
+ foreignKeyName: "item_itemGroupId_fkey"
+ columns: ["itemGroupId"]
isOneToOne: false
- referencedRelation: "partGroup"
+ referencedRelation: "itemGroup"
referencedColumns: ["id"]
},
{
@@ -5566,6 +5566,144 @@ export type Database = {
},
]
}
+ itemGroup: {
+ Row: {
+ active: boolean
+ companyId: string
+ createdAt: string
+ createdBy: string
+ customFields: Json | null
+ description: string | null
+ id: string
+ name: string
+ 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
+ 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
+ updatedAt?: string | null
+ updatedBy?: string | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "itemGroup_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemGroup_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemGroup_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "itemGroup_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "itemGroup_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemGroup_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemGroup_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemGroup_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemGroup_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "itemGroup_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemGroup_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemGroup_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemGroup_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemGroup_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ ]
+ }
journal: {
Row: {
accountingPeriodId: string | null
@@ -6277,261 +6415,123 @@ export type Database = {
}
Relationships: [
{
- foreignKeyName: "partCost_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "companies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "partCost_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "company"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "partCost_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "customFieldTables"
- referencedColumns: ["companyId"]
- },
- {
- foreignKeyName: "partCost_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "integrations"
- referencedColumns: ["companyId"]
- },
- {
- foreignKeyName: "partCost_partId_fkey"
- columns: ["partId", "companyId"]
- isOneToOne: false
- referencedRelation: "part"
- referencedColumns: ["id", "companyId"]
- },
- {
- foreignKeyName: "partCost_partId_fkey"
- columns: ["partId", "companyId"]
- isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["partId", "companyId"]
- },
- {
- foreignKeyName: "partCost_partId_fkey"
- columns: ["partId", "companyId"]
- isOneToOne: false
- referencedRelation: "parts"
- referencedColumns: ["id", "companyId"]
- },
- {
- foreignKeyName: "partGroup_createdBy_fkey"
+ foreignKeyName: "itemGroup_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partGroup_createdBy_fkey"
+ foreignKeyName: "itemGroup_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partGroup_createdBy_fkey"
+ foreignKeyName: "itemGroup_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partGroup_createdBy_fkey"
+ foreignKeyName: "itemGroup_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partGroup_createdBy_fkey"
+ foreignKeyName: "itemGroup_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
{
- foreignKeyName: "partGroup_updatedBy_fkey"
+ foreignKeyName: "itemGroup_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partGroup_updatedBy_fkey"
+ foreignKeyName: "itemGroup_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partGroup_updatedBy_fkey"
+ foreignKeyName: "itemGroup_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partGroup_updatedBy_fkey"
+ foreignKeyName: "itemGroup_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partGroup_updatedBy_fkey"
+ foreignKeyName: "itemGroup_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
- ]
- }
- partGroup: {
- Row: {
- active: boolean
- companyId: string
- createdAt: string
- createdBy: string
- customFields: Json | null
- description: string | null
- id: string
- name: string
- 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
- 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
- updatedAt?: string | null
- updatedBy?: string | null
- }
- Relationships: [
{
- foreignKeyName: "partGroup_companyId_fkey"
+ foreignKeyName: "partCost_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "companies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partGroup_companyId_fkey"
+ foreignKeyName: "partCost_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "company"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partGroup_companyId_fkey"
+ foreignKeyName: "partCost_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "customFieldTables"
referencedColumns: ["companyId"]
},
{
- foreignKeyName: "partGroup_companyId_fkey"
+ foreignKeyName: "partCost_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "integrations"
referencedColumns: ["companyId"]
},
{
- foreignKeyName: "partGroup_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "partGroup_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "partGroup_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "partGroup_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "partGroup_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
- {
- foreignKeyName: "partGroup_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "partGroup_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "partGroup_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "partCost_partId_fkey"
+ columns: ["partId", "companyId"]
isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
+ referencedRelation: "part"
+ referencedColumns: ["id", "companyId"]
},
{
- foreignKeyName: "partGroup_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "partCost_partId_fkey"
+ columns: ["partId", "companyId"]
isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
+ referencedRelation: "partQuantities"
+ referencedColumns: ["partId", "companyId"]
},
{
- foreignKeyName: "partGroup_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "partCost_partId_fkey"
+ columns: ["partId", "companyId"]
isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
+ referencedRelation: "parts"
+ referencedColumns: ["id", "companyId"]
},
]
}
@@ -8013,11 +8013,11 @@ export type Database = {
inventoryInvoicedNotReceivedAccount: string
inventoryReceivedNotInvoicedAccount: string
inventoryShippedNotInvoicedAccount: string
+ itemGroupId: string | null
locationId: string | null
materialVarianceAccount: string
overheadAccount: string
overheadCostAppliedAccount: string
- partGroupId: string | null
purchaseVarianceAccount: string
updatedBy: string | null
workInProgressAccount: string
@@ -8034,11 +8034,11 @@ export type Database = {
inventoryInvoicedNotReceivedAccount: string
inventoryReceivedNotInvoicedAccount: string
inventoryShippedNotInvoicedAccount: string
+ itemGroupId?: string | null
locationId?: string | null
materialVarianceAccount: string
overheadAccount: string
overheadCostAppliedAccount: string
- partGroupId?: string | null
purchaseVarianceAccount: string
updatedBy?: string | null
workInProgressAccount: string
@@ -8055,11 +8055,11 @@ export type Database = {
inventoryInvoicedNotReceivedAccount?: string
inventoryReceivedNotInvoicedAccount?: string
inventoryShippedNotInvoicedAccount?: string
+ itemGroupId?: string | null
locationId?: string | null
materialVarianceAccount?: string
overheadAccount?: string
overheadCostAppliedAccount?: string
- partGroupId?: string | null
purchaseVarianceAccount?: string
updatedBy?: string | null
workInProgressAccount?: string
@@ -8191,6 +8191,13 @@ export type Database = {
referencedRelation: "accounts"
referencedColumns: ["number", "companyId"]
},
+ {
+ foreignKeyName: "postingGroupInventory_itemGroupId_fkey"
+ columns: ["itemGroupId"]
+ isOneToOne: false
+ referencedRelation: "itemGroup"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "postingGroupInventory_locationId_fkey"
columns: ["locationId"]
@@ -8261,13 +8268,6 @@ export type Database = {
referencedRelation: "accounts"
referencedColumns: ["number", "companyId"]
},
- {
- foreignKeyName: "postingGroupInventory_partGroupId_fkey"
- columns: ["partGroupId"]
- isOneToOne: false
- referencedRelation: "partGroup"
- referencedColumns: ["id"]
- },
{
foreignKeyName: "postingGroupInventory_purchaseVarianceAccount_fkey"
columns: ["purchaseVarianceAccount", "companyId"]
@@ -8337,7 +8337,7 @@ export type Database = {
Row: {
companyId: string
id: string
- partGroupId: string | null
+ itemGroupId: string | null
payablesAccount: string
purchaseAccount: string
purchaseCreditAccount: string
@@ -8350,7 +8350,7 @@ export type Database = {
Insert: {
companyId: string
id?: string
- partGroupId?: string | null
+ itemGroupId?: string | null
payablesAccount: string
purchaseAccount: string
purchaseCreditAccount: string
@@ -8363,7 +8363,7 @@ export type Database = {
Update: {
companyId?: string
id?: string
- partGroupId?: string | null
+ itemGroupId?: string | null
payablesAccount?: string
purchaseAccount?: string
purchaseCreditAccount?: string
@@ -8403,10 +8403,10 @@ export type Database = {
referencedColumns: ["companyId"]
},
{
- foreignKeyName: "postingGroupPurchasing_partGroupId_fkey"
- columns: ["partGroupId"]
+ foreignKeyName: "postingGroupPurchasing_itemGroupId_fkey"
+ columns: ["itemGroupId"]
isOneToOne: false
- referencedRelation: "partGroup"
+ referencedRelation: "itemGroup"
referencedColumns: ["id"]
},
{
@@ -8542,7 +8542,7 @@ export type Database = {
companyId: string
customerTypeId: string | null
id: string
- partGroupId: string | null
+ itemGroupId: string | null
receivablesAccount: string
salesAccount: string
salesCreditAccount: string
@@ -8555,7 +8555,7 @@ export type Database = {
companyId: string
customerTypeId?: string | null
id?: string
- partGroupId?: string | null
+ itemGroupId?: string | null
receivablesAccount: string
salesAccount: string
salesCreditAccount: string
@@ -8568,7 +8568,7 @@ export type Database = {
companyId?: string
customerTypeId?: string | null
id?: string
- partGroupId?: string | null
+ itemGroupId?: string | null
receivablesAccount?: string
salesAccount?: string
salesCreditAccount?: string
@@ -8614,10 +8614,10 @@ export type Database = {
referencedColumns: ["id"]
},
{
- foreignKeyName: "postingGroupSales_partGroupId_fkey"
- columns: ["partGroupId"]
+ foreignKeyName: "postingGroupSales_itemGroupId_fkey"
+ columns: ["itemGroupId"]
isOneToOne: false
- referencedRelation: "partGroup"
+ referencedRelation: "itemGroup"
referencedColumns: ["id"]
},
{
@@ -19843,10 +19843,10 @@ export type Database = {
description: string | null
fromDate: string | null
id: string | null
+ itemGroup: string | null
+ itemGroupId: string | null
itemId: string | null
name: string | null
- partGroup: string | null
- partGroupId: string | null
partType: Database["public"]["Enums"]["partType"] | null
replenishmentSystem:
| Database["public"]["Enums"]["partReplenishmentSystem"]
@@ -19859,10 +19859,10 @@ export type Database = {
}
Relationships: [
{
- foreignKeyName: "item_partGroupId_fkey"
- columns: ["partGroupId"]
+ foreignKeyName: "item_itemGroupId_fkey"
+ columns: ["itemGroupId"]
isOneToOne: false
- referencedRelation: "partGroup"
+ referencedRelation: "itemGroup"
referencedColumns: ["id"]
},
{
@@ -20563,14 +20563,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["supplierCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["id"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["supplierCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["id"]
@@ -22225,10 +22225,10 @@ export type Database = {
description: string | null
fromDate: string | null
id: string | null
+ itemGroup: string | null
+ itemGroupId: string | null
itemId: string | null
name: string | null
- partGroup: string | null
- partGroupId: string | null
serviceType: Database["public"]["Enums"]["serviceType"] | null
supplierIds: string[] | null
toDate: string | null
@@ -22237,10 +22237,10 @@ export type Database = {
}
Relationships: [
{
- foreignKeyName: "item_partGroupId_fkey"
- columns: ["partGroupId"]
+ foreignKeyName: "item_itemGroupId_fkey"
+ columns: ["itemGroupId"]
isOneToOne: false
- referencedRelation: "partGroup"
+ referencedRelation: "itemGroup"
referencedColumns: ["id"]
},
{
diff --git a/packages/database/supabase/functions/lib/seed.ts b/packages/database/supabase/functions/lib/seed.ts
index 263eaf6f25..f6e65d4479 100644
--- a/packages/database/supabase/functions/lib/seed.ts
+++ b/packages/database/supabase/functions/lib/seed.ts
@@ -1978,7 +1978,7 @@ export const paymentTerms: Omit<
];
export const postingGroupInventory = {
- partGroupId: null,
+ itemGroupId: null,
locationId: null,
costOfGoodsSoldAccount: getDefaultAccount("costOfGoodsSoldAccount"),
inventoryAccount: getDefaultAccount("inventoryAccount"),
@@ -2008,7 +2008,7 @@ export const postingGroupInventory = {
};
export const postingGroupPurchasing = {
- partGroupId: null,
+ itemGroupId: null,
supplierTypeId: null,
payablesAccount: getDefaultAccount("payablesAccount"),
purchaseAccount: getDefaultAccount("purchaseAccount"),
@@ -2020,7 +2020,7 @@ export const postingGroupPurchasing = {
};
export const postingGroupSales = {
- partGroupId: null,
+ itemGroupId: null,
customerTypeId: null,
receivablesAccount: getDefaultAccount("receivablesAccount"),
salesAccount: getDefaultAccount("salesAccount"),
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index 57f902ced2..68a705ec68 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -5421,8 +5421,8 @@ export type Database = {
createdBy: string
description: string | null
id: string
+ itemGroupId: string | null
name: string
- partGroupId: string | null
readableId: string
type: Database["public"]["Enums"]["itemType"]
updatedAt: string | null
@@ -5436,8 +5436,8 @@ export type Database = {
createdBy: string
description?: string | null
id?: string
+ itemGroupId?: string | null
name: string
- partGroupId?: string | null
readableId: string
type: Database["public"]["Enums"]["itemType"]
updatedAt?: string | null
@@ -5451,8 +5451,8 @@ export type Database = {
createdBy?: string
description?: string | null
id?: string
+ itemGroupId?: string | null
name?: string
- partGroupId?: string | null
readableId?: string
type?: Database["public"]["Enums"]["itemType"]
updatedAt?: string | null
@@ -5523,10 +5523,10 @@ export type Database = {
referencedColumns: ["userId"]
},
{
- foreignKeyName: "item_partGroupId_fkey"
- columns: ["partGroupId"]
+ foreignKeyName: "item_itemGroupId_fkey"
+ columns: ["itemGroupId"]
isOneToOne: false
- referencedRelation: "partGroup"
+ referencedRelation: "itemGroup"
referencedColumns: ["id"]
},
{
@@ -5566,6 +5566,144 @@ export type Database = {
},
]
}
+ itemGroup: {
+ Row: {
+ active: boolean
+ companyId: string
+ createdAt: string
+ createdBy: string
+ customFields: Json | null
+ description: string | null
+ id: string
+ name: string
+ 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
+ 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
+ updatedAt?: string | null
+ updatedBy?: string | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "itemGroup_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemGroup_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemGroup_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "itemGroup_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "itemGroup_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemGroup_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemGroup_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemGroup_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemGroup_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "itemGroup_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemGroup_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemGroup_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemGroup_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemGroup_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ ]
+ }
journal: {
Row: {
accountingPeriodId: string | null
@@ -6277,261 +6415,123 @@ export type Database = {
}
Relationships: [
{
- foreignKeyName: "partCost_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "companies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "partCost_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "company"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "partCost_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "customFieldTables"
- referencedColumns: ["companyId"]
- },
- {
- foreignKeyName: "partCost_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "integrations"
- referencedColumns: ["companyId"]
- },
- {
- foreignKeyName: "partCost_partId_fkey"
- columns: ["partId", "companyId"]
- isOneToOne: false
- referencedRelation: "part"
- referencedColumns: ["id", "companyId"]
- },
- {
- foreignKeyName: "partCost_partId_fkey"
- columns: ["partId", "companyId"]
- isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["partId", "companyId"]
- },
- {
- foreignKeyName: "partCost_partId_fkey"
- columns: ["partId", "companyId"]
- isOneToOne: false
- referencedRelation: "parts"
- referencedColumns: ["id", "companyId"]
- },
- {
- foreignKeyName: "partGroup_createdBy_fkey"
+ foreignKeyName: "itemGroup_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partGroup_createdBy_fkey"
+ foreignKeyName: "itemGroup_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partGroup_createdBy_fkey"
+ foreignKeyName: "itemGroup_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partGroup_createdBy_fkey"
+ foreignKeyName: "itemGroup_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partGroup_createdBy_fkey"
+ foreignKeyName: "itemGroup_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
{
- foreignKeyName: "partGroup_updatedBy_fkey"
+ foreignKeyName: "itemGroup_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partGroup_updatedBy_fkey"
+ foreignKeyName: "itemGroup_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partGroup_updatedBy_fkey"
+ foreignKeyName: "itemGroup_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partGroup_updatedBy_fkey"
+ foreignKeyName: "itemGroup_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partGroup_updatedBy_fkey"
+ foreignKeyName: "itemGroup_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
- ]
- }
- partGroup: {
- Row: {
- active: boolean
- companyId: string
- createdAt: string
- createdBy: string
- customFields: Json | null
- description: string | null
- id: string
- name: string
- 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
- 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
- updatedAt?: string | null
- updatedBy?: string | null
- }
- Relationships: [
{
- foreignKeyName: "partGroup_companyId_fkey"
+ foreignKeyName: "partCost_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "companies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partGroup_companyId_fkey"
+ foreignKeyName: "partCost_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "company"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partGroup_companyId_fkey"
+ foreignKeyName: "partCost_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "customFieldTables"
referencedColumns: ["companyId"]
},
{
- foreignKeyName: "partGroup_companyId_fkey"
+ foreignKeyName: "partCost_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "integrations"
referencedColumns: ["companyId"]
},
{
- foreignKeyName: "partGroup_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "partGroup_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "partGroup_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "partGroup_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "partGroup_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
- {
- foreignKeyName: "partGroup_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "partGroup_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "partGroup_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "partCost_partId_fkey"
+ columns: ["partId", "companyId"]
isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
+ referencedRelation: "part"
+ referencedColumns: ["id", "companyId"]
},
{
- foreignKeyName: "partGroup_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "partCost_partId_fkey"
+ columns: ["partId", "companyId"]
isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
+ referencedRelation: "partQuantities"
+ referencedColumns: ["partId", "companyId"]
},
{
- foreignKeyName: "partGroup_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "partCost_partId_fkey"
+ columns: ["partId", "companyId"]
isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
+ referencedRelation: "parts"
+ referencedColumns: ["id", "companyId"]
},
]
}
@@ -8013,11 +8013,11 @@ export type Database = {
inventoryInvoicedNotReceivedAccount: string
inventoryReceivedNotInvoicedAccount: string
inventoryShippedNotInvoicedAccount: string
+ itemGroupId: string | null
locationId: string | null
materialVarianceAccount: string
overheadAccount: string
overheadCostAppliedAccount: string
- partGroupId: string | null
purchaseVarianceAccount: string
updatedBy: string | null
workInProgressAccount: string
@@ -8034,11 +8034,11 @@ export type Database = {
inventoryInvoicedNotReceivedAccount: string
inventoryReceivedNotInvoicedAccount: string
inventoryShippedNotInvoicedAccount: string
+ itemGroupId?: string | null
locationId?: string | null
materialVarianceAccount: string
overheadAccount: string
overheadCostAppliedAccount: string
- partGroupId?: string | null
purchaseVarianceAccount: string
updatedBy?: string | null
workInProgressAccount: string
@@ -8055,11 +8055,11 @@ export type Database = {
inventoryInvoicedNotReceivedAccount?: string
inventoryReceivedNotInvoicedAccount?: string
inventoryShippedNotInvoicedAccount?: string
+ itemGroupId?: string | null
locationId?: string | null
materialVarianceAccount?: string
overheadAccount?: string
overheadCostAppliedAccount?: string
- partGroupId?: string | null
purchaseVarianceAccount?: string
updatedBy?: string | null
workInProgressAccount?: string
@@ -8191,6 +8191,13 @@ export type Database = {
referencedRelation: "accounts"
referencedColumns: ["number", "companyId"]
},
+ {
+ foreignKeyName: "postingGroupInventory_itemGroupId_fkey"
+ columns: ["itemGroupId"]
+ isOneToOne: false
+ referencedRelation: "itemGroup"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "postingGroupInventory_locationId_fkey"
columns: ["locationId"]
@@ -8261,13 +8268,6 @@ export type Database = {
referencedRelation: "accounts"
referencedColumns: ["number", "companyId"]
},
- {
- foreignKeyName: "postingGroupInventory_partGroupId_fkey"
- columns: ["partGroupId"]
- isOneToOne: false
- referencedRelation: "partGroup"
- referencedColumns: ["id"]
- },
{
foreignKeyName: "postingGroupInventory_purchaseVarianceAccount_fkey"
columns: ["purchaseVarianceAccount", "companyId"]
@@ -8337,7 +8337,7 @@ export type Database = {
Row: {
companyId: string
id: string
- partGroupId: string | null
+ itemGroupId: string | null
payablesAccount: string
purchaseAccount: string
purchaseCreditAccount: string
@@ -8350,7 +8350,7 @@ export type Database = {
Insert: {
companyId: string
id?: string
- partGroupId?: string | null
+ itemGroupId?: string | null
payablesAccount: string
purchaseAccount: string
purchaseCreditAccount: string
@@ -8363,7 +8363,7 @@ export type Database = {
Update: {
companyId?: string
id?: string
- partGroupId?: string | null
+ itemGroupId?: string | null
payablesAccount?: string
purchaseAccount?: string
purchaseCreditAccount?: string
@@ -8403,10 +8403,10 @@ export type Database = {
referencedColumns: ["companyId"]
},
{
- foreignKeyName: "postingGroupPurchasing_partGroupId_fkey"
- columns: ["partGroupId"]
+ foreignKeyName: "postingGroupPurchasing_itemGroupId_fkey"
+ columns: ["itemGroupId"]
isOneToOne: false
- referencedRelation: "partGroup"
+ referencedRelation: "itemGroup"
referencedColumns: ["id"]
},
{
@@ -8542,7 +8542,7 @@ export type Database = {
companyId: string
customerTypeId: string | null
id: string
- partGroupId: string | null
+ itemGroupId: string | null
receivablesAccount: string
salesAccount: string
salesCreditAccount: string
@@ -8555,7 +8555,7 @@ export type Database = {
companyId: string
customerTypeId?: string | null
id?: string
- partGroupId?: string | null
+ itemGroupId?: string | null
receivablesAccount: string
salesAccount: string
salesCreditAccount: string
@@ -8568,7 +8568,7 @@ export type Database = {
companyId?: string
customerTypeId?: string | null
id?: string
- partGroupId?: string | null
+ itemGroupId?: string | null
receivablesAccount?: string
salesAccount?: string
salesCreditAccount?: string
@@ -8614,10 +8614,10 @@ export type Database = {
referencedColumns: ["id"]
},
{
- foreignKeyName: "postingGroupSales_partGroupId_fkey"
- columns: ["partGroupId"]
+ foreignKeyName: "postingGroupSales_itemGroupId_fkey"
+ columns: ["itemGroupId"]
isOneToOne: false
- referencedRelation: "partGroup"
+ referencedRelation: "itemGroup"
referencedColumns: ["id"]
},
{
@@ -19843,10 +19843,10 @@ export type Database = {
description: string | null
fromDate: string | null
id: string | null
+ itemGroup: string | null
+ itemGroupId: string | null
itemId: string | null
name: string | null
- partGroup: string | null
- partGroupId: string | null
partType: Database["public"]["Enums"]["partType"] | null
replenishmentSystem:
| Database["public"]["Enums"]["partReplenishmentSystem"]
@@ -19859,10 +19859,10 @@ export type Database = {
}
Relationships: [
{
- foreignKeyName: "item_partGroupId_fkey"
- columns: ["partGroupId"]
+ foreignKeyName: "item_itemGroupId_fkey"
+ columns: ["itemGroupId"]
isOneToOne: false
- referencedRelation: "partGroup"
+ referencedRelation: "itemGroup"
referencedColumns: ["id"]
},
{
@@ -20563,14 +20563,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["supplierCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["id"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["supplierCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["id"]
@@ -22225,10 +22225,10 @@ export type Database = {
description: string | null
fromDate: string | null
id: string | null
+ itemGroup: string | null
+ itemGroupId: string | null
itemId: string | null
name: string | null
- partGroup: string | null
- partGroupId: string | null
serviceType: Database["public"]["Enums"]["serviceType"] | null
supplierIds: string[] | null
toDate: string | null
@@ -22237,10 +22237,10 @@ export type Database = {
}
Relationships: [
{
- foreignKeyName: "item_partGroupId_fkey"
- columns: ["partGroupId"]
+ foreignKeyName: "item_itemGroupId_fkey"
+ columns: ["itemGroupId"]
isOneToOne: false
- referencedRelation: "partGroup"
+ referencedRelation: "itemGroup"
referencedColumns: ["id"]
},
{
diff --git a/packages/database/supabase/functions/post-purchase-invoice/index.ts b/packages/database/supabase/functions/post-purchase-invoice/index.ts
index 84931a1445..691f06a941 100644
--- a/packages/database/supabase/functions/post-purchase-invoice/index.ts
+++ b/packages/database/supabase/functions/post-purchase-invoice/index.ts
@@ -45,7 +45,7 @@ serve(async (req: Request) => {
const [parts, services, purchaseOrderLines, supplier] = await Promise.all([
client
.from("part")
- .select("id, partGroupId, partType")
+ .select("id, itemGroupId, partType")
.in(
"id",
purchaseInvoiceLines.data.reduce<string[]>((acc, invoiceLine) => {
@@ -58,7 +58,7 @@ serve(async (req: Request) => {
.eq("companyId", companyId),
client
.from("service")
- .select("id, partGroupId")
+ .select("id, itemGroupId")
.in(
"id",
purchaseInvoiceLines.data.reduce<string[]>((acc, invoiceLine) => {
@@ -91,8 +91,8 @@ serve(async (req: Request) => {
.eq("companyId", companyId)
.single(),
]);
- if (parts.error) throw new Error("Failed to fetch part groups");
- if (services.error) throw new Error("Failed to fetch service part groups");
+ if (parts.error) throw new Error("Failed to fetch item groups");
+ if (services.error) throw new Error("Failed to fetch service item groups");
if (purchaseOrderLines.error)
throw new Error("Failed to fetch purchase order lines");
if (supplier.error) throw new Error("Failed to fetch supplier");
@@ -240,7 +240,7 @@ serve(async (req: Request) => {
| Database["public"]["Tables"]["postingGroupInventory"]["Row"]
| null = null;
- let partGroupId: string | null = null;
+ let itemGroupId: string | null = null;
// purchasing posting group
const purchasingPostingGroups: Record<
@@ -365,20 +365,20 @@ serve(async (req: Request) => {
});
break;
case "Service":
- partGroupId =
+ itemGroupId =
services.data.find(
(service) => service.id === invoiceLine.serviceId
- )?.partGroupId ?? null;
+ )?.itemGroupId ?? null;
// inventory posting group
- if (`${partGroupId}-${locationId}` in inventoryPostingGroups) {
+ if (`${itemGroupId}-${locationId}` in inventoryPostingGroups) {
postingGroupInventory =
- inventoryPostingGroups[`${partGroupId}-${locationId}`];
+ inventoryPostingGroups[`${itemGroupId}-${locationId}`];
} else {
const inventoryPostingGroup = await getInventoryPostingGroup(
client,
{
- partGroupId,
+ itemGroupId,
locationId,
}
);
@@ -388,7 +388,7 @@ serve(async (req: Request) => {
}
postingGroupInventory = inventoryPostingGroup.data ?? null;
- inventoryPostingGroups[`${partGroupId}-${locationId}`] =
+ inventoryPostingGroups[`${itemGroupId}-${locationId}`] =
postingGroupInventory;
}
@@ -396,14 +396,14 @@ serve(async (req: Request) => {
throw new Error("No inventory posting group found");
}
- if (`${partGroupId}-${supplierTypeId}` in purchasingPostingGroups) {
+ if (`${itemGroupId}-${supplierTypeId}` in purchasingPostingGroups) {
postingGroupPurchasing =
- purchasingPostingGroups[`${partGroupId}-${supplierTypeId}`];
+ purchasingPostingGroups[`${itemGroupId}-${supplierTypeId}`];
} else {
const purchasingPostingGroup = await getPurchasingPostingGroup(
client,
{
- partGroupId,
+ itemGroupId,
supplierTypeId,
}
);
@@ -413,7 +413,7 @@ serve(async (req: Request) => {
}
postingGroupPurchasing = purchasingPostingGroup.data ?? null;
- purchasingPostingGroups[`${partGroupId}-${supplierTypeId}`] =
+ purchasingPostingGroups[`${itemGroupId}-${supplierTypeId}`] =
postingGroupPurchasing;
}
@@ -517,19 +517,19 @@ serve(async (req: Request) => {
parts.data.find((part) => part.id === invoiceLine.partId)
?.partType ?? "Inventory";
- partGroupId =
+ itemGroupId =
parts.data.find((part) => part.id === invoiceLine.partId)
- ?.partGroupId ?? null;
+ ?.itemGroupId ?? null;
// inventory posting group
- if (`${partGroupId}-${locationId}` in inventoryPostingGroups) {
+ if (`${itemGroupId}-${locationId}` in inventoryPostingGroups) {
postingGroupInventory =
- inventoryPostingGroups[`${partGroupId}-${locationId}`];
+ inventoryPostingGroups[`${itemGroupId}-${locationId}`];
} else {
const inventoryPostingGroup = await getInventoryPostingGroup(
client,
{
- partGroupId,
+ itemGroupId,
locationId,
}
);
@@ -539,7 +539,7 @@ serve(async (req: Request) => {
}
postingGroupInventory = inventoryPostingGroup.data ?? null;
- inventoryPostingGroups[`${partGroupId}-${locationId}`] =
+ inventoryPostingGroups[`${itemGroupId}-${locationId}`] =
postingGroupInventory;
}
@@ -547,14 +547,14 @@ serve(async (req: Request) => {
throw new Error("No inventory posting group found");
}
- if (`${partGroupId}-${supplierTypeId}` in purchasingPostingGroups) {
+ if (`${itemGroupId}-${supplierTypeId}` in purchasingPostingGroups) {
postingGroupPurchasing =
- purchasingPostingGroups[`${partGroupId}-${supplierTypeId}`];
+ purchasingPostingGroups[`${itemGroupId}-${supplierTypeId}`];
} else {
const purchasingPostingGroup = await getPurchasingPostingGroup(
client,
{
- partGroupId,
+ itemGroupId,
supplierTypeId,
}
);
@@ -564,7 +564,7 @@ serve(async (req: Request) => {
}
postingGroupPurchasing = purchasingPostingGroup.data ?? null;
- purchasingPostingGroups[`${partGroupId}-${supplierTypeId}`] =
+ purchasingPostingGroups[`${itemGroupId}-${supplierTypeId}`] =
postingGroupPurchasing;
}
diff --git a/packages/database/supabase/functions/post-receipt/index.ts b/packages/database/supabase/functions/post-receipt/index.ts
index deca79b0d5..3561bab977 100644
--- a/packages/database/supabase/functions/post-receipt/index.ts
+++ b/packages/database/supabase/functions/post-receipt/index.ts
@@ -40,7 +40,7 @@ serve(async (req: Request) => {
const parts = await client
.from("part")
- .select("id, partGroupId, partType")
+ .select("id, itemGroupId, partType")
.in(
"id",
receiptLines.data.reduce<string[]>((acc, receiptLine) => {
@@ -51,7 +51,7 @@ serve(async (req: Request) => {
}, [])
)
.eq("companyId", companyId);
- if (parts.error) throw new Error("Failed to fetch part groups");
+ if (parts.error) throw new Error("Failed to fetch item groups");
switch (receipt.data?.sourceDocument) {
case "Purchase Order": {
@@ -198,22 +198,22 @@ serve(async (req: Request) => {
parts.data.find((part) => part.id === receiptLine.partId)
?.partType ?? "Inventory";
- const partGroupId: string | null =
+ const itemGroupId: string | null =
parts.data.find((part) => part.id === receiptLine.partId)
- ?.partGroupId ?? null;
+ ?.itemGroupId ?? null;
const locationId = receiptLine.locationId ?? null;
const supplierTypeId: string | null =
supplier.data.supplierTypeId ?? null;
// inventory posting group
- if (`${partGroupId}-${locationId}` in inventoryPostingGroups) {
+ if (`${itemGroupId}-${locationId}` in inventoryPostingGroups) {
postingGroupInventory =
- inventoryPostingGroups[`${partGroupId}-${locationId}`];
+ inventoryPostingGroups[`${itemGroupId}-${locationId}`];
} else {
const inventoryPostingGroup = await getInventoryPostingGroup(
client,
{
- partGroupId,
+ itemGroupId,
locationId,
}
);
@@ -223,7 +223,7 @@ serve(async (req: Request) => {
}
postingGroupInventory = inventoryPostingGroup.data ?? null;
- inventoryPostingGroups[`${partGroupId}-${locationId}`] =
+ inventoryPostingGroups[`${itemGroupId}-${locationId}`] =
postingGroupInventory;
}
@@ -241,14 +241,14 @@ serve(async (req: Request) => {
| Database["public"]["Tables"]["postingGroupPurchasing"]["Row"]
| null = null;
- if (`${partGroupId}-${supplierTypeId}` in purchasingPostingGroups) {
+ if (`${itemGroupId}-${supplierTypeId}` in purchasingPostingGroups) {
postingGroupPurchasing =
- purchasingPostingGroups[`${partGroupId}-${supplierTypeId}`];
+ purchasingPostingGroups[`${itemGroupId}-${supplierTypeId}`];
} else {
const purchasingPostingGroup = await getPurchasingPostingGroup(
client,
{
- partGroupId,
+ itemGroupId,
supplierTypeId,
}
);
@@ -258,7 +258,7 @@ serve(async (req: Request) => {
}
postingGroupPurchasing = purchasingPostingGroup.data ?? null;
- purchasingPostingGroups[`${partGroupId}-${supplierTypeId}`] =
+ purchasingPostingGroups[`${itemGroupId}-${supplierTypeId}`] =
postingGroupPurchasing;
}
diff --git a/packages/database/supabase/functions/shared/get-posting-group.ts b/packages/database/supabase/functions/shared/get-posting-group.ts
index 63a137ab58..c23ec1bd0a 100644
--- a/packages/database/supabase/functions/shared/get-posting-group.ts
+++ b/packages/database/supabase/functions/shared/get-posting-group.ts
@@ -4,16 +4,16 @@ import { Database } from "../lib/types.ts";
export async function getInventoryPostingGroup(
client: SupabaseClient<Database>,
args: {
- partGroupId: string | null;
+ itemGroupId: string | null;
locationId: string | null;
}
) {
let query = client.from("postingGroupInventory").select("*");
- if (args.partGroupId === null) {
- query = query.is("partGroupId", null);
+ if (args.itemGroupId === null) {
+ query = query.is("itemGroupId", null);
} else {
- query = query.eq("partGroupId", args.partGroupId);
+ query = query.eq("itemGroupId", args.itemGroupId);
}
if (args.locationId === null) {
@@ -28,16 +28,16 @@ export async function getInventoryPostingGroup(
export async function getPurchasingPostingGroup(
client: SupabaseClient<Database>,
args: {
- partGroupId: string | null;
+ itemGroupId: string | null;
supplierTypeId: string | null;
}
) {
let query = client.from("postingGroupPurchasing").select("*");
- if (args.partGroupId === null) {
- query = query.is("partGroupId", null);
+ if (args.itemGroupId === null) {
+ query = query.is("itemGroupId", null);
} else {
- query = query.eq("partGroupId", args.partGroupId);
+ query = query.eq("itemGroupId", args.itemGroupId);
}
if (args.supplierTypeId === null) {
diff --git a/packages/database/supabase/migrations/20230330024716_parts.sql b/packages/database/supabase/migrations/20230330024716_parts.sql
index 5f911a05e7..c100ef0823 100644
--- a/packages/database/supabase/migrations/20230330024716_parts.sql
+++ b/packages/database/supabase/migrations/20230330024716_parts.sql
@@ -1,4 +1,4 @@
-CREATE TABLE "partGroup" (
+CREATE TABLE "itemGroup" (
"id" TEXT NOT NULL DEFAULT xid(),
"name" TEXT NOT NULL,
"description" TEXT,
@@ -10,18 +10,18 @@ CREATE TABLE "partGroup" (
"updatedAt" TIMESTAMP WITH TIME ZONE,
"customFields" JSONB,
- CONSTRAINT "partGroup_pkey" PRIMARY KEY ("id"),
- CONSTRAINT "partGroup_name_key" UNIQUE ("name", "companyId"),
- CONSTRAINT "partGroup_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company"("id") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "partGroup_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id"),
- CONSTRAINT "partGroup_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id")
+ CONSTRAINT "itemGroup_pkey" PRIMARY KEY ("id"),
+ CONSTRAINT "itemGroup_name_key" UNIQUE ("name", "companyId"),
+ CONSTRAINT "itemGroup_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company"("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "itemGroup_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id"),
+ CONSTRAINT "itemGroup_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id")
);
-CREATE INDEX "partGroup_companyId_idx" ON "partGroup" ("companyId");
+CREATE INDEX "itemGroup_companyId_idx" ON "itemGroup" ("companyId");
-ALTER TABLE "partGroup" ENABLE ROW LEVEL SECURITY;
+ALTER TABLE "itemGroup" ENABLE ROW LEVEL SECURITY;
-CREATE POLICY "Employees with parts_view can view part groups" ON "partGroup"
+CREATE POLICY "Employees with parts_view can view item groups" ON "itemGroup"
FOR SELECT
USING (
has_role('employee') AND
@@ -29,21 +29,21 @@ CREATE POLICY "Employees with parts_view can view part groups" ON "partGroup"
);
-CREATE POLICY "Employees with parts_create can insert part groups" ON "partGroup"
+CREATE POLICY "Employees with parts_create can insert item groups" ON "itemGroup"
FOR INSERT
WITH CHECK (
has_role('employee') AND
has_company_permission('parts_create', "companyId")
);
-CREATE POLICY "Employees with parts_update can update part groups" ON "partGroup"
+CREATE POLICY "Employees with parts_update can update item groups" ON "itemGroup"
FOR UPDATE
USING (
has_role('employee') AND
has_company_permission('parts_update', "companyId")
);
-CREATE POLICY "Employees with parts_delete can delete part groups" ON "partGroup"
+CREATE POLICY "Employees with parts_delete can delete item groups" ON "itemGroup"
FOR DELETE
USING (
has_role('employee') AND
@@ -67,7 +67,7 @@ CREATE TABLE "item" (
"type" "itemType" NOT NULL,
"name" TEXT NOT NULL,
"description" TEXT,
- "partGroupId" TEXT,
+ "itemGroupId" TEXT,
"active" BOOLEAN NOT NULL DEFAULT true,
"blocked" BOOLEAN NOT NULL DEFAULT false,
"companyId" TEXT NOT NULL,
@@ -79,7 +79,7 @@ CREATE TABLE "item" (
CONSTRAINT "item_pkey" PRIMARY KEY (id),
CONSTRAINT "item_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company"("id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "item_unique" UNIQUE ("readableId", "companyId", "type"),
- CONSTRAINT "item_partGroupId_fkey" FOREIGN KEY ("partGroupId") REFERENCES "partGroup"("id") ON DELETE SET NULL ON UPDATE CASCADE,
+ CONSTRAINT "item_itemGroupId_fkey" FOREIGN KEY ("itemGroupId") REFERENCES "itemGroup"("id") ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT "item_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id"),
CONSTRAINT "item_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id")
);
@@ -320,8 +320,8 @@ CREATE TABLE "partCost" (
CONSTRAINT "partCost_partId_fkey" FOREIGN KEY ("partId", "companyId") REFERENCES "part"("id", "companyId") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "partCost_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company"("id") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "partGroup_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id"),
- CONSTRAINT "partGroup_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id")
+ CONSTRAINT "itemGroup_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id"),
+ CONSTRAINT "itemGroup_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id")
);
CREATE INDEX "partCost_partId_idx" ON "partCost" ("partId");
diff --git a/packages/database/supabase/migrations/20230412120726_services.sql b/packages/database/supabase/migrations/20230412120726_services.sql
index 373648e3fc..8b033d2e64 100644
--- a/packages/database/supabase/migrations/20230412120726_services.sql
+++ b/packages/database/supabase/migrations/20230412120726_services.sql
@@ -147,7 +147,7 @@ CREATE OR REPLACE VIEW "services" WITH(SECURITY_INVOKER=true) AS
i."name",
i."description",
i."blocked",
- i."partGroupId",
+ i."itemGroupId",
s."serviceType",
i."active",
s."approved",
@@ -156,11 +156,11 @@ CREATE OR REPLACE VIEW "services" WITH(SECURITY_INVOKER=true) AS
s."toDate",
s."customFields",
s."companyId",
- pg.name AS "partGroup",
+ pg.name AS "itemGroup",
array_agg(ss."supplierId") AS "supplierIds"
FROM "service" s
INNER JOIN "item" i ON i."id" = s."itemId"
- LEFT JOIN "partGroup" pg ON pg.id = i."partGroupId"
+ LEFT JOIN "itemGroup" pg ON pg.id = i."itemGroupId"
LEFT JOIN "serviceSupplier" ss ON ss."serviceId" = s.id
GROUP BY
s."id",
@@ -168,7 +168,7 @@ CREATE OR REPLACE VIEW "services" WITH(SECURITY_INVOKER=true) AS
i."name",
i."description",
i."blocked",
- i."partGroupId",
+ i."itemGroupId",
i."active",
s."serviceType",
s."approved",
diff --git a/packages/database/supabase/migrations/20230704161623_parts-view.sql b/packages/database/supabase/migrations/20230704161623_parts-view.sql
index cd4e73416a..0384a0134a 100644
--- a/packages/database/supabase/migrations/20230704161623_parts-view.sql
+++ b/packages/database/supabase/migrations/20230704161623_parts-view.sql
@@ -5,8 +5,8 @@ CREATE OR REPLACE VIEW "parts" AS
i.name,
i.description,
p."partType",
- i."partGroupId",
- pg.name AS "partGroup",
+ i."itemGroupId",
+ pg.name AS "itemGroup",
p."replenishmentSystem",
i.active,
i.blocked,
@@ -15,13 +15,13 @@ CREATE OR REPLACE VIEW "parts" AS
array_agg(ps."supplierId") AS "supplierIds"
FROM "part" p
INNER JOIN "item" i ON i.id = p."itemId"
- LEFT JOIN "partGroup" pg ON pg.id = i."partGroupId"
+ LEFT JOIN "itemGroup" pg ON pg.id = i."itemGroupId"
LEFT JOIN "partSupplier" ps ON ps."partId" = p.id
GROUP BY p.id,
i.name,
i.description,
p."partType",
- i."partGroupId",
+ i."itemGroupId",
pg.name,
p."replenishmentSystem",
i.active,
diff --git a/packages/database/supabase/migrations/20230820020844_posting-groups.sql b/packages/database/supabase/migrations/20230820020844_posting-groups.sql
index 7440e7cb75..a205bd88bf 100644
--- a/packages/database/supabase/migrations/20230820020844_posting-groups.sql
+++ b/packages/database/supabase/migrations/20230820020844_posting-groups.sql
@@ -126,7 +126,7 @@ CREATE POLICY "Employees with accounting_update can update account defaults" ON
CREATE TABLE "postingGroupInventory" (
"id" TEXT NOT NULL DEFAULT xid(),
- "partGroupId" TEXT,
+ "itemGroupId" TEXT,
"locationId" TEXT,
"costOfGoodsSoldAccount" TEXT NOT NULL,
"inventoryAccount" TEXT NOT NULL,
@@ -146,8 +146,8 @@ CREATE TABLE "postingGroupInventory" (
"updatedBy" TEXT,
CONSTRAINT "postingGroupInventory_pkey" PRIMARY KEY ("id"),
- CONSTRAINT "postingGroupInventory_id_partGroupId_locationId_key" UNIQUE ("partGroupId", "locationId"),
- CONSTRAINT "postingGroupInventory_partGroupId_fkey" FOREIGN KEY ("partGroupId") REFERENCES "partGroup" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupInventory_id_itemGroupId_locationId_key" UNIQUE ("itemGroupId", "locationId"),
+ CONSTRAINT "postingGroupInventory_itemGroupId_fkey" FOREIGN KEY ("itemGroupId") REFERENCES "itemGroup" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "postingGroupInventory_locationId_fkey" FOREIGN KEY ("locationId") REFERENCES "location" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "postingGroupInventory_costOfGoodsSoldAccount_fkey" FOREIGN KEY ("costOfGoodsSoldAccount", "companyId") REFERENCES "account" ("number", "companyId") ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT "postingGroupInventory_inventoryAccount_fkey" FOREIGN KEY ("inventoryAccount", "companyId") REFERENCES "account" ("number", "companyId") ON DELETE RESTRICT ON UPDATE CASCADE,
@@ -166,7 +166,7 @@ CREATE TABLE "postingGroupInventory" (
CONSTRAINT "postingGroupInventory_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user" ("id") ON DELETE SET NULL ON UPDATE CASCADE
);
-CREATE INDEX "postingGroupInventory_partGroupId_locationId_idx" ON "postingGroupInventory" ("partGroupId", "locationId");
+CREATE INDEX "postingGroupInventory_itemGroupId_locationId_idx" ON "postingGroupInventory" ("itemGroupId", "locationId");
CREATE INDEX "postingGroupInventory_companyId_idx" ON "postingGroupInventory" ("companyId");
ALTER TABLE "postingGroupInventory" ENABLE ROW LEVEL SECURITY;
@@ -189,7 +189,7 @@ CREATE POLICY "Employees with accounting_update can update inventory posting gro
CREATE TABLE "postingGroupPurchasing" (
"id" TEXT NOT NULL DEFAULT xid(),
"supplierTypeId" TEXT,
- "partGroupId" TEXT,
+ "itemGroupId" TEXT,
"payablesAccount" TEXT NOT NULL,
"purchaseAccount" TEXT NOT NULL,
"purchaseDiscountAccount" TEXT NOT NULL,
@@ -200,8 +200,8 @@ CREATE TABLE "postingGroupPurchasing" (
"updatedBy" TEXT,
CONSTRAINT "postingGroupPurchasing_pkey" PRIMARY KEY ("id"),
- CONSTRAINT "postingGroupPurchasing_id_supplierTypeId_partGroupId_key" UNIQUE ("supplierTypeId", "partGroupId"),
- CONSTRAINT "postingGroupPurchasing_partGroupId_fkey" FOREIGN KEY ("partGroupId") REFERENCES "partGroup" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupPurchasing_id_supplierTypeId_itemGroupId_key" UNIQUE ("supplierTypeId", "itemGroupId"),
+ CONSTRAINT "postingGroupPurchasing_itemGroupId_fkey" FOREIGN KEY ("itemGroupId") REFERENCES "itemGroup" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "postingGroupPurchasing_supplierTypeId_fkey" FOREIGN KEY ("supplierTypeId") REFERENCES "supplierType" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "postingGroupPurchasing_payablesAccount_fkey" FOREIGN KEY ("payablesAccount", "companyId") REFERENCES "account" ("number", "companyId") ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT "postingGroupPurchasing_purchaseAccount_fkey" FOREIGN KEY ("purchaseAccount", "companyId") REFERENCES "account" ("number", "companyId") ON DELETE RESTRICT ON UPDATE CASCADE,
@@ -213,7 +213,7 @@ CREATE TABLE "postingGroupPurchasing" (
CONSTRAINT "postingGroupPurchasing_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user" ("id") ON DELETE SET NULL ON UPDATE CASCADE
);
-CREATE INDEX "postingGroupPurchasing_partGroupId_supplierTypeId_idx" ON "postingGroupPurchasing" ("partGroupId", "supplierTypeId");
+CREATE INDEX "postingGroupPurchasing_itemGroupId_supplierTypeId_idx" ON "postingGroupPurchasing" ("itemGroupId", "supplierTypeId");
CREATE INDEX "postingGroupPurchasing_companyId_idx" ON "postingGroupPurchasing" ("companyId");
ALTER TABLE "postingGroupPurchasing" ENABLE ROW LEVEL SECURITY;
@@ -235,7 +235,7 @@ CREATE POLICY "Employees with accounting_update can update purchasing posting gr
CREATE TABLE "postingGroupSales" (
"id" TEXT NOT NULL DEFAULT xid(),
"customerTypeId" TEXT,
- "partGroupId" TEXT,
+ "itemGroupId" TEXT,
"receivablesAccount" TEXT NOT NULL,
"salesAccount" TEXT NOT NULL,
"salesDiscountAccount" TEXT NOT NULL,
@@ -246,8 +246,8 @@ CREATE TABLE "postingGroupSales" (
"updatedBy" TEXT,
CONSTRAINT "postingGroupSales_pkey" PRIMARY KEY ("id"),
- CONSTRAINT "postingGroupSales_id_customerTypeId_partGroupId_key" UNIQUE ("customerTypeId", "partGroupId"),
- CONSTRAINT "postingGroupSales_partGroupId_fkey" FOREIGN KEY ("partGroupId") REFERENCES "partGroup" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupSales_id_customerTypeId_itemGroupId_key" UNIQUE ("customerTypeId", "itemGroupId"),
+ CONSTRAINT "postingGroupSales_itemGroupId_fkey" FOREIGN KEY ("itemGroupId") REFERENCES "itemGroup" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "postingGroupSales_customerTypeId_fkey" FOREIGN KEY ("customerTypeId") REFERENCES "customerType" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "postingGroupSales_receivablesAccount_fkey" FOREIGN KEY ("receivablesAccount", "companyId") REFERENCES "account" ("number", "companyId") ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT "postingGroupSales_salesAccount_fkey" FOREIGN KEY ("salesAccount", "companyId") REFERENCES "account" ("number", "companyId") ON DELETE RESTRICT ON UPDATE CASCADE,
@@ -259,7 +259,7 @@ CREATE TABLE "postingGroupSales" (
CONSTRAINT "postingGroupSales_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user" ("id") ON DELETE SET NULL ON UPDATE CASCADE
);
-CREATE INDEX "postingGroupSales_partGroupId_customerTypeId_idx" ON "postingGroupSales" ("partGroupId", "customerTypeId");
+CREATE INDEX "postingGroupSales_itemGroupId_customerTypeId_idx" ON "postingGroupSales" ("itemGroupId", "customerTypeId");
CREATE INDEX "postingGroupSales_companyId_idx" ON "postingGroupSales" ("companyId");
CREATE POLICY "Employees with accounting_view can view sales posting groups" ON "postingGroupSales"
@@ -284,10 +284,10 @@ DECLARE
BEGIN
SELECT * INTO account_defaults FROM "accountDefault" WHERE "companyId" = new."companyId";
- FOR part_group IN SELECT "id" FROM "partGroup"
+ FOR part_group IN SELECT "id" FROM "itemGroup"
LOOP
INSERT INTO "postingGroupInventory" (
- "partGroupId",
+ "itemGroupId",
"locationId",
"costOfGoodsSoldAccount",
"inventoryAccount",
@@ -327,9 +327,9 @@ BEGIN
);
END LOOP;
- -- insert the null part group
+ -- insert the null item group
INSERT INTO "postingGroupInventory" (
- "partGroupId",
+ "itemGroupId",
"locationId",
"costOfGoodsSoldAccount",
"inventoryAccount",
@@ -388,7 +388,7 @@ BEGIN
FOR rec IN SELECT "id" FROM "customerType"
LOOP
INSERT INTO "postingGroupSales" (
- "partGroupId",
+ "itemGroupId",
"customerTypeId",
"receivablesAccount",
"salesAccount",
@@ -414,7 +414,7 @@ BEGIN
-- insert the null customer type
INSERT INTO "postingGroupSales" (
- "partGroupId",
+ "itemGroupId",
"customerTypeId",
"receivablesAccount",
"salesAccount",
@@ -440,7 +440,7 @@ BEGIN
FOR rec IN SELECT "id" FROM "supplierType"
LOOP
INSERT INTO "postingGroupPurchasing" (
- "partGroupId",
+ "itemGroupId",
"supplierTypeId",
"payablesAccount",
"purchaseAccount",
@@ -466,7 +466,7 @@ BEGIN
-- insert the null supplier type
INSERT INTO "postingGroupPurchasing" (
- "partGroupId",
+ "itemGroupId",
"supplierTypeId",
"payablesAccount",
"purchaseAccount",
@@ -492,7 +492,7 @@ BEGIN
FOR rec IN SELECT "id" FROM "location"
LOOP
INSERT INTO "postingGroupInventory" (
- "partGroupId",
+ "itemGroupId",
"locationId",
"costOfGoodsSoldAccount",
"inventoryAccount",
@@ -534,7 +534,7 @@ BEGIN
-- insert the null location
INSERT INTO "postingGroupInventory" (
- "partGroupId",
+ "itemGroupId",
"locationId",
"costOfGoodsSoldAccount",
"inventoryAccount",
@@ -579,7 +579,7 @@ $$ LANGUAGE plpgsql SECURITY DEFINER;
CREATE TRIGGER create_part_group
- AFTER INSERT on public."partGroup"
+ AFTER INSERT on public."itemGroup"
FOR EACH ROW EXECUTE PROCEDURE public.create_posting_groups_for_part_group();
CREATE FUNCTION public.create_posting_groups_for_customer_type()
@@ -590,11 +590,11 @@ DECLARE
BEGIN
SELECT * INTO account_defaults FROM "accountDefault" WHERE "companyId" = new."companyId";
- FOR rec IN SELECT "id" FROM "partGroup"
+ FOR rec IN SELECT "id" FROM "itemGroup"
LOOP
INSERT INTO "postingGroupSales" (
"customerTypeId",
- "partGroupId",
+ "itemGroupId",
"receivablesAccount",
"salesAccount",
"salesDiscountAccount",
@@ -617,10 +617,10 @@ BEGIN
);
END LOOP;
- -- insert the null part group
+ -- insert the null item group
INSERT INTO "postingGroupSales" (
"customerTypeId",
- "partGroupId",
+ "itemGroupId",
"receivablesAccount",
"salesAccount",
"salesDiscountAccount",
@@ -659,11 +659,11 @@ DECLARE
BEGIN
SELECT * INTO account_defaults FROM "accountDefault" WHERE "companyId" = new."companyId";
- FOR rec IN SELECT "id" FROM "partGroup"
+ FOR rec IN SELECT "id" FROM "itemGroup"
LOOP
INSERT INTO "postingGroupPurchasing" (
"supplierTypeId",
- "partGroupId",
+ "itemGroupId",
"payablesAccount",
"purchaseAccount",
"purchaseDiscountAccount",
@@ -686,10 +686,10 @@ BEGIN
);
END LOOP;
- -- insert the null part group
+ -- insert the null item group
INSERT INTO "postingGroupPurchasing" (
"supplierTypeId",
- "partGroupId",
+ "itemGroupId",
"payablesAccount",
"purchaseAccount",
"purchaseDiscountAccount",
diff --git a/packages/database/supabase/migrations/20240324175747_assignee.sql b/packages/database/supabase/migrations/20240324175747_assignee.sql
index 6825feff80..c3817d6413 100644
--- a/packages/database/supabase/migrations/20240324175747_assignee.sql
+++ b/packages/database/supabase/migrations/20240324175747_assignee.sql
@@ -13,15 +13,15 @@ CREATE OR REPLACE VIEW "parts" WITH(SECURITY_INVOKER=true) AS
SELECT
i.name,
i.description,
- i."partGroupId",
+ i."itemGroupId",
i.active,
i.blocked,
p.*,
- pg.name AS "partGroup",
+ pg.name AS "itemGroup",
ps."supplierIds"
FROM "part" p
INNER JOIN "item" i ON i.id = p."itemId"
- LEFT JOIN "partGroup" pg ON pg.id = i."partGroupId"
+ LEFT JOIN "itemGroup" pg ON pg.id = i."itemGroupId"
LEFT JOIN (
SELECT
"partId",
@@ -148,14 +148,14 @@ CREATE OR REPLACE VIEW "services" WITH(SECURITY_INVOKER=true) AS
s.*,
i.name,
i.description,
- i."partGroupId",
+ i."itemGroupId",
i.active,
i.blocked,
- pg.name AS "partGroup",
+ pg.name AS "itemGroup",
ss."supplierIds"
FROM "service" s
INNER JOIN "item" i ON i.id = s."itemId"
- LEFT JOIN "partGroup" pg ON pg.id = i."partGroupId"
+ LEFT JOIN "itemGroup" pg ON pg.id = i."itemGroupId"
LEFT JOIN (
SELECT
"serviceId",
diff --git a/packages/database/supabase/migrations/20240511125727_seed_custom_fields.sql b/packages/database/supabase/migrations/20240511125727_seed_custom_fields.sql
index e625e09f04..6115e5f4d6 100644
--- a/packages/database/supabase/migrations/20240511125727_seed_custom_fields.sql
+++ b/packages/database/supabase/migrations/20240511125727_seed_custom_fields.sql
@@ -22,7 +22,7 @@ VALUES
('location', 'Location', 'Resources'),
('part', 'Part', 'Parts'),
('partCost', 'Part Cost', 'Parts'),
-('partGroup', 'Part Group', 'Parts'),
+('itemGroup', 'Item Group', 'Parts'),
('partInventory', 'Part Inventory', 'Parts'),
('partPlanning', 'Part Planning', 'Parts'),
('partReplenishment', 'Part Replenishment', 'Parts'),