Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

feat: replace pull from inventory with default method type and move posting group to accounting tab

Brad Barbin725c84a6d479
diff --git a/README.md b/README.md
index 10ffc5b700..3bfb040d53 100644
--- a/README.md
+++ b/README.md
@@ -149,7 +149,7 @@ $ npm run dev # npm run dev in all apps & packages
You can now sign in with:
password: carbon
Go ahead and create your own user account
diff --git a/apps/carbon/app/components/Form/DefaultMethodType.tsx b/apps/carbon/app/components/Form/DefaultMethodType.tsx
new file mode 100644
index 0000000000..1b611b2d9a
--- /dev/null
+++ b/apps/carbon/app/components/Form/DefaultMethodType.tsx
@@ -0,0 +1,23 @@
+import type { SelectProps } from "./SelectControlled";
+import SelectControlled from "./SelectControlled";
+
+export type DefaultMethodTypeSelectProps = Omit<SelectProps, "options"> & {
+ replenishmentSystem: string;
+};
+
+const DefaultMethodType = ({
+ replenishmentSystem,
+ ...props
+}: DefaultMethodTypeSelectProps) => {
+ const options = (
+ replenishmentSystem === "Buy"
+ ? ["Buy", "Pick"]
+ : replenishmentSystem === "Make"
+ ? ["Make", "Pick"]
+ : ["Buy", "Make", "Pick"]
+ ).map((t) => ({ value: t, label: t }));
+
+ return <SelectControlled {...props} options={options} />;
+};
+
+export default DefaultMethodType;
diff --git a/apps/carbon/app/components/Form/Item.tsx b/apps/carbon/app/components/Form/Item.tsx
index d688599547..4adbe29e3d 100644
--- a/apps/carbon/app/components/Form/Item.tsx
+++ b/apps/carbon/app/components/Form/Item.tsx
@@ -1,7 +1,13 @@
import type { Database } from "@carbon/database";
import { useDisclosure } from "@carbon/react";
import { useMemo, useRef, useState } from "react";
-import { PartForm, ToolForm } from "~/modules/items";
+import {
+ ConsumableForm,
+ FixtureForm,
+ MaterialForm,
+ PartForm,
+ ToolForm,
+} from "~/modules/items";
import { useItems } from "~/stores";
import type { ComboboxProps } from "./Combobox";
import CreatableCombobox from "./CreatableCombobox";
@@ -9,6 +15,7 @@ import CreatableCombobox from "./CreatableCombobox";
type ItemSelectProps = Omit<ComboboxProps, "options" | "type"> & {
type: Database["public"]["Enums"]["itemType"];
disabledItems?: string[];
+ replenishmentSystem?: string;
};
const Item = ({ type, ...props }: ItemSelectProps) => {
@@ -19,7 +26,14 @@ const Item = ({ type, ...props }: ItemSelectProps) => {
const options = useMemo(() => {
const results =
- items
+ (props?.replenishmentSystem
+ ? items.filter(
+ (item) =>
+ item.type === type &&
+ item.replenishmentSystem === props.replenishmentSystem
+ )
+ : items
+ )
.filter((item) => item.type === type)
.map((item) => ({
value: item.id,
@@ -33,7 +47,7 @@ const Item = ({ type, ...props }: ItemSelectProps) => {
}
return results;
- }, [items, props.disabledItems, type]);
+ }, [items, props.disabledItems, props.replenishmentSystem, type]);
return (
<>
@@ -59,14 +73,77 @@ const Item = ({ type, ...props }: ItemSelectProps) => {
id: "",
name: created,
description: "",
- itemInventoryType: "Inventory",
+ itemTrackingType: "Inventory",
replenishmentSystem: "Buy and Make",
unitOfMeasureCode: "EA",
- pullFromInventory: false,
+ defaultMethodType: "Make",
active: true,
}}
/>
)}
+ {type === "Consumable" && newItemsModal.isOpen && (
+ <ConsumableForm
+ type="modal"
+ onClose={() => {
+ setCreated("");
+ newItemsModal.onClose();
+ triggerRef.current?.click();
+ }}
+ initialValues={{
+ id: "",
+ name: created,
+ description: "",
+ itemTrackingType: "Non-Inventory",
+ unitOfMeasureCode: "EA",
+ replenishmentSystem: "Buy and Make",
+ defaultMethodType: "Buy",
+ active: true,
+ }}
+ />
+ )}
+ {type === "Fixture" && newItemsModal.isOpen && (
+ <FixtureForm
+ type="modal"
+ onClose={() => {
+ setCreated("");
+ newItemsModal.onClose();
+ triggerRef.current?.click();
+ }}
+ initialValues={{
+ id: "",
+ name: created,
+ description: "",
+ itemTrackingType: "Inventory",
+ unitOfMeasureCode: "EA",
+ replenishmentSystem: "Buy and Make",
+ defaultMethodType: "Buy",
+ active: true,
+ }}
+ />
+ )}
+ {type === "Material" && newItemsModal.isOpen && (
+ <MaterialForm
+ type="modal"
+ onClose={() => {
+ setCreated("");
+ newItemsModal.onClose();
+ triggerRef.current?.click();
+ }}
+ initialValues={{
+ id: "",
+ name: created,
+ description: "",
+ materialFormId: "",
+ materialSubstanceId: "",
+ itemTrackingType: "Inventory",
+ unitOfMeasureCode: "EA",
+ replenishmentSystem: "Buy and Make",
+ defaultMethodType: "Buy",
+ active: true,
+ }}
+ />
+ )}
+ {/* TODO: Add service */}
{type === "Tool" && newItemsModal.isOpen && (
<ToolForm
type="modal"
@@ -79,9 +156,10 @@ const Item = ({ type, ...props }: ItemSelectProps) => {
id: "",
name: created,
description: "",
- itemInventoryType: "Inventory",
+ itemTrackingType: "Inventory",
unitOfMeasureCode: "EA",
- pullFromInventory: false,
+ replenishmentSystem: "Buy and Make",
+ defaultMethodType: "Buy",
active: true,
}}
/>
diff --git a/apps/carbon/app/components/Form/ItemGroup.tsx b/apps/carbon/app/components/Form/ItemPostingGroup.tsx
similarity index 58%
rename from apps/carbon/app/components/Form/ItemGroup.tsx
rename to apps/carbon/app/components/Form/ItemPostingGroup.tsx
index eab6828c47..df084f23f6 100644
--- a/apps/carbon/app/components/Form/ItemGroup.tsx
+++ b/apps/carbon/app/components/Form/ItemPostingGroup.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 { getItemGroupsList } from "~/modules/items";
-import { ItemGroupForm } from "~/modules/items";
+import type { getItemPostingGroupsList } from "~/modules/items";
+import { ItemPostingGroupForm } from "~/modules/items";
import { path } from "~/utils/path";
import type { ComboboxProps } from "./Combobox";
import CreatableCombobox from "./CreatableCombobox";
-type ItemGroupSelectProps = Omit<ComboboxProps, "options">;
+type ItemPostingGroupSelectProps = Omit<ComboboxProps, "options">;
-const ItemGroup = (props: ItemGroupSelectProps) => {
- const newItemGroupModal = useDisclosure();
+const ItemPostingGroup = (props: ItemPostingGroupSelectProps) => {
+ const newItemPostingGroupModal = useDisclosure();
const [created, setCreated] = useState<string>("");
const triggerRef = useRef<HTMLButtonElement>(null);
- const options = useItemGroups();
+ const options = useItemPostingGroups();
return (
<>
@@ -22,18 +22,18 @@ const ItemGroup = (props: ItemGroupSelectProps) => {
ref={triggerRef}
options={options}
{...props}
- label={props?.label ?? "Item Group"}
+ label={props?.label ?? "Posting Group"}
onCreateOption={(option) => {
- newItemGroupModal.onOpen();
+ newItemPostingGroupModal.onOpen();
setCreated(option);
}}
/>
- {newItemGroupModal.isOpen && (
- <ItemGroupForm
+ {newItemPostingGroupModal.isOpen && (
+ <ItemPostingGroupForm
type="modal"
onClose={() => {
setCreated("");
- newItemGroupModal.onClose();
+ newItemPostingGroupModal.onClose();
triggerRef.current?.click();
}}
initialValues={{
@@ -45,16 +45,16 @@ const ItemGroup = (props: ItemGroupSelectProps) => {
);
};
-ItemGroup.displayName = "ItemGroup";
+ItemPostingGroup.displayName = "ItemPostingGroup";
-export default ItemGroup;
+export default ItemPostingGroup;
-export const useItemGroups = () => {
+export const useItemPostingGroups = () => {
const itemGroupFetcher =
- useFetcher<Awaited<ReturnType<typeof getItemGroupsList>>>();
+ useFetcher<Awaited<ReturnType<typeof getItemPostingGroupsList>>>();
useMount(() => {
- itemGroupFetcher.load(path.to.api.itemGroups);
+ itemGroupFetcher.load(path.to.api.itemPostingGroups);
});
const options = useMemo(
diff --git a/apps/carbon/app/components/Form/Part.tsx b/apps/carbon/app/components/Form/Part.tsx
index 59900a11e2..318f812ff7 100644
--- a/apps/carbon/app/components/Form/Part.tsx
+++ b/apps/carbon/app/components/Form/Part.tsx
@@ -6,10 +6,10 @@ import type { ComboboxProps } from "./Combobox";
import CreatableCombobox from "./CreatableCombobox";
type PartSelectProps = Omit<ComboboxProps, "options"> & {
- partReplenishmentSystem?: ItemReplenishmentSystem;
+ itemReplenishmentSystem?: ItemReplenishmentSystem;
};
-const Part = ({ partReplenishmentSystem, ...props }: PartSelectProps) => {
+const Part = ({ itemReplenishmentSystem, ...props }: PartSelectProps) => {
const parts = useParts();
const newPartsModal = useDisclosure();
const [created, setCreated] = useState<string>("");
@@ -49,10 +49,10 @@ const Part = ({ partReplenishmentSystem, ...props }: PartSelectProps) => {
id: "",
name: created,
description: "",
- itemInventoryType: "Inventory" as "Inventory",
- replenishmentSystem: partReplenishmentSystem ?? "Buy and Make",
+ itemTrackingType: "Inventory" as "Inventory",
+ replenishmentSystem: itemReplenishmentSystem ?? "Buy and Make",
+ defaultMethodType: "Buy",
unitOfMeasureCode: "EA",
- pullFromInventory: false,
active: true,
}}
/>
diff --git a/apps/carbon/app/components/Form/index.ts b/apps/carbon/app/components/Form/index.ts
index c430ec9a21..eb9b4db075 100644
--- a/apps/carbon/app/components/Form/index.ts
+++ b/apps/carbon/app/components/Form/index.ts
@@ -18,6 +18,7 @@ import CustomerLocation from "./CustomerLocation";
import CustomerStatus from "./CustomerStatus";
import CustomerType from "./CustomerType";
import DatePicker from "./DatePicker";
+import DefaultMethodType from "./DefaultMethodType";
import Department from "./Department";
import Employee from "./Employee";
import Employees from "./Employees";
@@ -26,7 +27,7 @@ import Hidden from "./Hidden";
import Input from "./Input";
import InputControlled from "./InputControlled";
import Item from "./Item";
-import ItemGroup from "./ItemGroup";
+import ItemPostingGroup from "./ItemPostingGroup";
import Location from "./Location";
import Number from "./Number";
import NumberControlled from "./NumberControlled";
@@ -76,6 +77,7 @@ export {
CustomerStatus,
CustomerType,
DatePicker,
+ DefaultMethodType,
Department,
Employee,
Employees,
@@ -84,7 +86,7 @@ export {
Input,
InputControlled,
Item,
- ItemGroup,
+ ItemPostingGroup,
Location,
Number,
NumberControlled,
diff --git a/apps/carbon/app/components/Table/Table.tsx b/apps/carbon/app/components/Table/Table.tsx
index d9b1c9d5ab..4d33a7f612 100644
--- a/apps/carbon/app/components/Table/Table.tsx
+++ b/apps/carbon/app/components/Table/Table.tsx
@@ -165,26 +165,29 @@ const Table = <T extends object>({
// These are not part of the standard API, but are accessible via table.options.meta
editableComponents,
updateData: (rowIndex, updates) => {
- setInternalData((previousData) =>
- previousData.map((row, index) => {
+ setInternalData((previousData) => {
+ const newData = previousData.map((row, index) => {
if (index === rowIndex) {
- let newRow = { ...row };
- Object.entries(updates).forEach(([columnId, value]) => {
- if (columnId.includes("_") && !(columnId in newRow)) {
- updateNestedProperty(newRow, columnId, value);
- return newRow;
- } else {
- return {
- ...newRow,
- [columnId]: value,
- };
- }
- });
- return newRow;
+ return Object.entries(updates).reduce(
+ (newRow, [columnId, value]) => {
+ if (columnId.includes("_") && !(columnId in newRow)) {
+ updateNestedProperty(newRow, columnId, value);
+ return newRow;
+ } else {
+ return {
+ ...newRow,
+ [columnId]: value,
+ };
+ }
+ },
+ row
+ );
}
return row;
- })
- );
+ });
+
+ return newData;
+ });
},
},
});
diff --git a/apps/carbon/app/modules/accounting/accounting.service.ts b/apps/carbon/app/modules/accounting/accounting.service.ts
index 2b39baa13d..68b4307fba 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: {
- itemGroupId: string | null;
+ itemPostingGroupId: string | null;
locationId: string | null;
}
) {
let query = client.from("postingGroupInventory").select("*");
- if (args.itemGroupId === null) {
- query = query.is("itemGroupId", null);
+ if (args.itemPostingGroupId === null) {
+ query = query.is("itemPostingGroupId", null);
} else {
- query = query.eq("itemGroupId", args.itemGroupId);
+ query = query.eq("itemPostingGroupId", args.itemPostingGroupId);
}
if (args.locationId === null) {
@@ -506,7 +506,7 @@ export async function getInventoryPostingGroups(
.eq("companyId", companyId);
query = setGenericQueryFilters(query, args, [
- { column: "itemGroupId", ascending: false },
+ { column: "itemPostingGroupId", ascending: false },
]);
return query;
}
@@ -562,16 +562,16 @@ export async function getPaymentTermsList(
export async function getPurchasingPostingGroup(
client: SupabaseClient<Database>,
args: {
- itemGroupId: string | null;
+ itemPostingGroupId: string | null;
supplierTypeId: string | null;
}
) {
let query = client.from("postingGroupInventory").select("*");
- if (args.itemGroupId === null) {
- query = query.is("itemGroupId", null);
+ if (args.itemPostingGroupId === null) {
+ query = query.is("itemPostingGroupId", null);
} else {
- query = query.eq("itemGroupId", args.itemGroupId);
+ query = query.eq("itemPostingGroupId", args.itemPostingGroupId);
}
if (args.supplierTypeId === null) {
@@ -596,7 +596,7 @@ export async function getPurchasingPostingGroups(
.eq("companyId", companyId);
query = setGenericQueryFilters(query, args, [
- { column: "itemGroupId", ascending: false },
+ { column: "itemPostingGroupId", ascending: false },
]);
return query;
}
@@ -604,16 +604,16 @@ export async function getPurchasingPostingGroups(
export async function getPurchasingSalesGroup(
client: SupabaseClient<Database>,
args: {
- itemGroupId: string | null;
+ itemPostingGroupId: string | null;
customerTypeId: string | null;
}
) {
let query = client.from("postingGroupInventory").select("*");
- if (args.itemGroupId === null) {
- query = query.is("itemGroupId", null);
+ if (args.itemPostingGroupId === null) {
+ query = query.is("itemPostingGroupId", null);
} else {
- query = query.eq("itemGroupId", args.itemGroupId);
+ query = query.eq("itemPostingGroupId", args.itemPostingGroupId);
}
if (args.customerTypeId === null) {
@@ -638,7 +638,7 @@ export async function getSalesPostingGroups(
.eq("companyId", companyId);
query = setGenericQueryFilters(query, args, [
- { column: "itemGroupId", ascending: false },
+ { column: "itemPostingGroupId", 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 e829e0d668..eee361a513 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;
- itemGroups: ListItem[];
+ itemPostingGroups: ListItem[];
locations: ListItem[];
balanceSheetAccounts: AccountListItem[];
incomeStatementAccounts: AccountListItem[];
@@ -22,7 +22,7 @@ type InventoryPostingGroupsTableProps = {
const InventoryPostingGroupsTable = ({
data,
count,
- itemGroups,
+ itemPostingGroups,
locations,
balanceSheetAccounts,
incomeStatementAccounts,
@@ -46,20 +46,21 @@ const InventoryPostingGroupsTable = ({
const columns = useMemo<ColumnDef<InventoryPostingGroup>[]>(() => {
return [
{
- id: "itemGroupId",
- header: "Item Group",
+ id: "itemPostingGroupId",
+ header: "Posting Group",
cell: ({ row }) => (
<Enumerable
value={
- itemGroups.find((group) => group.id === row.original.itemGroupId)
- ?.name ?? null
+ itemPostingGroups.find(
+ (group) => group.id === row.original.itemPostingGroupId
+ )?.name ?? null
}
/>
),
meta: {
filter: {
type: "static",
- options: itemGroups.map((group) => ({
+ options: itemPostingGroups.map((group) => ({
label: <Enumerable value={group.name} />,
value: group.id,
})),
@@ -158,7 +159,7 @@ const InventoryPostingGroupsTable = ({
cell: (item) => item.getValue(),
},
];
- }, [locations, itemGroups]);
+ }, [locations, itemPostingGroups]);
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 5c2b03d508..f9ce6e2b27 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;
- itemGroups: ListItem[];
+ itemPostingGroups: ListItem[];
supplierTypes: ListItem[];
balanceSheetAccounts: AccountListItem[];
incomeStatementAccounts: AccountListItem[];
@@ -22,7 +22,7 @@ type PurchasingPostingGroupsTableProps = {
const PurchasingPostingGroupsTable = ({
data,
count,
- itemGroups,
+ itemPostingGroups,
supplierTypes,
balanceSheetAccounts,
incomeStatementAccounts,
@@ -46,20 +46,21 @@ const PurchasingPostingGroupsTable = ({
const columns = useMemo<ColumnDef<PurchasingPostingGroup>[]>(() => {
return [
{
- id: "itemGroupId",
- header: "Item Group",
+ id: "itemPostingGroupId",
+ header: "Posting Group",
cell: ({ row }) => (
<Enumerable
value={
- itemGroups.find((group) => group.id === row.original.itemGroupId)
- ?.name ?? null
+ itemPostingGroups.find(
+ (group) => group.id === row.original.itemPostingGroupId
+ )?.name ?? null
}
/>
),
meta: {
filter: {
type: "static",
- options: itemGroups.map((group) => ({
+ options: itemPostingGroups.map((group) => ({
label: <Enumerable value={group.name} />,
value: group.id,
})),
@@ -119,7 +120,7 @@ const PurchasingPostingGroupsTable = ({
cell: (item) => item.getValue(),
},
];
- }, [supplierTypes, itemGroups]);
+ }, [supplierTypes, itemPostingGroups]);
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 202d57b070..afc20f0abc 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;
- itemGroups: ListItem[];
+ itemPostingGroups: ListItem[];
customerTypes: ListItem[];
balanceSheetAccounts: AccountListItem[];
incomeStatementAccounts: AccountListItem[];
@@ -19,7 +19,7 @@ type SalesPostingGroupsTableProps = {
const SalesPostingGroupsTable = ({
data,
count,
- itemGroups,
+ itemPostingGroups,
customerTypes,
balanceSheetAccounts,
incomeStatementAccounts,
@@ -43,20 +43,21 @@ const SalesPostingGroupsTable = ({
const columns = useMemo<ColumnDef<SalesPostingGroup>[]>(() => {
return [
{
- id: "itemGroupId",
- header: "Item Group",
+ id: "itemPostingGroupId",
+ header: "Posting Group",
cell: ({ row }) => (
<Enumerable
value={
- itemGroups.find((group) => group.id === row.original.itemGroupId)
- ?.name ?? null
+ itemPostingGroups.find(
+ (group) => group.id === row.original.itemPostingGroupId
+ )?.name ?? null
}
/>
),
meta: {
filter: {
type: "static",
- options: itemGroups.map((group) => ({
+ options: itemPostingGroups.map((group) => ({
label: <Enumerable value={group.name} />,
value: group.id,
})),
@@ -116,7 +117,7 @@ const SalesPostingGroupsTable = ({
cell: (item) => item.getValue(),
},
];
- }, [customerTypes, itemGroups]);
+ }, [customerTypes, itemPostingGroups]);
const editableComponents = useMemo(
() => ({
diff --git a/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceHeader.tsx b/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceHeader.tsx
index 3d3a1162fc..f5fbe22218 100644
--- a/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceHeader.tsx
+++ b/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceHeader.tsx
@@ -65,7 +65,13 @@ const PurchaseInvoiceHeader = () => {
.from("purchaseInvoiceLine")
.select("itemId, itemReadableId, quantity, conversionFactor")
.eq("invoiceId", invoiceId)
- .eq("invoiceLineType", "Part")
+ .in("invoiceLineType", [
+ "Part",
+ "Material",
+ "Tool",
+ "Fixture",
+ "Consumable",
+ ])
.is("purchaseOrderLineId", null);
if (error) throw new Error(error.message);
diff --git a/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLines/PurchaseInvoiceLines.tsx b/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLines/PurchaseInvoiceLines.tsx
index 0c118529a4..e0213a7b31 100644
--- a/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLines/PurchaseInvoiceLines.tsx
+++ b/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLines/PurchaseInvoiceLines.tsx
@@ -184,6 +184,10 @@ const PurchaseInvoiceLines = () => {
cell: ({ row }) => {
switch (row.original.invoiceLineType) {
case "Part":
+ case "Material":
+ case "Tool":
+ case "Fixture":
+ case "Consumable":
return (
<span>
{
@@ -193,6 +197,8 @@ const PurchaseInvoiceLines = () => {
}
</span>
);
+ default:
+ return null;
}
},
},
diff --git a/apps/carbon/app/modules/items/items.models.ts b/apps/carbon/app/modules/items/items.models.ts
index 76aa1c9f57..ad4fd40e7d 100644
--- a/apps/carbon/app/modules/items/items.models.ts
+++ b/apps/carbon/app/modules/items/items.models.ts
@@ -14,7 +14,7 @@ export const defaultWorkInstruction = {
],
};
-export const itemInventoryTypes = ["Inventory", "Non-Inventory"] as const;
+export const itemTrackingTypes = ["Inventory", "Non-Inventory"] as const;
export const itemCostingMethods = [
"Standard",
@@ -46,7 +46,7 @@ export const methodOperationOrders = [
"With Previous",
] as const;
-export const partReplenishmentSystems = [
+export const itemReplenishmentSystems = [
"Buy",
"Make",
"Buy and Make",
@@ -63,13 +63,21 @@ 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()),
- itemGroupId: zfd.text(z.string().optional()),
- itemInventoryType: z.enum(itemInventoryTypes, {
+ replenishmentSystem: z.enum(itemReplenishmentSystems, {
+ errorMap: (issue, ctx) => ({
+ message: "Replenishment system is required",
+ }),
+ }),
+ defaultMethodType: z.enum(methodType, {
+ errorMap: (issue, ctx) => ({
+ message: "Default method is required",
+ }),
+ }),
+ itemTrackingType: z.enum(itemTrackingTypes, {
errorMap: (issue, ctx) => ({
message: "Part type is required",
}),
}),
- pullFromInventory: zfd.checkbox(),
unitOfMeasureCode: z
.string()
.min(1, { message: "Unit of Measure is required" }),
@@ -166,6 +174,7 @@ export const methodOperationValidator = z.object({
export const itemCostValidator = z.object({
itemId: z.string().min(1, { message: "Item ID is required" }),
+ itemPostingGroupId: zfd.text(z.string().optional()),
costingMethod: z.enum(itemCostingMethods, {
errorMap: (issue, ctx) => ({
message: "Costing method is required",
@@ -176,7 +185,7 @@ export const itemCostValidator = z.object({
costIsAdjusted: zfd.checkbox(),
});
-export const itemGroupValidator = z.object({
+export const itemPostingGroupValidator = z.object({
id: zfd.text(z.string().optional()),
name: z.string().min(1, { message: "Name is required" }).max(255),
description: z.string().optional(),
@@ -238,11 +247,6 @@ export const materialSubstanceValidator = z.object({
export const partValidator = itemValidator.merge(
z.object({
id: z.string().min(1, { message: "Part ID is required" }).max(255),
- replenishmentSystem: z.enum(partReplenishmentSystems, {
- errorMap: (issue, ctx) => ({
- message: "Replenishment system is required",
- }),
- }),
})
);
diff --git a/apps/carbon/app/modules/items/items.service.ts b/apps/carbon/app/modules/items/items.service.ts
index fc9dff0c00..e9e8e78d53 100644
--- a/apps/carbon/app/modules/items/items.service.ts
+++ b/apps/carbon/app/modules/items/items.service.ts
@@ -10,8 +10,8 @@ import type {
consumableValidator,
fixtureValidator,
itemCostValidator,
- itemGroupValidator,
itemPlanningValidator,
+ itemPostingGroupValidator,
itemPurchasingValidator,
itemUnitSalePriceValidator,
itemValidator,
@@ -27,11 +27,11 @@ import type {
unitOfMeasureValidator,
} from "./items.models";
-export async function deleteItemGroup(
+export async function deleteItemPostingGroup(
client: SupabaseClient<Database>,
id: string
) {
- return client.from("itemGroup").delete().eq("id", id);
+ return client.from("itemPostingGroup").delete().eq("id", id);
}
export async function deleteMaterialForm(
@@ -205,20 +205,20 @@ export async function getItemCost(
.single();
}
-export async function getItemGroup(
+export async function getItemPostingGroup(
client: SupabaseClient<Database>,
id: string
) {
- return client.from("itemGroup").select("*").eq("id", id).single();
+ return client.from("itemPostingGroup").select("*").eq("id", id).single();
}
-export async function getItemGroups(
+export async function getItemPostingGroups(
client: SupabaseClient<Database>,
companyId: string,
args?: GenericQueryFilters & { search: string | null }
) {
let query = client
- .from("itemGroup")
+ .from("itemPostingGroup")
.select("*", {
count: "exact",
})
@@ -237,12 +237,12 @@ export async function getItemGroups(
return query;
}
-export async function getItemGroupsList(
+export async function getItemPostingGroupsList(
client: SupabaseClient<Database>,
companyId: string
) {
return client
- .from("itemGroup")
+ .from("itemPostingGroup")
.select("id, name", { count: "exact" })
.eq("companyId", companyId)
.order("name");
@@ -608,7 +608,7 @@ export async function getServices(
}
if (args.group) {
- query = query.eq("itemGroupId", args.group);
+ query = query.eq("itemPostingGroupId", args.group);
}
if (args.supplierId) {
@@ -834,10 +834,10 @@ export async function upsertConsumable(
readableId: consumable.id,
name: consumable.name,
type: "Consumable",
- itemGroupId: consumable.itemGroupId,
- itemInventoryType: consumable.itemInventoryType,
+ replenishmentSystem: consumable.replenishmentSystem,
+ defaultMethodType: consumable.defaultMethodType,
+ itemTrackingType: consumable.itemTrackingType,
unitOfMeasureCode: consumable.unitOfMeasureCode,
- pullFromInventory: consumable.pullFromInventory,
active: consumable.active,
companyId: consumable.companyId,
createdBy: consumable.createdBy,
@@ -864,10 +864,10 @@ export async function upsertConsumable(
id: consumable.id,
name: consumable.name,
description: consumable.description,
- itemGroupId: consumable.itemGroupId,
- itemInventoryType: consumable.itemInventoryType,
+ replenishmentSystem: consumable.replenishmentSystem,
+ defaultMethodType: consumable.defaultMethodType,
+ itemTrackingType: consumable.itemTrackingType,
unitOfMeasureCode: consumable.unitOfMeasureCode,
- pullFromInventory: consumable.pullFromInventory,
active: consumable.active,
};
@@ -916,10 +916,10 @@ export async function upsertFixture(
readableId: fixture.id,
name: fixture.name,
type: "Fixture",
- itemGroupId: fixture.itemGroupId,
- itemInventoryType: fixture.itemInventoryType,
+ replenishmentSystem: fixture.replenishmentSystem,
+ defaultMethodType: fixture.defaultMethodType,
+ itemTrackingType: fixture.itemTrackingType,
unitOfMeasureCode: "EA",
- pullFromInventory: true,
active: fixture.active,
companyId: fixture.companyId,
createdBy: fixture.createdBy,
@@ -948,11 +948,11 @@ export async function upsertFixture(
id: fixture.id,
name: fixture.name,
description: fixture.description,
- itemGroupId: fixture.itemGroupId,
- itemInventoryType: fixture.itemInventoryType,
+ replenishmentSystem: fixture.replenishmentSystem,
+ defaultMethodType: fixture.defaultMethodType,
+ itemTrackingType: fixture.itemTrackingType,
unitOfMeasureCode: "EA",
active: fixture.active,
- pullFromInventory: fixture.pullFromInventory,
};
const fixtureUpdate = {
@@ -1001,10 +1001,10 @@ export async function upsertPart(
readableId: part.id,
name: part.name,
type: "Part",
- itemGroupId: part.itemGroupId,
- itemInventoryType: part.itemInventoryType,
+ replenishmentSystem: part.replenishmentSystem,
+ defaultMethodType: part.defaultMethodType,
+ itemTrackingType: part.itemTrackingType,
unitOfMeasureCode: part.unitOfMeasureCode,
- pullFromInventory: part.pullFromInventory,
active: part.active,
companyId: part.companyId,
createdBy: part.createdBy,
@@ -1019,7 +1019,6 @@ export async function upsertPart(
.insert({
id: part.id,
itemId: itemId,
- replenishmentSystem: part.replenishmentSystem,
companyId: part.companyId,
createdBy: part.createdBy,
customFields: part.customFields,
@@ -1032,15 +1031,14 @@ export async function upsertPart(
id: part.id,
name: part.name,
description: part.description,
- itemGroupId: part.itemGroupId,
- itemInventoryType: part.itemInventoryType,
+ replenishmentSystem: part.replenishmentSystem,
+ defaultMethodType: part.defaultMethodType,
+ itemTrackingType: part.itemTrackingType,
unitOfMeasureCode: part.unitOfMeasureCode,
active: part.active,
- pullFromInventory: part.pullFromInventory,
};
const partUpdate = {
- replenishmentSystem: part.replenishmentSystem,
customFields: part.customFields,
};
@@ -1165,29 +1163,33 @@ export async function upsertItemPurchasing(
.eq("itemId", itemPurchasing.itemId);
}
-export async function upsertItemGroup(
+export async function upsertItemPostingGroup(
client: SupabaseClient<Database>,
- itemGroup:
- | (Omit<z.infer<typeof itemGroupValidator>, "id"> & {
+ itemPostingGroup:
+ | (Omit<z.infer<typeof itemPostingGroupValidator>, "id"> & {
companyId: string;
createdBy: string;
customFields?: Json;
})
- | (Omit<z.infer<typeof itemGroupValidator>, "id"> & {
+ | (Omit<z.infer<typeof itemPostingGroupValidator>, "id"> & {
id: string;
updatedBy: string;
customFields?: Json;
})
) {
- if ("createdBy" in itemGroup) {
- return client.from("itemGroup").insert([itemGroup]).select("*").single();
+ if ("createdBy" in itemPostingGroup) {
+ return client
+ .from("itemPostingGroup")
+ .insert([itemPostingGroup])
+ .select("*")
+ .single();
}
return (
client
- .from("itemGroup")
- .update(sanitize(itemGroup))
+ .from("itemPostingGroup")
+ .update(sanitize(itemPostingGroup))
// @ts-ignore
- .eq("id", itemGroup.id)
+ .eq("id", itemPostingGroup.id)
.select("id")
.single()
);
@@ -1281,10 +1283,10 @@ export async function upsertMaterial(
readableId: material.id,
name: material.name,
type: "Material",
- itemGroupId: material.itemGroupId,
- itemInventoryType: material.itemInventoryType,
+ replenishmentSystem: material.replenishmentSystem,
+ defaultMethodType: material.defaultMethodType,
+ itemTrackingType: material.itemTrackingType,
unitOfMeasureCode: material.unitOfMeasureCode,
- pullFromInventory: material.pullFromInventory,
active: material.active,
companyId: material.companyId,
createdBy: material.createdBy,
@@ -1316,11 +1318,11 @@ export async function upsertMaterial(
id: material.id,
name: material.name,
description: material.description,
- itemGroupId: material.itemGroupId,
- itemInventoryType: material.itemInventoryType,
+ replenishmentSystem: material.replenishmentSystem,
+ defaultMethodType: material.defaultMethodType,
+ itemTrackingType: material.itemTrackingType,
unitOfMeasureCode: material.unitOfMeasureCode,
active: material.active,
- pullFromInventory: material.pullFromInventory,
};
const materialUpdate = {
@@ -1332,7 +1334,7 @@ export async function upsertMaterial(
customFields: material.customFields,
};
- const [updateItem, updatePart] = await Promise.all([
+ const [updateItem, updateMaterial] = await Promise.all([
client
.from("item")
.update({
@@ -1350,7 +1352,7 @@ export async function upsertMaterial(
]);
if (updateItem.error) return updateItem;
- return updatePart;
+ return updateMaterial;
}
export async function upsertMaterialForm(
@@ -1438,10 +1440,11 @@ export async function upsertService(
readableId: service.id,
name: service.name,
type: "Service",
- itemGroupId: service.itemGroupId,
- itemInventoryType: service.itemInventoryType,
- unitOfMeasureCode: null,
- pullFromInventory: false,
+ replenishmentSystem:
+ service.serviceType === "External" ? "Buy" : "Make",
+ defaultMethodType: service.serviceType === "External" ? "Buy" : "Make",
+ itemTrackingType: service.itemTrackingType,
+ unitOfMeasureCode: "EA",
active: service.active,
companyId: service.companyId,
createdBy: service.createdBy,
@@ -1467,11 +1470,11 @@ export async function upsertService(
id: service.id,
name: service.name,
description: service.description,
- itemGroupId: service.itemGroupId,
- itemInventoryType: service.itemInventoryType,
+ replenishmentSystem: service.serviceType === "External" ? "Buy" : "Make",
+ defaultMethodType: service.serviceType === "External" ? "Buy" : "Make",
+ itemTrackingType: service.itemTrackingType,
unitOfMeasureCode: null,
active: service.active,
- pullFromInventory: service.pullFromInventory,
};
const serviceUpdate = {
@@ -1549,10 +1552,10 @@ export async function upsertTool(
readableId: tool.id,
name: tool.name,
type: "Tool",
- itemGroupId: tool.itemGroupId,
- itemInventoryType: tool.itemInventoryType,
+ replenishmentSystem: tool.replenishmentSystem,
+ defaultMethodType: tool.defaultMethodType,
+ itemTrackingType: tool.itemTrackingType,
unitOfMeasureCode: tool.unitOfMeasureCode,
- pullFromInventory: tool.pullFromInventory,
active: tool.active,
companyId: tool.companyId,
createdBy: tool.createdBy,
@@ -1579,18 +1582,18 @@ export async function upsertTool(
id: tool.id,
name: tool.name,
description: tool.description,
- itemGroupId: tool.itemGroupId,
- itemInventoryType: tool.itemInventoryType,
+ replenishmentSystem: tool.replenishmentSystem,
+ defaultMethodType: tool.defaultMethodType,
+ itemTrackingType: tool.itemTrackingType,
unitOfMeasureCode: tool.unitOfMeasureCode,
active: tool.active,
- pullFromInventory: tool.pullFromInventory,
};
const toolUpdate = {
customFields: tool.customFields,
};
- const [updateItem, updatePart] = await Promise.all([
+ const [updateItem, updateTool] = await Promise.all([
client
.from("item")
.update({
@@ -1608,5 +1611,5 @@ export async function upsertTool(
]);
if (updateItem.error) return updateItem;
- return updatePart;
+ return updateTool;
}
diff --git a/apps/carbon/app/modules/items/types.ts b/apps/carbon/app/modules/items/types.ts
index 8ed7337c2f..75b5bc408b 100644
--- a/apps/carbon/app/modules/items/types.ts
+++ b/apps/carbon/app/modules/items/types.ts
@@ -5,8 +5,8 @@ import type {
getConsumables,
getFixtures,
getItemCost,
- getItemGroups,
- getItemGroupsList,
+ getItemPostingGroups,
+ getItemPostingGroupsList,
getItemQuantities,
getMaterialForms,
getMaterialSubstances,
@@ -42,12 +42,12 @@ export type ItemCost = NonNullable<
export type ItemCostingMethod =
Database["public"]["Enums"]["itemCostingMethod"];
-export type ItemGroup = NonNullable<
- Awaited<ReturnType<typeof getItemGroups>>["data"]
+export type ItemPostingGroup = NonNullable<
+ Awaited<ReturnType<typeof getItemPostingGroups>>["data"]
>[number];
-export type ItemGroupListItem = NonNullable<
- Awaited<ReturnType<typeof getItemGroupsList>>["data"]
+export type ItemPostingGroupListItem = NonNullable<
+ Awaited<ReturnType<typeof getItemPostingGroupsList>>["data"]
>[number];
export type ItemQuantities = NonNullable<
@@ -64,8 +64,7 @@ export type BuyMethod = NonNullable<
Awaited<ReturnType<typeof getBuyMethods>>["data"]
>[number];
-export type InventoryItemType =
- Database["public"]["Enums"]["itemInventoryType"];
+export type InventoryItemType = Database["public"]["Enums"]["itemTrackingType"];
export type Material = NonNullable<
Awaited<ReturnType<typeof getMaterials>>["data"]
diff --git a/apps/carbon/app/modules/items/ui/Consumables/ConsumableForm.tsx b/apps/carbon/app/modules/items/ui/Consumables/ConsumableForm.tsx
index 302988e7e1..d9cdf6c1ec 100644
--- a/apps/carbon/app/modules/items/ui/Consumables/ConsumableForm.tsx
+++ b/apps/carbon/app/modules/items/ui/Consumables/ConsumableForm.tsx
@@ -21,14 +21,14 @@ import {
Hidden,
Input,
InputControlled,
- ItemGroup,
+ ItemPostingGroup,
Select,
Submit,
TextArea,
UnitOfMeasure,
} from "~/components/Form";
import { useNextItemId, usePermissions } from "~/hooks";
-import { consumableValidator, itemInventoryTypes } from "~/modules/items";
+import { consumableValidator, itemTrackingTypes } from "~/modules/items";
import { path } from "~/utils/path";
type ConsumableFormProps = {
@@ -63,10 +63,10 @@ const ConsumableForm = ({
const permissions = usePermissions();
const isEditing = !!initialValues.id;
- const itemInventoryTypeOptions =
- itemInventoryTypes.map((itemInventoryType) => ({
- label: itemInventoryType,
- value: itemInventoryType,
+ const itemTrackingTypeOptions =
+ itemTrackingTypes.map((itemTrackingType) => ({
+ label: itemTrackingType,
+ value: itemTrackingType,
})) ?? [];
return (
@@ -119,9 +119,9 @@ const ConsumableForm = ({
<Input name="name" label="Name" />
<Select
- name="itemInventoryType"
+ name="itemTrackingType"
label="Tracking Type"
- options={itemInventoryTypeOptions}
+ options={itemTrackingTypeOptions}
/>
{isEditing && (
<TextArea name="description" label="Description" />
@@ -131,7 +131,10 @@ const ConsumableForm = ({
name="unitOfMeasureCode"
label="Unit of Measure"
/>
- <ItemGroup name="itemGroupId" label="Posting Group" />
+ <ItemPostingGroup
+ name="itemPostingGroupId"
+ label="Posting Group"
+ />
<Boolean name="pullFromInventory" label="Pull from Inventory" />
<Boolean name="active" label="Active" />
diff --git a/apps/carbon/app/modules/items/ui/Consumables/ConsumableProperties.tsx b/apps/carbon/app/modules/items/ui/Consumables/ConsumableProperties.tsx
index 85c81225f6..9ebeced09e 100644
--- a/apps/carbon/app/modules/items/ui/Consumables/ConsumableProperties.tsx
+++ b/apps/carbon/app/modules/items/ui/Consumables/ConsumableProperties.tsx
@@ -108,7 +108,7 @@ const ConsumableProperties = () => {
className={cn(
routeData?.consumableSummary?.active === false && "opacity-50"
)}
- value={routeData?.consumableSummary?.itemInventoryType ?? null}
+ value={routeData?.consumableSummary?.itemTrackingType ?? null}
/>
</VStack>
diff --git a/apps/carbon/app/modules/items/ui/Consumables/ConsumablesTable.tsx b/apps/carbon/app/modules/items/ui/Consumables/ConsumablesTable.tsx
index 51077b659f..878f9d9f55 100644
--- a/apps/carbon/app/modules/items/ui/Consumables/ConsumablesTable.tsx
+++ b/apps/carbon/app/modules/items/ui/Consumables/ConsumablesTable.tsx
@@ -8,19 +8,19 @@ import { EmployeeAvatar, Hyperlink, New, Table } from "~/components";
import { usePermissions, useUrlParams } from "~/hooks";
import { useCustomColumns } from "~/hooks/useCustomColumns";
import type { Consumable } from "~/modules/items";
-import { itemInventoryTypes } from "~/modules/items";
+import { itemTrackingTypes, methodType } from "~/modules/items";
import { usePeople } from "~/stores";
import type { ListItem } from "~/types";
import { path } from "~/utils/path";
type ConsumablesTableProps = {
data: Consumable[];
- itemGroups: ListItem[];
+ itemPostingGroups: ListItem[];
count: number;
};
const ConsumablesTable = memo(
- ({ data, count, itemGroups }: ConsumablesTableProps) => {
+ ({ data, count, itemPostingGroups }: ConsumablesTableProps) => {
const navigate = useNavigate();
const permissions = usePermissions();
const [params] = useUrlParams();
@@ -49,13 +49,13 @@ const ConsumablesTable = memo(
cell: (item) => item.getValue(),
},
{
- accessorKey: "itemInventoryType",
- header: "Inventory",
+ accessorKey: "itemTrackingType",
+ header: "Tracking",
cell: (item) => <Enumerable value={item.getValue<string>()} />,
meta: {
filter: {
type: "static",
- options: itemInventoryTypes.map((type) => ({
+ options: itemTrackingTypes.map((type) => ({
value: type,
label: <Enumerable value={type} />,
})),
@@ -63,15 +63,15 @@ const ConsumablesTable = memo(
},
},
{
- accessorKey: "itemGroup",
- header: "Posting Group",
+ accessorKey: "defaultMethodType",
+ header: "Default Method",
cell: (item) => <Enumerable value={item.getValue<string>()} />,
meta: {
filter: {
type: "static",
- options: itemGroups.map(({ name }) => ({
- value: name,
- label: <Enumerable value={name} />,
+ options: methodType.map((value) => ({
+ value,
+ label: <Enumerable value={value} />,
})),
},
},
diff --git a/apps/carbon/app/modules/items/ui/Consumables/useConsumableNavigation.tsx b/apps/carbon/app/modules/items/ui/Consumables/useConsumableNavigation.tsx
index 4ac1f01657..112ed4cda5 100644
--- a/apps/carbon/app/modules/items/ui/Consumables/useConsumableNavigation.tsx
+++ b/apps/carbon/app/modules/items/ui/Consumables/useConsumableNavigation.tsx
@@ -31,9 +31,9 @@ export function useConsumableNavigation() {
shortcut: "Command+Shift+p",
},
{
- name: "Costing",
+ name: "Accounting",
to: path.to.consumableCosting(itemId),
- role: ["employee", "supplier"],
+ role: ["employee"],
icon: LuTags,
shortcut: "Command+Shift+c",
},
diff --git a/apps/carbon/app/modules/items/ui/Fixtures/FixtureForm.tsx b/apps/carbon/app/modules/items/ui/Fixtures/FixtureForm.tsx
index 4fa1090674..1f7104026f 100644
--- a/apps/carbon/app/modules/items/ui/Fixtures/FixtureForm.tsx
+++ b/apps/carbon/app/modules/items/ui/Fixtures/FixtureForm.tsx
@@ -22,13 +22,13 @@ import {
Hidden,
Input,
InputControlled,
- ItemGroup,
+ ItemPostingGroup,
Select,
Submit,
TextArea,
} from "~/components/Form";
import { useNextItemId, usePermissions } from "~/hooks";
-import { fixtureValidator, itemInventoryTypes } from "~/modules/items";
+import { fixtureValidator, itemTrackingTypes } from "~/modules/items";
import { path } from "~/utils/path";
type FixtureFormProps = {
@@ -63,10 +63,10 @@ const FixtureForm = ({
const permissions = usePermissions();
const isEditing = !!initialValues.id;
- const itemInventoryTypeOptions =
- itemInventoryTypes.map((itemInventoryType) => ({
- label: itemInventoryType,
- value: itemInventoryType,
+ const itemTrackingTypeOptions =
+ itemTrackingTypes.map((itemTrackingType) => ({
+ label: itemTrackingType,
+ value: itemTrackingType,
})) ?? [];
return (
@@ -126,11 +126,14 @@ const FixtureForm = ({
)}
<Select
- name="itemInventoryType"
+ name="itemTrackingType"
label="Tracking Type"
- options={itemInventoryTypeOptions}
+ options={itemTrackingTypeOptions}
+ />
+ <ItemPostingGroup
+ name="itemPostingGroupId"
+ label="Posting Group"
/>
- <ItemGroup name="itemGroupId" label="Posting Group" />
<Boolean name="active" label="Active" />
<CustomFormFields table="fixture" />
diff --git a/apps/carbon/app/modules/items/ui/Fixtures/FixturesTable.tsx b/apps/carbon/app/modules/items/ui/Fixtures/FixturesTable.tsx
index 4feb7b6146..b6723742d9 100644
--- a/apps/carbon/app/modules/items/ui/Fixtures/FixturesTable.tsx
+++ b/apps/carbon/app/modules/items/ui/Fixtures/FixturesTable.tsx
@@ -14,19 +14,19 @@ import {
import { usePermissions, useUrlParams } from "~/hooks";
import { useCustomColumns } from "~/hooks/useCustomColumns";
import type { Fixture } from "~/modules/items";
-import { itemInventoryTypes } from "~/modules/items";
+import { itemTrackingTypes, methodType } from "~/modules/items";
import { useCustomers, usePeople } from "~/stores";
import type { ListItem } from "~/types";
import { path } from "~/utils/path";
type FixturesTableProps = {
data: Fixture[];
- itemGroups: ListItem[];
+ itemPostingGroups: ListItem[];
count: number;
};
const FixturesTable = memo(
- ({ data, count, itemGroups }: FixturesTableProps) => {
+ ({ data, count, itemPostingGroups }: FixturesTableProps) => {
const navigate = useNavigate();
const permissions = usePermissions();
const [params] = useUrlParams();
@@ -56,13 +56,13 @@ const FixturesTable = memo(
cell: (item) => item.getValue(),
},
{
- accessorKey: "itemInventoryType",
- header: "Inventory",
+ accessorKey: "itemTrackingType",
+ header: "Tracking",
cell: (item) => <Enumerable value={item.getValue<string>()} />,
meta: {
filter: {
type: "static",
- options: itemInventoryTypes.map((type) => ({
+ options: itemTrackingTypes.map((type) => ({
value: type,
label: <Enumerable value={type} />,
})),
@@ -70,15 +70,15 @@ const FixturesTable = memo(
},
},
{
- accessorKey: "itemGroup",
- header: "Posting Group",
+ accessorKey: "defaultMethodType",
+ header: "Default Method",
cell: (item) => <Enumerable value={item.getValue<string>()} />,
meta: {
filter: {
type: "static",
- options: itemGroups.map(({ name }) => ({
- value: name,
- label: <Enumerable value={name} />,
+ options: methodType.map((value) => ({
+ value,
+ label: <Enumerable value={value} />,
})),
},
},
diff --git a/apps/carbon/app/modules/items/ui/Fixtures/useFixtureNavigation.tsx b/apps/carbon/app/modules/items/ui/Fixtures/useFixtureNavigation.tsx
index 9ff3b11b53..2e211c2e4e 100644
--- a/apps/carbon/app/modules/items/ui/Fixtures/useFixtureNavigation.tsx
+++ b/apps/carbon/app/modules/items/ui/Fixtures/useFixtureNavigation.tsx
@@ -25,9 +25,9 @@ export function useFixtureNavigation() {
shortcut: "Command+Shift+p",
},
{
- name: "Costing",
+ name: "Accounting",
to: path.to.fixtureCosting(itemId),
- role: ["employee", "supplier"],
+ role: ["employee"],
icon: LuTags,
shortcut: "Command+Shift+c",
},
diff --git a/apps/carbon/app/modules/items/ui/Item/BillOfMaterial.tsx b/apps/carbon/app/modules/items/ui/Item/BillOfMaterial.tsx
index 3b18076dc0..08c17bde64 100644
--- a/apps/carbon/app/modules/items/ui/Item/BillOfMaterial.tsx
+++ b/apps/carbon/app/modules/items/ui/Item/BillOfMaterial.tsx
@@ -21,12 +21,12 @@ import { flushSync } from "react-dom";
import { LuSettings2, LuX } from "react-icons/lu";
import type { z } from "zod";
import {
+ DefaultMethodType,
Hidden,
InputControlled,
Item,
Number,
Select,
- SelectControlled,
Submit,
UnitOfMeasure,
} from "~/components/Form";
@@ -393,15 +393,11 @@ function MaterialForm({
}>({
itemId: item.data.itemId ?? "",
itemReadableId: item.data.itemReadableId ?? "",
- methodType: item.data.methodType ?? "",
+ methodType: item.data.methodType ?? "Buy",
description: item.data.description ?? "",
unitOfMeasureCode: item.data.unitOfMeasureCode ?? "EA",
quantity: item.data.quantity ?? 1,
});
- const [methodTypeOptions, setMethodTypeOptions] = useState<MethodType[]>([
- "Buy",
- "Pick",
- ]);
const onTypeChange = (value: MethodItemType) => {
setItemType(value);
@@ -422,76 +418,26 @@ function MaterialForm({
return;
}
- switch (itemType) {
- case "Part":
- const [partItem, part] = await Promise.all([
- supabase
- .from("item")
- .select("name, readableId, unitOfMeasureCode, pullFromInventory")
- .eq("id", itemId)
- .eq("companyId", company.id)
- .single(),
- supabase
- .from("part")
- .select("replenishmentSystem")
- .eq("itemId", itemId)
- .eq("companyId", company.id)
- .single(),
- ]);
- let partMethodType: MethodType = "Buy";
-
- if (part.data?.replenishmentSystem === "Buy") {
- setMethodTypeOptions(["Buy", "Pick"]);
- partMethodType = partItem.data?.pullFromInventory ? "Pick" : "Buy";
- }
-
- if (part.data?.replenishmentSystem === "Make") {
- setMethodTypeOptions(["Make", "Pick"]);
- partMethodType = partItem.data?.pullFromInventory ? "Pick" : "Make";
- }
-
- if (part.data?.replenishmentSystem === "Buy and Make") {
- setMethodTypeOptions(["Buy", "Make", "Pick"]);
- partMethodType = partItem.data?.pullFromInventory ? "Pick" : "Make";
- }
-
- setItemData((d) => ({
- ...d,
- itemId,
- itemReadableId: partItem.data?.readableId ?? "",
- description: partItem.data?.name ?? "",
- unitOfMeasureCode: partItem.data?.unitOfMeasureCode ?? "EA",
- methodType: partMethodType,
- }));
- break;
- case "Consumable":
- case "Material":
- case "Tool":
- case "Fixture":
- const item = await supabase
- .from("item")
- .select("name, readableId, unitOfMeasureCode, pullFromInventory")
- .eq("id", itemId)
- .eq("companyId", company.id)
- .single();
-
- setMethodTypeOptions(["Buy", "Pick"]);
- const methodType = item.data?.pullFromInventory ? "Pick" : "Buy";
-
- setItemData((d) => ({
- ...d,
- itemId,
- itemReadableId: item.data?.readableId ?? "",
- description: item.data?.name ?? "",
- unitOfMeasureCode: item.data?.unitOfMeasureCode ?? "EA",
- methodType: methodType,
- }));
- break;
- case "Service":
- break;
- default:
- throw new Error(`Invalid item type: ${itemType}`);
+ const item = await supabase
+ .from("item")
+ .select("name, readableId, unitOfMeasureCode, defaultMethodType")
+ .eq("id", itemId)
+ .eq("companyId", company.id)
+ .single();
+
+ if (item.error) {
+ toast.error("Failed to load item details");
+ return;
}
+
+ setItemData((d) => ({
+ ...d,
+ itemId,
+ itemReadableId: item.data?.readableId ?? "",
+ description: item.data?.name ?? "",
+ unitOfMeasureCode: item.data?.unitOfMeasureCode ?? "EA",
+ methodType: item.data?.defaultMethodType ?? "Buy",
+ }));
};
return (
@@ -545,20 +491,11 @@ function MaterialForm({
onItemChange(value?.value as string);
}}
/>
- <SelectControlled
+ <DefaultMethodType
name="methodType"
- label="Method"
+ label="Method Type"
value={itemData.methodType}
- options={methodTypeOptions.map((value) => ({
- value,
- label: value,
- }))}
- onChange={(newValue) =>
- setItemData((d) => ({
- ...d,
- methodType: (newValue?.value ?? "Buy") as MethodType,
- }))
- }
+ replenishmentSystem="Buy and Make"
/>
<InputControlled
name="description"
diff --git a/apps/carbon/app/modules/items/ui/Item/ItemCostingForm.tsx b/apps/carbon/app/modules/items/ui/Item/ItemCostingForm.tsx
index e9b88bc209..74a424e2a6 100644
--- a/apps/carbon/app/modules/items/ui/Item/ItemCostingForm.tsx
+++ b/apps/carbon/app/modules/items/ui/Item/ItemCostingForm.tsx
@@ -12,6 +12,7 @@ import {
Boolean,
CustomFormFields,
Hidden,
+ ItemPostingGroup,
Number,
Select,
Submit,
@@ -59,6 +60,7 @@ const ItemCostingForm = ({ initialValues }: ItemCostingFormProps) => {
if (newValue) setItemCostingMethod(newValue.value);
}}
/>
+ <ItemPostingGroup name="itemPostingGroupId" label="Posting Group" />
<Number
name="standardCost"
label="Standard Cost"
diff --git a/apps/carbon/app/modules/items/ui/Item/ItemForm.tsx b/apps/carbon/app/modules/items/ui/Item/ItemForm.tsx
index b9c90fb3bb..1054018a23 100644
--- a/apps/carbon/app/modules/items/ui/Item/ItemForm.tsx
+++ b/apps/carbon/app/modules/items/ui/Item/ItemForm.tsx
@@ -14,7 +14,7 @@ import {
CustomFormFields,
Hidden,
Input,
- ItemGroup,
+ ItemPostingGroup,
Submit,
} from "~/components/Form";
import { usePermissions } from "~/hooks";
@@ -57,7 +57,7 @@ const ItemForm = ({ initialValues, type }: ItemFormProps) => {
/>
<Input name="name" label="Name" />
- <ItemGroup name="itemGroupId" label="Item Group" />
+ <ItemPostingGroup name="itemPostingGroupId" label="Posting Group" />
<Boolean name="active" label="Active" />
<CustomFormFields table="part" />
diff --git a/apps/carbon/app/modules/items/ui/ItemGroups/ItemGroupsTable.tsx b/apps/carbon/app/modules/items/ui/ItemGroups/ItemGroupsTable.tsx
deleted file mode 100644
index 5e62974d26..0000000000
--- a/apps/carbon/app/modules/items/ui/ItemGroups/ItemGroupsTable.tsx
+++ /dev/null
@@ -1,100 +0,0 @@
-import { Enumerable, MenuIcon, MenuItem } from "@carbon/react";
-import { useNavigate } from "@remix-run/react";
-import type { ColumnDef } from "@tanstack/react-table";
-import { memo, useCallback, useMemo } from "react";
-import { LuPencil, LuTrash } from "react-icons/lu";
-import { New, Table } from "~/components";
-import { usePermissions, useUrlParams } from "~/hooks";
-import { useCustomColumns } from "~/hooks/useCustomColumns";
-import type { ItemGroup } from "~/modules/items";
-import { path } from "~/utils/path";
-
-type ItemGroupsTableProps = {
- data: ItemGroup[];
- count: number;
-};
-
-const ItemGroupsTable = memo(({ data, count }: ItemGroupsTableProps) => {
- const [params] = useUrlParams();
- const navigate = useNavigate();
- const permissions = usePermissions();
-
- const rows = useMemo(() => data, [data]);
- const customColumns = useCustomColumns<ItemGroup>("itemGroup");
-
- const columns = useMemo<ColumnDef<(typeof rows)[number]>[]>(() => {
- const defaultColumns: ColumnDef<(typeof rows)[number]>[] = [
- {
- accessorKey: "name",
- header: "Name",
- cell: ({ row }) => (
- <Enumerable
- value={row.original.name}
- onClick={() =>
- navigate(
- `${path.to.itemGroup(row.original.id)}?${params.toString()}`
- )
- }
- className="cursor-pointer"
- />
- ),
- },
- {
- accessorKey: "description",
- header: "Description",
- cell: (item) => item.getValue(),
- },
- ];
- return [...defaultColumns, ...customColumns];
- }, [navigate, params, customColumns]);
-
- const renderContextMenu = useCallback(
- (row: (typeof rows)[number]) => {
- return (
- <>
- <MenuItem
- disabled={!permissions.can("update", "parts")}
- onClick={() => {
- navigate(`${path.to.itemGroup(row.id)}?${params.toString()}`);
- }}
- >
- <MenuIcon icon={<LuPencil />} />
- Edit Item Group
- </MenuItem>
- <MenuItem
- disabled={!permissions.can("delete", "parts")}
- onClick={() => {
- navigate(
- `${path.to.deleteItemGroup(row.id)}?${params.toString()}`
- );
- }}
- >
- <MenuIcon icon={<LuTrash />} />
- Delete Item Group
- </MenuItem>
- </>
- );
- },
- [navigate, params, permissions]
- );
-
- return (
- <Table<(typeof rows)[number]>
- data={data}
- columns={columns}
- count={count}
- primaryAction={
- permissions.can("create", "parts") && (
- <New
- label="Item Group"
- to={`${path.to.newItemGroup}?${params.toString()}`}
- />
- )
- }
- renderContextMenu={renderContextMenu}
- />
- );
-});
-
-ItemGroupsTable.displayName = "ItemGroupsTable";
-export default ItemGroupsTable;
diff --git a/apps/carbon/app/modules/items/ui/ItemGroups/index.ts b/apps/carbon/app/modules/items/ui/ItemGroups/index.ts
deleted file mode 100644
index 025ed88462..0000000000
--- a/apps/carbon/app/modules/items/ui/ItemGroups/index.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-import ItemGroupForm from "./ItemGroupForm";
-import ItemGroupsTable from "./ItemGroupsTable";
-
-export { ItemGroupForm, ItemGroupsTable };
diff --git a/apps/carbon/app/modules/items/ui/ItemGroups/ItemGroupForm.tsx b/apps/carbon/app/modules/items/ui/ItemPostingGroups/ItemPostingGroupForm.tsx
similarity index 85%
rename from apps/carbon/app/modules/items/ui/ItemGroups/ItemGroupForm.tsx
rename to apps/carbon/app/modules/items/ui/ItemPostingGroups/ItemPostingGroupForm.tsx
index bff7308055..70baa161ca 100644
--- a/apps/carbon/app/modules/items/ui/ItemGroups/ItemGroupForm.tsx
+++ b/apps/carbon/app/modules/items/ui/ItemPostingGroups/ItemPostingGroupForm.tsx
@@ -24,22 +24,22 @@ import {
TextArea,
} from "~/components/Form";
import { usePermissions } from "~/hooks";
-import { itemGroupValidator } from "~/modules/items";
+import { itemPostingGroupValidator } from "~/modules/items";
import { path } from "~/utils/path";
-type ItemGroupFormProps = {
- initialValues: z.infer<typeof itemGroupValidator>;
+type ItemPostingGroupFormProps = {
+ initialValues: z.infer<typeof itemPostingGroupValidator>;
type?: "modal" | "drawer";
open?: boolean;
onClose: (data?: { id: string; name: string }) => void;
};
-const ItemGroupForm = ({
+const ItemPostingGroupForm = ({
initialValues,
open = true,
type = "drawer",
onClose,
-}: ItemGroupFormProps) => {
+}: ItemPostingGroupFormProps) => {
const permissions = usePermissions();
const fetcher = useFetcher<PostgrestResponse<{ id: string; name: string }>>();
@@ -69,12 +69,12 @@ const ItemGroupForm = ({
>
<ModalDrawerContent>
<ValidatedForm
- validator={itemGroupValidator}
+ validator={itemPostingGroupValidator}
method="post"
action={
isEditing
- ? path.to.itemGroup(initialValues.id!)
- : path.to.newItemGroup
+ ? path.to.itemPostingGroup(initialValues.id!)
+ : path.to.newItemPostingGroup
}
defaultValues={initialValues}
fetcher={fetcher}
@@ -91,7 +91,7 @@ const ItemGroupForm = ({
<VStack spacing={4}>
<Input name="name" label="Name" />
<TextArea name="description" label="Description" />
- <CustomFormFields table="itemGroup" />
+ <CustomFormFields table="itemPostingGroup" />
</VStack>
</ModalDrawerBody>
<ModalDrawerFooter>
@@ -109,4 +109,4 @@ const ItemGroupForm = ({
);
};
-export default ItemGroupForm;
+export default ItemPostingGroupForm;
diff --git a/apps/carbon/app/modules/items/ui/ItemPostingGroups/ItemPostingGroupsTable.tsx b/apps/carbon/app/modules/items/ui/ItemPostingGroups/ItemPostingGroupsTable.tsx
new file mode 100644
index 0000000000..9cd3f35463
--- /dev/null
+++ b/apps/carbon/app/modules/items/ui/ItemPostingGroups/ItemPostingGroupsTable.tsx
@@ -0,0 +1,109 @@
+import { Enumerable, MenuIcon, MenuItem } from "@carbon/react";
+import { useNavigate } from "@remix-run/react";
+import type { ColumnDef } from "@tanstack/react-table";
+import { memo, useCallback, useMemo } from "react";
+import { LuPencil, LuTrash } from "react-icons/lu";
+import { New, Table } from "~/components";
+import { usePermissions, useUrlParams } from "~/hooks";
+import { useCustomColumns } from "~/hooks/useCustomColumns";
+import type { ItemPostingGroup } from "~/modules/items";
+import { path } from "~/utils/path";
+
+type ItemPostingGroupsTableProps = {
+ data: ItemPostingGroup[];
+ count: number;
+};
+
+const ItemPostingGroupsTable = memo(
+ ({ data, count }: ItemPostingGroupsTableProps) => {
+ const [params] = useUrlParams();
+ const navigate = useNavigate();
+ const permissions = usePermissions();
+
+ const rows = useMemo(() => data, [data]);
+ const customColumns =
+ useCustomColumns<ItemPostingGroup>("itemPostingGroup");
+
+ const columns = useMemo<ColumnDef<(typeof rows)[number]>[]>(() => {
+ const defaultColumns: ColumnDef<(typeof rows)[number]>[] = [
+ {
+ accessorKey: "name",
+ header: "Name",
+ cell: ({ row }) => (
+ <Enumerable
+ value={row.original.name}
+ onClick={() =>
+ navigate(
+ `${path.to.itemPostingGroup(
+ row.original.id
+ )}?${params.toString()}`
+ )
+ }
+ className="cursor-pointer"
+ />
+ ),
+ },
+ {
+ accessorKey: "description",
+ header: "Description",
+ cell: (item) => item.getValue(),
+ },
+ ];
+ return [...defaultColumns, ...customColumns];
+ }, [navigate, params, customColumns]);
+
+ const renderContextMenu = useCallback(
+ (row: (typeof rows)[number]) => {
+ return (
+ <>
+ <MenuItem
+ disabled={!permissions.can("update", "parts")}
+ onClick={() => {
+ navigate(
+ `${path.to.itemPostingGroup(row.id)}?${params.toString()}`
+ );
+ }}
+ >
+ <MenuIcon icon={<LuPencil />} />
+ Edit Item Group
+ </MenuItem>
+ <MenuItem
+ disabled={!permissions.can("delete", "parts")}
+ onClick={() => {
+ navigate(
+ `${path.to.deleteItemPostingGroup(
+ row.id
+ )}?${params.toString()}`
+ );
+ }}
+ >
+ <MenuIcon icon={<LuTrash />} />
+ Delete Item Group
+ </MenuItem>
+ </>
+ );
+ },
+ [navigate, params, permissions]
+ );
+
+ return (
+ <Table<(typeof rows)[number]>
+ data={data}
+ columns={columns}
+ count={count}
+ primaryAction={
+ permissions.can("create", "parts") && (
+ <New
+ label="Posting Group"
+ to={`${path.to.newItemPostingGroup}?${params.toString()}`}
+ />
+ )
+ }
+ renderContextMenu={renderContextMenu}
+ />
+ );
+ }
+);
+
+ItemPostingGroupsTable.displayName = "ItemPostingGroupsTable";
+export default ItemPostingGroupsTable;
diff --git a/apps/carbon/app/modules/items/ui/ItemPostingGroups/index.ts b/apps/carbon/app/modules/items/ui/ItemPostingGroups/index.ts
new file mode 100644
index 0000000000..c462fbd35f
--- /dev/null
+++ b/apps/carbon/app/modules/items/ui/ItemPostingGroups/index.ts
@@ -0,0 +1,4 @@
+import ItemPostingGroupForm from "./ItemPostingGroupForm";
+import ItemPostingGroupsTable from "./ItemPostingGroupsTable";
+
+export { ItemPostingGroupForm, ItemPostingGroupsTable };
diff --git a/apps/carbon/app/modules/items/ui/Materials/MaterialForm.tsx b/apps/carbon/app/modules/items/ui/Materials/MaterialForm.tsx
index 4af25c8a1f..1e775a7850 100644
--- a/apps/carbon/app/modules/items/ui/Materials/MaterialForm.tsx
+++ b/apps/carbon/app/modules/items/ui/Materials/MaterialForm.tsx
@@ -14,15 +14,15 @@ import {
import { ValidatedForm } from "@carbon/remix-validated-form";
import { useFetcher } from "@remix-run/react";
import type { PostgrestResponse } from "@supabase/supabase-js";
-import { useEffect, useMemo } from "react";
+import { useEffect, useMemo, useState } from "react";
import type { z } from "zod";
import {
Boolean,
CustomFormFields,
+ DefaultMethodType,
Hidden,
Input,
InputControlled,
- ItemGroup,
Select,
Submit,
TextArea,
@@ -33,7 +33,7 @@ import type {
getMaterialFormsList,
getMaterialSubstancesList,
} from "~/modules/items";
-import { itemInventoryTypes, materialValidator } from "~/modules/items";
+import { itemTrackingTypes, materialValidator } from "~/modules/items";
import type { ListItem } from "~/types";
import { path } from "~/utils/path";
@@ -71,10 +71,14 @@ const MaterialForm = ({
const permissions = usePermissions();
const isEditing = !!initialValues.id;
- const itemInventoryTypeOptions =
- itemInventoryTypes.map((itemInventoryType) => ({
- label: itemInventoryType,
- value: itemInventoryType,
+ const [defaultMethodType, setDefaultMethodType] = useState<string>(
+ initialValues.defaultMethodType ?? "Buy"
+ );
+
+ const itemTrackingTypeOptions =
+ itemTrackingTypes.map((itemTrackingType) => ({
+ label: itemTrackingType,
+ value: itemTrackingType,
})) ?? [];
return (
@@ -101,6 +105,7 @@ const MaterialForm = ({
</ModalCardHeader>
<ModalCardBody>
<Hidden name="type" value={type} />
+ <Hidden name="replenishmentSystem" value="Buy" />
<div
className={cn(
"grid w-full gap-x-8 gap-y-4",
@@ -140,17 +145,25 @@ const MaterialForm = ({
<Input name="dimensions" label="Dimensions" />
<Select
- name="itemInventoryType"
+ name="itemTrackingType"
label="Tracking Type"
- options={itemInventoryTypeOptions}
+ options={itemTrackingTypeOptions}
+ />
+
+ <DefaultMethodType
+ name="defaultMethodType"
+ label="Default Method Type"
+ replenishmentSystem="Buy"
+ value={defaultMethodType}
+ onChange={(newValue) =>
+ setDefaultMethodType(newValue?.value ?? "Buy")
+ }
/>
<UnitOfMeasure
name="unitOfMeasureCode"
label="Unit of Measure"
/>
- <ItemGroup name="itemGroupId" label="Posting Group" />
- <Boolean name="pullFromInventory" label="Pull from Inventory" />
<Boolean name="active" label="Active" />
<CustomFormFields table="material" />
diff --git a/apps/carbon/app/modules/items/ui/Materials/MaterialProperties.tsx b/apps/carbon/app/modules/items/ui/Materials/MaterialProperties.tsx
index 33d82d8796..0dcf5d2dac 100644
--- a/apps/carbon/app/modules/items/ui/Materials/MaterialProperties.tsx
+++ b/apps/carbon/app/modules/items/ui/Materials/MaterialProperties.tsx
@@ -120,7 +120,7 @@ const MaterialProperties = () => {
className={cn(
routeData?.materialSummary?.active === false && "opacity-50"
)}
- value={routeData?.materialSummary?.itemInventoryType ?? null}
+ value={routeData?.materialSummary?.itemTrackingType ?? null}
/>
</VStack>
diff --git a/apps/carbon/app/modules/items/ui/Materials/MaterialsTable.tsx b/apps/carbon/app/modules/items/ui/Materials/MaterialsTable.tsx
index 786a19caea..5657890589 100644
--- a/apps/carbon/app/modules/items/ui/Materials/MaterialsTable.tsx
+++ b/apps/carbon/app/modules/items/ui/Materials/MaterialsTable.tsx
@@ -8,19 +8,19 @@ import { EmployeeAvatar, Hyperlink, New, Table } from "~/components";
import { usePermissions, useUrlParams } from "~/hooks";
import { useCustomColumns } from "~/hooks/useCustomColumns";
import type { Material } from "~/modules/items";
-import { itemInventoryTypes } from "~/modules/items";
+import { itemTrackingTypes, methodType } from "~/modules/items";
import { usePeople } from "~/stores";
import type { ListItem } from "~/types";
import { path } from "~/utils/path";
type MaterialsTableProps = {
data: Material[];
- itemGroups: ListItem[];
+ itemPostingGroups: ListItem[];
count: number;
};
const MaterialsTable = memo(
- ({ data, count, itemGroups }: MaterialsTableProps) => {
+ ({ data, count, itemPostingGroups }: MaterialsTableProps) => {
const navigate = useNavigate();
const permissions = usePermissions();
const [params] = useUrlParams();
@@ -96,13 +96,13 @@ const MaterialsTable = memo(
cell: (item) => item.getValue(),
},
{
- accessorKey: "itemInventoryType",
- header: "Inventory",
+ accessorKey: "itemTrackingType",
+ header: "Tracking",
cell: (item) => <Enumerable value={item.getValue<string>()} />,
meta: {
filter: {
type: "static",
- options: itemInventoryTypes.map((type) => ({
+ options: itemTrackingTypes.map((type) => ({
value: type,
label: <Enumerable value={type} />,
})),
@@ -110,15 +110,15 @@ const MaterialsTable = memo(
},
},
{
- accessorKey: "itemGroup",
- header: "Posting Group",
+ accessorKey: "defaultMethodType",
+ header: "Default Method",
cell: (item) => <Enumerable value={item.getValue<string>()} />,
meta: {
filter: {
type: "static",
- options: itemGroups.map(({ name }) => ({
- value: name,
- label: <Enumerable value={name} />,
+ options: methodType.map((value) => ({
+ value,
+ label: <Enumerable value={value} />,
})),
},
},
diff --git a/apps/carbon/app/modules/items/ui/Materials/useMaterialNavigation.tsx b/apps/carbon/app/modules/items/ui/Materials/useMaterialNavigation.tsx
index 165e3fddc8..445e629222 100644
--- a/apps/carbon/app/modules/items/ui/Materials/useMaterialNavigation.tsx
+++ b/apps/carbon/app/modules/items/ui/Materials/useMaterialNavigation.tsx
@@ -31,9 +31,9 @@ export function useMaterialNavigation() {
shortcut: "Command+Shift+p",
},
{
- name: "Costing",
+ name: "Accounting",
to: path.to.materialCosting(itemId),
- role: ["employee", "supplier"],
+ role: ["employee"],
icon: LuTags,
shortcut: "Command+Shift+c",
},
diff --git a/apps/carbon/app/modules/items/ui/Parts/PartForm.tsx b/apps/carbon/app/modules/items/ui/Parts/PartForm.tsx
index aa9f3c35f2..e4eb788a47 100644
--- a/apps/carbon/app/modules/items/ui/Parts/PartForm.tsx
+++ b/apps/carbon/app/modules/items/ui/Parts/PartForm.tsx
@@ -13,15 +13,15 @@ import {
import { ValidatedForm } from "@carbon/remix-validated-form";
import { useFetcher } from "@remix-run/react";
import type { PostgrestResponse } from "@supabase/supabase-js";
-import { useEffect } from "react";
+import { useEffect, useState } from "react";
import type { z } from "zod";
import {
Boolean,
CustomFormFields,
+ DefaultMethodType,
Hidden,
Input,
InputControlled,
- ItemGroup,
Select,
Submit,
TextArea,
@@ -29,8 +29,8 @@ import {
} from "~/components/Form";
import { useNextItemId, usePermissions } from "~/hooks";
import {
- itemInventoryTypes,
- partReplenishmentSystems,
+ itemReplenishmentSystems,
+ itemTrackingTypes,
partValidator,
} from "~/modules/items";
import { path } from "~/utils/path";
@@ -63,16 +63,22 @@ const PartForm = ({ initialValues, type = "card", onClose }: PartFormProps) => {
const permissions = usePermissions();
const isEditing = !!initialValues.id;
- const itemInventoryTypeOptions =
- itemInventoryTypes.map((itemInventoryType) => ({
- label: itemInventoryType,
- value: itemInventoryType,
+ const itemTrackingTypeOptions =
+ itemTrackingTypes.map((itemTrackingType) => ({
+ label: itemTrackingType,
+ value: itemTrackingType,
})) ?? [];
- const partReplenishmentSystemOptions =
- partReplenishmentSystems.map((partReplenishmentSystem) => ({
- label: partReplenishmentSystem,
- value: partReplenishmentSystem,
+ const [replenishmentSystem, setReplenishmentSystem] = useState<string>(
+ initialValues.replenishmentSystem ?? "Buy"
+ );
+ const [defaultMethodType, setDefaultMethodType] = useState<string>(
+ initialValues.defaultMethodType ?? "Buy"
+ );
+ const itemReplenishmentSystemOptions =
+ itemReplenishmentSystems.map((itemReplenishmentSystem) => ({
+ label: itemReplenishmentSystem,
+ value: itemReplenishmentSystem,
})) ?? [];
return (
@@ -125,9 +131,9 @@ const PartForm = ({ initialValues, type = "card", onClose }: PartFormProps) => {
<Input name="name" label="Name" />
<Select
- name="itemInventoryType"
+ name="itemTrackingType"
label="Tracking Type"
- options={itemInventoryTypeOptions}
+ options={itemTrackingTypeOptions}
/>
{isEditing && (
<TextArea name="description" label="Description" />
@@ -136,15 +142,30 @@ const PartForm = ({ initialValues, type = "card", onClose }: PartFormProps) => {
<Select
name="replenishmentSystem"
label="Replenishment System"
- options={partReplenishmentSystemOptions}
+ options={itemReplenishmentSystemOptions}
+ onChange={(newValue) => {
+ setReplenishmentSystem(newValue?.value ?? "Buy");
+ if (newValue?.value === "Buy") {
+ setDefaultMethodType("Buy");
+ } else {
+ setDefaultMethodType("Make");
+ }
+ }}
+ />
+ <DefaultMethodType
+ name="defaultMethodType"
+ label="Default Method Type"
+ replenishmentSystem={replenishmentSystem}
+ value={defaultMethodType}
+ onChange={(newValue) =>
+ setDefaultMethodType(newValue?.value ?? "Buy")
+ }
/>
<UnitOfMeasure
name="unitOfMeasureCode"
label="Unit of Measure"
/>
- <ItemGroup name="itemGroupId" label="Posting Group" />
- <Boolean name="pullFromInventory" label="Pull from Inventory" />
<Boolean name="active" label="Active" />
<CustomFormFields table="part" />
diff --git a/apps/carbon/app/modules/items/ui/Parts/PartProperties.tsx b/apps/carbon/app/modules/items/ui/Parts/PartProperties.tsx
index 50719db12f..e4074e8593 100644
--- a/apps/carbon/app/modules/items/ui/Parts/PartProperties.tsx
+++ b/apps/carbon/app/modules/items/ui/Parts/PartProperties.tsx
@@ -118,7 +118,7 @@ const PartProperties = () => {
className={cn(
routeData?.partSummary?.active === false && "opacity-50"
)}
- value={routeData?.partSummary?.itemInventoryType ?? null}
+ value={routeData?.partSummary?.itemTrackingType ?? null}
/>
</VStack>
diff --git a/apps/carbon/app/modules/items/ui/Parts/PartsTable.tsx b/apps/carbon/app/modules/items/ui/Parts/PartsTable.tsx
index b00f99ea31..505850df1e 100644
--- a/apps/carbon/app/modules/items/ui/Parts/PartsTable.tsx
+++ b/apps/carbon/app/modules/items/ui/Parts/PartsTable.tsx
@@ -8,203 +8,209 @@ import { EmployeeAvatar, Hyperlink, New, Table } from "~/components";
import { usePermissions, useUrlParams } from "~/hooks";
import { useCustomColumns } from "~/hooks/useCustomColumns";
import type { Part } from "~/modules/items";
-import { itemInventoryTypes, partReplenishmentSystems } from "~/modules/items";
+import {
+ itemReplenishmentSystems,
+ itemTrackingTypes,
+ methodType,
+} from "~/modules/items";
import { usePeople } from "~/stores";
import type { ListItem } from "~/types";
import { path } from "~/utils/path";
type PartsTableProps = {
data: Part[];
- itemGroups: ListItem[];
+ itemPostingGroups: ListItem[];
count: number;
};
-const PartsTable = memo(({ data, count, itemGroups }: PartsTableProps) => {
- const navigate = useNavigate();
- const permissions = usePermissions();
- const [params] = useUrlParams();
- const [people] = usePeople();
- const customColumns = useCustomColumns<Part>("part");
+const PartsTable = memo(
+ ({ data, count, itemPostingGroups }: PartsTableProps) => {
+ const navigate = useNavigate();
+ const permissions = usePermissions();
+ const [params] = useUrlParams();
+ const [people] = usePeople();
+ const customColumns = useCustomColumns<Part>("part");
- const columns = useMemo<ColumnDef<Part>[]>(() => {
- const defaultColumns: ColumnDef<Part>[] = [
- {
- accessorKey: "id",
- header: "Part ID",
- cell: ({ row }) => (
- <Hyperlink to={path.to.partDetails(row.original.itemId!)}>
- {row.original.id}
- </Hyperlink>
- ),
- },
- {
- accessorKey: "name",
- header: "Name",
- cell: (item) => item.getValue(),
- },
- {
- accessorKey: "description",
- header: "Description",
- cell: (item) => item.getValue(),
- },
- {
- accessorKey: "itemInventoryType",
- header: "Inventory",
- cell: (item) => <Enumerable value={item.getValue<string>()} />,
- meta: {
- filter: {
- type: "static",
- options: itemInventoryTypes.map((type) => ({
- value: type,
- label: <Enumerable value={type} />,
- })),
+ const columns = useMemo<ColumnDef<Part>[]>(() => {
+ const defaultColumns: ColumnDef<Part>[] = [
+ {
+ accessorKey: "id",
+ header: "Part ID",
+ cell: ({ row }) => (
+ <Hyperlink to={path.to.partDetails(row.original.itemId!)}>
+ {row.original.id}
+ </Hyperlink>
+ ),
+ },
+ {
+ accessorKey: "name",
+ header: "Name",
+ cell: (item) => item.getValue(),
+ },
+ {
+ accessorKey: "description",
+ header: "Description",
+ cell: (item) => item.getValue(),
+ },
+ {
+ accessorKey: "itemTrackingType",
+ header: "Tracking",
+ cell: (item) => <Enumerable value={item.getValue<string>()} />,
+ meta: {
+ filter: {
+ type: "static",
+ options: itemTrackingTypes.map((type) => ({
+ value: type,
+ label: <Enumerable value={type} />,
+ })),
+ },
},
},
- },
- {
- accessorKey: "replenishmentSystem",
- header: "Replenishment",
- cell: (item) => <Enumerable value={item.getValue<string>()} />,
- meta: {
- filter: {
- type: "static",
- options: partReplenishmentSystems.map((type) => ({
- value: type,
- label: <Enumerable value={type} />,
- })),
+ {
+ accessorKey: "replenishmentSystem",
+ header: "Replenishment",
+ cell: (item) => <Enumerable value={item.getValue<string>()} />,
+ meta: {
+ filter: {
+ type: "static",
+ options: itemReplenishmentSystems.map((type) => ({
+ value: type,
+ label: <Enumerable value={type} />,
+ })),
+ },
},
},
- },
- {
- accessorKey: "itemGroup",
- header: "Posting Group",
- cell: (item) => <Enumerable value={item.getValue<string>()} />,
- meta: {
- filter: {
- type: "static",
- options: itemGroups.map(({ name }) => ({
- value: name,
- label: <Enumerable value={name} />,
- })),
+ {
+ accessorKey: "defaultMethodType",
+ header: "Default Method",
+ cell: (item) => <Enumerable value={item.getValue<string>()} />,
+ meta: {
+ filter: {
+ type: "static",
+ options: methodType.map((value) => ({
+ value,
+ label: <Enumerable value={value} />,
+ })),
+ },
},
},
- },
- {
- accessorKey: "active",
- header: "Active",
- cell: (item) => <Checkbox isChecked={item.getValue<boolean>()} />,
- meta: {
- filter: {
- type: "static",
- options: [
- { value: "true", label: "Active" },
- { value: "false", label: "Inactive" },
- ],
+ {
+ accessorKey: "active",
+ header: "Active",
+ cell: (item) => <Checkbox isChecked={item.getValue<boolean>()} />,
+ meta: {
+ filter: {
+ type: "static",
+ options: [
+ { value: "true", label: "Active" },
+ { value: "false", label: "Inactive" },
+ ],
+ },
+ pluralHeader: "Active Statuses",
},
- pluralHeader: "Active Statuses",
},
- },
- {
- id: "assignee",
- header: "Assignee",
- cell: ({ row }) => (
- <EmployeeAvatar employeeId={row.original.assignee} />
- ),
- meta: {
- filter: {
- type: "static",
- options: people.map((employee) => ({
- value: employee.id,
- label: employee.name,
- })),
+ {
+ id: "assignee",
+ header: "Assignee",
+ cell: ({ row }) => (
+ <EmployeeAvatar employeeId={row.original.assignee} />
+ ),
+ meta: {
+ filter: {
+ type: "static",
+ options: people.map((employee) => ({
+ value: employee.id,
+ label: employee.name,
+ })),
+ },
},
},
- },
- {
- id: "createdBy",
- header: "Created By",
- cell: ({ row }) => (
- <EmployeeAvatar employeeId={row.original.createdBy} />
- ),
- meta: {
- filter: {
- type: "static",
- options: people.map((employee) => ({
- value: employee.id,
- label: employee.name,
- })),
+ {
+ id: "createdBy",
+ header: "Created By",
+ cell: ({ row }) => (
+ <EmployeeAvatar employeeId={row.original.createdBy} />
+ ),
+ meta: {
+ filter: {
+ type: "static",
+ options: people.map((employee) => ({
+ value: employee.id,
+ label: employee.name,
+ })),
+ },
},
},
- },
- {
- accessorKey: "createdAt",
- header: "Created At",
- cell: (item) => formatDate(item.getValue<string>()),
- },
- {
- id: "updatedBy",
- header: "Updated By",
- cell: ({ row }) => (
- <EmployeeAvatar employeeId={row.original.updatedBy} />
- ),
- meta: {
- filter: {
- type: "static",
- options: people.map((employee) => ({
- value: employee.id,
- label: employee.name,
- })),
+ {
+ accessorKey: "createdAt",
+ header: "Created At",
+ cell: (item) => formatDate(item.getValue<string>()),
+ },
+ {
+ id: "updatedBy",
+ header: "Updated By",
+ cell: ({ row }) => (
+ <EmployeeAvatar employeeId={row.original.updatedBy} />
+ ),
+ meta: {
+ filter: {
+ type: "static",
+ options: people.map((employee) => ({
+ value: employee.id,
+ label: employee.name,
+ })),
+ },
},
},
- },
- {
- accessorKey: "updatedAt",
- header: "Created At",
- cell: (item) => formatDate(item.getValue<string>()),
- },
- ];
- return [...defaultColumns, ...customColumns];
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [params]);
+ {
+ accessorKey: "updatedAt",
+ header: "Created At",
+ cell: (item) => formatDate(item.getValue<string>()),
+ },
+ ];
+ return [...defaultColumns, ...customColumns];
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [params]);
- const renderContextMenu = useMemo(() => {
- // eslint-disable-next-line react/display-name
- return (row: Part) => (
- <MenuItem onClick={() => navigate(path.to.part(row.itemId!))}>
- <MenuIcon icon={<LuPencil />} />
- Edit Part
- </MenuItem>
- );
- }, [navigate]);
+ const renderContextMenu = useMemo(() => {
+ // eslint-disable-next-line react/display-name
+ return (row: Part) => (
+ <MenuItem onClick={() => navigate(path.to.part(row.itemId!))}>
+ <MenuIcon icon={<LuPencil />} />
+ Edit Part
+ </MenuItem>
+ );
+ }, [navigate]);
- return (
- <>
- <Table<Part>
- count={count}
- columns={columns}
- data={data}
- defaultColumnPinning={{
- left: ["id"],
- }}
- defaultColumnVisibility={{
- description: false,
- active: false,
- createdBy: false,
- createdAt: false,
- updatedBy: false,
- updatedAt: false,
- }}
- primaryAction={
- permissions.can("create", "parts") && (
- <New label="Part" to={path.to.newPart} />
- )
- }
- renderContextMenu={renderContextMenu}
- withColumnOrdering
- />
- </>
- );
-});
+ return (
+ <>
+ <Table<Part>
+ count={count}
+ columns={columns}
+ data={data}
+ defaultColumnPinning={{
+ left: ["id"],
+ }}
+ defaultColumnVisibility={{
+ description: false,
+ active: false,
+ createdBy: false,
+ createdAt: false,
+ updatedBy: false,
+ updatedAt: false,
+ }}
+ primaryAction={
+ permissions.can("create", "parts") && (
+ <New label="Part" to={path.to.newPart} />
+ )
+ }
+ renderContextMenu={renderContextMenu}
+ withColumnOrdering
+ />
+ </>
+ );
+ }
+);
PartsTable.displayName = "PartTable";
diff --git a/apps/carbon/app/modules/items/ui/Parts/usePartNavigation.tsx b/apps/carbon/app/modules/items/ui/Parts/usePartNavigation.tsx
index 90a9393974..954035af14 100644
--- a/apps/carbon/app/modules/items/ui/Parts/usePartNavigation.tsx
+++ b/apps/carbon/app/modules/items/ui/Parts/usePartNavigation.tsx
@@ -58,9 +58,9 @@ export function usePartNavigation() {
shortcut: "Command+Shift+i",
},
{
- name: "Costing",
+ name: "Accounting",
to: path.to.partCosting(itemId),
- role: ["employee", "supplier"],
+ role: ["employee"],
icon: LuTags,
shortcut: "Command+Shift+c",
},
diff --git a/apps/carbon/app/modules/items/ui/Services/ServiceForm.tsx b/apps/carbon/app/modules/items/ui/Services/ServiceForm.tsx
index 12bf6b4ff3..529c767e83 100644
--- a/apps/carbon/app/modules/items/ui/Services/ServiceForm.tsx
+++ b/apps/carbon/app/modules/items/ui/Services/ServiceForm.tsx
@@ -15,7 +15,7 @@ import {
Hidden,
Input,
InputControlled,
- ItemGroup,
+ ItemPostingGroup,
Select,
Submit,
TextArea,
@@ -57,7 +57,7 @@ const ServiceForm = ({ initialValues }: ServiceFormProps) => {
)}
</CardHeader>
<CardContent>
- <Hidden name="itemInventoryType" value="Non-Inventory" />
+ <Hidden name="itemTrackingType" value="Non-Inventory" />
<Hidden name="unitOfMeasureCode" value="EA" />
<Hidden name="pullFromInventory" value="on" />
<div
@@ -87,7 +87,7 @@ const ServiceForm = ({ initialValues }: ServiceFormProps) => {
label="Service Type"
options={serviceTypeOptions}
/>
- <ItemGroup name="itemGroupId" label="Posting Group" />
+ <ItemPostingGroup name="itemPostingGroupId" label="Posting Group" />
<Boolean name="active" label="Active" />
<CustomFormFields table="service" />
diff --git a/apps/carbon/app/modules/items/ui/Services/ServicesTable.tsx b/apps/carbon/app/modules/items/ui/Services/ServicesTable.tsx
index 8040a2041d..921dfb438a 100644
--- a/apps/carbon/app/modules/items/ui/Services/ServicesTable.tsx
+++ b/apps/carbon/app/modules/items/ui/Services/ServicesTable.tsx
@@ -8,189 +8,185 @@ import { EmployeeAvatar, Hyperlink, New, Table } from "~/components";
import { usePermissions } from "~/hooks";
import { useCustomColumns } from "~/hooks/useCustomColumns";
import type { Service } from "~/modules/items";
-import { serviceType } from "~/modules/items";
+import { methodType, serviceType } from "~/modules/items";
import { usePeople } from "~/stores";
-import type { ListItem } from "~/types";
import { path } from "~/utils/path";
type ServicesTableProps = {
data: Service[];
- itemGroups: ListItem[];
count: number;
};
-const ServicesTable = memo(
- ({ data, count, itemGroups }: ServicesTableProps) => {
- const navigate = useNavigate();
- const permissions = usePermissions();
- const customColumns = useCustomColumns<Service>("part");
- const [people] = usePeople();
+const ServicesTable = memo(({ data, count }: ServicesTableProps) => {
+ const navigate = useNavigate();
+ const permissions = usePermissions();
+ const customColumns = useCustomColumns<Service>("part");
+ const [people] = usePeople();
- const columns = useMemo<ColumnDef<Service>[]>(() => {
- const defaultColumns: ColumnDef<Service>[] = [
- {
- accessorKey: "id",
- header: "Service ID",
- cell: ({ row }) => (
- <Hyperlink to={path.to.serviceDetails(row.original.itemId!)}>
- {row.original.id}
- </Hyperlink>
- ),
- },
- {
- accessorKey: "name",
- header: "Name",
- cell: (item) => item.getValue(),
- },
- {
- accessorKey: "description",
- header: "Description",
- cell: (item) => item.getValue(),
- },
- {
- accessorKey: "serviceType",
- header: "Service Type",
- cell: (item) => <Enumerable value={item.getValue<string>()} />,
- meta: {
- filter: {
- type: "static",
- options: serviceType.map((type) => ({
- value: type,
- label: <Enumerable value={type} />,
- })),
- },
+ const columns = useMemo<ColumnDef<Service>[]>(() => {
+ const defaultColumns: ColumnDef<Service>[] = [
+ {
+ accessorKey: "id",
+ header: "Service ID",
+ cell: ({ row }) => (
+ <Hyperlink to={path.to.serviceDetails(row.original.itemId!)}>
+ {row.original.id}
+ </Hyperlink>
+ ),
+ },
+ {
+ accessorKey: "name",
+ header: "Name",
+ cell: (item) => item.getValue(),
+ },
+ {
+ accessorKey: "description",
+ header: "Description",
+ cell: (item) => item.getValue(),
+ },
+ {
+ accessorKey: "serviceType",
+ header: "Service Type",
+ cell: (item) => <Enumerable value={item.getValue<string>()} />,
+ meta: {
+ filter: {
+ type: "static",
+ options: serviceType.map((type) => ({
+ value: type,
+ label: <Enumerable value={type} />,
+ })),
},
},
- {
- accessorKey: "itemGroup",
- header: "Item Group",
- cell: (item) => <Enumerable value={item.getValue<string>()} />,
- meta: {
- filter: {
- type: "static",
- options: itemGroups.map(({ id, name }) => ({
- value: name,
- label: <Enumerable value={name} />,
- })),
- },
+ },
+ {
+ accessorKey: "defaultMethodType",
+ header: "Default Method",
+ cell: (item) => <Enumerable value={item.getValue<string>()} />,
+ meta: {
+ filter: {
+ type: "static",
+ options: methodType.map((value) => ({
+ value,
+ label: <Enumerable value={value} />,
+ })),
},
},
- {
- accessorKey: "active",
- header: "Active",
- cell: (item) => <Checkbox isChecked={item.getValue<boolean>()} />,
- meta: {
- filter: {
- type: "static",
- options: [
- { value: "true", label: "Active" },
- { value: "false", label: "Inactive" },
- ],
- },
- pluralHeader: "Active Statuses",
+ },
+ {
+ accessorKey: "active",
+ header: "Active",
+ cell: (item) => <Checkbox isChecked={item.getValue<boolean>()} />,
+ meta: {
+ filter: {
+ type: "static",
+ options: [
+ { value: "true", label: "Active" },
+ { value: "false", label: "Inactive" },
+ ],
},
+ pluralHeader: "Active Statuses",
},
- {
- id: "assignee",
- header: "Assignee",
- cell: ({ row }) => (
- <EmployeeAvatar employeeId={row.original.assignee} />
- ),
- meta: {
- filter: {
- type: "static",
- options: people.map((employee) => ({
- value: employee.id,
- label: employee.name,
- })),
- },
+ },
+ {
+ id: "assignee",
+ header: "Assignee",
+ cell: ({ row }) => (
+ <EmployeeAvatar employeeId={row.original.assignee} />
+ ),
+ meta: {
+ filter: {
+ type: "static",
+ options: people.map((employee) => ({
+ value: employee.id,
+ label: employee.name,
+ })),
},
},
- {
- id: "createdBy",
- header: "Created By",
- cell: ({ row }) => (
- <EmployeeAvatar employeeId={row.original.createdBy} />
- ),
- meta: {
- filter: {
- type: "static",
- options: people.map((employee) => ({
- value: employee.id,
- label: employee.name,
- })),
- },
+ },
+ {
+ id: "createdBy",
+ header: "Created By",
+ cell: ({ row }) => (
+ <EmployeeAvatar employeeId={row.original.createdBy} />
+ ),
+ meta: {
+ filter: {
+ type: "static",
+ options: people.map((employee) => ({
+ value: employee.id,
+ label: employee.name,
+ })),
},
},
- {
- accessorKey: "createdAt",
- header: "Created At",
- cell: (item) => formatDate(item.getValue<string>()),
- },
- {
- id: "updatedBy",
- header: "Updated By",
- cell: ({ row }) => (
- <EmployeeAvatar employeeId={row.original.updatedBy} />
- ),
- meta: {
- filter: {
- type: "static",
- options: people.map((employee) => ({
- value: employee.id,
- label: employee.name,
- })),
- },
+ },
+ {
+ accessorKey: "createdAt",
+ header: "Created At",
+ cell: (item) => formatDate(item.getValue<string>()),
+ },
+ {
+ id: "updatedBy",
+ header: "Updated By",
+ cell: ({ row }) => (
+ <EmployeeAvatar employeeId={row.original.updatedBy} />
+ ),
+ meta: {
+ filter: {
+ type: "static",
+ options: people.map((employee) => ({
+ value: employee.id,
+ label: employee.name,
+ })),
},
},
- {
- accessorKey: "updatedAt",
- header: "Created At",
- cell: (item) => formatDate(item.getValue<string>()),
- },
- ];
- return [...defaultColumns, ...customColumns];
- }, [customColumns, itemGroups, people]);
-
- const renderContextMenu = useMemo(() => {
- // eslint-disable-next-line react/display-name
- return (row: Service) => (
- <MenuItem onClick={() => navigate(path.to.service(row.itemId!))}>
- <MenuIcon icon={<LuPencil />} />
- Edit Service
- </MenuItem>
- );
- }, [navigate]);
+ },
+ {
+ accessorKey: "updatedAt",
+ header: "Created At",
+ cell: (item) => formatDate(item.getValue<string>()),
+ },
+ ];
+ return [...defaultColumns, ...customColumns];
+ }, [customColumns, people]);
- return (
- <>
- <Table<Service>
- count={count}
- columns={columns}
- data={data}
- defaultColumnPinning={{
- left: ["id"],
- }}
- defaultColumnVisibility={{
- description: false,
- active: false,
- createdBy: false,
- createdAt: false,
- updatedBy: false,
- updatedAt: false,
- }}
- primaryAction={
- permissions.can("create", "parts") && (
- <New label="Service" to={path.to.newService} />
- )
- }
- renderContextMenu={renderContextMenu}
- withColumnOrdering
- />
- </>
+ const renderContextMenu = useMemo(() => {
+ // eslint-disable-next-line react/display-name
+ return (row: Service) => (
+ <MenuItem onClick={() => navigate(path.to.part(row.itemId!))}>
+ <MenuIcon icon={<LuPencil />} />
+ Edit Service
+ </MenuItem>
);
- }
-);
+ }, [navigate]);
+
+ return (
+ <>
+ <Table<Service>
+ count={count}
+ columns={columns}
+ data={data}
+ defaultColumnPinning={{
+ left: ["id"],
+ }}
+ defaultColumnVisibility={{
+ description: false,
+ active: false,
+ createdBy: false,
+ createdAt: false,
+ updatedBy: false,
+ updatedAt: false,
+ }}
+ primaryAction={
+ permissions.can("create", "parts") && (
+ <New label="Service" to={path.to.newService} />
+ )
+ }
+ renderContextMenu={renderContextMenu}
+ withColumnOrdering
+ />
+ </>
+ );
+});
ServicesTable.displayName = "ServiceTable";
diff --git a/apps/carbon/app/modules/items/ui/Tools/ToolForm.tsx b/apps/carbon/app/modules/items/ui/Tools/ToolForm.tsx
index d9e9ceb821..671c315d2a 100644
--- a/apps/carbon/app/modules/items/ui/Tools/ToolForm.tsx
+++ b/apps/carbon/app/modules/items/ui/Tools/ToolForm.tsx
@@ -21,14 +21,14 @@ import {
Hidden,
Input,
InputControlled,
- ItemGroup,
+ ItemPostingGroup,
Select,
Submit,
TextArea,
UnitOfMeasure,
} from "~/components/Form";
import { useNextItemId, usePermissions } from "~/hooks";
-import { itemInventoryTypes, toolValidator } from "~/modules/items";
+import { itemTrackingTypes, toolValidator } from "~/modules/items";
import { path } from "~/utils/path";
type ToolFormProps = {
@@ -59,10 +59,10 @@ const ToolForm = ({ initialValues, type = "card", onClose }: ToolFormProps) => {
const permissions = usePermissions();
const isEditing = !!initialValues.id;
- const itemInventoryTypeOptions =
- itemInventoryTypes.map((itemInventoryType) => ({
- label: itemInventoryType,
- value: itemInventoryType,
+ const itemTrackingTypeOptions =
+ itemTrackingTypes.map((itemTrackingType) => ({
+ label: itemTrackingType,
+ value: itemTrackingType,
})) ?? [];
return (
@@ -115,9 +115,9 @@ const ToolForm = ({ initialValues, type = "card", onClose }: ToolFormProps) => {
<Input name="name" label="Name" />
<Select
- name="itemInventoryType"
+ name="itemTrackingType"
label="Tracking Type"
- options={itemInventoryTypeOptions}
+ options={itemTrackingTypeOptions}
/>
{isEditing && (
<TextArea name="description" label="Description" />
@@ -127,7 +127,10 @@ const ToolForm = ({ initialValues, type = "card", onClose }: ToolFormProps) => {
name="unitOfMeasureCode"
label="Unit of Measure"
/>
- <ItemGroup name="itemGroupId" label="Posting Group" />
+ <ItemPostingGroup
+ name="itemPostingGroupId"
+ label="Posting Group"
+ />
<Boolean name="pullFromInventory" label="Pull from Inventory" />
<Boolean name="active" label="Active" />
diff --git a/apps/carbon/app/modules/items/ui/Tools/ToolProperties.tsx b/apps/carbon/app/modules/items/ui/Tools/ToolProperties.tsx
index f259de8be5..b4ee891d0f 100644
--- a/apps/carbon/app/modules/items/ui/Tools/ToolProperties.tsx
+++ b/apps/carbon/app/modules/items/ui/Tools/ToolProperties.tsx
@@ -108,7 +108,7 @@ const ToolProperties = () => {
className={cn(
routeData?.toolSummary?.active === false && "opacity-50"
)}
- value={routeData?.toolSummary?.itemInventoryType ?? null}
+ value={routeData?.toolSummary?.itemTrackingType ?? null}
/>
</VStack>
diff --git a/apps/carbon/app/modules/items/ui/Tools/ToolsTable.tsx b/apps/carbon/app/modules/items/ui/Tools/ToolsTable.tsx
index c0a3ec5385..18a3c0dbb8 100644
--- a/apps/carbon/app/modules/items/ui/Tools/ToolsTable.tsx
+++ b/apps/carbon/app/modules/items/ui/Tools/ToolsTable.tsx
@@ -8,189 +8,191 @@ import { EmployeeAvatar, Hyperlink, New, Table } from "~/components";
import { usePermissions, useUrlParams } from "~/hooks";
import { useCustomColumns } from "~/hooks/useCustomColumns";
import type { Tool } from "~/modules/items";
-import { itemInventoryTypes } from "~/modules/items";
+import { itemTrackingTypes, methodType } from "~/modules/items";
import { usePeople } from "~/stores";
import type { ListItem } from "~/types";
import { path } from "~/utils/path";
type ToolsTableProps = {
data: Tool[];
- itemGroups: ListItem[];
+ itemPostingGroups: ListItem[];
count: number;
};
-const ToolsTable = memo(({ data, count, itemGroups }: ToolsTableProps) => {
- const navigate = useNavigate();
- const permissions = usePermissions();
- const [params] = useUrlParams();
- const [people] = usePeople();
- const customColumns = useCustomColumns<Tool>("tool");
+const ToolsTable = memo(
+ ({ data, count, itemPostingGroups }: ToolsTableProps) => {
+ const navigate = useNavigate();
+ const permissions = usePermissions();
+ const [params] = useUrlParams();
+ const [people] = usePeople();
+ const customColumns = useCustomColumns<Tool>("tool");
- const columns = useMemo<ColumnDef<Tool>[]>(() => {
- const defaultColumns: ColumnDef<Tool>[] = [
- {
- accessorKey: "id",
- header: "Tool ID",
- cell: ({ row }) => (
- <Hyperlink to={path.to.toolDetails(row.original.itemId!)}>
- {row.original.id}
- </Hyperlink>
- ),
- },
- {
- accessorKey: "name",
- header: "Name",
- cell: (item) => item.getValue(),
- },
- {
- accessorKey: "description",
- header: "Description",
- cell: (item) => item.getValue(),
- },
- {
- accessorKey: "itemInventoryType",
- header: "Inventory",
- cell: (item) => <Enumerable value={item.getValue<string>()} />,
- meta: {
- filter: {
- type: "static",
- options: itemInventoryTypes.map((type) => ({
- value: type,
- label: <Enumerable value={type} />,
- })),
+ const columns = useMemo<ColumnDef<Tool>[]>(() => {
+ const defaultColumns: ColumnDef<Tool>[] = [
+ {
+ accessorKey: "id",
+ header: "Tool ID",
+ cell: ({ row }) => (
+ <Hyperlink to={path.to.toolDetails(row.original.itemId!)}>
+ {row.original.id}
+ </Hyperlink>
+ ),
+ },
+ {
+ accessorKey: "name",
+ header: "Name",
+ cell: (item) => item.getValue(),
+ },
+ {
+ accessorKey: "description",
+ header: "Description",
+ cell: (item) => item.getValue(),
+ },
+ {
+ accessorKey: "itemTrackingType",
+ header: "Tracking",
+ cell: (item) => <Enumerable value={item.getValue<string>()} />,
+ meta: {
+ filter: {
+ type: "static",
+ options: itemTrackingTypes.map((type) => ({
+ value: type,
+ label: <Enumerable value={type} />,
+ })),
+ },
},
},
- },
- {
- accessorKey: "itemGroup",
- header: "Posting Group",
- cell: (item) => <Enumerable value={item.getValue<string>()} />,
- meta: {
- filter: {
- type: "static",
- options: itemGroups.map(({ name }) => ({
- value: name,
- label: <Enumerable value={name} />,
- })),
+ {
+ accessorKey: "defaultMethodType",
+ header: "Default Method",
+ cell: (item) => <Enumerable value={item.getValue<string>()} />,
+ meta: {
+ filter: {
+ type: "static",
+ options: methodType.map((value) => ({
+ value,
+ label: <Enumerable value={value} />,
+ })),
+ },
},
},
- },
- {
- accessorKey: "active",
- header: "Active",
- cell: (item) => <Checkbox isChecked={item.getValue<boolean>()} />,
- meta: {
- filter: {
- type: "static",
- options: [
- { value: "true", label: "Active" },
- { value: "false", label: "Inactive" },
- ],
+ {
+ accessorKey: "active",
+ header: "Active",
+ cell: (item) => <Checkbox isChecked={item.getValue<boolean>()} />,
+ meta: {
+ filter: {
+ type: "static",
+ options: [
+ { value: "true", label: "Active" },
+ { value: "false", label: "Inactive" },
+ ],
+ },
+ pluralHeader: "Active Statuses",
},
- pluralHeader: "Active Statuses",
},
- },
- {
- id: "assignee",
- header: "Assignee",
- cell: ({ row }) => (
- <EmployeeAvatar employeeId={row.original.assignee} />
- ),
- meta: {
- filter: {
- type: "static",
- options: people.map((employee) => ({
- value: employee.id,
- label: employee.name,
- })),
+ {
+ id: "assignee",
+ header: "Assignee",
+ cell: ({ row }) => (
+ <EmployeeAvatar employeeId={row.original.assignee} />
+ ),
+ meta: {
+ filter: {
+ type: "static",
+ options: people.map((employee) => ({
+ value: employee.id,
+ label: employee.name,
+ })),
+ },
},
},
- },
- {
- id: "createdBy",
- header: "Created By",
- cell: ({ row }) => (
- <EmployeeAvatar employeeId={row.original.createdBy} />
- ),
- meta: {
- filter: {
- type: "static",
- options: people.map((employee) => ({
- value: employee.id,
- label: employee.name,
- })),
+ {
+ id: "createdBy",
+ header: "Created By",
+ cell: ({ row }) => (
+ <EmployeeAvatar employeeId={row.original.createdBy} />
+ ),
+ meta: {
+ filter: {
+ type: "static",
+ options: people.map((employee) => ({
+ value: employee.id,
+ label: employee.name,
+ })),
+ },
},
},
- },
- {
- accessorKey: "createdAt",
- header: "Created At",
- cell: (item) => formatDate(item.getValue<string>()),
- },
- {
- id: "updatedBy",
- header: "Updated By",
- cell: ({ row }) => (
- <EmployeeAvatar employeeId={row.original.updatedBy} />
- ),
- meta: {
- filter: {
- type: "static",
- options: people.map((employee) => ({
- value: employee.id,
- label: employee.name,
- })),
+ {
+ accessorKey: "createdAt",
+ header: "Created At",
+ cell: (item) => formatDate(item.getValue<string>()),
+ },
+ {
+ id: "updatedBy",
+ header: "Updated By",
+ cell: ({ row }) => (
+ <EmployeeAvatar employeeId={row.original.updatedBy} />
+ ),
+ meta: {
+ filter: {
+ type: "static",
+ options: people.map((employee) => ({
+ value: employee.id,
+ label: employee.name,
+ })),
+ },
},
},
- },
- {
- accessorKey: "updatedAt",
- header: "Created At",
- cell: (item) => formatDate(item.getValue<string>()),
- },
- ];
- return [...defaultColumns, ...customColumns];
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [params]);
+ {
+ accessorKey: "updatedAt",
+ header: "Created At",
+ cell: (item) => formatDate(item.getValue<string>()),
+ },
+ ];
+ return [...defaultColumns, ...customColumns];
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [params]);
- const renderContextMenu = useMemo(() => {
- // eslint-disable-next-line react/display-name
- return (row: Tool) => (
- <MenuItem onClick={() => navigate(path.to.tool(row.itemId!))}>
- <MenuIcon icon={<LuPencil />} />
- Edit Tool
- </MenuItem>
- );
- }, [navigate]);
+ const renderContextMenu = useMemo(() => {
+ // eslint-disable-next-line react/display-name
+ return (row: Tool) => (
+ <MenuItem onClick={() => navigate(path.to.tool(row.itemId!))}>
+ <MenuIcon icon={<LuPencil />} />
+ Edit Tool
+ </MenuItem>
+ );
+ }, [navigate]);
- return (
- <>
- <Table<Tool>
- count={count}
- columns={columns}
- data={data}
- defaultColumnPinning={{
- left: ["id"],
- }}
- defaultColumnVisibility={{
- description: false,
- active: false,
- createdBy: false,
- createdAt: false,
- updatedBy: false,
- updatedAt: false,
- }}
- primaryAction={
- permissions.can("create", "parts") && (
- <New label="Tool" to={path.to.newTool} />
- )
- }
- renderContextMenu={renderContextMenu}
- withColumnOrdering
- />
- </>
- );
-});
+ return (
+ <>
+ <Table<Tool>
+ count={count}
+ columns={columns}
+ data={data}
+ defaultColumnPinning={{
+ left: ["id"],
+ }}
+ defaultColumnVisibility={{
+ description: false,
+ active: false,
+ createdBy: false,
+ createdAt: false,
+ updatedBy: false,
+ updatedAt: false,
+ }}
+ primaryAction={
+ permissions.can("create", "parts") && (
+ <New label="Tool" to={path.to.newTool} />
+ )
+ }
+ renderContextMenu={renderContextMenu}
+ withColumnOrdering
+ />
+ </>
+ );
+ }
+);
ToolsTable.displayName = "ToolTable";
diff --git a/apps/carbon/app/modules/items/ui/Tools/useToolNavigation.tsx b/apps/carbon/app/modules/items/ui/Tools/useToolNavigation.tsx
index ff850ce2f7..e3286d8759 100644
--- a/apps/carbon/app/modules/items/ui/Tools/useToolNavigation.tsx
+++ b/apps/carbon/app/modules/items/ui/Tools/useToolNavigation.tsx
@@ -31,9 +31,9 @@ export function useToolNavigation() {
shortcut: "Command+Shift+p",
},
{
- name: "Costing",
+ name: "Accounting",
to: path.to.toolCosting(itemId),
- role: ["employee", "supplier"],
+ role: ["employee"],
icon: LuTags,
shortcut: "Command+Shift+c",
},
diff --git a/apps/carbon/app/modules/items/ui/index.ts b/apps/carbon/app/modules/items/ui/index.ts
index d2834221d9..b7404fadce 100644
--- a/apps/carbon/app/modules/items/ui/index.ts
+++ b/apps/carbon/app/modules/items/ui/index.ts
@@ -3,7 +3,7 @@ import useItemsSubmodules from "./useItemsSubmodules";
export * from "./Consumables";
export * from "./Fixtures";
export * from "./Item";
-export * from "./ItemGroups";
+export * from "./ItemPostingGroups";
export * from "./MaterialForms";
export * from "./MaterialSubstances";
export * from "./Materials";
diff --git a/apps/carbon/app/modules/items/ui/useItemsSubmodules.tsx b/apps/carbon/app/modules/items/ui/useItemsSubmodules.tsx
index e283fa0240..4129a55746 100644
--- a/apps/carbon/app/modules/items/ui/useItemsSubmodules.tsx
+++ b/apps/carbon/app/modules/items/ui/useItemsSubmodules.tsx
@@ -65,7 +65,7 @@ const itemsRoutes: AuthenticatedRouteGroup[] = [
},
{
name: "Posting Groups",
- to: path.to.itemGroups,
+ to: path.to.itemPostingGroups,
role: "employee",
icon: <PiPiggyBank />,
},
diff --git a/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLines/PurchaseOrderLines.tsx b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLines/PurchaseOrderLines.tsx
index 039418d0d1..a37ce22dc4 100644
--- a/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLines/PurchaseOrderLines.tsx
+++ b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLines/PurchaseOrderLines.tsx
@@ -202,11 +202,17 @@ const PurchaseOrderLines = () => {
cell: ({ row }) => {
switch (row.original.purchaseOrderLineType) {
case "Part":
+ case "Material":
+ case "Tool":
+ case "Fixture":
+ case "Consumable":
return (
<span>
{locations.find((l) => l.id == row.original.locationId)?.name}
</span>
);
+ default:
+ return null;
}
},
},
diff --git a/apps/carbon/app/modules/sales/ui/Quotation/QuotationAssemblyForm.tsx b/apps/carbon/app/modules/sales/ui/Quotation/QuotationAssemblyForm.tsx
index d419c605fa..00a56e751c 100644
--- a/apps/carbon/app/modules/sales/ui/Quotation/QuotationAssemblyForm.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotation/QuotationAssemblyForm.tsx
@@ -159,7 +159,7 @@ const QuotationAssemblyForm = ({
<Part
name="itemId"
label="Manufactured Part"
- partReplenishmentSystem="Make"
+ itemReplenishmentSystem="Make"
onChange={(value) => {
onPartChange(value?.value as string);
}}
diff --git a/apps/carbon/app/modules/sales/ui/Quotation/QuotationMaterialForm.tsx b/apps/carbon/app/modules/sales/ui/Quotation/QuotationMaterialForm.tsx
index 63627c3088..750fcda404 100644
--- a/apps/carbon/app/modules/sales/ui/Quotation/QuotationMaterialForm.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotation/QuotationMaterialForm.tsx
@@ -137,7 +137,7 @@ const QuotationMaterialForm = ({
<Part
name="itemId"
label="Part"
- partReplenishmentSystem="Buy"
+ itemReplenishmentSystem="Buy"
onChange={(value) => {
onPartChange(value?.value as string);
}}
diff --git a/apps/carbon/app/modules/shared/ui/Realtime/RealtimeDataProvider.tsx b/apps/carbon/app/modules/shared/ui/Realtime/RealtimeDataProvider.tsx
index 44252eb2d4..51c66725a2 100644
--- a/apps/carbon/app/modules/shared/ui/Realtime/RealtimeDataProvider.tsx
+++ b/apps/carbon/app/modules/shared/ui/Realtime/RealtimeDataProvider.tsx
@@ -44,7 +44,7 @@ const RealtimeDataProvider = ({ children }: { children: React.ReactNode }) => {
const [items, suppliers, customers, people] = await Promise.all([
supabase
.from("item")
- .select("id, readableId, name, type")
+ .select("id, readableId, name, type, replenishmentSystem")
.eq("companyId", companyId)
.eq("active", true)
.order("name"),
@@ -115,8 +115,9 @@ const RealtimeDataProvider = ({ children }: { children: React.ReactNode }) => {
...items,
{
id: inserted.id,
- readableId: inserted.readableId,
name: inserted.name,
+ readableId: inserted.readableId,
+ replenishmentSystem: inserted.replenishmentSystem,
type: inserted.type,
},
].sort((a, b) => a.name.localeCompare(b.name))
diff --git a/apps/carbon/app/routes/api+/items.groups.ts b/apps/carbon/app/routes/api+/items.groups.ts
index 0c13a60194..58a2587950 100644
--- a/apps/carbon/app/routes/api+/items.groups.ts
+++ b/apps/carbon/app/routes/api+/items.groups.ts
@@ -1,10 +1,10 @@
import type { LoaderFunctionArgs } from "@remix-run/node";
import { json } from "@remix-run/node";
-import { getItemGroupsList } from "~/modules/items";
+import { getItemPostingGroupsList } from "~/modules/items";
import { requirePermissions } from "~/services/auth/auth.server";
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {});
- return json(await getItemGroupsList(client, companyId));
+ return json(await getItemPostingGroupsList(client, companyId));
}
diff --git a/apps/carbon/app/routes/onboarding+/user.tsx b/apps/carbon/app/routes/onboarding+/user.tsx
index 1c0f0f607e..44ced8a7bd 100644
--- a/apps/carbon/app/routes/onboarding+/user.tsx
+++ b/apps/carbon/app/routes/onboarding+/user.tsx
@@ -90,7 +90,7 @@ export default function OnboardingUser() {
const initialValues = {} as z.infer<typeof onboardingUserValidator>;
- if (user?.email && user.email !== "[email protected]") {
+ if (user?.email && user.email !== "[email protected]") {
initialValues.email = user.email;
}
if (
diff --git a/apps/carbon/app/routes/x+/accounting+/groups.inventory.tsx b/apps/carbon/app/routes/x+/accounting+/groups.inventory.tsx
index e1ea50c3d8..3de86ff810 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 { getItemGroupsList } from "~/modules/items";
+import { getItemPostingGroupsList } from "~/modules/items";
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, itemGroups, locations] = await Promise.all([
+ const [inventoryGroups, itemPostingGroups, locations] = await Promise.all([
getInventoryPostingGroups(client, companyId, {
limit,
offset,
sorts,
filters,
}),
- getItemGroupsList(client, companyId),
+ getItemPostingGroupsList(client, companyId),
getLocationsList(client, companyId),
]);
if (inventoryGroups.error) {
@@ -55,14 +55,15 @@ export async function loader({ request }: LoaderFunctionArgs) {
return json({
data: inventoryGroups.data ?? [],
- itemGroups: itemGroups.data ?? [],
+ itemPostingGroups: itemPostingGroups.data ?? [],
locations: locations.data ?? [],
count: inventoryGroups.count ?? 0,
});
}
export default function InventoryPostingGroupsRoute() {
- const { data, itemGroups, locations, count } = useLoaderData<typeof loader>();
+ const { data, itemPostingGroups, locations, count } =
+ useLoaderData<typeof loader>();
const routeData = useRouteData<{
balanceSheetAccounts: AccountListItem[];
@@ -74,7 +75,7 @@ export default function InventoryPostingGroupsRoute() {
<InventoryPostingGroupsTable
data={data}
count={count}
- itemGroups={itemGroups}
+ itemPostingGroups={itemPostingGroups}
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 f3e43ba61a..6fef9edf7d 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 { getItemGroupsList } from "~/modules/items";
+import { getItemPostingGroupsList } from "~/modules/items";
import { getSupplierTypesList } from "~/modules/purchasing";
import { requirePermissions } from "~/services/auth/auth.server";
import { flash } from "~/services/session.server";
@@ -32,16 +32,17 @@ export async function loader({ request }: LoaderFunctionArgs) {
const { limit, offset, sorts, filters } =
getGenericQueryFilters(searchParams);
- const [purchasingGroups, itemGroups, supplierTypes] = await Promise.all([
- getPurchasingPostingGroups(client, companyId, {
- limit,
- offset,
- sorts,
- filters,
- }),
- getItemGroupsList(client, companyId),
- getSupplierTypesList(client, companyId),
- ]);
+ const [purchasingGroups, itemPostingGroups, supplierTypes] =
+ await Promise.all([
+ getPurchasingPostingGroups(client, companyId, {
+ limit,
+ offset,
+ sorts,
+ filters,
+ }),
+ getItemPostingGroupsList(client, companyId),
+ getSupplierTypesList(client, companyId),
+ ]);
if (purchasingGroups.error) {
throw redirect(
path.to.accounting,
@@ -57,14 +58,14 @@ export async function loader({ request }: LoaderFunctionArgs) {
return json({
data: purchasingGroups.data ?? [],
- itemGroups: itemGroups.data ?? [],
+ itemPostingGroups: itemPostingGroups.data ?? [],
supplierTypes: supplierTypes.data ?? [],
count: purchasingGroups.count ?? 0,
});
}
export default function PurchasingPostingGroupsRoute() {
- const { data, itemGroups, supplierTypes, count } =
+ const { data, itemPostingGroups, supplierTypes, count } =
useLoaderData<typeof loader>();
const routeData = useRouteData<{
@@ -77,7 +78,7 @@ export default function PurchasingPostingGroupsRoute() {
<PurchasingPostingGroupsTable
data={data}
count={count}
- itemGroups={itemGroups}
+ itemPostingGroups={itemPostingGroups}
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 d759cef51e..69bd3969c1 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 { getItemGroupsList } from "~/modules/items";
+import { getItemPostingGroupsList } from "~/modules/items";
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, itemGroups, customerTypes] = await Promise.all([
+ const [salesGroups, itemPostingGroups, customerTypes] = await Promise.all([
getSalesPostingGroups(client, companyId, {
limit,
offset,
sorts,
filters,
}),
- getItemGroupsList(client, companyId),
+ getItemPostingGroupsList(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,
- itemGroups: itemGroups.data ?? [],
+ itemPostingGroups: itemPostingGroups.data ?? [],
customerTypes: customerTypes.data ?? [],
});
}
export default function SalesPostingGroupsRoute() {
- const { data, count, itemGroups, customerTypes } =
+ const { data, count, itemPostingGroups, customerTypes } =
useLoaderData<typeof loader>();
const routeData = useRouteData<{
@@ -74,7 +74,7 @@ export default function SalesPostingGroupsRoute() {
<SalesPostingGroupsTable
data={data}
count={count}
- itemGroups={itemGroups}
+ itemPostingGroups={itemPostingGroups}
customerTypes={customerTypes}
balanceSheetAccounts={routeData?.balanceSheetAccounts ?? []}
incomeStatementAccounts={routeData?.incomeStatementAccounts ?? []}
diff --git a/apps/carbon/app/routes/x+/consumable+/$itemId.costing.tsx b/apps/carbon/app/routes/x+/consumable+/$itemId.costing.tsx
index 2910093c49..7c5dbc38a0 100644
--- a/apps/carbon/app/routes/x+/consumable+/$itemId.costing.tsx
+++ b/apps/carbon/app/routes/x+/consumable+/$itemId.costing.tsx
@@ -94,7 +94,11 @@ export default function ConsumableCostingRoute() {
return (
<ItemCostingForm
key={itemCost.itemId}
- initialValues={{ ...itemCost, ...getCustomFields(itemCost.customFields) }}
+ initialValues={{
+ ...itemCost,
+ itemPostingGroupId: itemCost?.itemPostingGroupId ?? undefined,
+ ...getCustomFields(itemCost.customFields),
+ }}
/>
);
}
diff --git a/apps/carbon/app/routes/x+/consumable+/$itemId.details.tsx b/apps/carbon/app/routes/x+/consumable+/$itemId.details.tsx
index a776a8b9e1..393bd8652e 100644
--- a/apps/carbon/app/routes/x+/consumable+/$itemId.details.tsx
+++ b/apps/carbon/app/routes/x+/consumable+/$itemId.details.tsx
@@ -68,12 +68,13 @@ export default function ConsumableDetailsRoute() {
itemId: consumableData.consumableSummary?.itemId ?? "",
name: consumableData.consumableSummary?.name ?? "",
description: consumableData.consumableSummary?.description ?? "",
- itemGroupId: consumableData.consumableSummary?.itemGroupId ?? "",
- itemInventoryType:
- consumableData.consumableSummary?.itemInventoryType ?? "Inventory",
+ replenishmentSystem:
+ consumableData.consumableSummary?.replenishmentSystem ?? "Buy",
+ defaultMethodType:
+ consumableData.consumableSummary?.defaultMethodType ?? "Buy",
+ itemTrackingType:
+ consumableData.consumableSummary?.itemTrackingType ?? "Inventory",
active: consumableData.consumableSummary?.active ?? true,
- pullFromInventory:
- consumableData.consumableSummary?.pullFromInventory ?? false,
unitOfMeasureCode:
consumableData.consumableSummary?.unitOfMeasureCode ?? "EA",
...getCustomFields(consumableData.consumableSummary?.customFields ?? {}),
diff --git a/apps/carbon/app/routes/x+/consumable+/new.tsx b/apps/carbon/app/routes/x+/consumable+/new.tsx
index 006cee2fda..4bcaf0fb25 100644
--- a/apps/carbon/app/routes/x+/consumable+/new.tsx
+++ b/apps/carbon/app/routes/x+/consumable+/new.tsx
@@ -65,9 +65,10 @@ export default function ConsumablesNewRoute() {
id: "",
name: "",
description: "",
- itemInventoryType: "Non-Inventory" as "Non-Inventory",
+ itemTrackingType: "Non-Inventory" as "Non-Inventory",
+ replenishmentSystem: "Buy" as const,
+ defaultMethodType: "Buy" as const,
unitOfMeasureCode: "EA",
- pullFromInventory: true,
active: true,
};
diff --git a/apps/carbon/app/routes/x+/fixture+/$itemId.costing.tsx b/apps/carbon/app/routes/x+/fixture+/$itemId.costing.tsx
index fc71146ef3..17c8d4356d 100644
--- a/apps/carbon/app/routes/x+/fixture+/$itemId.costing.tsx
+++ b/apps/carbon/app/routes/x+/fixture+/$itemId.costing.tsx
@@ -94,7 +94,11 @@ export default function FixtureCostingRoute() {
return (
<ItemCostingForm
key={itemCost.itemId}
- initialValues={{ ...itemCost, ...getCustomFields(itemCost.customFields) }}
+ initialValues={{
+ ...itemCost,
+ itemPostingGroupId: itemCost?.itemPostingGroupId ?? undefined,
+ ...getCustomFields(itemCost.customFields),
+ }}
/>
);
}
diff --git a/apps/carbon/app/routes/x+/fixture+/$itemId.details.tsx b/apps/carbon/app/routes/x+/fixture+/$itemId.details.tsx
index e8d3b39ea2..c32278d0ab 100644
--- a/apps/carbon/app/routes/x+/fixture+/$itemId.details.tsx
+++ b/apps/carbon/app/routes/x+/fixture+/$itemId.details.tsx
@@ -64,11 +64,12 @@ export default function FixtureDetailsRoute() {
itemId: fixtureData.fixtureSummary?.itemId ?? "",
name: fixtureData.fixtureSummary?.name ?? "",
description: fixtureData.fixtureSummary?.description ?? "",
- itemGroupId: fixtureData.fixtureSummary?.itemGroupId ?? "",
- itemInventoryType:
- fixtureData.fixtureSummary?.itemInventoryType ?? "Inventory",
+ replenishmentSystem:
+ fixtureData.fixtureSummary?.replenishmentSystem ?? "Buy",
+ defaultMethodType: fixtureData.fixtureSummary?.defaultMethodType ?? "Buy",
+ itemTrackingType:
+ fixtureData.fixtureSummary?.itemTrackingType ?? "Inventory",
active: fixtureData.fixtureSummary?.active ?? true,
- pullFromInventory: fixtureData.fixtureSummary?.pullFromInventory ?? false,
customerId: fixtureData.fixtureSummary?.customerId ?? "",
unitOfMeasureCode: "EA",
...getCustomFields(fixtureData.fixtureSummary?.customFields ?? {}),
diff --git a/apps/carbon/app/routes/x+/fixture+/new.tsx b/apps/carbon/app/routes/x+/fixture+/new.tsx
index 0409faed1c..52bdb8891c 100644
--- a/apps/carbon/app/routes/x+/fixture+/new.tsx
+++ b/apps/carbon/app/routes/x+/fixture+/new.tsx
@@ -61,9 +61,10 @@ export default function FixturesNewRoute() {
id: "",
name: "",
description: "",
- itemInventoryType: "Inventory" as "Inventory",
+ replenishmentSystem: "Buy" as const,
+ defaultMethodType: "Buy" as const,
+ itemTrackingType: "Inventory" as "Inventory",
unitOfMeasureCode: "EA",
- pullFromInventory: true,
active: true,
};
diff --git a/apps/carbon/app/routes/x+/items+/consumables.tsx b/apps/carbon/app/routes/x+/items+/consumables.tsx
index 7af5570fa2..79db90f189 100644
--- a/apps/carbon/app/routes/x+/items+/consumables.tsx
+++ b/apps/carbon/app/routes/x+/items+/consumables.tsx
@@ -5,7 +5,7 @@ import { Outlet, useLoaderData } from "@remix-run/react";
import {
ConsumablesTable,
getConsumables,
- getItemGroupsList,
+ getItemPostingGroupsList,
} from "~/modules/items";
import { requirePermissions } from "~/services/auth/auth.server";
import { flash } from "~/services/session.server";
@@ -32,7 +32,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
const { limit, offset, sorts, filters } =
getGenericQueryFilters(searchParams);
- const [consumables, itemGroups] = await Promise.all([
+ const [consumables, itemPostingGroups] = await Promise.all([
getConsumables(client, companyId, {
search,
supplierId,
@@ -41,7 +41,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
sorts,
filters,
}),
- getItemGroupsList(client, companyId),
+ getItemPostingGroupsList(client, companyId),
]);
if (consumables.error) {
@@ -57,19 +57,20 @@ export async function loader({ request }: LoaderFunctionArgs) {
return json({
count: consumables.count ?? 0,
consumables: consumables.data ?? [],
- itemGroups: itemGroups.data ?? [],
+ itemPostingGroups: itemPostingGroups.data ?? [],
});
}
export default function ConsumablesSearchRoute() {
- const { count, consumables, itemGroups } = useLoaderData<typeof loader>();
+ const { count, consumables, itemPostingGroups } =
+ useLoaderData<typeof loader>();
return (
<VStack spacing={0} className="h-full">
<ConsumablesTable
data={consumables}
count={count}
- itemGroups={itemGroups}
+ itemPostingGroups={itemPostingGroups}
/>
<Outlet />
</VStack>
diff --git a/apps/carbon/app/routes/x+/items+/fixtures.tsx b/apps/carbon/app/routes/x+/items+/fixtures.tsx
index b6948f7099..d518ee498f 100644
--- a/apps/carbon/app/routes/x+/items+/fixtures.tsx
+++ b/apps/carbon/app/routes/x+/items+/fixtures.tsx
@@ -2,7 +2,11 @@ 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 { FixturesTable, getFixtures, getItemGroupsList } from "~/modules/items";
+import {
+ FixturesTable,
+ getFixtures,
+ getItemPostingGroupsList,
+} from "~/modules/items";
import { requirePermissions } from "~/services/auth/auth.server";
import { flash } from "~/services/session.server";
import type { Handle } from "~/utils/handle";
@@ -28,7 +32,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
const { limit, offset, sorts, filters } =
getGenericQueryFilters(searchParams);
- const [fixtures, itemGroups] = await Promise.all([
+ const [fixtures, itemPostingGroups] = await Promise.all([
getFixtures(client, companyId, {
search,
supplierId,
@@ -37,7 +41,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
sorts,
filters,
}),
- getItemGroupsList(client, companyId),
+ getItemPostingGroupsList(client, companyId),
]);
if (fixtures.error) {
@@ -50,16 +54,20 @@ export async function loader({ request }: LoaderFunctionArgs) {
return json({
count: fixtures.count ?? 0,
fixtures: fixtures.data ?? [],
- itemGroups: itemGroups.data ?? [],
+ itemPostingGroups: itemPostingGroups.data ?? [],
});
}
export default function FixturesSearchRoute() {
- const { count, fixtures, itemGroups } = useLoaderData<typeof loader>();
+ const { count, fixtures, itemPostingGroups } = useLoaderData<typeof loader>();
return (
<VStack spacing={0} className="h-full">
- <FixturesTable data={fixtures} count={count} itemGroups={itemGroups} />
+ <FixturesTable
+ data={fixtures}
+ count={count}
+ itemPostingGroups={itemPostingGroups}
+ />
<Outlet />
</VStack>
);
diff --git a/apps/carbon/app/routes/x+/items+/groups.$groupId.tsx b/apps/carbon/app/routes/x+/items+/groups.$groupId.tsx
index dbb064a0f6..b09acef083 100644
--- a/apps/carbon/app/routes/x+/items+/groups.$groupId.tsx
+++ b/apps/carbon/app/routes/x+/items+/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 {
- ItemGroupForm,
- getItemGroup,
- itemGroupValidator,
- upsertItemGroup,
+ ItemPostingGroupForm,
+ getItemPostingGroup,
+ itemPostingGroupValidator,
+ upsertItemPostingGroup,
} from "~/modules/items";
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 itemGroup = await getItemGroup(client, groupId);
+ const itemPostingGroup = await getItemPostingGroup(client, groupId);
return json({
- itemGroup: itemGroup?.data ?? null,
+ itemPostingGroup: itemPostingGroup?.data ?? null,
});
}
@@ -41,48 +41,50 @@ 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(itemGroupValidator).validate(formData);
+ const validation = await validator(itemPostingGroupValidator).validate(
+ formData
+ );
if (validation.error) {
return validationError(validation.error);
}
- const updateItemGroup = await upsertItemGroup(client, {
+ const updateItemPostingGroup = await upsertItemPostingGroup(client, {
id: groupId,
...validation.data,
updatedBy: userId,
customFields: setCustomFields(formData),
});
- if (updateItemGroup.error) {
+ if (updateItemPostingGroup.error) {
return json(
{},
await flash(
request,
- error(updateItemGroup.error, "Failed to update item group")
+ error(updateItemPostingGroup.error, "Failed to update item group")
)
);
}
throw redirect(
- `${path.to.itemGroups}?${getParams(request)}`,
+ `${path.to.itemPostingGroups}?${getParams(request)}`,
await flash(request, success("Updated item group"))
);
}
-export default function EditItemGroupsRoute() {
- const { itemGroup } = useLoaderData<typeof loader>();
+export default function EditItemPostingGroupsRoute() {
+ const { itemPostingGroup } = useLoaderData<typeof loader>();
const navigate = useNavigate();
const initialValues = {
- id: itemGroup?.id ?? undefined,
- name: itemGroup?.name ?? "",
- description: itemGroup?.description ?? "",
- ...getCustomFields(itemGroup?.customFields),
+ id: itemPostingGroup?.id ?? undefined,
+ name: itemPostingGroup?.name ?? "",
+ description: itemPostingGroup?.description ?? "",
+ ...getCustomFields(itemPostingGroup?.customFields),
};
return (
- <ItemGroupForm
+ <ItemPostingGroupForm
key={initialValues.id}
initialValues={initialValues}
onClose={() => navigate(-1)}
diff --git a/apps/carbon/app/routes/x+/items+/groups.delete.$groupId.tsx b/apps/carbon/app/routes/x+/items+/groups.delete.$groupId.tsx
index b5403bc7fd..b7e3483907 100644
--- a/apps/carbon/app/routes/x+/items+/groups.delete.$groupId.tsx
+++ b/apps/carbon/app/routes/x+/items+/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 { deleteItemGroup, getItemGroup } from "~/modules/items";
+import { deleteItemPostingGroup, getItemPostingGroup } from "~/modules/items";
import { requirePermissions } from "~/services/auth/auth.server";
import { flash } from "~/services/session.server";
import { notFound } from "~/utils/http";
@@ -16,15 +16,18 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
const { groupId } = params;
if (!groupId) throw notFound("groupId not found");
- const itemGroup = await getItemGroup(client, groupId);
- if (itemGroup.error) {
+ const itemPostingGroup = await getItemPostingGroup(client, groupId);
+ if (itemPostingGroup.error) {
throw redirect(
- path.to.itemGroups,
- await flash(request, error(itemGroup.error, "Failed to get item group"))
+ path.to.itemPostingGroups,
+ await flash(
+ request,
+ error(itemPostingGroup.error, "Failed to get item group")
+ )
);
}
- return json({ itemGroup: itemGroup.data });
+ return json({ itemPostingGroup: itemPostingGroup.data });
}
export async function action({ request, params }: ActionFunctionArgs) {
@@ -35,15 +38,18 @@ export async function action({ request, params }: ActionFunctionArgs) {
const { groupId } = params;
if (!groupId) {
throw redirect(
- path.to.itemGroups,
+ path.to.itemPostingGroups,
await flash(request, error(params, "Failed to get an item group id"))
);
}
- const { error: deleteTypeError } = await deleteItemGroup(client, groupId);
+ const { error: deleteTypeError } = await deleteItemPostingGroup(
+ client,
+ groupId
+ );
if (deleteTypeError) {
throw redirect(
- `${path.to.itemGroups}?${getParams(request)}`,
+ `${path.to.itemPostingGroups}?${getParams(request)}`,
await flash(
request,
error(deleteTypeError, "Failed to delete item group")
@@ -52,27 +58,27 @@ export async function action({ request, params }: ActionFunctionArgs) {
}
throw redirect(
- path.to.itemGroups,
+ path.to.itemPostingGroups,
await flash(request, success("Successfully deleted item group"))
);
}
-export default function DeleteItemGroupRoute() {
+export default function DeleteItemPostingGroupRoute() {
const { groupId } = useParams();
if (!groupId) throw new Error("groupId not found");
- const { itemGroup } = useLoaderData<typeof loader>();
+ const { itemPostingGroup } = useLoaderData<typeof loader>();
const navigate = useNavigate();
- if (!itemGroup) return null;
+ if (!itemPostingGroup) return null;
const onCancel = () => navigate(-1);
return (
<ConfirmDelete
- 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.`}
+ action={path.to.deleteItemPostingGroup(groupId)}
+ name={itemPostingGroup.name}
+ text={`Are you sure you want to delete the item group: ${itemPostingGroup.name}? This cannot be undone.`}
onCancel={onCancel}
/>
);
diff --git a/apps/carbon/app/routes/x+/items+/groups.new.tsx b/apps/carbon/app/routes/x+/items+/groups.new.tsx
index 80227ac751..adbe65b502 100644
--- a/apps/carbon/app/routes/x+/items+/groups.new.tsx
+++ b/apps/carbon/app/routes/x+/items+/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 {
- ItemGroupForm,
- itemGroupValidator,
- upsertItemGroup,
+ ItemPostingGroupForm,
+ itemPostingGroupValidator,
+ upsertItemPostingGroup,
} from "~/modules/items";
import { requirePermissions } from "~/services/auth/auth.server";
import { flash } from "~/services/session.server";
@@ -31,7 +31,9 @@ export async function action({ request }: ActionFunctionArgs) {
const formData = await request.formData();
const modal = formData.get("type") == "modal";
- const validation = await validator(itemGroupValidator).validate(formData);
+ const validation = await validator(itemPostingGroupValidator).validate(
+ formData
+ );
if (validation.error) {
return validationError(validation.error);
@@ -39,42 +41,42 @@ export async function action({ request }: ActionFunctionArgs) {
const { id, ...data } = validation.data;
- const insertItemGroup = await upsertItemGroup(client, {
+ const insertItemPostingGroup = await upsertItemPostingGroup(client, {
...data,
companyId,
createdBy: userId,
customFields: setCustomFields(formData),
});
- if (insertItemGroup.error) {
+ if (insertItemPostingGroup.error) {
return json(
{},
await flash(
request,
- error(insertItemGroup.error, "Failed to insert item group")
+ error(insertItemPostingGroup.error, "Failed to insert item group")
)
);
}
- const itemGroupId = insertItemGroup.data?.id;
- if (!itemGroupId) {
+ const itemPostingGroupId = insertItemPostingGroup.data?.id;
+ if (!itemPostingGroupId) {
return json(
{},
await flash(
request,
- error(insertItemGroup, "Failed to insert item group")
+ error(insertItemPostingGroup, "Failed to insert item group")
)
);
}
return modal
- ? json(insertItemGroup, { status: 201 })
+ ? json(insertItemPostingGroup, { status: 201 })
: redirect(
- `${path.to.itemGroups}?${getParams(request)}`,
+ `${path.to.itemPostingGroups}?${getParams(request)}`,
await flash(request, success("Item posting group created"))
);
}
-export default function NewItemGroupsRoute() {
+export default function NewItemPostingGroupsRoute() {
const navigate = useNavigate();
const initialValues = {
name: "",
@@ -82,6 +84,9 @@ export default function NewItemGroupsRoute() {
};
return (
- <ItemGroupForm onClose={() => navigate(-1)} initialValues={initialValues} />
+ <ItemPostingGroupForm
+ onClose={() => navigate(-1)}
+ initialValues={initialValues}
+ />
);
}
diff --git a/apps/carbon/app/routes/x+/items+/groups.tsx b/apps/carbon/app/routes/x+/items+/groups.tsx
index c61cd0a103..16cfa39b9d 100644
--- a/apps/carbon/app/routes/x+/items+/groups.tsx
+++ b/apps/carbon/app/routes/x+/items+/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 { ItemGroupsTable, getItemGroups } from "~/modules/items";
+import { ItemPostingGroupsTable, getItemPostingGroups } from "~/modules/items";
import { requirePermissions } from "~/services/auth/auth.server";
import { flash } from "~/services/session.server";
import type { Handle } from "~/utils/handle";
@@ -13,7 +13,7 @@ import { error } from "~/utils/result";
export const handle: Handle = {
breadcrumb: "Posting Groups",
- to: path.to.itemGroups,
+ to: path.to.itemPostingGroups,
};
export async function loader({ request }: LoaderFunctionArgs) {
@@ -28,8 +28,8 @@ export async function loader({ request }: LoaderFunctionArgs) {
const { limit, offset, sorts, filters } =
getGenericQueryFilters(searchParams);
- const [itemGroups, accounts] = await Promise.all([
- getItemGroups(client, companyId, {
+ const [itemPostingGroups, accounts] = await Promise.all([
+ getItemPostingGroups(client, companyId, {
limit,
offset,
sorts,
@@ -39,7 +39,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
getAccountsList(client, companyId),
]);
- if (itemGroups.error) {
+ if (itemPostingGroups.error) {
throw redirect(
path.to.items,
await flash(request, error(null, "Error loading item groups"))
@@ -48,24 +48,24 @@ export async function loader({ request }: LoaderFunctionArgs) {
if (accounts.error) {
throw redirect(
- path.to.itemGroups,
+ path.to.itemPostingGroups,
await flash(request, error(accounts.error, "Error loading accounts"))
);
}
return json({
- itemGroups: itemGroups.data ?? [],
- count: itemGroups.count ?? 0,
+ itemPostingGroups: itemPostingGroups.data ?? [],
+ count: itemPostingGroups.count ?? 0,
accounts: accounts.data ?? [],
});
}
-export default function ItemGroupsRoute() {
- const { itemGroups, count } = useLoaderData<typeof loader>();
+export default function ItemPostingGroupsRoute() {
+ const { itemPostingGroups, count } = useLoaderData<typeof loader>();
return (
<VStack spacing={0} className="h-full">
- <ItemGroupsTable data={itemGroups} count={count ?? 0} />
+ <ItemPostingGroupsTable data={itemPostingGroups} count={count ?? 0} />
<Outlet />
</VStack>
);
diff --git a/apps/carbon/app/routes/x+/items+/materials.tsx b/apps/carbon/app/routes/x+/items+/materials.tsx
index 3985625beb..2a446b73c3 100644
--- a/apps/carbon/app/routes/x+/items+/materials.tsx
+++ b/apps/carbon/app/routes/x+/items+/materials.tsx
@@ -4,7 +4,7 @@ import { json, redirect } from "@remix-run/node";
import { Outlet, useLoaderData } from "@remix-run/react";
import {
MaterialsTable,
- getItemGroupsList,
+ getItemPostingGroupsList,
getMaterials,
} from "~/modules/items";
import { requirePermissions } from "~/services/auth/auth.server";
@@ -32,7 +32,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
const { limit, offset, sorts, filters } =
getGenericQueryFilters(searchParams);
- const [materials, itemGroups] = await Promise.all([
+ const [materials, itemPostingGroups] = await Promise.all([
getMaterials(client, companyId, {
search,
supplierId,
@@ -41,7 +41,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
sorts,
filters,
}),
- getItemGroupsList(client, companyId),
+ getItemPostingGroupsList(client, companyId),
]);
if (materials.error) {
@@ -54,16 +54,21 @@ export async function loader({ request }: LoaderFunctionArgs) {
return json({
count: materials.count ?? 0,
materials: materials.data ?? [],
- itemGroups: itemGroups.data ?? [],
+ itemPostingGroups: itemPostingGroups.data ?? [],
});
}
export default function MaterialsSearchRoute() {
- const { count, materials, itemGroups } = useLoaderData<typeof loader>();
+ const { count, materials, itemPostingGroups } =
+ useLoaderData<typeof loader>();
return (
<VStack spacing={0} className="h-full">
- <MaterialsTable data={materials} count={count} itemGroups={itemGroups} />
+ <MaterialsTable
+ data={materials}
+ count={count}
+ itemPostingGroups={itemPostingGroups}
+ />
<Outlet />
</VStack>
);
diff --git a/apps/carbon/app/routes/x+/items+/parts.tsx b/apps/carbon/app/routes/x+/items+/parts.tsx
index 2f978cad55..bf7aaffd3f 100644
--- a/apps/carbon/app/routes/x+/items+/parts.tsx
+++ b/apps/carbon/app/routes/x+/items+/parts.tsx
@@ -2,7 +2,11 @@ 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, getItemGroupsList, getParts } from "~/modules/items";
+import {
+ PartsTable,
+ getItemPostingGroupsList,
+ getParts,
+} from "~/modules/items";
import { requirePermissions } from "~/services/auth/auth.server";
import { flash } from "~/services/session.server";
import type { Handle } from "~/utils/handle";
@@ -28,7 +32,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
const { limit, offset, sorts, filters } =
getGenericQueryFilters(searchParams);
- const [parts, itemGroups] = await Promise.all([
+ const [parts, itemPostingGroups] = await Promise.all([
getParts(client, companyId, {
search,
supplierId,
@@ -37,7 +41,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
sorts,
filters,
}),
- getItemGroupsList(client, companyId),
+ getItemPostingGroupsList(client, companyId),
]);
if (parts.error) {
@@ -50,16 +54,20 @@ export async function loader({ request }: LoaderFunctionArgs) {
return json({
count: parts.count ?? 0,
parts: parts.data ?? [],
- itemGroups: itemGroups.data ?? [],
+ itemPostingGroups: itemPostingGroups.data ?? [],
});
}
export default function PartsSearchRoute() {
- const { count, parts, itemGroups } = useLoaderData<typeof loader>();
+ const { count, parts, itemPostingGroups } = useLoaderData<typeof loader>();
return (
<VStack spacing={0} className="h-full">
- <PartsTable data={parts} count={count} itemGroups={itemGroups} />
+ <PartsTable
+ data={parts}
+ count={count}
+ itemPostingGroups={itemPostingGroups}
+ />
<Outlet />
</VStack>
);
diff --git a/apps/carbon/app/routes/x+/items+/services.tsx b/apps/carbon/app/routes/x+/items+/services.tsx
index 3a12f40112..ff1d842106 100644
--- a/apps/carbon/app/routes/x+/items+/services.tsx
+++ b/apps/carbon/app/routes/x+/items+/services.tsx
@@ -2,7 +2,11 @@ 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, getItemGroupsList, getServices } from "~/modules/items";
+import {
+ ServicesTable,
+ getItemPostingGroupsList,
+ getServices,
+} from "~/modules/items";
import { requirePermissions } from "~/services/auth/auth.server";
import { flash } from "~/services/session.server";
import type { Handle } from "~/utils/handle";
@@ -30,7 +34,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
const { limit, offset, sorts, filters } =
getGenericQueryFilters(searchParams);
- const [services, itemGroups] = await Promise.all([
+ const [services] = await Promise.all([
getServices(client, companyId, {
search,
type,
@@ -41,7 +45,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
sorts,
filters,
}),
- getItemGroupsList(client, companyId),
+ getItemPostingGroupsList(client, companyId),
]);
if (services.error) {
@@ -54,16 +58,15 @@ export async function loader({ request }: LoaderFunctionArgs) {
return json({
count: services.count ?? 0,
services: services.data ?? [],
- itemGroups: itemGroups.data ?? [],
});
}
export default function ServicesSearchRoute() {
- const { count, services, itemGroups } = useLoaderData<typeof loader>();
+ const { count, services } = useLoaderData<typeof loader>();
return (
<VStack spacing={0} className="h-full">
- <ServicesTable data={services} count={count} itemGroups={itemGroups} />
+ <ServicesTable data={services} count={count} />
<Outlet />
</VStack>
);
diff --git a/apps/carbon/app/routes/x+/items+/tools.tsx b/apps/carbon/app/routes/x+/items+/tools.tsx
index 2d35a1b06e..a7260881b0 100644
--- a/apps/carbon/app/routes/x+/items+/tools.tsx
+++ b/apps/carbon/app/routes/x+/items+/tools.tsx
@@ -2,7 +2,11 @@ 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 { ToolsTable, getItemGroupsList, getTools } from "~/modules/items";
+import {
+ ToolsTable,
+ getItemPostingGroupsList,
+ getTools,
+} from "~/modules/items";
import { requirePermissions } from "~/services/auth/auth.server";
import { flash } from "~/services/session.server";
import type { Handle } from "~/utils/handle";
@@ -28,7 +32,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
const { limit, offset, sorts, filters } =
getGenericQueryFilters(searchParams);
- const [tools, itemGroups] = await Promise.all([
+ const [tools, itemPostingGroups] = await Promise.all([
getTools(client, companyId, {
search,
supplierId,
@@ -37,7 +41,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
sorts,
filters,
}),
- getItemGroupsList(client, companyId),
+ getItemPostingGroupsList(client, companyId),
]);
if (tools.error) {
@@ -50,16 +54,20 @@ export async function loader({ request }: LoaderFunctionArgs) {
return json({
count: tools.count ?? 0,
tools: tools.data ?? [],
- itemGroups: itemGroups.data ?? [],
+ itemPostingGroups: itemPostingGroups.data ?? [],
});
}
export default function ToolsSearchRoute() {
- const { count, tools, itemGroups } = useLoaderData<typeof loader>();
+ const { count, tools, itemPostingGroups } = useLoaderData<typeof loader>();
return (
<VStack spacing={0} className="h-full">
- <ToolsTable data={tools} count={count} itemGroups={itemGroups} />
+ <ToolsTable
+ data={tools}
+ count={count}
+ itemPostingGroups={itemPostingGroups}
+ />
<Outlet />
</VStack>
);
diff --git a/apps/carbon/app/routes/x+/material+/$itemId.costing.tsx b/apps/carbon/app/routes/x+/material+/$itemId.costing.tsx
index 72bb8e6e2c..292b074327 100644
--- a/apps/carbon/app/routes/x+/material+/$itemId.costing.tsx
+++ b/apps/carbon/app/routes/x+/material+/$itemId.costing.tsx
@@ -94,7 +94,11 @@ export default function MaterialostingRoute() {
return (
<ItemCostingForm
key={itemCost.itemId}
- initialValues={{ ...itemCost, ...getCustomFields(itemCost.customFields) }}
+ initialValues={{
+ ...itemCost,
+ itemPostingGroupId: itemCost?.itemPostingGroupId ?? undefined,
+ ...getCustomFields(itemCost.customFields),
+ }}
/>
);
}
diff --git a/apps/carbon/app/routes/x+/material+/$itemId.details.tsx b/apps/carbon/app/routes/x+/material+/$itemId.details.tsx
index 301b35e8a6..6e36e5f28f 100644
--- a/apps/carbon/app/routes/x+/material+/$itemId.details.tsx
+++ b/apps/carbon/app/routes/x+/material+/$itemId.details.tsx
@@ -77,11 +77,13 @@ export default function MaterialDetailsRoute() {
finish: materialData.materialSummary?.finish ?? "",
grade: materialData.materialSummary?.grade ?? "",
dimensions: materialData.materialSummary?.dimensions ?? "",
- itemGroupId: materialData.materialSummary?.itemGroupId ?? "",
- itemInventoryType:
- materialData.materialSummary?.itemInventoryType ?? "Inventory",
+ replenishmentSystem:
+ materialData.materialSummary?.replenishmentSystem ?? "Buy",
+ defaultMethodType: materialData.materialSummary?.defaultMethodType ?? "Buy",
+
+ itemTrackingType:
+ materialData.materialSummary?.itemTrackingType ?? "Inventory",
active: materialData.materialSummary?.active ?? true,
- pullFromInventory: materialData.materialSummary?.pullFromInventory ?? false,
unitOfMeasureCode: materialData.materialSummary?.unitOfMeasureCode ?? "EA",
...getCustomFields(materialData.materialSummary?.customFields ?? {}),
};
diff --git a/apps/carbon/app/routes/x+/material+/new.tsx b/apps/carbon/app/routes/x+/material+/new.tsx
index 0fa77467aa..014459bcb1 100644
--- a/apps/carbon/app/routes/x+/material+/new.tsx
+++ b/apps/carbon/app/routes/x+/material+/new.tsx
@@ -67,9 +67,10 @@ export default function MaterialsNewRoute() {
description: "",
materialFormId: "",
materialSubstanceId: "",
- itemInventoryType: "Inventory" as "Inventory",
+ replenishmentSystem: "Buy" as const,
+ defaultMethodType: "Buy" as const,
+ itemTrackingType: "Inventory" as "Inventory",
unitOfMeasureCode: "EA",
- pullFromInventory: false,
active: true,
};
diff --git a/apps/carbon/app/routes/x+/part+/$itemId.costing.tsx b/apps/carbon/app/routes/x+/part+/$itemId.costing.tsx
index 2d886b72f2..0aca3f2417 100644
--- a/apps/carbon/app/routes/x+/part+/$itemId.costing.tsx
+++ b/apps/carbon/app/routes/x+/part+/$itemId.costing.tsx
@@ -95,6 +95,7 @@ export default function PartCostingRoute() {
key={itemCost.itemId}
initialValues={{
...itemCost,
+ itemPostingGroupId: itemCost?.itemPostingGroupId ?? undefined,
...getCustomFields(itemCost.customFields),
}}
/>
diff --git a/apps/carbon/app/routes/x+/part+/$itemId.details.tsx b/apps/carbon/app/routes/x+/part+/$itemId.details.tsx
index 488322ec2f..c428552932 100644
--- a/apps/carbon/app/routes/x+/part+/$itemId.details.tsx
+++ b/apps/carbon/app/routes/x+/part+/$itemId.details.tsx
@@ -61,11 +61,10 @@ export default function PartDetailsRoute() {
itemId: partData.partSummary?.itemId ?? "",
name: partData.partSummary?.name ?? "",
description: partData.partSummary?.description ?? "",
- itemGroupId: partData.partSummary?.itemGroupId ?? "",
- itemInventoryType: partData.partSummary?.itemInventoryType ?? "Inventory",
- active: partData.partSummary?.active ?? true,
- pullFromInventory: partData.partSummary?.pullFromInventory ?? false,
replenishmentSystem: partData.partSummary?.replenishmentSystem ?? "Buy",
+ defaultMethodType: partData.partSummary?.defaultMethodType ?? "Buy",
+ itemTrackingType: partData.partSummary?.itemTrackingType ?? "Inventory",
+ active: partData.partSummary?.active ?? true,
unitOfMeasureCode: partData.partSummary?.unitOfMeasureCode ?? "EA",
...getCustomFields(partData.partSummary?.customFields ?? {}),
};
diff --git a/apps/carbon/app/routes/x+/part+/new.tsx b/apps/carbon/app/routes/x+/part+/new.tsx
index 7f45e914ae..09dac85661 100644
--- a/apps/carbon/app/routes/x+/part+/new.tsx
+++ b/apps/carbon/app/routes/x+/part+/new.tsx
@@ -55,10 +55,10 @@ export default function PartsNewRoute() {
id: "",
name: "",
description: "",
- itemInventoryType: "Inventory" as "Inventory",
+ itemTrackingType: "Inventory" as "Inventory",
replenishmentSystem: "Buy" as "Buy",
+ defaultMethodType: "Buy" as "Buy",
unitOfMeasureCode: "EA",
- pullFromInventory: false,
active: true,
};
diff --git a/apps/carbon/app/routes/x+/service+/$itemId.details.tsx b/apps/carbon/app/routes/x+/service+/$itemId.details.tsx
index cd07ea1f92..7c502652f4 100644
--- a/apps/carbon/app/routes/x+/service+/$itemId.details.tsx
+++ b/apps/carbon/app/routes/x+/service+/$itemId.details.tsx
@@ -60,11 +60,11 @@ export default function ServiceDetailsRoute() {
name: routeData.service?.name ?? "",
description: routeData.service?.description ?? undefined,
serviceType: routeData.service?.serviceType ?? "Internal",
- itemGroupId: routeData.service?.itemGroupId ?? undefined,
- itemInventoryType: "Non-Inventory" as const,
+ replenishmentSystem: routeData.service?.replenishmentSystem ?? "Make",
+ defaultMethodType: routeData.service?.defaultMethodType ?? "Make",
+ itemTrackingType: "Non-Inventory" as const,
active: routeData.service?.active ?? true,
unitOfMeasureCode: "EA",
- pullFromInventory: 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 fc09764c6c..e9d99ea9c3 100644
--- a/apps/carbon/app/routes/x+/service+/_layout.tsx
+++ b/apps/carbon/app/routes/x+/service+/_layout.tsx
@@ -1,6 +1,6 @@
import type { LoaderFunctionArgs, MetaFunction } from "@remix-run/node";
import { Outlet } from "@remix-run/react";
-import { getItemGroupsList } from "~/modules/items";
+import { getItemPostingGroupsList } from "~/modules/items";
import { getLocationsList } from "~/modules/resources";
import { requirePermissions } from "~/services/auth/auth.server";
import type { Handle } from "~/utils/handle";
@@ -21,14 +21,14 @@ export async function loader({ request }: LoaderFunctionArgs) {
view: "parts",
});
- const [itemGroups, locations] = await Promise.all([
- getItemGroupsList(client, companyId),
+ const [itemPostingGroups, locations] = await Promise.all([
+ getItemPostingGroupsList(client, companyId),
getLocationsList(client, companyId),
]);
return {
locations: locations?.data ?? [],
- itemGroups: itemGroups?.data ?? [],
+ itemPostingGroups: itemPostingGroups?.data ?? [],
};
}
diff --git a/apps/carbon/app/routes/x+/tool+/$itemId.costing.tsx b/apps/carbon/app/routes/x+/tool+/$itemId.costing.tsx
index 450a5da205..f61df006bd 100644
--- a/apps/carbon/app/routes/x+/tool+/$itemId.costing.tsx
+++ b/apps/carbon/app/routes/x+/tool+/$itemId.costing.tsx
@@ -91,7 +91,11 @@ export default function ToolCostingRoute() {
return (
<ItemCostingForm
key={itemCost.itemId}
- initialValues={{ ...itemCost, ...getCustomFields(itemCost.customFields) }}
+ initialValues={{
+ ...itemCost,
+ itemPostingGroupId: itemCost?.itemPostingGroupId ?? undefined,
+ ...getCustomFields(itemCost.customFields),
+ }}
/>
);
}
diff --git a/apps/carbon/app/routes/x+/tool+/$itemId.details.tsx b/apps/carbon/app/routes/x+/tool+/$itemId.details.tsx
index c0b9b93f6a..4eccb4bb44 100644
--- a/apps/carbon/app/routes/x+/tool+/$itemId.details.tsx
+++ b/apps/carbon/app/routes/x+/tool+/$itemId.details.tsx
@@ -61,10 +61,10 @@ export default function ToolDetailsRoute() {
itemId: toolData.toolSummary?.itemId ?? "",
name: toolData.toolSummary?.name ?? "",
description: toolData.toolSummary?.description ?? "",
- itemGroupId: toolData.toolSummary?.itemGroupId ?? "",
- itemInventoryType: toolData.toolSummary?.itemInventoryType ?? "Inventory",
+ replenishmentSystem: toolData.toolSummary?.replenishmentSystem ?? "Buy",
+ defaultMethodType: toolData.toolSummary?.defaultMethodType ?? "Buy",
+ itemTrackingType: toolData.toolSummary?.itemTrackingType ?? "Inventory",
active: toolData.toolSummary?.active ?? true,
- pullFromInventory: toolData.toolSummary?.pullFromInventory ?? false,
unitOfMeasureCode: toolData.toolSummary?.unitOfMeasureCode ?? "EA",
...getCustomFields(toolData.toolSummary?.customFields ?? {}),
};
diff --git a/apps/carbon/app/routes/x+/tool+/new.tsx b/apps/carbon/app/routes/x+/tool+/new.tsx
index 0b8e2b510d..a041301151 100644
--- a/apps/carbon/app/routes/x+/tool+/new.tsx
+++ b/apps/carbon/app/routes/x+/tool+/new.tsx
@@ -55,9 +55,10 @@ export default function ToolsNewRoute() {
id: "",
name: "",
description: "",
- itemInventoryType: "Inventory" as "Inventory",
+ replenishmentSystem: "Buy" as const,
+ defaultMethodType: "Buy" as const,
+ itemTrackingType: "Inventory" as "Inventory",
unitOfMeasureCode: "EA",
- pullFromInventory: true,
active: true,
};
diff --git a/apps/carbon/app/stores/items.ts b/apps/carbon/app/stores/items.ts
index 65f9f56b32..d1070a402b 100644
--- a/apps/carbon/app/stores/items.ts
+++ b/apps/carbon/app/stores/items.ts
@@ -7,6 +7,7 @@ import type { ListItem } from "~/types";
export type Item = ListItem & {
readableId: string;
type: Database["public"]["Enums"]["itemType"];
+ replenishmentSystem: Database["public"]["Enums"]["itemReplenishmentSystem"];
};
const $itemsStore = atom<Item[]>([]);
diff --git a/apps/carbon/app/utils/path.ts b/apps/carbon/app/utils/path.ts
index d458a8300f..8e05210185 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`,
- itemGroups: `${api}/items/groups`,
+ itemPostingGroups: `${api}/items/groups`,
materialForms: `${api}/items/forms`,
materialSubstances: `${api}/items/substances`,
rollback: (table: string, id: string) =>
@@ -206,7 +206,7 @@ export const path = {
deleteLocation: (id: string) =>
generatePath(`${x}/resources/locations/delete/${id}`),
deleteNote: (id: string) => generatePath(`${x}/shared/notes/${id}/delete`),
- deleteItemGroup: (id: string) =>
+ deleteItemPostingGroup: (id: string) =>
generatePath(`${x}/items/groups/delete/${id}`),
deleteMaterialForm: (id: string) =>
generatePath(`${x}/items/forms/delete/${id}`),
@@ -317,8 +317,8 @@ export const path = {
inventory: `${x}/inventory`,
invoicing: `${x}/invoicing`,
items: `${x}/items`,
- itemGroup: (id: string) => generatePath(`${x}/items/groups/${id}`),
- itemGroups: `${x}/items/groups`,
+ itemPostingGroup: (id: string) => generatePath(`${x}/items/groups/${id}`),
+ itemPostingGroups: `${x}/items/groups`,
jobs: `${x}/jobs`,
location: (id: string) => generatePath(`${x}/resources/locations/${id}`),
locations: `${x}/resources/locations`,
@@ -410,7 +410,7 @@ export const path = {
generatePath(`${x}/items/methods/${id}/operation/new`),
newNote: `${x}/shared/notes/new`,
newPart: `${x}/part/new`,
- newItemGroup: `${x}/items/groups/new`,
+ newItemPostingGroup: `${x}/items/groups/new`,
newMaterialForm: `${x}/items/forms/new`,
newMaterialSubstance: `${x}/items/substances/new`,
newMaterialSupplier: (id: string) =>
diff --git a/apps/website/src/app/layout.tsx b/apps/website/src/app/layout.tsx
index 1df78815e5..c9ae31a7ae 100644
--- a/apps/website/src/app/layout.tsx
+++ b/apps/website/src/app/layout.tsx
@@ -9,7 +9,7 @@ import { ThemeProvider } from "next-themes";
import type { ReactElement } from "react";
export const metadata: Metadata = {
- metadataBase: new URL("https://carbon.us.org"),
+ metadataBase: new URL("https://carbonos.dev"),
title: "Carbon | ERP for the builders",
description:
"Carbon is an open-source ERP to meet your exact manufacturing needs",
diff --git a/packages/database/src/seed/admin.ts b/packages/database/src/seed/admin.ts
index d2c3c4126d..2719039d76 100644
--- a/packages/database/src/seed/admin.ts
+++ b/packages/database/src/seed/admin.ts
@@ -1,5 +1,5 @@
const admin = {
- email: "[email protected]",
+ email: "[email protected]",
password: "carbon",
firstName: "Carbon",
lastName: "Admin",
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index cd523f5163..090d19d29a 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -6022,13 +6022,13 @@ export type Database = {
companyId: string | null
createdAt: string
createdBy: string
+ defaultMethodType: Database["public"]["Enums"]["methodType"] | null
description: string | null
id: string
- itemGroupId: string | null
- itemInventoryType: Database["public"]["Enums"]["itemInventoryType"]
+ itemTrackingType: Database["public"]["Enums"]["itemTrackingType"]
name: string
- pullFromInventory: boolean
readableId: string
+ replenishmentSystem: Database["public"]["Enums"]["itemReplenishmentSystem"]
type: Database["public"]["Enums"]["itemType"]
unitOfMeasureCode: string | null
updatedAt: string | null
@@ -6040,13 +6040,13 @@ export type Database = {
companyId?: string | null
createdAt?: string
createdBy: string
+ defaultMethodType?: Database["public"]["Enums"]["methodType"] | null
description?: string | null
id?: string
- itemGroupId?: string | null
- itemInventoryType: Database["public"]["Enums"]["itemInventoryType"]
+ itemTrackingType: Database["public"]["Enums"]["itemTrackingType"]
name: string
- pullFromInventory?: boolean
readableId: string
+ replenishmentSystem?: Database["public"]["Enums"]["itemReplenishmentSystem"]
type: Database["public"]["Enums"]["itemType"]
unitOfMeasureCode?: string | null
updatedAt?: string | null
@@ -6058,13 +6058,13 @@ export type Database = {
companyId?: string | null
createdAt?: string
createdBy?: string
+ defaultMethodType?: Database["public"]["Enums"]["methodType"] | null
description?: string | null
id?: string
- itemGroupId?: string | null
- itemInventoryType?: Database["public"]["Enums"]["itemInventoryType"]
+ itemTrackingType?: Database["public"]["Enums"]["itemTrackingType"]
name?: string
- pullFromInventory?: boolean
readableId?: string
+ replenishmentSystem?: Database["public"]["Enums"]["itemReplenishmentSystem"]
type?: Database["public"]["Enums"]["itemType"]
unitOfMeasureCode?: string | null
updatedAt?: string | null
@@ -6169,13 +6169,6 @@ export type Database = {
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
- {
- foreignKeyName: "item_itemGroupId_fkey"
- columns: ["itemGroupId"]
- isOneToOne: false
- referencedRelation: "itemGroup"
- referencedColumns: ["id"]
- },
{
foreignKeyName: "item_unitOfMeasureCode_fkey"
columns: ["unitOfMeasureCode", "companyId"]
@@ -6229,6 +6222,7 @@ export type Database = {
createdBy: string
customFields: Json | null
itemId: string
+ itemPostingGroupId: string | null
standardCost: number
unitCost: number
updatedAt: string | null
@@ -6242,6 +6236,7 @@ export type Database = {
createdBy: string
customFields?: Json | null
itemId: string
+ itemPostingGroupId?: string | null
standardCost?: number
unitCost?: number
updatedAt?: string | null
@@ -6255,6 +6250,7 @@ export type Database = {
createdBy?: string
customFields?: Json | null
itemId?: string
+ itemPostingGroupId?: string | null
standardCost?: number
unitCost?: number
updatedAt?: string | null
@@ -6304,208 +6300,77 @@ export type Database = {
referencedColumns: ["itemId"]
},
{
- 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"]
- },
- ]
- }
- 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"]
+ foreignKeyName: "itemCost_itemPostingGroupId_fkey"
+ columns: ["itemPostingGroupId"]
isOneToOne: false
- referencedRelation: "company"
+ referencedRelation: "itemPostingGroup"
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"
+ foreignKeyName: "itemPostingGroup_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "itemGroup_createdBy_fkey"
+ foreignKeyName: "itemPostingGroup_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "itemGroup_createdBy_fkey"
+ foreignKeyName: "itemPostingGroup_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "itemGroup_createdBy_fkey"
+ foreignKeyName: "itemPostingGroup_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "itemGroup_createdBy_fkey"
+ foreignKeyName: "itemPostingGroup_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
{
- foreignKeyName: "itemGroup_updatedBy_fkey"
+ foreignKeyName: "itemPostingGroup_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "itemGroup_updatedBy_fkey"
+ foreignKeyName: "itemPostingGroup_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "itemGroup_updatedBy_fkey"
+ foreignKeyName: "itemPostingGroup_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "itemGroup_updatedBy_fkey"
+ foreignKeyName: "itemPostingGroup_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "itemGroup_updatedBy_fkey"
+ foreignKeyName: "itemPostingGroup_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "userDefaults"
@@ -6861,6 +6726,144 @@ export type Database = {
},
]
}
+ itemPostingGroup: {
+ 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: "itemPostingGroup_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemPostingGroup_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemPostingGroup_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "itemPostingGroup_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "itemPostingGroup_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemPostingGroup_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemPostingGroup_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemPostingGroup_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemPostingGroup_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "itemPostingGroup_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemPostingGroup_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemPostingGroup_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemPostingGroup_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemPostingGroup_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ ]
+ }
itemReplenishment: {
Row: {
companyId: string
@@ -8737,7 +8740,6 @@ export type Database = {
fromDate: string | null
id: string
itemId: string
- replenishmentSystem: Database["public"]["Enums"]["itemReplenishmentSystem"]
toDate: string | null
updatedAt: string | null
updatedBy: string | null
@@ -8752,7 +8754,6 @@ export type Database = {
fromDate?: string | null
id: string
itemId: string
- replenishmentSystem: Database["public"]["Enums"]["itemReplenishmentSystem"]
toDate?: string | null
updatedAt?: string | null
updatedBy?: string | null
@@ -8767,7 +8768,6 @@ export type Database = {
fromDate?: string | null
id?: string
itemId?: string
- replenishmentSystem?: Database["public"]["Enums"]["itemReplenishmentSystem"]
toDate?: string | null
updatedAt?: string | null
updatedBy?: string | null
@@ -9418,7 +9418,7 @@ export type Database = {
inventoryInvoicedNotReceivedAccount: string
inventoryReceivedNotInvoicedAccount: string
inventoryShippedNotInvoicedAccount: string
- itemGroupId: string | null
+ itemPostingGroupId: string | null
locationId: string | null
materialVarianceAccount: string
overheadAccount: string
@@ -9439,7 +9439,7 @@ export type Database = {
inventoryInvoicedNotReceivedAccount: string
inventoryReceivedNotInvoicedAccount: string
inventoryShippedNotInvoicedAccount: string
- itemGroupId?: string | null
+ itemPostingGroupId?: string | null
locationId?: string | null
materialVarianceAccount: string
overheadAccount: string
@@ -9460,7 +9460,7 @@ export type Database = {
inventoryInvoicedNotReceivedAccount?: string
inventoryReceivedNotInvoicedAccount?: string
inventoryShippedNotInvoicedAccount?: string
- itemGroupId?: string | null
+ itemPostingGroupId?: string | null
locationId?: string | null
materialVarianceAccount?: string
overheadAccount?: string
@@ -9597,10 +9597,10 @@ export type Database = {
referencedColumns: ["number", "companyId"]
},
{
- foreignKeyName: "postingGroupInventory_itemGroupId_fkey"
- columns: ["itemGroupId"]
+ foreignKeyName: "postingGroupInventory_itemPostingGroupId_fkey"
+ columns: ["itemPostingGroupId"]
isOneToOne: false
- referencedRelation: "itemGroup"
+ referencedRelation: "itemPostingGroup"
referencedColumns: ["id"]
},
{
@@ -9742,7 +9742,7 @@ export type Database = {
Row: {
companyId: string
id: string
- itemGroupId: string | null
+ itemPostingGroupId: string | null
payablesAccount: string
purchaseAccount: string
purchaseCreditAccount: string
@@ -9755,7 +9755,7 @@ export type Database = {
Insert: {
companyId: string
id?: string
- itemGroupId?: string | null
+ itemPostingGroupId?: string | null
payablesAccount: string
purchaseAccount: string
purchaseCreditAccount: string
@@ -9768,7 +9768,7 @@ export type Database = {
Update: {
companyId?: string
id?: string
- itemGroupId?: string | null
+ itemPostingGroupId?: string | null
payablesAccount?: string
purchaseAccount?: string
purchaseCreditAccount?: string
@@ -9808,10 +9808,10 @@ export type Database = {
referencedColumns: ["companyId"]
},
{
- foreignKeyName: "postingGroupPurchasing_itemGroupId_fkey"
- columns: ["itemGroupId"]
+ foreignKeyName: "postingGroupPurchasing_itemPostingGroupId_fkey"
+ columns: ["itemPostingGroupId"]
isOneToOne: false
- referencedRelation: "itemGroup"
+ referencedRelation: "itemPostingGroup"
referencedColumns: ["id"]
},
{
@@ -9947,7 +9947,7 @@ export type Database = {
companyId: string
customerTypeId: string | null
id: string
- itemGroupId: string | null
+ itemPostingGroupId: string | null
receivablesAccount: string
salesAccount: string
salesCreditAccount: string
@@ -9960,7 +9960,7 @@ export type Database = {
companyId: string
customerTypeId?: string | null
id?: string
- itemGroupId?: string | null
+ itemPostingGroupId?: string | null
receivablesAccount: string
salesAccount: string
salesCreditAccount: string
@@ -9973,7 +9973,7 @@ export type Database = {
companyId?: string
customerTypeId?: string | null
id?: string
- itemGroupId?: string | null
+ itemPostingGroupId?: string | null
receivablesAccount?: string
salesAccount?: string
salesCreditAccount?: string
@@ -10019,10 +10019,10 @@ export type Database = {
referencedColumns: ["id"]
},
{
- foreignKeyName: "postingGroupSales_itemGroupId_fkey"
- columns: ["itemGroupId"]
+ foreignKeyName: "postingGroupSales_itemPostingGroupId_fkey"
+ columns: ["itemPostingGroupId"]
isOneToOne: false
- referencedRelation: "itemGroup"
+ referencedRelation: "itemPostingGroup"
referencedColumns: ["id"]
},
{
@@ -20235,16 +20235,17 @@ export type Database = {
createdAt: string | null
createdBy: string | null
customFields: Json | null
+ defaultMethodType: Database["public"]["Enums"]["methodType"] | null
description: string | null
id: string | null
- itemGroup: string | null
- itemGroupId: string | null
itemId: string | null
- itemInventoryType:
- | Database["public"]["Enums"]["itemInventoryType"]
+ itemTrackingType:
+ | Database["public"]["Enums"]["itemTrackingType"]
| null
name: string | null
- pullFromInventory: boolean | null
+ replenishmentSystem:
+ | Database["public"]["Enums"]["itemReplenishmentSystem"]
+ | null
supplierIds: string[] | null
unitOfMeasure: string | null
unitOfMeasureCode: string | null
@@ -20434,13 +20435,6 @@ export type Database = {
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
- {
- foreignKeyName: "item_itemGroupId_fkey"
- columns: ["itemGroupId"]
- isOneToOne: false
- referencedRelation: "itemGroup"
- referencedColumns: ["id"]
- },
]
}
contractors: {
@@ -20975,16 +20969,17 @@ export type Database = {
customer: string | null
customerId: string | null
customFields: Json | null
+ defaultMethodType: Database["public"]["Enums"]["methodType"] | null
description: string | null
id: string | null
- itemGroup: string | null
- itemGroupId: string | null
itemId: string | null
- itemInventoryType:
- | Database["public"]["Enums"]["itemInventoryType"]
+ itemTrackingType:
+ | Database["public"]["Enums"]["itemTrackingType"]
| null
name: string | null
- pullFromInventory: boolean | null
+ replenishmentSystem:
+ | Database["public"]["Enums"]["itemReplenishmentSystem"]
+ | null
supplierIds: string[] | null
updatedAt: string | null
updatedBy: string | null
@@ -21193,13 +21188,6 @@ export type Database = {
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
- {
- foreignKeyName: "item_itemGroupId_fkey"
- columns: ["itemGroupId"]
- isOneToOne: false
- referencedRelation: "itemGroup"
- referencedColumns: ["id"]
- },
]
}
groupMembers: {
@@ -21431,23 +21419,24 @@ export type Database = {
createdAt: string | null
createdBy: string | null
customFields: Json | null
+ defaultMethodType: Database["public"]["Enums"]["methodType"] | null
description: string | null
dimensions: string | null
finish: string | null
grade: string | null
id: string | null
- itemGroup: string | null
- itemGroupId: string | null
itemId: string | null
- itemInventoryType:
- | Database["public"]["Enums"]["itemInventoryType"]
+ itemTrackingType:
+ | Database["public"]["Enums"]["itemTrackingType"]
| null
materialForm: string | null
materialFormId: string | null
materialSubstance: string | null
materialSubstanceId: string | null
name: string | null
- pullFromInventory: boolean | null
+ replenishmentSystem:
+ | Database["public"]["Enums"]["itemReplenishmentSystem"]
+ | null
supplierIds: string[] | null
unitOfMeasure: string | null
unitOfMeasureCode: string | null
@@ -21490,13 +21479,6 @@ export type Database = {
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
- {
- foreignKeyName: "item_itemGroupId_fkey"
- columns: ["itemGroupId"]
- isOneToOne: false
- referencedRelation: "itemGroup"
- referencedColumns: ["id"]
- },
{
foreignKeyName: "material_approvedBy_fkey"
columns: ["approvedBy"]
@@ -21817,17 +21799,15 @@ export type Database = {
createdAt: string | null
createdBy: string | null
customFields: Json | null
+ defaultMethodType: Database["public"]["Enums"]["methodType"] | null
description: string | null
fromDate: string | null
id: string | null
- itemGroup: string | null
- itemGroupId: string | null
itemId: string | null
- itemInventoryType:
- | Database["public"]["Enums"]["itemInventoryType"]
+ itemTrackingType:
+ | Database["public"]["Enums"]["itemTrackingType"]
| null
name: string | null
- pullFromInventory: boolean | null
replenishmentSystem:
| Database["public"]["Enums"]["itemReplenishmentSystem"]
| null
@@ -21874,13 +21854,6 @@ export type Database = {
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
- {
- foreignKeyName: "item_itemGroupId_fkey"
- columns: ["itemGroupId"]
- isOneToOne: false
- referencedRelation: "itemGroup"
- referencedColumns: ["id"]
- },
{
foreignKeyName: "part_approvedBy_fkey"
columns: ["approvedBy"]
@@ -24157,14 +24130,15 @@ export type Database = {
createdAt: string | null
createdBy: string | null
customFields: Json | null
+ defaultMethodType: Database["public"]["Enums"]["methodType"] | null
description: string | null
fromDate: string | null
id: string | null
- itemGroup: string | null
- itemGroupId: string | null
itemId: string | null
name: string | null
- pullFromInventory: boolean | null
+ replenishmentSystem:
+ | Database["public"]["Enums"]["itemReplenishmentSystem"]
+ | null
serviceType: Database["public"]["Enums"]["serviceType"] | null
supplierIds: string[] | null
toDate: string | null
@@ -24207,13 +24181,6 @@ export type Database = {
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
- {
- foreignKeyName: "item_itemGroupId_fkey"
- columns: ["itemGroupId"]
- isOneToOne: false
- referencedRelation: "itemGroup"
- referencedColumns: ["id"]
- },
{
foreignKeyName: "service_approvedBy_fkey"
columns: ["approvedBy"]
@@ -24731,16 +24698,17 @@ export type Database = {
createdAt: string | null
createdBy: string | null
customFields: Json | null
+ defaultMethodType: Database["public"]["Enums"]["methodType"] | null
description: string | null
id: string | null
- itemGroup: string | null
- itemGroupId: string | null
itemId: string | null
- itemInventoryType:
- | Database["public"]["Enums"]["itemInventoryType"]
+ itemTrackingType:
+ | Database["public"]["Enums"]["itemTrackingType"]
| null
name: string | null
- pullFromInventory: boolean | null
+ replenishmentSystem:
+ | Database["public"]["Enums"]["itemReplenishmentSystem"]
+ | null
supplierIds: string[] | null
unitOfMeasure: string | null
unitOfMeasureCode: string | null
@@ -24783,13 +24751,6 @@ export type Database = {
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
- {
- foreignKeyName: "item_itemGroupId_fkey"
- columns: ["itemGroupId"]
- isOneToOne: false
- referencedRelation: "itemGroup"
- referencedColumns: ["id"]
- },
{
foreignKeyName: "tool_approvedBy_fkey"
columns: ["approvedBy"]
@@ -25233,7 +25194,6 @@ export type Database = {
glConsolidatedRate: "Average" | "Current" | "Historical"
glIncomeBalance: "Balance Sheet" | "Income Statement"
itemCostingMethod: "Standard" | "Average" | "LIFO" | "FIFO"
- itemInventoryType: "Inventory" | "Non-Inventory"
itemLedgerDocumentType:
| "Sales Shipment"
| "Sales Invoice"
@@ -25268,6 +25228,7 @@ export type Database = {
| "Fixed Reorder Quantity"
| "Maximum Quantity"
itemReplenishmentSystem: "Buy" | "Make" | "Buy and Make"
+ itemTrackingType: "Inventory" | "Non-Inventory"
itemType:
| "Part"
| "Material"
diff --git a/packages/database/supabase/functions/create-receipt-from-purchase-order/index.ts b/packages/database/supabase/functions/create-receipt-from-purchase-order/index.ts
index 07ba996b54..248d3acff5 100644
--- a/packages/database/supabase/functions/create-receipt-from-purchase-order/index.ts
+++ b/packages/database/supabase/functions/create-receipt-from-purchase-order/index.ts
@@ -43,7 +43,13 @@ serve(async (req: Request) => {
.from("purchaseOrderLine")
.select("*")
.eq("purchaseOrderId", purchaseOrderId)
- .eq("purchaseOrderLineType", "Part")
+ .in("purchaseOrderLineType", [
+ "Part",
+ "Material",
+ "Tool",
+ "Fixture",
+ "Consumable",
+ ])
.eq("locationId", locationId),
client
.from("receipt")
diff --git a/packages/database/supabase/functions/lib/seed.ts b/packages/database/supabase/functions/lib/seed.ts
index f6e65d4479..fb985de206 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 = {
- itemGroupId: null,
+ itemPostingGroupId: null,
locationId: null,
costOfGoodsSoldAccount: getDefaultAccount("costOfGoodsSoldAccount"),
inventoryAccount: getDefaultAccount("inventoryAccount"),
@@ -2008,7 +2008,7 @@ export const postingGroupInventory = {
};
export const postingGroupPurchasing = {
- itemGroupId: null,
+ itemPostingGroupId: null,
supplierTypeId: null,
payablesAccount: getDefaultAccount("payablesAccount"),
purchaseAccount: getDefaultAccount("purchaseAccount"),
@@ -2020,7 +2020,7 @@ export const postingGroupPurchasing = {
};
export const postingGroupSales = {
- itemGroupId: null,
+ itemPostingGroupId: 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 cd523f5163..090d19d29a 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -6022,13 +6022,13 @@ export type Database = {
companyId: string | null
createdAt: string
createdBy: string
+ defaultMethodType: Database["public"]["Enums"]["methodType"] | null
description: string | null
id: string
- itemGroupId: string | null
- itemInventoryType: Database["public"]["Enums"]["itemInventoryType"]
+ itemTrackingType: Database["public"]["Enums"]["itemTrackingType"]
name: string
- pullFromInventory: boolean
readableId: string
+ replenishmentSystem: Database["public"]["Enums"]["itemReplenishmentSystem"]
type: Database["public"]["Enums"]["itemType"]
unitOfMeasureCode: string | null
updatedAt: string | null
@@ -6040,13 +6040,13 @@ export type Database = {
companyId?: string | null
createdAt?: string
createdBy: string
+ defaultMethodType?: Database["public"]["Enums"]["methodType"] | null
description?: string | null
id?: string
- itemGroupId?: string | null
- itemInventoryType: Database["public"]["Enums"]["itemInventoryType"]
+ itemTrackingType: Database["public"]["Enums"]["itemTrackingType"]
name: string
- pullFromInventory?: boolean
readableId: string
+ replenishmentSystem?: Database["public"]["Enums"]["itemReplenishmentSystem"]
type: Database["public"]["Enums"]["itemType"]
unitOfMeasureCode?: string | null
updatedAt?: string | null
@@ -6058,13 +6058,13 @@ export type Database = {
companyId?: string | null
createdAt?: string
createdBy?: string
+ defaultMethodType?: Database["public"]["Enums"]["methodType"] | null
description?: string | null
id?: string
- itemGroupId?: string | null
- itemInventoryType?: Database["public"]["Enums"]["itemInventoryType"]
+ itemTrackingType?: Database["public"]["Enums"]["itemTrackingType"]
name?: string
- pullFromInventory?: boolean
readableId?: string
+ replenishmentSystem?: Database["public"]["Enums"]["itemReplenishmentSystem"]
type?: Database["public"]["Enums"]["itemType"]
unitOfMeasureCode?: string | null
updatedAt?: string | null
@@ -6169,13 +6169,6 @@ export type Database = {
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
- {
- foreignKeyName: "item_itemGroupId_fkey"
- columns: ["itemGroupId"]
- isOneToOne: false
- referencedRelation: "itemGroup"
- referencedColumns: ["id"]
- },
{
foreignKeyName: "item_unitOfMeasureCode_fkey"
columns: ["unitOfMeasureCode", "companyId"]
@@ -6229,6 +6222,7 @@ export type Database = {
createdBy: string
customFields: Json | null
itemId: string
+ itemPostingGroupId: string | null
standardCost: number
unitCost: number
updatedAt: string | null
@@ -6242,6 +6236,7 @@ export type Database = {
createdBy: string
customFields?: Json | null
itemId: string
+ itemPostingGroupId?: string | null
standardCost?: number
unitCost?: number
updatedAt?: string | null
@@ -6255,6 +6250,7 @@ export type Database = {
createdBy?: string
customFields?: Json | null
itemId?: string
+ itemPostingGroupId?: string | null
standardCost?: number
unitCost?: number
updatedAt?: string | null
@@ -6304,208 +6300,77 @@ export type Database = {
referencedColumns: ["itemId"]
},
{
- 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"]
- },
- ]
- }
- 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"]
+ foreignKeyName: "itemCost_itemPostingGroupId_fkey"
+ columns: ["itemPostingGroupId"]
isOneToOne: false
- referencedRelation: "company"
+ referencedRelation: "itemPostingGroup"
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"
+ foreignKeyName: "itemPostingGroup_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "itemGroup_createdBy_fkey"
+ foreignKeyName: "itemPostingGroup_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "itemGroup_createdBy_fkey"
+ foreignKeyName: "itemPostingGroup_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "itemGroup_createdBy_fkey"
+ foreignKeyName: "itemPostingGroup_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "itemGroup_createdBy_fkey"
+ foreignKeyName: "itemPostingGroup_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
{
- foreignKeyName: "itemGroup_updatedBy_fkey"
+ foreignKeyName: "itemPostingGroup_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "itemGroup_updatedBy_fkey"
+ foreignKeyName: "itemPostingGroup_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "itemGroup_updatedBy_fkey"
+ foreignKeyName: "itemPostingGroup_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "itemGroup_updatedBy_fkey"
+ foreignKeyName: "itemPostingGroup_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "itemGroup_updatedBy_fkey"
+ foreignKeyName: "itemPostingGroup_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "userDefaults"
@@ -6861,6 +6726,144 @@ export type Database = {
},
]
}
+ itemPostingGroup: {
+ 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: "itemPostingGroup_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemPostingGroup_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemPostingGroup_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "itemPostingGroup_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "itemPostingGroup_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemPostingGroup_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemPostingGroup_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemPostingGroup_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemPostingGroup_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "itemPostingGroup_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemPostingGroup_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemPostingGroup_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemPostingGroup_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemPostingGroup_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ ]
+ }
itemReplenishment: {
Row: {
companyId: string
@@ -8737,7 +8740,6 @@ export type Database = {
fromDate: string | null
id: string
itemId: string
- replenishmentSystem: Database["public"]["Enums"]["itemReplenishmentSystem"]
toDate: string | null
updatedAt: string | null
updatedBy: string | null
@@ -8752,7 +8754,6 @@ export type Database = {
fromDate?: string | null
id: string
itemId: string
- replenishmentSystem: Database["public"]["Enums"]["itemReplenishmentSystem"]
toDate?: string | null
updatedAt?: string | null
updatedBy?: string | null
@@ -8767,7 +8768,6 @@ export type Database = {
fromDate?: string | null
id?: string
itemId?: string
- replenishmentSystem?: Database["public"]["Enums"]["itemReplenishmentSystem"]
toDate?: string | null
updatedAt?: string | null
updatedBy?: string | null
@@ -9418,7 +9418,7 @@ export type Database = {
inventoryInvoicedNotReceivedAccount: string
inventoryReceivedNotInvoicedAccount: string
inventoryShippedNotInvoicedAccount: string
- itemGroupId: string | null
+ itemPostingGroupId: string | null
locationId: string | null
materialVarianceAccount: string
overheadAccount: string
@@ -9439,7 +9439,7 @@ export type Database = {
inventoryInvoicedNotReceivedAccount: string
inventoryReceivedNotInvoicedAccount: string
inventoryShippedNotInvoicedAccount: string
- itemGroupId?: string | null
+ itemPostingGroupId?: string | null
locationId?: string | null
materialVarianceAccount: string
overheadAccount: string
@@ -9460,7 +9460,7 @@ export type Database = {
inventoryInvoicedNotReceivedAccount?: string
inventoryReceivedNotInvoicedAccount?: string
inventoryShippedNotInvoicedAccount?: string
- itemGroupId?: string | null
+ itemPostingGroupId?: string | null
locationId?: string | null
materialVarianceAccount?: string
overheadAccount?: string
@@ -9597,10 +9597,10 @@ export type Database = {
referencedColumns: ["number", "companyId"]
},
{
- foreignKeyName: "postingGroupInventory_itemGroupId_fkey"
- columns: ["itemGroupId"]
+ foreignKeyName: "postingGroupInventory_itemPostingGroupId_fkey"
+ columns: ["itemPostingGroupId"]
isOneToOne: false
- referencedRelation: "itemGroup"
+ referencedRelation: "itemPostingGroup"
referencedColumns: ["id"]
},
{
@@ -9742,7 +9742,7 @@ export type Database = {
Row: {
companyId: string
id: string
- itemGroupId: string | null
+ itemPostingGroupId: string | null
payablesAccount: string
purchaseAccount: string
purchaseCreditAccount: string
@@ -9755,7 +9755,7 @@ export type Database = {
Insert: {
companyId: string
id?: string
- itemGroupId?: string | null
+ itemPostingGroupId?: string | null
payablesAccount: string
purchaseAccount: string
purchaseCreditAccount: string
@@ -9768,7 +9768,7 @@ export type Database = {
Update: {
companyId?: string
id?: string
- itemGroupId?: string | null
+ itemPostingGroupId?: string | null
payablesAccount?: string
purchaseAccount?: string
purchaseCreditAccount?: string
@@ -9808,10 +9808,10 @@ export type Database = {
referencedColumns: ["companyId"]
},
{
- foreignKeyName: "postingGroupPurchasing_itemGroupId_fkey"
- columns: ["itemGroupId"]
+ foreignKeyName: "postingGroupPurchasing_itemPostingGroupId_fkey"
+ columns: ["itemPostingGroupId"]
isOneToOne: false
- referencedRelation: "itemGroup"
+ referencedRelation: "itemPostingGroup"
referencedColumns: ["id"]
},
{
@@ -9947,7 +9947,7 @@ export type Database = {
companyId: string
customerTypeId: string | null
id: string
- itemGroupId: string | null
+ itemPostingGroupId: string | null
receivablesAccount: string
salesAccount: string
salesCreditAccount: string
@@ -9960,7 +9960,7 @@ export type Database = {
companyId: string
customerTypeId?: string | null
id?: string
- itemGroupId?: string | null
+ itemPostingGroupId?: string | null
receivablesAccount: string
salesAccount: string
salesCreditAccount: string
@@ -9973,7 +9973,7 @@ export type Database = {
companyId?: string
customerTypeId?: string | null
id?: string
- itemGroupId?: string | null
+ itemPostingGroupId?: string | null
receivablesAccount?: string
salesAccount?: string
salesCreditAccount?: string
@@ -10019,10 +10019,10 @@ export type Database = {
referencedColumns: ["id"]
},
{
- foreignKeyName: "postingGroupSales_itemGroupId_fkey"
- columns: ["itemGroupId"]
+ foreignKeyName: "postingGroupSales_itemPostingGroupId_fkey"
+ columns: ["itemPostingGroupId"]
isOneToOne: false
- referencedRelation: "itemGroup"
+ referencedRelation: "itemPostingGroup"
referencedColumns: ["id"]
},
{
@@ -20235,16 +20235,17 @@ export type Database = {
createdAt: string | null
createdBy: string | null
customFields: Json | null
+ defaultMethodType: Database["public"]["Enums"]["methodType"] | null
description: string | null
id: string | null
- itemGroup: string | null
- itemGroupId: string | null
itemId: string | null
- itemInventoryType:
- | Database["public"]["Enums"]["itemInventoryType"]
+ itemTrackingType:
+ | Database["public"]["Enums"]["itemTrackingType"]
| null
name: string | null
- pullFromInventory: boolean | null
+ replenishmentSystem:
+ | Database["public"]["Enums"]["itemReplenishmentSystem"]
+ | null
supplierIds: string[] | null
unitOfMeasure: string | null
unitOfMeasureCode: string | null
@@ -20434,13 +20435,6 @@ export type Database = {
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
- {
- foreignKeyName: "item_itemGroupId_fkey"
- columns: ["itemGroupId"]
- isOneToOne: false
- referencedRelation: "itemGroup"
- referencedColumns: ["id"]
- },
]
}
contractors: {
@@ -20975,16 +20969,17 @@ export type Database = {
customer: string | null
customerId: string | null
customFields: Json | null
+ defaultMethodType: Database["public"]["Enums"]["methodType"] | null
description: string | null
id: string | null
- itemGroup: string | null
- itemGroupId: string | null
itemId: string | null
- itemInventoryType:
- | Database["public"]["Enums"]["itemInventoryType"]
+ itemTrackingType:
+ | Database["public"]["Enums"]["itemTrackingType"]
| null
name: string | null
- pullFromInventory: boolean | null
+ replenishmentSystem:
+ | Database["public"]["Enums"]["itemReplenishmentSystem"]
+ | null
supplierIds: string[] | null
updatedAt: string | null
updatedBy: string | null
@@ -21193,13 +21188,6 @@ export type Database = {
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
- {
- foreignKeyName: "item_itemGroupId_fkey"
- columns: ["itemGroupId"]
- isOneToOne: false
- referencedRelation: "itemGroup"
- referencedColumns: ["id"]
- },
]
}
groupMembers: {
@@ -21431,23 +21419,24 @@ export type Database = {
createdAt: string | null
createdBy: string | null
customFields: Json | null
+ defaultMethodType: Database["public"]["Enums"]["methodType"] | null
description: string | null
dimensions: string | null
finish: string | null
grade: string | null
id: string | null
- itemGroup: string | null
- itemGroupId: string | null
itemId: string | null
- itemInventoryType:
- | Database["public"]["Enums"]["itemInventoryType"]
+ itemTrackingType:
+ | Database["public"]["Enums"]["itemTrackingType"]
| null
materialForm: string | null
materialFormId: string | null
materialSubstance: string | null
materialSubstanceId: string | null
name: string | null
- pullFromInventory: boolean | null
+ replenishmentSystem:
+ | Database["public"]["Enums"]["itemReplenishmentSystem"]
+ | null
supplierIds: string[] | null
unitOfMeasure: string | null
unitOfMeasureCode: string | null
@@ -21490,13 +21479,6 @@ export type Database = {
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
- {
- foreignKeyName: "item_itemGroupId_fkey"
- columns: ["itemGroupId"]
- isOneToOne: false
- referencedRelation: "itemGroup"
- referencedColumns: ["id"]
- },
{
foreignKeyName: "material_approvedBy_fkey"
columns: ["approvedBy"]
@@ -21817,17 +21799,15 @@ export type Database = {
createdAt: string | null
createdBy: string | null
customFields: Json | null
+ defaultMethodType: Database["public"]["Enums"]["methodType"] | null
description: string | null
fromDate: string | null
id: string | null
- itemGroup: string | null
- itemGroupId: string | null
itemId: string | null
- itemInventoryType:
- | Database["public"]["Enums"]["itemInventoryType"]
+ itemTrackingType:
+ | Database["public"]["Enums"]["itemTrackingType"]
| null
name: string | null
- pullFromInventory: boolean | null
replenishmentSystem:
| Database["public"]["Enums"]["itemReplenishmentSystem"]
| null
@@ -21874,13 +21854,6 @@ export type Database = {
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
- {
- foreignKeyName: "item_itemGroupId_fkey"
- columns: ["itemGroupId"]
- isOneToOne: false
- referencedRelation: "itemGroup"
- referencedColumns: ["id"]
- },
{
foreignKeyName: "part_approvedBy_fkey"
columns: ["approvedBy"]
@@ -24157,14 +24130,15 @@ export type Database = {
createdAt: string | null
createdBy: string | null
customFields: Json | null
+ defaultMethodType: Database["public"]["Enums"]["methodType"] | null
description: string | null
fromDate: string | null
id: string | null
- itemGroup: string | null
- itemGroupId: string | null
itemId: string | null
name: string | null
- pullFromInventory: boolean | null
+ replenishmentSystem:
+ | Database["public"]["Enums"]["itemReplenishmentSystem"]
+ | null
serviceType: Database["public"]["Enums"]["serviceType"] | null
supplierIds: string[] | null
toDate: string | null
@@ -24207,13 +24181,6 @@ export type Database = {
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
- {
- foreignKeyName: "item_itemGroupId_fkey"
- columns: ["itemGroupId"]
- isOneToOne: false
- referencedRelation: "itemGroup"
- referencedColumns: ["id"]
- },
{
foreignKeyName: "service_approvedBy_fkey"
columns: ["approvedBy"]
@@ -24731,16 +24698,17 @@ export type Database = {
createdAt: string | null
createdBy: string | null
customFields: Json | null
+ defaultMethodType: Database["public"]["Enums"]["methodType"] | null
description: string | null
id: string | null
- itemGroup: string | null
- itemGroupId: string | null
itemId: string | null
- itemInventoryType:
- | Database["public"]["Enums"]["itemInventoryType"]
+ itemTrackingType:
+ | Database["public"]["Enums"]["itemTrackingType"]
| null
name: string | null
- pullFromInventory: boolean | null
+ replenishmentSystem:
+ | Database["public"]["Enums"]["itemReplenishmentSystem"]
+ | null
supplierIds: string[] | null
unitOfMeasure: string | null
unitOfMeasureCode: string | null
@@ -24783,13 +24751,6 @@ export type Database = {
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
- {
- foreignKeyName: "item_itemGroupId_fkey"
- columns: ["itemGroupId"]
- isOneToOne: false
- referencedRelation: "itemGroup"
- referencedColumns: ["id"]
- },
{
foreignKeyName: "tool_approvedBy_fkey"
columns: ["approvedBy"]
@@ -25233,7 +25194,6 @@ export type Database = {
glConsolidatedRate: "Average" | "Current" | "Historical"
glIncomeBalance: "Balance Sheet" | "Income Statement"
itemCostingMethod: "Standard" | "Average" | "LIFO" | "FIFO"
- itemInventoryType: "Inventory" | "Non-Inventory"
itemLedgerDocumentType:
| "Sales Shipment"
| "Sales Invoice"
@@ -25268,6 +25228,7 @@ export type Database = {
| "Fixed Reorder Quantity"
| "Maximum Quantity"
itemReplenishmentSystem: "Buy" | "Make" | "Buy and Make"
+ itemTrackingType: "Inventory" | "Non-Inventory"
itemType:
| "Part"
| "Material"
diff --git a/packages/database/supabase/functions/post-purchase-invoice/index.ts b/packages/database/supabase/functions/post-purchase-invoice/index.ts
index 0a01d0e969..d6006ff416 100644
--- a/packages/database/supabase/functions/post-purchase-invoice/index.ts
+++ b/packages/database/supabase/functions/post-purchase-invoice/index.ts
@@ -41,22 +41,26 @@ serve(async (req: Request) => {
throw new Error("Failed to fetch receipt lines");
const companyId = purchaseInvoice.data.companyId;
+ const itemIds = purchaseInvoiceLines.data.reduce<string[]>(
+ (acc, invoiceLine) => {
+ if (invoiceLine.itemId && !acc.includes(invoiceLine.itemId)) {
+ acc.push(invoiceLine.itemId);
+ }
+ return acc;
+ },
+ []
+ );
- const [items, purchaseOrderLines, supplier] = await Promise.all([
+ const [items, itemCosts, purchaseOrderLines, supplier] = await Promise.all([
client
.from("item")
- .select("id, itemGroupId, itemInventoryType, readableId")
- .in(
- "id",
- purchaseInvoiceLines.data.reduce<string[]>((acc, invoiceLine) => {
- if (invoiceLine.itemId && !acc.includes(invoiceLine.itemId)) {
- acc.push(invoiceLine.itemId);
- }
- return acc;
- }, [])
- )
+ .select("id, itemTrackingType, readableId")
+ .in("id", itemIds)
.eq("companyId", companyId),
-
+ client
+ .from("itemCost")
+ .select("itemId, itemPostingGroupId")
+ .in("itemId", itemIds),
client
.from("purchaseOrderLine")
.select("*")
@@ -79,7 +83,8 @@ serve(async (req: Request) => {
.eq("companyId", companyId)
.single(),
]);
- if (items.error) throw new Error("Failed to fetch item groups");
+ if (items.error) throw new Error("Failed to fetch items");
+ if (itemCosts.error) throw new Error("Failed to fetch item costs");
if (purchaseOrderLines.error)
throw new Error("Failed to fetch purchase order lines");
if (supplier.error) throw new Error("Failed to fetch supplier");
@@ -227,7 +232,7 @@ serve(async (req: Request) => {
| Database["public"]["Tables"]["postingGroupInventory"]["Row"]
| null = null;
- let itemGroupId: string | null = null;
+ let itemPostingGroupId: string | null = null;
// purchasing posting group
const purchasingPostingGroups: Record<
@@ -252,23 +257,23 @@ serve(async (req: Request) => {
case "Fixture":
case "Material":
case "Tool":
- const itemInventoryType =
+ const itemTrackingType =
items.data.find((item) => item.id === invoiceLine.itemId)
- ?.itemInventoryType ?? "Inventory";
+ ?.itemTrackingType ?? "Inventory";
- itemGroupId =
- items.data.find((item) => item.id === invoiceLine.itemId)
- ?.itemGroupId ?? null;
+ itemPostingGroupId =
+ itemCosts.data.find((item) => item.itemId === invoiceLine.itemId)
+ ?.itemPostingGroupId ?? null;
// inventory posting group
- if (`${itemGroupId}-${locationId}` in inventoryPostingGroups) {
+ if (`${itemPostingGroupId}-${locationId}` in inventoryPostingGroups) {
postingGroupInventory =
- inventoryPostingGroups[`${itemGroupId}-${locationId}`];
+ inventoryPostingGroups[`${itemPostingGroupId}-${locationId}`];
} else {
const inventoryPostingGroup = await getInventoryPostingGroup(
client,
{
- itemGroupId,
+ itemPostingGroupId,
locationId,
}
);
@@ -278,7 +283,7 @@ serve(async (req: Request) => {
}
postingGroupInventory = inventoryPostingGroup.data ?? null;
- inventoryPostingGroups[`${itemGroupId}-${locationId}`] =
+ inventoryPostingGroups[`${itemPostingGroupId}-${locationId}`] =
postingGroupInventory;
}
@@ -286,14 +291,18 @@ serve(async (req: Request) => {
throw new Error("No inventory posting group found");
}
- if (`${itemGroupId}-${supplierTypeId}` in purchasingPostingGroups) {
+ if (
+ `${itemPostingGroupId}-${supplierTypeId}` in purchasingPostingGroups
+ ) {
postingGroupPurchasing =
- purchasingPostingGroups[`${itemGroupId}-${supplierTypeId}`];
+ purchasingPostingGroups[
+ `${itemPostingGroupId}-${supplierTypeId}`
+ ];
} else {
const purchasingPostingGroup = await getPurchasingPostingGroup(
client,
{
- itemGroupId,
+ itemPostingGroupId,
supplierTypeId,
}
);
@@ -303,7 +312,7 @@ serve(async (req: Request) => {
}
postingGroupPurchasing = purchasingPostingGroup.data ?? null;
- purchasingPostingGroups[`${itemGroupId}-${supplierTypeId}`] =
+ purchasingPostingGroups[`${itemPostingGroupId}-${supplierTypeId}`] =
postingGroupPurchasing;
}
@@ -328,7 +337,7 @@ serve(async (req: Request) => {
companyId,
});
- if (itemInventoryType === "Inventory") {
+ if (itemTrackingType === "Inventory") {
// create the part ledger line
itemLedgerInserts.push({
postingDate: today,
@@ -367,7 +376,7 @@ serve(async (req: Request) => {
journalLineReference = nanoid();
- if (itemInventoryType === "Inventory") {
+ if (itemTrackingType === "Inventory") {
// debit the inventory account
journalLineInserts.push({
accountNumber: postingGroupInventory.inventoryAccount,
@@ -645,7 +654,7 @@ serve(async (req: Request) => {
journalLineReference = nanoid();
- if (itemInventoryType === "Inventory") {
+ if (itemTrackingType === "Inventory") {
// debit the inventory account
journalLineInserts.push({
accountNumber: postingGroupInventory.inventoryAccount,
diff --git a/packages/database/supabase/functions/post-receipt/index.ts b/packages/database/supabase/functions/post-receipt/index.ts
index e208a11888..7861a7fcb8 100644
--- a/packages/database/supabase/functions/post-receipt/index.ts
+++ b/packages/database/supabase/functions/post-receipt/index.ts
@@ -38,20 +38,29 @@ serve(async (req: Request) => {
const companyId = receipt.data?.companyId;
- const items = await client
- .from("item")
- .select("id, itemGroupId, itemInventoryType")
- .in(
- "id",
- receiptLines.data.reduce<string[]>((acc, receiptLine) => {
- if (receiptLine.itemId && !acc.includes(receiptLine.itemId)) {
- acc.push(receiptLine.itemId);
- }
- return acc;
- }, [])
- )
- .eq("companyId", companyId);
- if (items.error) throw new Error("Failed to fetch item groups");
+ const itemIds = receiptLines.data.reduce<string[]>((acc, receiptLine) => {
+ if (receiptLine.itemId && !acc.includes(receiptLine.itemId)) {
+ acc.push(receiptLine.itemId);
+ }
+ return acc;
+ }, []);
+ const [items, itemCosts] = await Promise.all([
+ client
+ .from("item")
+ .select("id, itemTrackingType")
+ .in("id", itemIds)
+ .eq("companyId", companyId),
+ client
+ .from("itemCost")
+ .select("itemId, itemPostingGroupId")
+ .in("itemId", itemIds),
+ ]);
+ if (items.error) {
+ throw new Error("Failed to fetch items");
+ }
+ if (itemCosts.error) {
+ throw new Error("Failed to fetch item costs");
+ }
switch (receipt.data?.sourceDocument) {
case "Purchase Order": {
@@ -194,26 +203,27 @@ serve(async (req: Request) => {
| Database["public"]["Tables"]["postingGroupInventory"]["Row"]
| null = null;
- const itemInventoryType =
+ const itemTrackingType =
items.data.find((item) => item.id === receiptLine.itemId)
- ?.itemInventoryType ?? "Inventory";
+ ?.itemTrackingType ?? "Inventory";
+
+ const itemPostingGroupId =
+ itemCosts.data.find((item) => item.itemId === receiptLine.itemId)
+ ?.itemPostingGroupId ?? null;
- const itemGroupId: string | null =
- items.data.find((item) => item.id === receiptLine.itemId)
- ?.itemGroupId ?? null;
const locationId = receiptLine.locationId ?? null;
const supplierTypeId: string | null =
supplier.data.supplierTypeId ?? null;
// inventory posting group
- if (`${itemGroupId}-${locationId}` in inventoryPostingGroups) {
+ if (`${itemPostingGroupId}-${locationId}` in inventoryPostingGroups) {
postingGroupInventory =
- inventoryPostingGroups[`${itemGroupId}-${locationId}`];
+ inventoryPostingGroups[`${itemPostingGroupId}-${locationId}`];
} else {
const inventoryPostingGroup = await getInventoryPostingGroup(
client,
{
- itemGroupId,
+ itemPostingGroupId,
locationId,
}
);
@@ -223,7 +233,7 @@ serve(async (req: Request) => {
}
postingGroupInventory = inventoryPostingGroup.data ?? null;
- inventoryPostingGroups[`${itemGroupId}-${locationId}`] =
+ inventoryPostingGroups[`${itemPostingGroupId}-${locationId}`] =
postingGroupInventory;
}
@@ -241,14 +251,18 @@ serve(async (req: Request) => {
| Database["public"]["Tables"]["postingGroupPurchasing"]["Row"]
| null = null;
- if (`${itemGroupId}-${supplierTypeId}` in purchasingPostingGroups) {
+ if (
+ `${itemPostingGroupId}-${supplierTypeId}` in purchasingPostingGroups
+ ) {
postingGroupPurchasing =
- purchasingPostingGroups[`${itemGroupId}-${supplierTypeId}`];
+ purchasingPostingGroups[
+ `${itemPostingGroupId}-${supplierTypeId}`
+ ];
} else {
const purchasingPostingGroup = await getPurchasingPostingGroup(
client,
{
- itemGroupId,
+ itemPostingGroupId,
supplierTypeId,
}
);
@@ -258,7 +272,7 @@ serve(async (req: Request) => {
}
postingGroupPurchasing = purchasingPostingGroup.data ?? null;
- purchasingPostingGroups[`${itemGroupId}-${supplierTypeId}`] =
+ purchasingPostingGroups[`${itemPostingGroupId}-${supplierTypeId}`] =
postingGroupPurchasing;
}
@@ -436,7 +450,7 @@ serve(async (req: Request) => {
let journalLineReference = nanoid();
- if (itemInventoryType === "Inventory") {
+ if (itemTrackingType === "Inventory") {
// debit the inventory account
journalLineInserts.push({
accountNumber: postingGroupInventory.inventoryAccount,
@@ -581,7 +595,7 @@ serve(async (req: Request) => {
});
}
- if (itemInventoryType === "Inventory") {
+ if (itemTrackingType === "Inventory") {
itemLedgerInserts.push({
postingDate: today,
itemId: receiptLine.itemId,
diff --git a/packages/database/supabase/functions/shared/get-posting-group.ts b/packages/database/supabase/functions/shared/get-posting-group.ts
index c23ec1bd0a..2011fcec5a 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: {
- itemGroupId: string | null;
+ itemPostingGroupId: string | null;
locationId: string | null;
}
) {
let query = client.from("postingGroupInventory").select("*");
- if (args.itemGroupId === null) {
- query = query.is("itemGroupId", null);
+ if (args.itemPostingGroupId === null) {
+ query = query.is("itemPostingGroupId", null);
} else {
- query = query.eq("itemGroupId", args.itemGroupId);
+ query = query.eq("itemPostingGroupId", args.itemPostingGroupId);
}
if (args.locationId === null) {
@@ -28,16 +28,16 @@ export async function getInventoryPostingGroup(
export async function getPurchasingPostingGroup(
client: SupabaseClient<Database>,
args: {
- itemGroupId: string | null;
+ itemPostingGroupId: string | null;
supplierTypeId: string | null;
}
) {
let query = client.from("postingGroupPurchasing").select("*");
- if (args.itemGroupId === null) {
- query = query.is("itemGroupId", null);
+ if (args.itemPostingGroupId === null) {
+ query = query.is("itemPostingGroupId", null);
} else {
- query = query.eq("itemGroupId", args.itemGroupId);
+ query = query.eq("itemPostingGroupId", args.itemPostingGroupId);
}
if (args.supplierTypeId === null) {
diff --git a/packages/database/supabase/migrations/20230123004317_companies.sql b/packages/database/supabase/migrations/20230123004317_companies.sql
index 628aea5104..ac4d418c20 100644
--- a/packages/database/supabase/migrations/20230123004317_companies.sql
+++ b/packages/database/supabase/migrations/20230123004317_companies.sql
@@ -96,7 +96,7 @@ CREATE POLICY "Users can view other users from their same company" ON "user" FOR
);
INSERT INTO "user" ("id", "email", "firstName", "lastName")
-VALUES ('system', '[email protected]', 'System', 'Operation');
+VALUES ('system', '[email protected]', 'System', 'Operation');
CREATE TABLE "userPermission" (
diff --git a/packages/database/supabase/migrations/20230330024716_parts.sql b/packages/database/supabase/migrations/20230330024716_parts.sql
index 52fc7ae8dc..46b9c5e71a 100644
--- a/packages/database/supabase/migrations/20230330024716_parts.sql
+++ b/packages/database/supabase/migrations/20230330024716_parts.sql
@@ -54,7 +54,7 @@ CREATE POLICY "Employees with parts_delete can delete units of measure" ON "unit
);
-CREATE TABLE "itemGroup" (
+CREATE TABLE "itemPostingGroup" (
"id" TEXT NOT NULL DEFAULT xid(),
"name" TEXT NOT NULL,
"description" TEXT,
@@ -66,18 +66,18 @@ CREATE TABLE "itemGroup" (
"updatedAt" TIMESTAMP WITH TIME ZONE,
"customFields" JSONB,
- 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")
+ CONSTRAINT "itemPostingGroup_pkey" PRIMARY KEY ("id"),
+ CONSTRAINT "itemPostingGroup_name_key" UNIQUE ("name", "companyId"),
+ CONSTRAINT "itemPostingGroup_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company"("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "itemPostingGroup_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id"),
+ CONSTRAINT "itemPostingGroup_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id")
);
-CREATE INDEX "itemGroup_companyId_idx" ON "itemGroup" ("companyId");
+CREATE INDEX "itemPostingGroup_companyId_idx" ON "itemPostingGroup" ("companyId");
-ALTER TABLE "itemGroup" ENABLE ROW LEVEL SECURITY;
+ALTER TABLE "itemPostingGroup" ENABLE ROW LEVEL SECURITY;
-CREATE POLICY "Employees with parts_view can view item groups" ON "itemGroup"
+CREATE POLICY "Employees with parts_view can view item groups" ON "itemPostingGroup"
FOR SELECT
USING (
has_role('employee') AND
@@ -85,21 +85,21 @@ CREATE POLICY "Employees with parts_view can view item groups" ON "itemGroup"
);
-CREATE POLICY "Employees with parts_create can insert item groups" ON "itemGroup"
+CREATE POLICY "Employees with parts_create can insert item groups" ON "itemPostingGroup"
FOR INSERT
WITH CHECK (
has_role('employee') AND
has_company_permission('parts_create', "companyId")
);
-CREATE POLICY "Employees with parts_update can update item groups" ON "itemGroup"
+CREATE POLICY "Employees with parts_update can update item groups" ON "itemPostingGroup"
FOR UPDATE
USING (
has_role('employee') AND
has_company_permission('parts_update', "companyId")
);
-CREATE POLICY "Employees with parts_delete can delete item groups" ON "itemGroup"
+CREATE POLICY "Employees with parts_delete can delete item groups" ON "itemPostingGroup"
FOR DELETE
USING (
has_role('employee') AND
@@ -116,19 +116,32 @@ CREATE TYPE "itemType" AS ENUM (
'Fixture'
);
-CREATE TYPE "itemInventoryType" AS ENUM (
+CREATE TYPE "itemTrackingType" AS ENUM (
'Inventory',
'Non-Inventory'
);
+CREATE TYPE "itemReplenishmentSystem" AS ENUM (
+ 'Buy',
+ 'Make',
+ 'Buy and Make'
+);
+
+CREATE TYPE "methodType" AS ENUM (
+ 'Buy',
+ 'Make',
+ 'Pick'
+);
+
CREATE TABLE "item" (
"id" TEXT NOT NULL DEFAULT xid(),
"readableId" TEXT NOT NULL,
"type" "itemType" NOT NULL,
+ "replenishmentSystem" "itemReplenishmentSystem" NOT NULL DEFAULT 'Buy',
+ "defaultMethodType" "methodType" DEFAULT 'Buy',
"name" TEXT NOT NULL,
"description" TEXT,
- "itemGroupId" TEXT,
- "itemInventoryType" "itemInventoryType" NOT NULL,
+ "itemTrackingType" "itemTrackingType" NOT NULL,
"unitOfMeasureCode" TEXT,
"active" BOOLEAN NOT NULL DEFAULT true,
"blocked" BOOLEAN NOT NULL DEFAULT false,
@@ -142,7 +155,6 @@ CREATE TABLE "item" (
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_unitOfMeasureCode_fkey" FOREIGN KEY ("unitOfMeasureCode", "companyId") REFERENCES "unitOfMeasure"("code", "companyId") 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")
);
@@ -152,6 +164,7 @@ ALTER publication supabase_realtime ADD TABLE "item";
CREATE INDEX "item_companyId_idx" ON "item" ("companyId");
CREATE INDEX "item_name_companyId_idx" ON "item" ("name", "companyId");
CREATE INDEX "item_type_companyId_idx" ON "item" ("type", "companyId");
+CREATE INDEX "item_replenishmentSystem_idx" ON "item"("replenishmentSystem", "companyId");
ALTER TABLE "item" ENABLE ROW LEVEL SECURITY;
@@ -186,11 +199,7 @@ CREATE POLICY "Employees with parts_delete can delete items" ON "item"
);
-CREATE TYPE "itemReplenishmentSystem" AS ENUM (
- 'Buy',
- 'Make',
- 'Buy and Make'
-);
+
CREATE TYPE "partManufacturingPolicy" AS ENUM (
'Make to Order',
@@ -216,7 +225,6 @@ CREATE TYPE "itemReorderingPolicy" AS ENUM (
CREATE TABLE "part" (
"id" TEXT NOT NULL,
"itemId" TEXT NOT NULL,
- "replenishmentSystem" "itemReplenishmentSystem" NOT NULL,
"approved" BOOLEAN NOT NULL DEFAULT false,
"approvedBy" TEXT,
"fromDate" DATE,
@@ -240,7 +248,7 @@ CREATE TABLE "part" (
CREATE INDEX "part_itemId_idx" ON "part" ("itemId");
CREATE INDEX "part_companyId_idx" ON "part" ("companyId");
-CREATE INDEX "part_replenishmentSystem_idx" ON "part"("replenishmentSystem", "companyId");
+
ALTER publication supabase_realtime ADD TABLE "part";
ALTER TABLE "part" ENABLE ROW LEVEL SECURITY;
@@ -340,6 +348,7 @@ CREATE TRIGGER delete_item_search_result
CREATE TABLE "itemCost" (
"itemId" TEXT NOT NULL,
+ "itemPostingGroupId" TEXT,
"costingMethod" "itemCostingMethod" NOT NULL,
"standardCost" NUMERIC(15,5) NOT NULL DEFAULT 0,
"unitCost" NUMERIC(15,5) NOT NULL DEFAULT 0,
@@ -353,9 +362,10 @@ CREATE TABLE "itemCost" (
CONSTRAINT "itemCost_itemId_fkey" FOREIGN KEY ("itemId") REFERENCES "item"("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "itemCost_itemPostingGroupId_fkey" FOREIGN KEY ("itemPostingGroupId") REFERENCES "itemPostingGroup"("id") ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT "itemCost_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")
+ CONSTRAINT "itemPostingGroup_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id"),
+ CONSTRAINT "itemPostingGroup_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id")
);
CREATE INDEX "itemCost_itemId_idx" ON "itemCost" ("itemId");
diff --git a/packages/database/supabase/migrations/20230412120726_services.sql b/packages/database/supabase/migrations/20230412120726_services.sql
index 8b033d2e64..9a93e342dc 100644
--- a/packages/database/supabase/migrations/20230412120726_services.sql
+++ b/packages/database/supabase/migrations/20230412120726_services.sql
@@ -147,7 +147,6 @@ CREATE OR REPLACE VIEW "services" WITH(SECURITY_INVOKER=true) AS
i."name",
i."description",
i."blocked",
- i."itemGroupId",
s."serviceType",
i."active",
s."approved",
@@ -156,11 +155,9 @@ CREATE OR REPLACE VIEW "services" WITH(SECURITY_INVOKER=true) AS
s."toDate",
s."customFields",
s."companyId",
- pg.name AS "itemGroup",
array_agg(ss."supplierId") AS "supplierIds"
FROM "service" s
INNER JOIN "item" i ON i."id" = s."itemId"
- LEFT JOIN "itemGroup" pg ON pg.id = i."itemGroupId"
LEFT JOIN "serviceSupplier" ss ON ss."serviceId" = s.id
GROUP BY
s."id",
@@ -168,7 +165,6 @@ CREATE OR REPLACE VIEW "services" WITH(SECURITY_INVOKER=true) AS
i."name",
i."description",
i."blocked",
- i."itemGroupId",
i."active",
s."serviceType",
s."approved",
@@ -176,5 +172,4 @@ CREATE OR REPLACE VIEW "services" WITH(SECURITY_INVOKER=true) AS
s."fromDate",
s."toDate",
s."customFields",
- s."companyId",
- pg.name;
\ No newline at end of file
+ s."companyId";
\ No newline at end of file
diff --git a/packages/database/supabase/migrations/20230704161623_parts-view.sql b/packages/database/supabase/migrations/20230704161623_parts-view.sql
index 3470fae533..d1ece205de 100644
--- a/packages/database/supabase/migrations/20230704161623_parts-view.sql
+++ b/packages/database/supabase/migrations/20230704161623_parts-view.sql
@@ -4,12 +4,9 @@ CREATE OR REPLACE VIEW "parts" AS
p."itemId",
i.name,
i.description,
- i."itemGroupId",
- i."itemInventoryType",
+ i."itemTrackingType",
i."unitOfMeasureCode",
- pg.name AS "itemGroup",
uom.name as "unitOfMeasure",
- p."replenishmentSystem",
i.active,
i.blocked,
p."customFields",
@@ -17,17 +14,13 @@ CREATE OR REPLACE VIEW "parts" AS
array_agg(s."supplierId") AS "supplierIds"
FROM "part" p
INNER JOIN "item" i ON i.id = p."itemId"
- LEFT JOIN "itemGroup" pg ON pg.id = i."itemGroupId"
LEFT JOIN "buyMethod" s ON s."itemId" = p."itemId"
LEFT JOIN "unitOfMeasure" uom ON uom.code = i."unitOfMeasureCode" AND uom."companyId" = i."companyId"
GROUP BY p.id,
i.name,
- i.description,
- i."itemGroupId",
- i."itemInventoryType",
+ i.description,
+ i."itemTrackingType",
i."unitOfMeasureCode",
- pg.name,
- p."replenishmentSystem",
i.active,
i.blocked,
p."customFields",
diff --git a/packages/database/supabase/migrations/20230820020844_posting-groups.sql b/packages/database/supabase/migrations/20230820020844_posting-groups.sql
index a205bd88bf..b871919a34 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(),
- "itemGroupId" TEXT,
+ "itemPostingGroupId" 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_itemGroupId_locationId_key" UNIQUE ("itemGroupId", "locationId"),
- CONSTRAINT "postingGroupInventory_itemGroupId_fkey" FOREIGN KEY ("itemGroupId") REFERENCES "itemGroup" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupInventory_id_itemPostingGroupId_locationId_key" UNIQUE ("itemPostingGroupId", "locationId"),
+ CONSTRAINT "postingGroupInventory_itemPostingGroupId_fkey" FOREIGN KEY ("itemPostingGroupId") REFERENCES "itemPostingGroup" ("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_itemGroupId_locationId_idx" ON "postingGroupInventory" ("itemGroupId", "locationId");
+CREATE INDEX "postingGroupInventory_itemPostingGroupId_locationId_idx" ON "postingGroupInventory" ("itemPostingGroupId", "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,
- "itemGroupId" TEXT,
+ "itemPostingGroupId" 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_itemGroupId_key" UNIQUE ("supplierTypeId", "itemGroupId"),
- CONSTRAINT "postingGroupPurchasing_itemGroupId_fkey" FOREIGN KEY ("itemGroupId") REFERENCES "itemGroup" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupPurchasing_id_supplierTypeId_itemPostingGroupId_key" UNIQUE ("supplierTypeId", "itemPostingGroupId"),
+ CONSTRAINT "postingGroupPurchasing_itemPostingGroupId_fkey" FOREIGN KEY ("itemPostingGroupId") REFERENCES "itemPostingGroup" ("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_itemGroupId_supplierTypeId_idx" ON "postingGroupPurchasing" ("itemGroupId", "supplierTypeId");
+CREATE INDEX "postingGroupPurchasing_itemPostingGroupId_supplierTypeId_idx" ON "postingGroupPurchasing" ("itemPostingGroupId", "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,
- "itemGroupId" TEXT,
+ "itemPostingGroupId" 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_itemGroupId_key" UNIQUE ("customerTypeId", "itemGroupId"),
- CONSTRAINT "postingGroupSales_itemGroupId_fkey" FOREIGN KEY ("itemGroupId") REFERENCES "itemGroup" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupSales_id_customerTypeId_itemPostingGroupId_key" UNIQUE ("customerTypeId", "itemPostingGroupId"),
+ CONSTRAINT "postingGroupSales_itemPostingGroupId_fkey" FOREIGN KEY ("itemPostingGroupId") REFERENCES "itemPostingGroup" ("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_itemGroupId_customerTypeId_idx" ON "postingGroupSales" ("itemGroupId", "customerTypeId");
+CREATE INDEX "postingGroupSales_itemPostingGroupId_customerTypeId_idx" ON "postingGroupSales" ("itemPostingGroupId", "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 "itemGroup"
+ FOR part_group IN SELECT "id" FROM "itemPostingGroup"
LOOP
INSERT INTO "postingGroupInventory" (
- "itemGroupId",
+ "itemPostingGroupId",
"locationId",
"costOfGoodsSoldAccount",
"inventoryAccount",
@@ -329,7 +329,7 @@ BEGIN
-- insert the null item group
INSERT INTO "postingGroupInventory" (
- "itemGroupId",
+ "itemPostingGroupId",
"locationId",
"costOfGoodsSoldAccount",
"inventoryAccount",
@@ -388,7 +388,7 @@ BEGIN
FOR rec IN SELECT "id" FROM "customerType"
LOOP
INSERT INTO "postingGroupSales" (
- "itemGroupId",
+ "itemPostingGroupId",
"customerTypeId",
"receivablesAccount",
"salesAccount",
@@ -414,7 +414,7 @@ BEGIN
-- insert the null customer type
INSERT INTO "postingGroupSales" (
- "itemGroupId",
+ "itemPostingGroupId",
"customerTypeId",
"receivablesAccount",
"salesAccount",
@@ -440,7 +440,7 @@ BEGIN
FOR rec IN SELECT "id" FROM "supplierType"
LOOP
INSERT INTO "postingGroupPurchasing" (
- "itemGroupId",
+ "itemPostingGroupId",
"supplierTypeId",
"payablesAccount",
"purchaseAccount",
@@ -466,7 +466,7 @@ BEGIN
-- insert the null supplier type
INSERT INTO "postingGroupPurchasing" (
- "itemGroupId",
+ "itemPostingGroupId",
"supplierTypeId",
"payablesAccount",
"purchaseAccount",
@@ -492,7 +492,7 @@ BEGIN
FOR rec IN SELECT "id" FROM "location"
LOOP
INSERT INTO "postingGroupInventory" (
- "itemGroupId",
+ "itemPostingGroupId",
"locationId",
"costOfGoodsSoldAccount",
"inventoryAccount",
@@ -534,7 +534,7 @@ BEGIN
-- insert the null location
INSERT INTO "postingGroupInventory" (
- "itemGroupId",
+ "itemPostingGroupId",
"locationId",
"costOfGoodsSoldAccount",
"inventoryAccount",
@@ -579,7 +579,7 @@ $$ LANGUAGE plpgsql SECURITY DEFINER;
CREATE TRIGGER create_part_group
- AFTER INSERT on public."itemGroup"
+ AFTER INSERT on public."itemPostingGroup"
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 "itemGroup"
+ FOR rec IN SELECT "id" FROM "itemPostingGroup"
LOOP
INSERT INTO "postingGroupSales" (
"customerTypeId",
- "itemGroupId",
+ "itemPostingGroupId",
"receivablesAccount",
"salesAccount",
"salesDiscountAccount",
@@ -620,7 +620,7 @@ BEGIN
-- insert the null item group
INSERT INTO "postingGroupSales" (
"customerTypeId",
- "itemGroupId",
+ "itemPostingGroupId",
"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 "itemGroup"
+ FOR rec IN SELECT "id" FROM "itemPostingGroup"
LOOP
INSERT INTO "postingGroupPurchasing" (
"supplierTypeId",
- "itemGroupId",
+ "itemPostingGroupId",
"payablesAccount",
"purchaseAccount",
"purchaseDiscountAccount",
@@ -689,7 +689,7 @@ BEGIN
-- insert the null item group
INSERT INTO "postingGroupPurchasing" (
"supplierTypeId",
- "itemGroupId",
+ "itemPostingGroupId",
"payablesAccount",
"purchaseAccount",
"purchaseDiscountAccount",
diff --git a/packages/database/supabase/migrations/20240324175747_assignee.sql b/packages/database/supabase/migrations/20240324175747_assignee.sql
index b74669d4c1..3a38726670 100644
--- a/packages/database/supabase/migrations/20240324175747_assignee.sql
+++ b/packages/database/supabase/migrations/20240324175747_assignee.sql
@@ -13,17 +13,14 @@ CREATE OR REPLACE VIEW "parts" WITH(SECURITY_INVOKER=true) AS
SELECT
i.name,
i.description,
- i."itemGroupId",
- i."itemInventoryType",
+ i."itemTrackingType",
i.active,
i.blocked,
p.*,
- pg.name AS "itemGroup",
ps."supplierIds",
uom.name as "unitOfMeasure"
FROM "part" p
INNER JOIN "item" i ON i.id = p."itemId"
- LEFT JOIN "itemGroup" pg ON pg.id = i."itemGroupId"
LEFT JOIN (
SELECT
"itemId",
@@ -151,14 +148,11 @@ CREATE OR REPLACE VIEW "services" WITH(SECURITY_INVOKER=true) AS
s.*,
i.name,
i.description,
- i."itemGroupId",
i.active,
i.blocked,
- pg.name AS "itemGroup",
ss."supplierIds"
FROM "service" s
INNER JOIN "item" i ON i.id = s."itemId"
- 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 6a65c2dbfb..e0df7b25d9 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'),
('itemCost', 'Item Cost', 'Parts'),
-('itemGroup', 'Item Group', 'Parts'),
+('itemPostingGroup', 'Item Posting Group', 'Parts'),
('pickMethod', 'Item Inventory', 'Parts'),
('itemPlanning', 'Item Planning', 'Parts'),
('itemReplenishment', 'Item Replenishment', 'Parts'),
diff --git a/packages/database/supabase/migrations/20240601210618_assignee-to-item.sql b/packages/database/supabase/migrations/20240601210618_assignee-to-item.sql
index 37507260c8..e6f969bbde 100644
--- a/packages/database/supabase/migrations/20240601210618_assignee-to-item.sql
+++ b/packages/database/supabase/migrations/20240601210618_assignee-to-item.sql
@@ -13,19 +13,16 @@ CREATE OR REPLACE VIEW "parts" WITH(SECURITY_INVOKER=true) AS
SELECT
i.name,
i.description,
- i."itemGroupId",
- i."itemInventoryType",
+ i."itemTrackingType",
i."unitOfMeasureCode",
i.active,
i.blocked,
i.assignee,
p.*,
- pg.name AS "itemGroup",
ps."supplierIds",
uom.name as "unitOfMeasure"
FROM "part" p
INNER JOIN "item" i ON i.id = p."itemId"
- LEFT JOIN "itemGroup" pg ON pg.id = i."itemGroupId"
LEFT JOIN (
SELECT
"itemId",
@@ -41,15 +38,12 @@ CREATE OR REPLACE VIEW "services" WITH(SECURITY_INVOKER=true) AS
s.*,
i.name,
i.description,
- i."itemGroupId",
i.active,
i.blocked,
i.assignee,
- pg.name AS "itemGroup",
ss."supplierIds"
FROM "service" s
INNER JOIN "item" i ON i.id = s."itemId"
- LEFT JOIN "itemGroup" pg ON pg.id = i."itemGroupId"
LEFT JOIN (
SELECT
"itemId",
diff --git a/packages/database/supabase/migrations/20240608103855_tools.sql b/packages/database/supabase/migrations/20240608103855_tools.sql
index 2611d153cf..65c7b85d51 100644
--- a/packages/database/supabase/migrations/20240608103855_tools.sql
+++ b/packages/database/supabase/migrations/20240608103855_tools.sql
@@ -64,19 +64,16 @@ CREATE OR REPLACE VIEW "tools" WITH(SECURITY_INVOKER=true) AS
SELECT
i.name,
i.description,
- i."itemGroupId",
- i."itemInventoryType",
+ i."itemTrackingType",
i.active,
i.blocked,
i.assignee,
i."unitOfMeasureCode",
t.*,
- ig.name AS "itemGroup",
s."supplierIds",
uom.name as "unitOfMeasure"
FROM "tool" t
INNER JOIN "item" i ON i.id = t."itemId"
- LEFT JOIN "itemGroup" ig ON ig.id = i."itemGroupId"
LEFT JOIN (
SELECT
"itemId",
diff --git a/packages/database/supabase/migrations/20240608105638_consumables.sql b/packages/database/supabase/migrations/20240608105638_consumables.sql
index e15764245c..be856695aa 100644
--- a/packages/database/supabase/migrations/20240608105638_consumables.sql
+++ b/packages/database/supabase/migrations/20240608105638_consumables.sql
@@ -60,19 +60,16 @@ CREATE OR REPLACE VIEW "consumables" WITH(SECURITY_INVOKER=true) AS
SELECT
i.name,
i.description,
- i."itemGroupId",
- i."itemInventoryType",
+ i."itemTrackingType",
i."unitOfMeasureCode",
i.active,
i.blocked,
i.assignee,
c.*,
- ig.name AS "itemGroup",
s."supplierIds",
uom.name as "unitOfMeasure"
FROM "consumable" c
INNER JOIN "item" i ON i.id = c."itemId"
- LEFT JOIN "itemGroup" ig ON ig.id = i."itemGroupId"
LEFT JOIN (
SELECT
"itemId",
diff --git a/packages/database/supabase/migrations/20240608111319_fixtures.sql b/packages/database/supabase/migrations/20240608111319_fixtures.sql
index ee70b68f1b..60736b15ef 100644
--- a/packages/database/supabase/migrations/20240608111319_fixtures.sql
+++ b/packages/database/supabase/migrations/20240608111319_fixtures.sql
@@ -62,18 +62,15 @@ CREATE OR REPLACE VIEW "fixtures" WITH(SECURITY_INVOKER=true) AS
SELECT
i.name,
i.description,
- i."itemGroupId",
- i."itemInventoryType",
+ i."itemTrackingType",
i.active,
i.blocked,
i.assignee,
f.*,
- ig.name AS "itemGroup",
s."supplierIds",
c.name as "customer"
FROM "fixture" f
INNER JOIN "item" i ON i.id = f."itemId"
- LEFT JOIN "itemGroup" ig ON ig.id = i."itemGroupId"
LEFT JOIN (
SELECT
"itemId",
diff --git a/packages/database/supabase/migrations/20240608114413_materials.sql b/packages/database/supabase/migrations/20240608114413_materials.sql
index 7e8ddeeff5..a12969b855 100644
--- a/packages/database/supabase/migrations/20240608114413_materials.sql
+++ b/packages/database/supabase/migrations/20240608114413_materials.sql
@@ -195,8 +195,7 @@ CREATE OR REPLACE VIEW "materials" WITH(SECURITY_INVOKER=true) AS
SELECT
i.name,
i.description,
- i."itemGroupId",
- i."itemInventoryType",
+ i."itemTrackingType",
i."unitOfMeasureCode",
i.active,
i.blocked,
@@ -204,12 +203,10 @@ CREATE OR REPLACE VIEW "materials" WITH(SECURITY_INVOKER=true) AS
m.*,
mf."name" AS "materialForm",
ms."name" AS "materialSubstance",
- ig.name AS "itemGroup",
s."supplierIds",
uom.name as "unitOfMeasure"
FROM "material" m
INNER JOIN "item" i ON i.id = m."itemId"
- LEFT JOIN "itemGroup" ig ON ig.id = i."itemGroupId"
LEFT JOIN (
SELECT
"itemId",
diff --git a/packages/database/supabase/migrations/20240619095417_methods.sql b/packages/database/supabase/migrations/20240619095417_methods.sql
index e9c59de4b8..64db607b8b 100644
--- a/packages/database/supabase/migrations/20240619095417_methods.sql
+++ b/packages/database/supabase/migrations/20240619095417_methods.sql
@@ -1,8 +1,6 @@
ALTER TABLE "itemReplenishment" DROP COLUMN "manufacturingPolicy";
DROP TYPE "partManufacturingPolicy";
-ALTER TABLE "item" ADD COLUMN "pullFromInventory" BOOLEAN NOT NULL DEFAULT false;
-
CREATE TABLE "makeMethod" (
"id" TEXT NOT NULL DEFAULT xid(),
"itemId" TEXT NOT NULL,
@@ -85,11 +83,7 @@ CREATE TABLE "methodOperation" (
CONSTRAINT "methodOperation_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user" ("id") ON UPDATE CASCADE ON DELETE RESTRICT
);
-CREATE TYPE "methodType" AS ENUM (
- 'Buy',
- 'Make',
- 'Pick'
-);
+
CREATE TABLE "methodMaterial" (
"id" TEXT NOT NULL DEFAULT xid(),
diff --git a/packages/database/supabase/migrations/20240620095152_remove-blocked.sql b/packages/database/supabase/migrations/20240620095152_remove-blocked.sql
index 2fbdd64695..403b79f841 100644
--- a/packages/database/supabase/migrations/20240620095152_remove-blocked.sql
+++ b/packages/database/supabase/migrations/20240620095152_remove-blocked.sql
@@ -10,19 +10,17 @@ CREATE OR REPLACE VIEW "parts" WITH(SECURITY_INVOKER=true) AS
SELECT
i.name,
i.description,
- i."itemGroupId",
- i."itemInventoryType",
+ i."itemTrackingType",
i."unitOfMeasureCode",
i.active,
- i."pullFromInventory",
+ i."replenishmentSystem",
+ i."defaultMethodType",
i.assignee,
p.*,
- pg.name AS "itemGroup",
ps."supplierIds",
uom.name as "unitOfMeasure"
FROM "part" p
INNER JOIN "item" i ON i.id = p."itemId"
- LEFT JOIN "itemGroup" pg ON pg.id = i."itemGroupId"
LEFT JOIN (
SELECT
"itemId",
@@ -38,15 +36,13 @@ CREATE OR REPLACE VIEW "services" WITH(SECURITY_INVOKER=true) AS
s.*,
i.name,
i.description,
- i."itemGroupId",
i.active,
- i."pullFromInventory",
+ i."replenishmentSystem",
+ i."defaultMethodType",
i.assignee,
- pg.name AS "itemGroup",
ss."supplierIds"
FROM "service" s
INNER JOIN "item" i ON i.id = s."itemId"
- LEFT JOIN "itemGroup" pg ON pg.id = i."itemGroupId"
LEFT JOIN (
SELECT
"itemId",
@@ -59,21 +55,19 @@ CREATE OR REPLACE VIEW "materials" WITH(SECURITY_INVOKER=true) AS
SELECT
i.name,
i.description,
- i."itemGroupId",
- i."itemInventoryType",
+ i."itemTrackingType",
i."unitOfMeasureCode",
i.active,
- i."pullFromInventory",
+ i."replenishmentSystem",
+ i."defaultMethodType",
i.assignee,
m.*,
mf."name" AS "materialForm",
ms."name" AS "materialSubstance",
- ig.name AS "itemGroup",
s."supplierIds",
uom.name as "unitOfMeasure"
FROM "material" m
INNER JOIN "item" i ON i.id = m."itemId"
- LEFT JOIN "itemGroup" ig ON ig.id = i."itemGroupId"
LEFT JOIN (
SELECT
"itemId",
@@ -89,19 +83,17 @@ CREATE OR REPLACE VIEW "tools" WITH(SECURITY_INVOKER=true) AS
SELECT
i.name,
i.description,
- i."itemGroupId",
- i."itemInventoryType",
+ i."itemTrackingType",
i.active,
- i."pullFromInventory",
+ i."replenishmentSystem",
+ i."defaultMethodType",
i.assignee,
i."unitOfMeasureCode",
t.*,
- ig.name AS "itemGroup",
s."supplierIds",
uom.name as "unitOfMeasure"
FROM "tool" t
INNER JOIN "item" i ON i.id = t."itemId"
- LEFT JOIN "itemGroup" ig ON ig.id = i."itemGroupId"
LEFT JOIN (
SELECT
"itemId",
@@ -115,19 +107,17 @@ CREATE OR REPLACE VIEW "consumables" WITH(SECURITY_INVOKER=true) AS
SELECT
i.name,
i.description,
- i."itemGroupId",
- i."itemInventoryType",
+ i."itemTrackingType",
i."unitOfMeasureCode",
i.active,
- i."pullFromInventory",
+ i."replenishmentSystem",
+ i."defaultMethodType",
i.assignee,
c.*,
- ig.name AS "itemGroup",
s."supplierIds",
uom.name as "unitOfMeasure"
FROM "consumable" c
INNER JOIN "item" i ON i.id = c."itemId"
- LEFT JOIN "itemGroup" ig ON ig.id = i."itemGroupId"
LEFT JOIN (
SELECT
"itemId",
@@ -141,18 +131,16 @@ CREATE OR REPLACE VIEW "fixtures" WITH(SECURITY_INVOKER=true) AS
SELECT
i.name,
i.description,
- i."itemGroupId",
- i."itemInventoryType",
+ i."itemTrackingType",
i.active,
- i."pullFromInventory",
+ i."replenishmentSystem",
+ i."defaultMethodType",
i.assignee,
f.*,
- ig.name AS "itemGroup",
s."supplierIds",
c.name as "customer"
FROM "fixture" f
INNER JOIN "item" i ON i.id = f."itemId"
- LEFT JOIN "itemGroup" ig ON ig.id = i."itemGroupId"
LEFT JOIN (
SELECT
"itemId",