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.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
feat: refactor part layout
Brad Barbin0abe798bcba0
diff --git a/apps/carbon/app/components/Assignee.tsx b/apps/carbon/app/components/Assignee.tsxnew file mode 100644index 0000000000..49489d5322--- /dev/null+++ b/apps/carbon/app/components/Assignee.tsx@@ -0,0 +1,148 @@+import {+ Command,+ CommandEmpty,+ CommandGroup,+ CommandInput,+ CommandItem,+ Popover,+ PopoverContent,+ PopoverTrigger,+ cn,+} from "@carbon/react";+import { useFetcher, useFetchers } from "@remix-run/react";+import type { ComponentPropsWithoutRef } from "react";+import { forwardRef, useMemo, useState } from "react";+import { RxCheck } from "react-icons/rx";+import { useUser } from "~/hooks";+import { usePeople } from "~/stores";+import { path } from "~/utils/path";+import EmployeeAvatar from "./EmployeeAvatar";++export type ComboboxProps = Omit<+ ComponentPropsWithoutRef<"button">,+ "onChange"+> & {+ id: string;+ table: string;+ size?: "sm" | "md" | "lg";+ value?: string;+ isReadOnly?: boolean;+ placeholder?: string;+ onChange?: (selected: string) => void;+};++const Assign = forwardRef<HTMLButtonElement, ComboboxProps>(+ (+ { id, table, size, value, isReadOnly, placeholder, onChange, ...props },+ ref+ ) => {+ const [open, setOpen] = useState(false);+ const [people] = usePeople();+ const fetcher = useFetcher();+ const user = useUser();++ const handleChange = (value: string) => {+ const formData = new FormData();+ formData.append("id", id);+ formData.append("assignee", value);+ formData.append("table", table);++ fetcher.submit(formData, {+ method: "post",+ action: path.to.api.assign,+ });+ };++ const options = useMemo(() => {+ const base =+ people+ .filter((person) => person.id !== user.id)+ .map((person) => ({+ value: person.id,+ label: person.name,+ })) ?? [];++ return [+ { value: "", label: "Unassigned" },+ { value: user.id, label: `${user.firstName} ${user.lastName}` },+ ...base,+ ];+ }, [people, user]);++ return (+ <Popover open={open} onOpenChange={setOpen}>+ <PopoverTrigger asChild>+ <button+ className="rounded-md px-2.5 py-0.5 text-sm hover:bg-muted/50 transition-colors cursor-pointer border border-border"+ role="combobox"+ aria-expanded={open}+ ref={ref}+ onClick={() => setOpen(true)}+ {...props}+ >+ {value ? (+ <EmployeeAvatar size={size ?? "xs"} employeeId={value ?? null} />+ ) : (+ <span className="text-sm">Unassigned</span>+ )}+ </button>+ </PopoverTrigger>+ <PopoverContent className="min-w-[200px] w-[--radix-popover-trigger-width] p-0">+ <Command>+ <CommandInput placeholder="Search..." className="h-9" />+ <CommandEmpty>No option found.</CommandEmpty>+ <CommandGroup>+ {options.map((option) => (+ <CommandItem+ value={+ typeof option.label === "string" ? option.label : undefined+ }+ key={option.value}+ onSelect={() => {+ handleChange(option.value);+ onChange?.(option.value);+ setOpen(false);+ }}+ >+ {option.label}++ <RxCheck+ className={cn(+ "ml-auto h-4 w-4",+ option.value === value ? "opacity-100" : "opacity-0"+ )}+ />+ </CommandItem>+ ))}+ </CommandGroup>+ </Command>+ </PopoverContent>+ </Popover>+ );+ }+);+Assign.displayName = "Assign";++export default Assign;++export function useOptimisticAssignment({+ id,+ table,+}: {+ id: string;+ table: string;+}) {+ const fetchers = useFetchers();+ const assignFetcher = fetchers.find(+ (f) => f.formAction === path.to.api.assign+ );++ if (assignFetcher && assignFetcher.formData) {+ if (+ assignFetcher.formData.get("id") === id &&+ assignFetcher.formData.get("table") === table+ ) {+ return assignFetcher.formData.get("assignee") as string;+ }+ }+}diff --git a/apps/carbon/app/components/Editable/EditablePurchaseInvoiceLineNumber.tsx b/apps/carbon/app/components/Editable/EditablePurchaseInvoiceLineNumber.tsxindex 2efacdf8f4..4cb7486bbe 100644--- a/apps/carbon/app/components/Editable/EditablePurchaseInvoiceLineNumber.tsx+++ b/apps/carbon/app/components/Editable/EditablePurchaseInvoiceLineNumber.tsx@@ -87,7 +87,7 @@ const EditablePurchaseInvoiceLineNumber =case "Tool":case "Fixture":case "Consumable":- const [item, itemSupplier, inventory] = await Promise.all([+ const [item, buyMethod, inventory] = await Promise.all([client.from("item").select(@@ -97,14 +97,14 @@ const EditablePurchaseInvoiceLineNumber =.eq("companyId", row.companyId!).single(),client- .from("itemSupplier")+ .from("buyMethod").select("*").eq("itemId", itemId).eq("companyId", row.companyId!).eq("supplierId", supplierId).maybeSingle(),client- .from("itemInventory")+ .from("pickMethod").select("defaultShelfId").eq("itemId", itemId).eq("companyId", row.companyId!)@@ -115,7 +115,7 @@ const EditablePurchaseInvoiceLineNumber =const itemCost = item?.data?.itemCost?.[0];const itemReplenishment = item?.data?.itemReplenishment?.[0];- if (item.error || itemSupplier.error || inventory.error) {+ if (item.error || buyMethod.error || inventory.error) {onError();return;}@@ -125,8 +125,8 @@ const EditablePurchaseInvoiceLineNumber =itemReadableId: item.data?.readableId,locationId: options.defaultLocationId,description: item.data?.name ?? "",- quantity: itemSupplier?.data?.minimumOrderQuantity ?? 1,- unitPrice: itemSupplier?.data?.unitPrice ?? itemCost?.unitCost ?? 0,+ quantity: buyMethod?.data?.minimumOrderQuantity ?? 1,+ unitPrice: buyMethod?.data?.unitPrice ?? itemCost?.unitCost ?? 0,purchaseUnitOfMeasureCode:itemReplenishment?.purchasingUnitOfMeasureCode ??item.data?.unitOfMeasureCode ??@@ -144,9 +144,9 @@ const EditablePurchaseInvoiceLineNumber =itemReadableId: item.data?.readableId,locationId: options.defaultLocationId,description: item.data?.name ?? "",- quantity: itemSupplier?.data?.minimumOrderQuantity ?? 1,+ quantity: buyMethod?.data?.minimumOrderQuantity ?? 1,unitPrice:- itemSupplier?.data?.unitPrice ?? itemCost?.unitCost ?? 0,+ buyMethod?.data?.unitPrice ?? itemCost?.unitCost ?? 0,purchaseUnitOfMeasureCode:itemReplenishment?.purchasingUnitOfMeasureCode ??item.data?.unitOfMeasureCode ??diff --git a/apps/carbon/app/components/Editable/EditablePurchaseOrderLineNumber.tsx b/apps/carbon/app/components/Editable/EditablePurchaseOrderLineNumber.tsxindex 820cfd4ff0..06974f87d6 100644--- a/apps/carbon/app/components/Editable/EditablePurchaseOrderLineNumber.tsx+++ b/apps/carbon/app/components/Editable/EditablePurchaseOrderLineNumber.tsx@@ -92,7 +92,7 @@ const EditablePurchaseOrderLineNumber =case "Tool":case "Fixture":case "Consumable":- const [item, itemSupplier, inventory] = await Promise.all([+ const [item, buyMethod, inventory] = await Promise.all([client.from("item").select(@@ -103,14 +103,14 @@ const EditablePurchaseOrderLineNumber =.single(),client- .from("itemSupplier")+ .from("buyMethod").select("*").eq("itemId", itemId).eq("companyId", row.companyId!).eq("supplierId", supplierId).maybeSingle(),client- .from("itemInventory")+ .from("pickMethod").select("defaultShelfId").eq("itemId", itemId).eq("companyId", row.companyId!)@@ -121,7 +121,7 @@ const EditablePurchaseOrderLineNumber =const itemCost = item?.data?.itemCost?.[0];const itemReplenishment = item?.data?.itemReplenishment?.[0];- if (item.error || itemSupplier.error || inventory.error) {+ if (item.error || buyMethod.error || inventory.error) {onError();return;}@@ -131,8 +131,8 @@ const EditablePurchaseOrderLineNumber =itemReadableId: item.data?.readableId,locationId: options.defaultLocationId,description: item.data?.name ?? "",- purchaseQuantity: itemSupplier?.data?.minimumOrderQuantity ?? 1,- unitPrice: itemSupplier?.data?.unitPrice ?? itemCost?.unitCost ?? 0,+ purchaseQuantity: buyMethod?.data?.minimumOrderQuantity ?? 1,+ unitPrice: buyMethod?.data?.unitPrice ?? itemCost?.unitCost ?? 0,purchaseUnitOfMeasureCode:itemReplenishment?.purchasingUnitOfMeasureCode ??item.data?.unitOfMeasureCode ??@@ -150,9 +150,9 @@ const EditablePurchaseOrderLineNumber =itemReadableId: item.data?.readableId,locationId: options.defaultLocationId,description: item.data?.name ?? "",- purchaseQuantity: itemSupplier?.data?.minimumOrderQuantity ?? 1,+ purchaseQuantity: buyMethod?.data?.minimumOrderQuantity ?? 1,unitPrice:- itemSupplier?.data?.unitPrice ?? itemCost?.unitCost ?? 0,+ buyMethod?.data?.unitPrice ?? itemCost?.unitCost ?? 0,purchaseUnitOfMeasureCode:itemReplenishment?.purchasingUnitOfMeasureCode ??item.data?.unitOfMeasureCode ??diff --git a/apps/carbon/app/components/Editable/EditableSalesOrderLineNumber.tsx b/apps/carbon/app/components/Editable/EditableSalesOrderLineNumber.tsxindex ef45081f9d..6dcc863473 100644--- a/apps/carbon/app/components/Editable/EditableSalesOrderLineNumber.tsx+++ b/apps/carbon/app/components/Editable/EditableSalesOrderLineNumber.tsx@@ -60,7 +60,7 @@ const EditableSalesOrderLineNumber =.eq("companyId", row.companyId!).single(),client- .from("itemInventory")+ .from("pickMethod").select("defaultShelfId").eq("itemId", itemId).eq("companyId", row.companyId!)diff --git a/apps/carbon/app/components/Form/Supplier.tsx b/apps/carbon/app/components/Form/Supplier.tsxindex c0a95a568c..6df478104d 100644--- a/apps/carbon/app/components/Form/Supplier.tsx+++ b/apps/carbon/app/components/Form/Supplier.tsx@@ -5,22 +5,27 @@ import { useSuppliers } from "~/stores";import type { ComboboxProps } from "./Combobox";import CreatableCombobox from "./CreatableCombobox";-type SupplierSelectProps = Omit<ComboboxProps, "options">;+type SupplierSelectProps = Omit<ComboboxProps, "options"> & {+ allowedSuppliers?: string[];+};-const Supplier = (props: SupplierSelectProps) => {+const Supplier = ({ allowedSuppliers, ...props }: SupplierSelectProps) => {const [suppliers] = useSuppliers();const newSuppliersModal = useDisclosure();const [created, setCreated] = useState<string>("");const triggerRef = useRef<HTMLButtonElement>(null);- const options = useMemo(- () =>+ const options = useMemo(() => {+ const result =suppliers.map((c) => ({value: c.id,label: c.name,- })) ?? [],- [suppliers]- );+ })) ?? [];+ if (allowedSuppliers) {+ return result.filter((c) => allowedSuppliers.includes(c.value));+ }+ return result;+ }, [suppliers, allowedSuppliers]);return (<>diff --git a/apps/carbon/app/components/Layout/Navigation/DetailsTopbar.tsx b/apps/carbon/app/components/Layout/Navigation/DetailsTopbar.tsxnew file mode 100644index 0000000000..9f4f61221d--- /dev/null+++ b/apps/carbon/app/components/Layout/Navigation/DetailsTopbar.tsx@@ -0,0 +1,73 @@+import {+ Count,+ HStack,+ Tooltip,+ TooltipContent,+ TooltipTrigger,+ cn,+ useKeyboardShortcuts,+} from "@carbon/react";+import { prettifyKeyboardShortcut } from "@carbon/utils";+import { Link, useNavigate } from "@remix-run/react";+import type { IconType } from "react-icons";+import { useOptimisticLocation } from "~/hooks";++type DetailTopbarProps = {+ links: {+ name: string;+ to: string;+ icon?: IconType;+ count?: number;+ shortcut?: string;+ }[];+};++const DetailTopbar = ({ links }: DetailTopbarProps) => {+ const navigate = useNavigate();+ const location = useOptimisticLocation();++ useKeyboardShortcuts(+ links.reduce<Record<string, () => void>>((acc, link) => {+ if (link.shortcut) {+ acc[link.shortcut] = () => navigate(link.to);+ }+ return acc;+ }, {})+ );++ return (+ <div className="inline-flex h-8 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground">+ {links.map((route) => {+ const isActive = location.pathname.includes(route.to);++ return (+ <Tooltip key={route.name}>+ <TooltipTrigger className="w-full">+ <Link+ to={route.to}+ prefetch="intent"+ className={cn(+ "inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-xs font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",+ isActive && "bg-background text-foreground shadow"+ )}+ >+ {route.icon && <route.icon className="mr-2" />}+ <span>{route.name}</span>+ {route.count !== undefined && (+ <Count count={route.count} className="ml-auto" />+ )}+ </Link>+ </TooltipTrigger>+ {route.shortcut && (+ <TooltipContent side="bottom">+ <HStack>{prettifyKeyboardShortcut(route.shortcut)}</HStack>+ </TooltipContent>+ )}+ </Tooltip>+ );+ })}+ </div>+ );+};++export default DetailTopbar;diff --git a/apps/carbon/app/components/Layout/Navigation/index.ts b/apps/carbon/app/components/Layout/Navigation/index.tsindex b3aaf091f9..f2f011b114 100644--- a/apps/carbon/app/components/Layout/Navigation/index.ts+++ b/apps/carbon/app/components/Layout/Navigation/index.ts@@ -1,6 +1,7 @@import { CollapsibleSidebar } from "./CollapsibleSidebar";import ContentSidebar from "./ContentSidebar";import DetailSidebar from "./DetailSidebar";+import DetailsTopbar from "./DetailsTopbar";import GroupedContentSidebar from "./GroupedContentSidebar";import IconSidebar from "./IconSidebar";@@ -8,6 +9,7 @@ export {CollapsibleSidebar,ContentSidebar,DetailSidebar,+ DetailsTopbar,GroupedContentSidebar,IconSidebar,};diff --git a/apps/carbon/app/components/Layout/index.ts b/apps/carbon/app/components/Layout/index.tsindex 0a97729bf7..67db49d127 100644--- a/apps/carbon/app/components/Layout/index.ts+++ b/apps/carbon/app/components/Layout/index.ts@@ -3,6 +3,7 @@ import {CollapsibleSidebar,ContentSidebar,DetailSidebar,+ DetailsTopbar,GroupedContentSidebar,IconSidebar,} from "./Navigation";@@ -16,6 +17,7 @@ export {CollapsibleSidebar,ContentSidebar,DetailSidebar,+ DetailsTopbar,GroupedContentSidebar,IconSidebar,PageTitle,diff --git a/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLineForm.tsx b/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLineForm.tsxindex 2df5fd93b0..39cd0d1cbd 100644--- a/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLineForm.tsx+++ b/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLineForm.tsx@@ -157,7 +157,7 @@ const PurchaseInvoiceLineForm = ({case "Part":case "Tool":case "Fixture":- const [item, itemSupplier, inventory] = await Promise.all([+ const [item, buyMethod, inventory] = await Promise.all([supabase.from("item").select(@@ -167,14 +167,14 @@ const PurchaseInvoiceLineForm = ({.eq("companyId", company.id).single(),supabase- .from("itemSupplier")+ .from("buyMethod").select("*").eq("itemId", itemId).eq("companyId", company.id).eq("supplierId", routeData?.purchaseInvoice.supplierId!).maybeSingle(),supabase- .from("itemInventory")+ .from("pickMethod").select("defaultShelfId").eq("itemId", itemId).eq("companyId", company.id)@@ -189,8 +189,8 @@ const PurchaseInvoiceLineForm = ({itemId: itemId,itemReadableId: item.data?.readableId ?? "",description: item.data?.name ?? "",- quantity: itemSupplier?.data?.minimumOrderQuantity ?? 1,- unitPrice: itemSupplier?.data?.unitPrice ?? itemCost?.unitCost ?? 0,+ quantity: buyMethod?.data?.minimumOrderQuantity ?? 1,+ unitPrice: buyMethod?.data?.unitPrice ?? itemCost?.unitCost ?? 0,purchaseUom:itemReplenishment?.purchasingUnitOfMeasureCode ??item.data?.unitOfMeasureCode ??@@ -239,7 +239,7 @@ const PurchaseInvoiceLineForm = ({setLocationId(newLocation.value);if (!itemData.itemId) return;const shelf = await supabase- .from("itemInventory")+ .from("pickMethod").select("defaultShelfId").eq("itemId", itemData.itemId).eq("companyId", company.id)diff --git a/apps/carbon/app/modules/items/items.models.ts b/apps/carbon/app/modules/items/items.models.tsindex 64bd92feb4..158611991a 100644--- a/apps/carbon/app/modules/items/items.models.ts+++ b/apps/carbon/app/modules/items/items.models.ts@@ -122,7 +122,7 @@ export const itemGroupValidator = z.object({description: z.string().optional(),});-export const itemInventoryValidator = z.object({+export const pickMethodValidator = z.object({itemId: z.string().min(1, { message: "Item ID is required" }),locationId: z.string().min(20, { message: "Location is required" }),defaultShelfId: zfd.text(z.string().optional()),@@ -161,16 +161,16 @@ export const itemPlanningValidator = z.object({}),}),critical: zfd.checkbox(),- safetyStockQuantity: zfd.numeric(z.number().min(0)),- safetyStockLeadTime: zfd.numeric(z.number().min(0)),- demandAccumulationPeriod: zfd.numeric(z.number().min(0)),- demandReschedulingPeriod: zfd.numeric(z.number().min(0)),- demandAccumulationIncludesInventory: zfd.checkbox(),- reorderPoint: zfd.numeric(z.number().min(0)),- reorderQuantity: zfd.numeric(z.number().min(0)),- reorderMaximumInventory: zfd.numeric(z.number().min(0)),- minimumOrderQuantity: zfd.numeric(z.number().min(0)),- maximumOrderQuantity: zfd.numeric(z.number().min(0)),+ safetyStockQuantity: zfd.numeric(z.number().min(0).optional()),+ safetyStockLeadTime: zfd.numeric(z.number().min(0).optional()),+ demandAccumulationPeriod: zfd.numeric(z.number().min(0).optional()),+ demandReschedulingPeriod: zfd.numeric(z.number().min(0).optional()),+ demandAccumulationIncludesInventory: zfd.checkbox().optional(),+ reorderPoint: zfd.numeric(z.number().min(0).optional()).optional(),+ reorderQuantity: zfd.numeric(z.number().min(0)).optional(),+ reorderMaximumInventory: zfd.numeric(z.number().min(0)).optional(),+ minimumOrderQuantity: zfd.numeric(z.number().min(0)).optional(),+ maximumOrderQuantity: zfd.numeric(z.number().min(0)).optional(),orderMultiple: zfd.numeric(z.number().min(1)),});@@ -183,7 +183,7 @@ export const itemPurchasingValidator = z.object({purchasingBlocked: zfd.checkbox(),});-export const itemSupplierValidator = z.object({+export const buyMethodValidator = z.object({id: zfd.text(z.string().optional()),itemId: z.string().min(1, { message: "Item ID is required" }),supplierId: z.string().min(36, { message: "Supplier ID is required" }),diff --git a/apps/carbon/app/modules/items/items.service.ts b/apps/carbon/app/modules/items/items.service.tsindex a2fb8c791e..16bdcf8ba0 100644--- a/apps/carbon/app/modules/items/items.service.ts+++ b/apps/carbon/app/modules/items/items.service.ts@@ -6,14 +6,13 @@ import type { GenericQueryFilters } from "~/utils/query";import { setGenericQueryFilters } from "~/utils/query";import { sanitize } from "~/utils/supabase";import type {+ buyMethodValidator,consumableValidator,fixtureValidator,itemCostValidator,itemGroupValidator,- itemInventoryValidator,itemPlanningValidator,itemPurchasingValidator,- itemSupplierValidator,itemUnitSalePriceValidator,itemValidator,materialFormValidator,@@ -21,6 +20,7 @@ import type {materialValidator,partManufacturingValidator,partValidator,+ pickMethodValidator,serviceValidator,toolValidator,unitOfMeasureValidator,@@ -54,6 +54,27 @@ export async function deleteUnitOfMeasure(return client.from("unitOfMeasure").delete().eq("id", id);}+export async function getBuyMethods(+ client: SupabaseClient<Database>,+ id: string,+ companyId: string+) {+ return client+ .from("buyMethod")+ .select(+ `+ id, supplier(id, name),+ supplierPartId, supplierUnitOfMeasureCode,+ minimumOrderQuantity, conversionFactor,+ unitPrice,+ customFields+ `+ )+ .eq("active", true)+ .eq("itemId", id)+ .eq("companyId", companyId);+}+export async function getConsumable(client: SupabaseClient<Database>,itemId: string,@@ -228,21 +249,6 @@ export async function getItemGroupsList(.order("name");}-export async function getItemInventory(- client: SupabaseClient<Database>,- itemId: string,- companyId: string,- locationId: string-) {- return client- .from("itemInventory")- .select("*")- .eq("itemId", itemId)- .eq("companyId", companyId)- .eq("locationId", locationId)- .maybeSingle();-}-export async function getItemManufacturing(client: SupabaseClient<Database>,id: string,@@ -429,6 +435,34 @@ export async function getMaterialSubstancesList(.order("name");}+export async function getItemQuantities(+ client: SupabaseClient<Database>,+ itemId: string,+ companyId: string,+ locationId: string+) {+ return client+ .from("itemQuantities")+ .select("*")+ .eq("itemId", itemId)+ .eq("companyId", companyId)+ .eq("locationId", locationId)+ .maybeSingle();+}++export async function getItemUnitSalePrice(+ client: SupabaseClient<Database>,+ id: string,+ companyId: string+) {+ return client+ .from("itemUnitSalePrice")+ .select("*")+ .eq("itemId", id)+ .eq("companyId", companyId)+ .single();+}+export async function getPart(client: SupabaseClient<Database>,itemId: string,@@ -488,14 +522,14 @@ export async function getPartsList(return query.order("name");}-export async function getItemQuantities(+export async function getPickMethod(client: SupabaseClient<Database>,itemId: string,companyId: string,locationId: string) {return client- .from("itemQuantities")+ .from("pickMethod").select("*").eq("itemId", itemId).eq("companyId", companyId)@@ -503,38 +537,16 @@ export async function getItemQuantities(.maybeSingle();}-export async function getItemSuppliers(- client: SupabaseClient<Database>,- id: string,- companyId: string-) {- return client- .from("itemSupplier")- .select(- `- id, supplier(id, name),- supplierPartId, supplierUnitOfMeasureCode,- minimumOrderQuantity, conversionFactor,- unitPrice,- customFields- `- )- .eq("active", true)- .eq("itemId", id)- .eq("companyId", companyId);-}--export async function getItemUnitSalePrice(+export async function getPickMethods(client: SupabaseClient<Database>,- id: string,+ itemId: string,companyId: string) {return client- .from("itemUnitSalePrice")+ .from("pickMethod").select("*")- .eq("itemId", id)- .eq("companyId", companyId)- .single();+ .eq("itemId", itemId)+ .eq("companyId", companyId);}export async function getServices(@@ -1031,28 +1043,28 @@ export async function upsertItemCost(.eq("itemId", itemCost.itemId);}-export async function upsertItemInventory(+export async function upsertPickMethod(client: SupabaseClient<Database>,- itemInventory:- | (z.infer<typeof itemInventoryValidator> & {+ pickMethod:+ | (z.infer<typeof pickMethodValidator> & {companyId: string;createdBy: string;customFields?: Json;})- | (z.infer<typeof itemInventoryValidator> & {+ | (z.infer<typeof pickMethodValidator> & {updatedBy: string;customFields?: Json;})) {- if ("createdBy" in itemInventory) {- return client.from("itemInventory").insert(itemInventory);+ if ("createdBy" in pickMethod) {+ return client.from("pickMethod").insert(pickMethod);}return client- .from("itemInventory")- .update(sanitize(itemInventory))- .eq("itemId", itemInventory.itemId)- .eq("locationId", itemInventory.locationId);+ .from("pickMethod")+ .update(sanitize(pickMethod))+ .eq("itemId", pickMethod.itemId)+ .eq("locationId", pickMethod.locationId);}export async function upsertItemManufacturing(@@ -1132,31 +1144,27 @@ export async function upsertItemGroup();}-export async function upsertItemSupplier(+export async function upsertBuyMethod(client: SupabaseClient<Database>,- itemSupplier:- | (Omit<z.infer<typeof itemSupplierValidator>, "id"> & {+ buyMethod:+ | (Omit<z.infer<typeof buyMethodValidator>, "id"> & {companyId: string;createdBy: string;customFields?: Json;})- | (Omit<z.infer<typeof itemSupplierValidator>, "id"> & {+ | (Omit<z.infer<typeof buyMethodValidator>, "id"> & {id: string;updatedBy: string;customFields?: Json;})) {- if ("createdBy" in itemSupplier) {- return client- .from("itemSupplier")- .insert([itemSupplier])- .select("id")- .single();+ if ("createdBy" in buyMethod) {+ return client.from("buyMethod").insert([buyMethod]).select("id").single();}return client- .from("itemSupplier")- .update(sanitize(itemSupplier))- .eq("id", itemSupplier.id)+ .from("buyMethod")+ .update(sanitize(buyMethod))+ .eq("id", buyMethod.id).select("id").single();}diff --git a/apps/carbon/app/modules/items/types.ts b/apps/carbon/app/modules/items/types.tsindex 6d695371e9..1d17515133 100644--- a/apps/carbon/app/modules/items/types.ts+++ b/apps/carbon/app/modules/items/types.ts@@ -1,17 +1,18 @@import type { Database } from "@carbon/database";import type {+ getBuyMethods,getConsumables,getFixtures,getItemCost,getItemGroups,getItemGroupsList,getItemQuantities,- getItemSuppliers,getMaterialForms,getMaterialSubstances,getMaterials,getPart,getParts,+ getPickMethods,getServices,getTool,getTools,@@ -56,8 +57,8 @@ export type ItemReorderingPolicy =export type ItemReplenishmentSystem =Database["public"]["Enums"]["itemReplenishmentSystem"];-export type ItemSupplier = NonNullable<- Awaited<ReturnType<typeof getItemSuppliers>>["data"]+export type BuyMethod = NonNullable<+ Awaited<ReturnType<typeof getBuyMethods>>["data"]>[number];export type InventoryItemType =@@ -78,6 +79,10 @@ export type PartSummary = NonNullable<Awaited<ReturnType<typeof getPart>>>["data"];+export type PickMethod = NonNullable<+ Awaited<ReturnType<typeof getPickMethods>>["data"]+>[number];+export type Service = NonNullable<Awaited<ReturnType<typeof getServices>>["data"]>[number];diff --git a/apps/carbon/app/modules/items/ui/Item/ItemSupplierForm.tsx b/apps/carbon/app/modules/items/ui/Item/BuyMethodForm.tsxsimilarity index 91%rename from apps/carbon/app/modules/items/ui/Item/ItemSupplierForm.tsxrename to apps/carbon/app/modules/items/ui/Item/BuyMethodForm.tsxindex d60086358d..b15624f856 100644--- a/apps/carbon/app/modules/items/ui/Item/ItemSupplierForm.tsx+++ b/apps/carbon/app/modules/items/ui/Item/BuyMethodForm.tsx@@ -25,15 +25,15 @@ import {} from "~/components/Form";import { usePermissions, useRouteData } from "~/hooks";import type { PartSummary } from "~/modules/items";-import { itemSupplierValidator } from "~/modules/items";+import { buyMethodValidator } from "~/modules/items";import { path } from "~/utils/path";-type ItemSupplierFormProps = {- initialValues: z.infer<typeof itemSupplierValidator>;+type BuyMethodFormProps = {+ initialValues: z.infer<typeof buyMethodValidator>;type: "Part" | "Service" | "Tool" | "Consumable" | "Material" | "Fixture";};-const ItemSupplierForm = ({ initialValues, type }: ItemSupplierFormProps) => {+const BuyMethodForm = ({ initialValues, type }: BuyMethodFormProps) => {const permissions = usePermissions();const navigate = useNavigate();const { itemId } = useParams();@@ -65,15 +65,13 @@ const ItemSupplierForm = ({ initialValues, type }: ItemSupplierFormProps) => {<DrawerContent><ValidatedFormdefaultValues={initialValues}- validator={itemSupplierValidator}+ validator={buyMethodValidator}method="post"action={action}className="flex flex-col h-full"><DrawerHeader>- <DrawerTitle>- {isEditing ? "Edit" : "New"} Part Supplier- </DrawerTitle>+ <DrawerTitle>{isEditing ? "Edit" : "New"} Buy Method</DrawerTitle></DrawerHeader><DrawerBody><Hidden name="id" />@@ -120,7 +118,7 @@ const ItemSupplierForm = ({ initialValues, type }: ItemSupplierFormProps) => {);};-export default ItemSupplierForm;+export default BuyMethodForm;function getAction(isEditing: boolean,diff --git a/apps/carbon/app/modules/items/ui/Item/ItemSuppliers/ItemSuppliers.tsx b/apps/carbon/app/modules/items/ui/Item/BuyMethods/BuyMethods.tsxsimilarity index 85%rename from apps/carbon/app/modules/items/ui/Item/ItemSuppliers/ItemSuppliers.tsxrename to apps/carbon/app/modules/items/ui/Item/BuyMethods/BuyMethods.tsxindex f66b03d23b..83927d5377 100644--- a/apps/carbon/app/modules/items/ui/Item/ItemSuppliers/ItemSuppliers.tsx+++ b/apps/carbon/app/modules/items/ui/Item/BuyMethods/BuyMethods.tsx@@ -18,12 +18,12 @@ import {import Grid from "~/components/Grid";import { useRouteData } from "~/hooks";import { useCustomColumns } from "~/hooks/useCustomColumns";-import type { ItemSupplier, UnitOfMeasureListItem } from "~/modules/items";+import type { BuyMethod, UnitOfMeasureListItem } from "~/modules/items";import { path } from "~/utils/path";-import useItemSuppliers from "./useItemSuppliers";+import useBuyMethods from "./useBuyMethods";-type ItemSuppliersProps = {- suppliers: ItemSupplier[];+type BuyMethodsProps = {+ buyMethods: BuyMethod[];};// TODO: make dynamic@@ -32,9 +32,9 @@ const formatter = new Intl.NumberFormat("en-US", {currency: "USD",});-const ItemSuppliers = ({ suppliers }: ItemSuppliersProps) => {+const BuyMethods = ({ buyMethods }: BuyMethodsProps) => {const navigate = useNavigate();- const { canEdit, onCellEdit } = useItemSuppliers();+ const { canEdit, onCellEdit } = useBuyMethods();const sharedPartData = useRouteData<{unitOfMeasures: UnitOfMeasureListItem[];}>(path.to.partRoot);@@ -48,10 +48,10 @@ const ItemSuppliers = ({ suppliers }: ItemSuppliersProps) => {);}, [sharedPartData?.unitOfMeasures]);- const customColumns = useCustomColumns<ItemSupplier>("itemSupplier");+ const customColumns = useCustomColumns<BuyMethod>("buyMethod");- const columns = useMemo<ColumnDef<ItemSupplier>[]>(() => {- const defaultColumns: ColumnDef<ItemSupplier>[] = [+ const columns = useMemo<ColumnDef<BuyMethod>[]>(() => {+ const defaultColumns: ColumnDef<BuyMethod>[] = [{accessorKey: "supplier.id",header: "Supplier",@@ -123,13 +123,13 @@ const ItemSuppliers = ({ suppliers }: ItemSuppliersProps) => {<Card className="w-full h-full min-h-[50vh]"><HStack className="justify-between items-start"><CardHeader>- <CardTitle>Suppliers</CardTitle>+ <CardTitle>Buy Methods</CardTitle></CardHeader><CardAction>{canEdit && <New to="new" />}</CardAction></HStack><CardContent>- <Grid<ItemSupplier>- data={suppliers}+ <Grid<BuyMethod>+ data={buyMethods}columns={columns}canEdit={canEdit}editableComponents={editableComponents}@@ -142,4 +142,4 @@ const ItemSuppliers = ({ suppliers }: ItemSuppliersProps) => {);};-export default ItemSuppliers;+export default BuyMethods;diff --git a/apps/carbon/app/modules/items/ui/Item/BuyMethods/index.ts b/apps/carbon/app/modules/items/ui/Item/BuyMethods/index.tsnew file mode 100644index 0000000000..88776619db--- /dev/null+++ b/apps/carbon/app/modules/items/ui/Item/BuyMethods/index.ts@@ -0,0 +1,3 @@+import BuyMethods from "./BuyMethods";++export default BuyMethods;diff --git a/apps/carbon/app/modules/items/ui/Item/ItemSuppliers/useItemSuppliers.tsx b/apps/carbon/app/modules/items/ui/Item/BuyMethods/useBuyMethods.tsxsimilarity index 76%rename from apps/carbon/app/modules/items/ui/Item/ItemSuppliers/useItemSuppliers.tsxrename to apps/carbon/app/modules/items/ui/Item/BuyMethods/useBuyMethods.tsxindex 646517f809..7e4f529529 100644--- a/apps/carbon/app/modules/items/ui/Item/ItemSuppliers/useItemSuppliers.tsx+++ b/apps/carbon/app/modules/items/ui/Item/BuyMethods/useBuyMethods.tsx@@ -1,9 +1,9 @@import { useCallback } from "react";import { usePermissions } from "~/hooks";import { useSupabase } from "~/lib/supabase";-import type { ItemSupplier } from "~/modules/items";+import type { BuyMethod } from "~/modules/items";-export default function useItemSuppliers() {+export default function useBuyMethods() {const { supabase } = useSupabase();const permissions = usePermissions();@@ -11,10 +11,10 @@ export default function useItemSuppliers() {const canDelete = permissions.can("delete", "parts");const onCellEdit = useCallback(- async (id: string, value: unknown, row: ItemSupplier) => {+ async (id: string, value: unknown, row: BuyMethod) => {if (!supabase) throw new Error("Supabase client not found");return await supabase- .from("itemSupplier")+ .from("buyMethod").update({[id]: value,})diff --git a/apps/carbon/app/modules/items/ui/Item/ItemCostingForm.tsx b/apps/carbon/app/modules/items/ui/Item/ItemCostingForm.tsxindex eeb06aee83..ed1231fb46 100644--- a/apps/carbon/app/modules/items/ui/Item/ItemCostingForm.tsx+++ b/apps/carbon/app/modules/items/ui/Item/ItemCostingForm.tsx@@ -39,12 +39,12 @@ const ItemCostingForm = ({ initialValues }: ItemCostingFormProps) => {);return (- <ValidatedForm- method="post"- validator={itemCostValidator}- defaultValues={initialValues}- >- <Card>+ <Card>+ <ValidatedForm+ method="post"+ validator={itemCostValidator}+ defaultValues={initialValues}+ ><CardHeader><CardTitle>Costing & Posting</CardTitle></CardHeader>@@ -102,8 +102,8 @@ const ItemCostingForm = ({ initialValues }: ItemCostingFormProps) => {<CardFooter><Submit isDisabled={!permissions.can("update", "parts")}>Save</Submit></CardFooter>- </Card>- </ValidatedForm>+ </ValidatedForm>+ </Card>);};diff --git a/apps/carbon/app/modules/items/ui/Item/ItemPlanningForm.tsx b/apps/carbon/app/modules/items/ui/Item/ItemPlanningForm.tsxindex 7ec33dd45b..a54ee29bbe 100644--- a/apps/carbon/app/modules/items/ui/Item/ItemPlanningForm.tsx+++ b/apps/carbon/app/modules/items/ui/Item/ItemPlanningForm.tsx@@ -8,6 +8,7 @@ import {HStack,} from "@carbon/react";import { ValidatedForm } from "@carbon/remix-validated-form";+import { useState } from "react";import type { z } from "zod";import { Combobox } from "~/components";import {@@ -41,13 +42,15 @@ const ItemPlanningForm = ({value: location.id,}));+ const [policy, setPolicy] = useState(initialValues.reorderingPolicy);+return (- <ValidatedForm- method="post"- validator={itemPlanningValidator}- defaultValues={initialValues}- >- <Card>+ <Card>+ <ValidatedForm+ method="post"+ validator={itemPlanningValidator}+ defaultValues={initialValues}+ ><HStack className="w-full justify-between items-start"><CardHeader><CardTitle>Planning</CardTitle>@@ -79,49 +82,69 @@ const ItemPlanningForm = ({label: policy,value: policy,}))}+ onChange={(selected) => {+ // @ts-ignore+ setPolicy(selected?.value || "Manual Reorder");+ }}/>- <Number name="safetyStockQuantity" label="Safety Stock Quantity" />- <Number- name="safetyStockLeadTime"- label="Safety Stock Lead Time (Days)"- />- <Number- name="minimumOrderQuantity"- label="Minimum Order Quantity"- minValue={0}- />- <Number- name="maximumOrderQuantity"- label="Maximum Order Quantity"- minValue={0}- />- <Number name="orderMultiple" label="Order Multiple" minValue={0} />+ {policy === "Maximum Quantity" && (+ <>+ <Number+ name="safetyStockQuantity"+ label="Safety Stock Quantity"+ />+ <Number+ name="safetyStockLeadTime"+ label="Safety Stock Lead Time (Days)"+ />+ <Number+ name="minimumOrderQuantity"+ label="Minimum Order Quantity"+ minValue={0}+ />+ <Number+ name="maximumOrderQuantity"+ label="Maximum Order Quantity"+ minValue={0}+ />+ </>+ )}- <Number- name="demandAccumulationPeriod"- label="Demand Accumulation Period (Days)"- minValue={0}- />- <Number- name="demandReschedulingPeriod"- label="Rescheduling Period (Days)"- minValue={0}- />- <Number name="reorderPoint" label="Reorder Point" />- <Number- name="reorderQuantity"- label="Reorder Quantity"- minValue={0}- />- <Number- name="reorderMaximumInventory"- label="Reorder Maximum Inventory"- minValue={0}- />- <Boolean- name="demandAccumulationIncludesInventory"- label="Demand Includes Inventory"- />+ {policy === "Demand-Based Reorder" && (+ <>+ <Number+ name="demandAccumulationPeriod"+ label="Demand Accumulation Period (Days)"+ minValue={0}+ />+ <Number+ name="demandReschedulingPeriod"+ label="Rescheduling Period (Days)"+ minValue={0}+ />+ <Boolean+ name="demandAccumulationIncludesInventory"+ label="Demand Includes Inventory"+ />+ </>+ )}+ {policy === "Fixed Reorder Quantity" && (+ <>+ <Number name="reorderPoint" label="Reorder Point" />+ <Number+ name="reorderQuantity"+ label="Reorder Quantity"+ minValue={0}+ />+ <Number+ name="reorderMaximumInventory"+ label="Reorder Maximum Inventory"+ minValue={0}+ />+ </>+ )}++ <Number name="orderMultiple" label="Order Multiple" minValue={0} /><Boolean name="critical" label="Critical" /><CustomFormFields table="partPlanning" /></div>@@ -129,8 +152,8 @@ const ItemPlanningForm = ({<CardFooter><Submit isDisabled={!permissions.can("update", "parts")}>Save</Submit></CardFooter>- </Card>- </ValidatedForm>+ </ValidatedForm>+ </Card>);};diff --git a/apps/carbon/app/modules/items/ui/Item/ItemPurchasingForm.tsx b/apps/carbon/app/modules/items/ui/Item/ItemPurchasingForm.tsxindex a0f160c611..ad6a747b6c 100644--- a/apps/carbon/app/modules/items/ui/Item/ItemPurchasingForm.tsx+++ b/apps/carbon/app/modules/items/ui/Item/ItemPurchasingForm.tsx@@ -25,9 +25,13 @@ import { path } from "~/utils/path";type ItemPurchasingFormProps = {initialValues: z.infer<typeof itemPurchasingValidator>;+ allowedSuppliers?: string[];};-const ItemPurchasingForm = ({ initialValues }: ItemPurchasingFormProps) => {+const ItemPurchasingForm = ({+ initialValues,+ allowedSuppliers,+}: ItemPurchasingFormProps) => {const permissions = usePermissions();const { itemId } = useParams();if (!itemId) throw new Error("itemId not found");@@ -42,19 +46,23 @@ const ItemPurchasingForm = ({ initialValues }: ItemPurchasingFormProps) => {);return (- <ValidatedForm- method="post"- validator={itemPurchasingValidator}- defaultValues={initialValues}- >- <Card>+ <Card>+ <ValidatedForm+ method="post"+ validator={itemPurchasingValidator}+ defaultValues={initialValues}+ ><CardHeader><CardTitle>Purchasing</CardTitle></CardHeader><CardContent><Hidden name="itemId" /><div className="grid grid-cols-1 lg:grid-cols-3 gap-x-8 gap-y-2 w-full">- <Supplier name="preferredSupplierId" label="Preferred Supplier" />+ <Supplier+ name="preferredSupplierId"+ label="Preferred Supplier"+ allowedSuppliers={allowedSuppliers}+ /><Number name="purchasingLeadTime" label="Lead Time (Days)" /><UnitOfMeasurename="purchasingUnitOfMeasureCode"@@ -75,8 +83,8 @@ const ItemPurchasingForm = ({ initialValues }: ItemPurchasingFormProps) => {<CardFooter><Submit isDisabled={!permissions.can("update", "parts")}>Save</Submit></CardFooter>- </Card>- </ValidatedForm>+ </ValidatedForm>+ </Card>);};diff --git a/apps/carbon/app/modules/items/ui/Item/ItemSalePriceForm.tsx b/apps/carbon/app/modules/items/ui/Item/ItemSalePriceForm.tsxindex a9f120881a..381245cef8 100644--- a/apps/carbon/app/modules/items/ui/Item/ItemSalePriceForm.tsx+++ b/apps/carbon/app/modules/items/ui/Item/ItemSalePriceForm.tsx@@ -29,12 +29,12 @@ const ItemSalePriceForm = ({ initialValues }: ItemSalePriceFormProps) => {const [currency, setCurrency] = useState(initialValues.currencyCode);return (- <ValidatedForm- method="post"- validator={itemUnitSalePriceValidator}- defaultValues={initialValues}- >- <Card>+ <Card>+ <ValidatedForm+ method="post"+ validator={itemUnitSalePriceValidator}+ defaultValues={initialValues}+ ><CardHeader><CardTitle>Sale Price</CardTitle></CardHeader>@@ -75,8 +75,8 @@ const ItemSalePriceForm = ({ initialValues }: ItemSalePriceFormProps) => {<CardFooter><Submit isDisabled={!permissions.can("update", "parts")}>Save</Submit></CardFooter>- </Card>- </ValidatedForm>+ </ValidatedForm>+ </Card>);};diff --git a/apps/carbon/app/modules/items/ui/Item/ItemSuppliers/index.ts b/apps/carbon/app/modules/items/ui/Item/ItemSuppliers/index.tsdeleted file mode 100644index 5f5884ea60..0000000000--- a/apps/carbon/app/modules/items/ui/Item/ItemSuppliers/index.ts+++ /dev/null@@ -1,3 +0,0 @@-import ItemSuppliers from "./ItemSuppliers";--export default ItemSuppliers;diff --git a/apps/carbon/app/modules/items/ui/Item/MethodIcon.tsx b/apps/carbon/app/modules/items/ui/Item/MethodIcon.tsxnew file mode 100644index 0000000000..b066414e0e--- /dev/null+++ b/apps/carbon/app/modules/items/ui/Item/MethodIcon.tsx@@ -0,0 +1,28 @@+import { cn } from "@carbon/react";+import { AiOutlinePartition } from "react-icons/ai";+import { FaCodePullRequest } from "react-icons/fa6";+import { HiSquares2X2 } from "react-icons/hi2";+import { LuHammer, LuShoppingCart } from "react-icons/lu";++export const MethodIcon = ({+ type,+ className,+}: {+ type: string;+ className?: string;+}) => {+ switch (type) {+ case "Method":+ return (+ <AiOutlinePartition className={cn(className, "text-foreground")} />+ );+ case "Buy":+ return <LuShoppingCart className={cn("text-blue-500", className)} />;+ case "Make":+ return <LuHammer className={cn("text-green-500", className)} />;+ case "Pick":+ return <FaCodePullRequest className={cn("text-yellow-500", className)} />;+ }++ return <HiSquares2X2 className={cn("text-muted-foreground", className)} />;+};diff --git a/apps/carbon/app/modules/items/ui/Item/ItemInventoryForm.tsx b/apps/carbon/app/modules/items/ui/Item/PickMethodForm.tsxsimilarity index 90%rename from apps/carbon/app/modules/items/ui/Item/ItemInventoryForm.tsxrename to apps/carbon/app/modules/items/ui/Item/PickMethodForm.tsxindex f08f2502ff..f400ba4124 100644--- a/apps/carbon/app/modules/items/ui/Item/ItemInventoryForm.tsx+++ b/apps/carbon/app/modules/items/ui/Item/PickMethodForm.tsx@@ -21,25 +21,25 @@ import {import { usePermissions, useUser } from "~/hooks";import { useSupabase } from "~/lib/supabase";import type { ItemQuantities } from "~/modules/items";-import { itemInventoryValidator } from "~/modules/items";+import { pickMethodValidator } from "~/modules/items";import type { ListItem } from "~/types";import { path } from "~/utils/path";-type ItemInventoryFormProps = {- initialValues: z.infer<typeof itemInventoryValidator>;+type PickMethodFormProps = {+ initialValues: z.infer<typeof pickMethodValidator>;quantities: ItemQuantities;locations: ListItem[];shelves: string[];type: "Part" | "Material" | "Tool" | "Fixture" | "Consumable";};-const ItemInventoryForm = ({+const PickMethodForm = ({initialValues,locations,quantities,shelves,type,-}: ItemInventoryFormProps) => {+}: PickMethodFormProps) => {const permissions = usePermissions();const { supabase } = useSupabase();const user = useUser();@@ -52,12 +52,12 @@ const ItemInventoryForm = ({}));return (- <ValidatedForm- method="post"- validator={itemInventoryValidator}- defaultValues={{ ...quantities, ...initialValues }}- >- <Card>+ <Card>+ <ValidatedForm+ method="post"+ validator={pickMethodValidator}+ defaultValues={{ ...quantities, ...initialValues }}+ ><HStack className="w-full justify-between items-start"><CardHeader><CardTitle>Inventory</CardTitle>@@ -130,12 +130,12 @@ const ItemInventoryForm = ({<CardFooter><Submit isDisabled={!permissions.can("update", "parts")}>Save</Submit></CardFooter>- </Card>- </ValidatedForm>+ </ValidatedForm>+ </Card>);};-export default ItemInventoryForm;+export default PickMethodForm;function getLocationPath(itemId: string,diff --git a/apps/carbon/app/modules/items/ui/Item/index.ts b/apps/carbon/app/modules/items/ui/Item/index.tsindex af6d49c7c9..1f870cb4ac 100644--- a/apps/carbon/app/modules/items/ui/Item/index.ts+++ b/apps/carbon/app/modules/items/ui/Item/index.ts@@ -1,19 +1,21 @@+import BuyMethodForm from "./BuyMethodForm";+import BuyMethods from "./BuyMethods";import ItemCostingForm from "./ItemCostingForm";import ItemForm from "./ItemForm";-import ItemInventoryForm from "./ItemInventoryForm";import ItemPlanningForm from "./ItemPlanningForm";import ItemPurchasingForm from "./ItemPurchasingForm";import ItemSalePriceForm from "./ItemSalePriceForm";-import ItemSupplierForm from "./ItemSupplierForm";-import ItemSuppliers from "./ItemSuppliers";+import { MethodIcon } from "./MethodIcon";+import PickMethodForm from "./PickMethodForm";export {+ BuyMethodForm,+ BuyMethods,ItemCostingForm,ItemForm,- ItemInventoryForm,ItemPlanningForm,ItemPurchasingForm,ItemSalePriceForm,- ItemSupplierForm,- ItemSuppliers,+ MethodIcon,+ PickMethodForm,};diff --git a/apps/carbon/app/modules/items/ui/MaterialForms/MaterialFormsTable.tsx b/apps/carbon/app/modules/items/ui/MaterialForms/MaterialFormsTable.tsxdeleted file mode 100644index 5673c76fa6..0000000000--- a/apps/carbon/app/modules/items/ui/MaterialForms/MaterialFormsTable.tsx+++ /dev/null@@ -1,106 +0,0 @@-import { Badge, 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 { Hyperlink, New, Table } from "~/components";-import { usePermissions, useUrlParams } from "~/hooks";-import { useCustomColumns } from "~/hooks/useCustomColumns";-import type { Form } from "~/modules/items";-import { path } from "~/utils/path";--type MaterialFormsTableProps = {- data: Form[];- count: number;-};--const MaterialFormsTable = memo(({ data, count }: MaterialFormsTableProps) => {- const [params] = useUrlParams();- const navigate = useNavigate();- const permissions = usePermissions();-- const rows = useMemo(() => data, [data]);- const customColumns = useCustomColumns<Form>("materialForm");-- const columns = useMemo<ColumnDef<(typeof rows)[number]>[]>(() => {- const defaultColumns: ColumnDef<(typeof rows)[number]>[] = [- {- accessorKey: "name",- header: "Name",- cell: ({ row }) => (- <Hyperlink- to={`${path.to.materialForm(row.original.id)}?${params.toString()}`}- >- {row.original.name}- </Hyperlink>- ),- },- {- header: "Type",- cell: ({ row }) =>- row.original.companyId === null ? (- <Badge className="border-dashed" variant="outline">- Global- </Badge>- ) : (- <Badge>Company</Badge>- ),- },- ];- return [...defaultColumns, ...customColumns];- }, [params, customColumns]);-- const renderContextMenu = useCallback(- (row: (typeof rows)[number]) => {- return (- <>- <MenuItem- disabled={- !permissions.can("update", "parts") || row.companyId === null- }- onClick={() => {- navigate(`${path.to.materialForm(row.id)}?${params.toString()}`);- }}- >- <MenuIcon icon={<LuPencil />} />- Edit Material Form- </MenuItem>- <MenuItem- disabled={- !permissions.can("delete", "parts") || row.companyId === null- }- onClick={() => {- navigate(- `${path.to.deleteMaterialForm(row.id)}?${params.toString()}`- );- }}- >- <MenuIcon icon={<LuTrash />} />- Delete Material Form- </MenuItem>- </>- );- },- [navigate, params, permissions]- );-- return (- <Table<(typeof rows)[number]>- data={data}- columns={columns}- count={count}- primaryAction={- permissions.can("create", "parts") && (- <New- label="Material Form"- to={`${path.to.newMaterialForm}?${params.toString()}`}- />- )- }- renderContextMenu={renderContextMenu}- />- );-});--MaterialFormsTable.displayName = "MaterialFormsTable";-export default MaterialFormsTable;diff --git a/apps/carbon/app/modules/items/ui/MaterialForms/MaterialFormForm.tsx b/apps/carbon/app/modules/items/ui/MaterialForms/MaterialShapeForm.tsxsimilarity index 94%rename from apps/carbon/app/modules/items/ui/MaterialForms/MaterialFormForm.tsxrename to apps/carbon/app/modules/items/ui/MaterialForms/MaterialShapeForm.tsxindex e2c7166f20..d79428b2f7 100644--- a/apps/carbon/app/modules/items/ui/MaterialForms/MaterialFormForm.tsx+++ b/apps/carbon/app/modules/items/ui/MaterialForms/MaterialShapeForm.tsx@@ -21,19 +21,19 @@ import { usePermissions } from "~/hooks";import { materialFormValidator } from "~/modules/items";import { path } from "~/utils/path";-type MaterialFormFormProps = {+type MaterialShapeFormProps = {initialValues: z.infer<typeof materialFormValidator>;type?: "modal" | "drawer";open?: boolean;onClose: (data?: { id: string; name: string }) => void;};-const MaterialFormForm = ({+const MaterialShapeForm = ({initialValues,open = true,type = "drawer",onClose,-}: MaterialFormFormProps) => {+}: MaterialShapeFormProps) => {const permissions = usePermissions();const fetcher = useFetcher<PostgrestResponse<{ id: string; name: string }>>();@@ -78,7 +78,7 @@ const MaterialFormForm = ({><ModalDrawerHeader><ModalDrawerTitle>- {isEditing ? "Edit" : "New"} Material Form+ {isEditing ? "Edit" : "New"} Material Shape</ModalDrawerTitle></ModalDrawerHeader><ModalDrawerBody>@@ -104,4 +104,4 @@ const MaterialFormForm = ({);};-export default MaterialFormForm;+export default MaterialShapeForm;diff --git a/apps/carbon/app/modules/items/ui/MaterialForms/MaterialShapesTable.tsx b/apps/carbon/app/modules/items/ui/MaterialForms/MaterialShapesTable.tsxnew file mode 100644index 0000000000..3f65904eaa--- /dev/null+++ b/apps/carbon/app/modules/items/ui/MaterialForms/MaterialShapesTable.tsx@@ -0,0 +1,112 @@+import { Badge, 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 { Hyperlink, New, Table } from "~/components";+import { usePermissions, useUrlParams } from "~/hooks";+import { useCustomColumns } from "~/hooks/useCustomColumns";+import type { Form } from "~/modules/items";+import { path } from "~/utils/path";++type MaterialShapesTableProps = {+ data: Form[];+ count: number;+};++const MaterialShapesTable = memo(+ ({ data, count }: MaterialShapesTableProps) => {+ const [params] = useUrlParams();+ const navigate = useNavigate();+ const permissions = usePermissions();++ const rows = useMemo(() => data, [data]);+ const customColumns = useCustomColumns<Form>("materialForm");++ const columns = useMemo<ColumnDef<(typeof rows)[number]>[]>(() => {+ const defaultColumns: ColumnDef<(typeof rows)[number]>[] = [+ {+ accessorKey: "name",+ header: "Name",+ cell: ({ row }) => (+ <Hyperlink+ to={`${path.to.materialForm(+ row.original.id+ )}?${params.toString()}`}+ >+ {row.original.name}+ </Hyperlink>+ ),+ },+ {+ header: "Type",+ cell: ({ row }) =>+ row.original.companyId === null ? (+ <Badge className="border-dashed" variant="outline">+ Global+ </Badge>+ ) : (+ <Badge>Company</Badge>+ ),+ },+ ];+ return [...defaultColumns, ...customColumns];+ }, [params, customColumns]);++ const renderContextMenu = useCallback(+ (row: (typeof rows)[number]) => {+ return (+ <>+ <MenuItem+ disabled={+ !permissions.can("update", "parts") || row.companyId === null+ }+ onClick={() => {+ navigate(+ `${path.to.materialForm(row.id)}?${params.toString()}`+ );+ }}+ >+ <MenuIcon icon={<LuPencil />} />+ Edit Material Shape+ </MenuItem>+ <MenuItem+ disabled={+ !permissions.can("delete", "parts") || row.companyId === null+ }+ onClick={() => {+ navigate(+ `${path.to.deleteMaterialForm(row.id)}?${params.toString()}`+ );+ }}+ >+ <MenuIcon icon={<LuTrash />} />+ Delete Material Shape+ </MenuItem>+ </>+ );+ },+ [navigate, params, permissions]+ );++ return (+ <Table<(typeof rows)[number]>+ data={data}+ columns={columns}+ count={count}+ primaryAction={+ permissions.can("create", "parts") && (+ <New+ label="Material Form"+ to={`${path.to.newMaterialForm}?${params.toString()}`}+ />+ )+ }+ renderContextMenu={renderContextMenu}+ />+ );+ }+);++MaterialShapesTable.displayName = "MaterialShapesTable";+export default MaterialShapesTable;diff --git a/apps/carbon/app/modules/items/ui/MaterialForms/index.ts b/apps/carbon/app/modules/items/ui/MaterialForms/index.tsindex bb058c52d1..68235bf000 100644--- a/apps/carbon/app/modules/items/ui/MaterialForms/index.ts+++ b/apps/carbon/app/modules/items/ui/MaterialForms/index.ts@@ -1,4 +1,4 @@-import MaterialFormForm from "./MaterialFormForm";-import MaterialFormsTable from "./MaterialFormsTable";+import MaterialShapeForm from "./MaterialShapeForm";+import MaterialFormsTable from "./MaterialShapesTable";-export { MaterialFormForm, MaterialFormsTable };+export { MaterialFormsTable, MaterialShapeForm };diff --git a/apps/carbon/app/modules/items/ui/MaterialSubstances/MaterialSubstanceForm.tsx b/apps/carbon/app/modules/items/ui/MaterialSubstances/MaterialSubstanceForm.tsxindex 94f295a22a..cc1d181dd3 100644--- a/apps/carbon/app/modules/items/ui/MaterialSubstances/MaterialSubstanceForm.tsx+++ b/apps/carbon/app/modules/items/ui/MaterialSubstances/MaterialSubstanceForm.tsx@@ -55,8 +55,6 @@ const MaterialSubstanceForm = ({}}, [fetcher.data, fetcher.state, onClose, type]);- console.log(isEditing);-return (<ModalDrawerProvider type={type}><ModalDrawerdiff --git a/apps/carbon/app/modules/items/ui/Parts/PartHeader.tsx b/apps/carbon/app/modules/items/ui/Parts/PartHeader.tsxindex 8b22549b20..2eb1126c2d 100644--- a/apps/carbon/app/modules/items/ui/Parts/PartHeader.tsx+++ b/apps/carbon/app/modules/items/ui/Parts/PartHeader.tsx@@ -1,28 +1,14 @@-import {- Card,- CardAction,- CardAttribute,- CardAttributeLabel,- CardAttributeValue,- CardAttributes,- CardContent,- CardDescription,- CardHeader,- CardTitle,- Enumerable,- HStack,- Menubar,- VStack,-} from "@carbon/react";+import { Enumerable, HStack, Heading, VStack } from "@carbon/react";import { useParams } from "@remix-run/react";-import { Assign, EmployeeAvatar, useOptimisticAssignment } from "~/components";-import { usePermissions, useRouteData } from "~/hooks";+import { DetailsTopbar } from "~/components/Layout";+import { useRouteData } from "~/hooks";import type { PartSummary } from "~/modules/items";import { path } from "~/utils/path";+import { usePartNavigation } from "./usePartNavigation";const PartHeader = () => {- const permissions = usePermissions();+ const links = usePartNavigation();const { itemId } = useParams();if (!itemId) throw new Error("itemId not found");@@ -30,82 +16,18 @@ const PartHeader = () => {path.to.part(itemId));- const optimisticAssignment = useOptimisticAssignment({- id: itemId,- table: "item",- });- const assignee =- optimisticAssignment !== undefined- ? optimisticAssignment- : routeData?.partSummary?.assignee;-return (- <VStack>- {permissions.is("employee") && !!routeData?.partSummary?.id && (- <Menubar>- <Assign- id={itemId}- table="item"- value={routeData?.partSummary?.assignee ?? ""}- />- </Menubar>- )}- <Card>- <HStack className="justify-between items-start">- <CardHeader>- <CardTitle>{routeData?.partSummary?.id}</CardTitle>- <CardDescription>{routeData?.partSummary?.name}</CardDescription>- </CardHeader>- <CardAction>- {/* <Button- variant="secondary"- onClick={() => alert("TODO")}- leftIcon={<FaHistory />}- >- View History- </Button> */}- </CardAction>+ <div className="flex flex-shrink-0 items-center justify-between px-4 py-2 bg-card">+ <VStack spacing={0} className="flex-grow">+ <HStack>+ <Heading size="h2">{routeData?.partSummary?.id}</Heading>+ <Enumerable value="Part" /></HStack>- <CardContent>- <CardAttributes>- <CardAttribute>- <CardAttributeLabel>Assignee</CardAttributeLabel>- <CardAttributeValue>- {assignee ? (- <EmployeeAvatar employeeId={assignee ?? null} />- ) : (- "-"- )}- </CardAttributeValue>- </CardAttribute>- <CardAttribute>- <CardAttributeLabel>Replenishment</CardAttributeLabel>- <CardAttributeValue>- <Enumerable- value={routeData?.partSummary?.replenishmentSystem ?? null}- />- </CardAttributeValue>- </CardAttribute>- <CardAttribute>- <CardAttributeLabel>Inventory Type</CardAttributeLabel>- <CardAttributeValue>- <Enumerable- value={routeData?.partSummary?.itemInventoryType ?? null}- />- </CardAttributeValue>- </CardAttribute>- <CardAttribute>- <CardAttributeLabel>UoM</CardAttributeLabel>- <CardAttributeValue>- <Enumerable- value={routeData?.partSummary?.unitOfMeasure ?? null}- />- </CardAttributeValue>- </CardAttribute>- </CardAttributes>- </CardContent>- </Card>- </VStack>+ </VStack>+ <VStack spacing={0} className="flex-shrink justify-center items-end">+ <DetailsTopbar links={links} />+ </VStack>+ </div>);};diff --git a/apps/carbon/app/modules/items/ui/Parts/PartManufacturingForm.tsx b/apps/carbon/app/modules/items/ui/Parts/PartManufacturingForm.tsxindex da1dd40be1..4e739586b8 100644--- a/apps/carbon/app/modules/items/ui/Parts/PartManufacturingForm.tsx+++ b/apps/carbon/app/modules/items/ui/Parts/PartManufacturingForm.tsx@@ -37,12 +37,12 @@ const PartManufacturingForm = ({})) ?? [];return (- <ValidatedForm- method="post"- validator={partManufacturingValidator}- defaultValues={initialValues}- >- <Card>+ <Card>+ <ValidatedForm+ method="post"+ validator={partManufacturingValidator}+ defaultValues={initialValues}+ ><CardHeader><CardTitle>Manufacturing</CardTitle></CardHeader>@@ -82,8 +82,8 @@ const PartManufacturingForm = ({<CardFooter><Submit isDisabled={!permissions.can("update", "parts")}>Save</Submit></CardFooter>- </Card>- </ValidatedForm>+ </ValidatedForm>+ </Card>);};diff --git a/apps/carbon/app/modules/items/ui/Parts/PartNavigation.tsx b/apps/carbon/app/modules/items/ui/Parts/PartNavigation.tsxindex 194f11de7a..334a85b3d9 100644--- a/apps/carbon/app/modules/items/ui/Parts/PartNavigation.tsx+++ b/apps/carbon/app/modules/items/ui/Parts/PartNavigation.tsx@@ -1,107 +1,8 @@-import { useParams } from "@remix-run/react";--import { BiListCheck } from "react-icons/bi";-import {- LuBox,- LuFileBarChart,- LuFileText,- LuReceipt,- LuShare2,- LuShoppingCart,- LuTags,-} from "react-icons/lu";import { DetailSidebar } from "~/components/Layout";-import { usePermissions, useRouteData } from "~/hooks";-import type {- ItemReplenishmentSystem,- PartSummary,-} from "~/modules/items/types";-import type { Role } from "~/types";-import { path } from "~/utils/path";--export function usePartNavigation(replenishment: ItemReplenishmentSystem) {- const permissions = usePermissions();- const { itemId } = useParams();- if (!itemId) throw new Error("itemId not found");-- return [- {- name: "Details",- to: path.to.partDetails(itemId),- icon: LuFileText,- shortcut: "Command+Shift+d",- },- {- name: "Purchasing",- to: path.to.partPurchasing(itemId),- isDisabled: replenishment === "Make",- role: ["employee", "supplier"],- icon: LuShoppingCart,- shortcut: "Command+Shift+p",- },- {- name: "Suppliers",- to: path.to.partSuppliers(itemId),- isDisabled: replenishment === "Make",- role: ["employee", "supplier"],- icon: LuShare2,- shortcut: "Command+Shift+s",- },- {- name: "Manufacturing",- to: path.to.partManufacturing(itemId),- isDisabled: replenishment === "Buy",- role: ["employee"],- icon: BiListCheck,- shortcut: "Command+Shift+m",- },- {- name: "Costing",- to: path.to.partCosting(itemId),- role: ["employee", "supplier"],- icon: LuTags,- shortcut: "Command+Shift+c",- },- {- name: "Planning",- to: path.to.partPlanning(itemId),- role: ["employee"],- icon: LuFileBarChart,- shortcut: "Command+Shift+p",- },- {- name: "Inventory",- to: path.to.partInventory(itemId),- role: ["employee", "supplier"],- icon: LuBox,- shortcut: "Command+Shift+i",- },- {- name: "Sale Price",- to: path.to.partSalePrice(itemId),- role: ["employee", "customer"],- icon: LuReceipt,- shortcut: "Command+Shift+x",- },- ].filter(- (item) =>- !item.isDisabled &&- (item.role === undefined ||- item.role.some((role) => permissions.is(role as Role)))- );-}+import { usePartNavigation } from "./usePartNavigation";const PartNavigation = () => {- const { itemId } = useParams();- if (!itemId) throw new Error("itemId not found");-- const routeData = useRouteData<{ partSummary: PartSummary }>(- path.to.part(itemId)- );- if (!routeData?.partSummary?.replenishmentSystem)- throw new Error("Could not find replenishmentSystem in routeData");-- const links = usePartNavigation(routeData.partSummary.replenishmentSystem);+ const links = usePartNavigation();return <DetailSidebar links={links} />;};diff --git a/apps/carbon/app/modules/items/ui/Parts/usePartNavigation.tsx b/apps/carbon/app/modules/items/ui/Parts/usePartNavigation.tsxnew file mode 100644index 0000000000..90a9393974--- /dev/null+++ b/apps/carbon/app/modules/items/ui/Parts/usePartNavigation.tsx@@ -0,0 +1,87 @@+import { useParams } from "@remix-run/react";++import { BiListCheck } from "react-icons/bi";+import {+ LuBox,+ LuFileBarChart,+ LuFileText,+ LuReceipt,+ LuShoppingCart,+ LuTags,+} from "react-icons/lu";+import { usePermissions, useRouteData } from "~/hooks";+import type { PartSummary } from "~/modules/items/types";+import type { Role } from "~/types";+import { path } from "~/utils/path";++export function usePartNavigation() {+ const permissions = usePermissions();+ const { itemId } = useParams();+ if (!itemId) throw new Error("itemId not found");++ const routeData = useRouteData<{ partSummary: PartSummary }>(+ path.to.part(itemId)+ );+ if (!routeData?.partSummary?.replenishmentSystem)+ throw new Error("Could not find replenishmentSystem in routeData");++ const replenishment = routeData.partSummary.replenishmentSystem;++ return [+ {+ name: "Details",+ to: path.to.partDetails(itemId),+ icon: LuFileText,+ shortcut: "Command+Shift+d",+ },+ {+ name: "Purchasing",+ to: path.to.partPurchasing(itemId),+ isDisabled: replenishment === "Make",+ role: ["employee", "supplier"],+ icon: LuShoppingCart,+ shortcut: "Command+Shift+p",+ },+ {+ name: "Manufacturing",+ to: path.to.partManufacturing(itemId),+ isDisabled: replenishment === "Buy",+ role: ["employee"],+ icon: BiListCheck,+ shortcut: "Command+Shift+m",+ },+ {+ name: "Inventory",+ to: path.to.partInventory(itemId),+ role: ["employee", "supplier"],+ icon: LuBox,+ shortcut: "Command+Shift+i",+ },+ {+ name: "Costing",+ to: path.to.partCosting(itemId),+ role: ["employee", "supplier"],+ icon: LuTags,+ shortcut: "Command+Shift+c",+ },+ {+ name: "Planning",+ to: path.to.partPlanning(itemId),+ role: ["employee"],+ icon: LuFileBarChart,+ shortcut: "Command+Shift+p",+ },+ {+ name: "Sale Price",+ to: path.to.partSalePrice(itemId),+ role: ["employee", "customer"],+ icon: LuReceipt,+ shortcut: "Command+Shift+x",+ },+ ].filter(+ (item) =>+ !item.isDisabled &&+ (item.role === undefined ||+ item.role.some((role) => permissions.is(role as Role)))+ );+}diff --git a/apps/carbon/app/modules/items/ui/Services/ServiceForm.tsx b/apps/carbon/app/modules/items/ui/Services/ServiceForm.tsxindex 71c168a4a9..f77a998ee1 100644--- a/apps/carbon/app/modules/items/ui/Services/ServiceForm.tsx+++ b/apps/carbon/app/modules/items/ui/Services/ServiceForm.tsx@@ -58,7 +58,7 @@ const ServiceForm = ({ initialValues }: ServiceFormProps) => {</CardHeader><CardContent><Hidden name="itemInventoryType" value="Non-Inventory" />- <Hidden name="unitOfMeasureCode" value="" />+ <Hidden name="unitOfMeasureCode" value="EA" /><divclassName={cn("grid w-full gap-x-8 gap-y-2",diff --git a/apps/carbon/app/modules/items/ui/useItemsSubmodules.tsx b/apps/carbon/app/modules/items/ui/useItemsSubmodules.tsxindex bd45f0872b..e283fa0240 100644--- a/apps/carbon/app/modules/items/ui/useItemsSubmodules.tsx+++ b/apps/carbon/app/modules/items/ui/useItemsSubmodules.tsx@@ -1,3 +1,10 @@+import { AiOutlinePartition } from "react-icons/ai";+import { CiFries } from "react-icons/ci";+import { FaRulerVertical } from "react-icons/fa";+import { GiIBeam, GiWoodBeam } from "react-icons/gi";+import { LuGrip, LuHammer, LuShapes } from "react-icons/lu";+import { PiPiggyBank } from "react-icons/pi";+import { RiCustomerServiceLine } from "react-icons/ri";import { usePermissions } from "~/hooks";import type { AuthenticatedRouteGroup } from "~/types";import { path } from "~/utils/path";@@ -9,32 +16,32 @@ const itemsRoutes: AuthenticatedRouteGroup[] = [{name: "Parts",to: path.to.parts,- // icon: <AiOutlinePartition />,+ icon: <AiOutlinePartition />,},{name: "Materials",to: path.to.materials,- // icon: <GiIBeam />,+ icon: <GiIBeam />,},{name: "Tools",to: path.to.tools,- // icon: <LuHammer />,+ icon: <LuHammer />,},{name: "Fixtures",to: path.to.fixtures,- // icon: <LuGrip />,+ icon: <LuGrip />,},{name: "Consumables",to: path.to.consumables,- // icon: <CiFries />,+ icon: <CiFries />,},{name: "Services",to: path.to.services,- // icon: <RiCustomerServiceLine />,+ icon: <RiCustomerServiceLine />,},// {// name: "Routing",@@ -47,25 +54,26 @@ const itemsRoutes: AuthenticatedRouteGroup[] = [name: "Configure",routes: [{- name: "Forms",+ name: "Shapes",to: path.to.materialForms,- // icon: <LuShapes />,+ icon: <LuShapes />,},{name: "Substances",to: path.to.materialSubstances,- // icon: <GiWoodBeam />,+ icon: <GiWoodBeam />,},{name: "Posting Groups",to: path.to.itemGroups,role: "employee",+ icon: <PiPiggyBank />,},{name: "Units of Measure",to: path.to.uoms,role: "employee",- // icon: <FaRulerVertical />,+ icon: <FaRulerVertical />,},],},diff --git a/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLineForm.tsx b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLineForm.tsxindex c34b137f2f..4045516abe 100644--- a/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLineForm.tsx+++ b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLineForm.tsx@@ -153,7 +153,7 @@ const PurchaseOrderLineForm = ({case "Part":case "Tool":case "Fixture":- const [item, itemSupplier, inventory] = await Promise.all([+ const [item, buyMethod, inventory] = await Promise.all([supabase.from("item").select(@@ -163,14 +163,14 @@ const PurchaseOrderLineForm = ({.eq("companyId", company.id).single(),supabase- .from("itemSupplier")+ .from("buyMethod").select("*").eq("itemId", itemId).eq("companyId", company.id).eq("supplierId", routeData?.purchaseOrder.supplierId!).maybeSingle(),supabase- .from("itemInventory")+ .from("pickMethod").select("defaultShelfId").eq("itemId", itemId).eq("companyId", company.id)@@ -185,8 +185,8 @@ const PurchaseOrderLineForm = ({itemId: itemId,itemReadableId: item.data?.readableId ?? "",description: item.data?.name ?? "",- purchaseQuantity: itemSupplier?.data?.minimumOrderQuantity ?? 1,- unitPrice: itemSupplier?.data?.unitPrice ?? itemCost?.unitCost ?? 0,+ purchaseQuantity: buyMethod?.data?.minimumOrderQuantity ?? 1,+ unitPrice: buyMethod?.data?.unitPrice ?? itemCost?.unitCost ?? 0,purchaseUom:itemReplenishment?.purchasingUnitOfMeasureCode ??item.data?.unitOfMeasureCode ??@@ -235,7 +235,7 @@ const PurchaseOrderLineForm = ({setLocationId(newLocation.value);if (!itemData.itemId) return;const shelf = await supabase- .from("itemInventory")+ .from("pickMethod").select("defaultShelfId").eq("itemId", itemData.itemId).eq("companyId", company.id)diff --git a/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderLineForm.tsx b/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderLineForm.tsxindex 63a7fc125c..36e47359d0 100644--- a/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderLineForm.tsx+++ b/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderLineForm.tsx@@ -134,7 +134,7 @@ const SalesOrderLineForm = ({ initialValues }: SalesOrderLineFormProps) => {.eq("companyId", company.id).single(),supabase- .from("itemInventory")+ .from("pickMethod").select("defaultShelfId").eq("itemId", itemId).eq("companyId", company.id)@@ -166,7 +166,7 @@ const SalesOrderLineForm = ({ initialValues }: SalesOrderLineFormProps) => {setLocationId(newLocation.value);if (!itemData.itemId) return;const shelf = await supabase- .from("itemInventory")+ .from("pickMethod").select("defaultShelfId").eq("itemId", itemData.itemId).eq("companyId", company.id)diff --git a/apps/carbon/app/routes/x+/consumable+/$itemId.inventory.tsx b/apps/carbon/app/routes/x+/consumable+/$itemId.inventory.tsxindex 4796224530..df70006dc0 100644--- a/apps/carbon/app/routes/x+/consumable+/$itemId.inventory.tsx+++ b/apps/carbon/app/routes/x+/consumable+/$itemId.inventory.tsx@@ -4,12 +4,12 @@ import { json, redirect } from "@remix-run/node";import { useLoaderData } from "@remix-run/react";import { useRouteData } from "~/hooks";import {- ItemInventoryForm,- getItemInventory,+ PickMethodForm,getItemQuantities,+ getPickMethod,getShelvesList,- itemInventoryValidator,- upsertItemInventory,+ pickMethodValidator,+ upsertPickMethod,} from "~/modules/items";import { getLocationsList } from "~/modules/resources";import { getUserDefaults } from "~/modules/users/users.server";@@ -63,12 +63,12 @@ export async function loader({ request, params }: LoaderFunctionArgs) {}let [consumableInventory, shelves] = await Promise.all([- getItemInventory(client, itemId, companyId, locationId),+ getPickMethod(client, itemId, companyId, locationId),getShelvesList(client, locationId),]);if (consumableInventory.error || !consumableInventory.data) {- const insertItemInventory = await upsertItemInventory(client, {+ const insertPickMethod = await upsertPickMethod(client, {itemId,companyId,locationId,@@ -76,20 +76,17 @@ export async function loader({ request, params }: LoaderFunctionArgs) {createdBy: userId,});- if (insertItemInventory.error) {+ if (insertPickMethod.error) {throw redirect(path.to.consumable(itemId),await flash(request,- error(- insertItemInventory.error,- "Failed to insert consumable inventory"- )+ error(insertPickMethod.error, "Failed to insert consumable inventory")));}- consumableInventory = await getItemInventory(+ consumableInventory = await getPickMethod(client,itemId,companyId,@@ -150,7 +147,7 @@ export async function action({ request, params }: ActionFunctionArgs) {const formData = await request.formData();// validate with consumablesValidator- const validation = await validator(itemInventoryValidator).validate(formData);+ const validation = await validator(pickMethodValidator).validate(formData);if (validation.error) {return validationError(validation.error);@@ -158,21 +155,18 @@ export async function action({ request, params }: ActionFunctionArgs) {const { ...update } = validation.data;- const updateItemInventory = await upsertItemInventory(client, {+ const updatePickMethod = await upsertPickMethod(client, {...update,itemId,customFields: setCustomFields(formData),updatedBy: userId,});- if (updateItemInventory.error) {+ if (updatePickMethod.error) {throw redirect(path.to.consumable(itemId),await flash(request,- error(- updateItemInventory.error,- "Failed to update consumable inventory"- )+ error(updatePickMethod.error, "Failed to update consumable inventory")));}@@ -196,7 +190,7 @@ export default function ConsumableInventoryRoute() {...getCustomFields(consumableInventory.customFields ?? {}),};return (- <ItemInventoryForm+ <PickMethodFormkey={initialValues.itemId}initialValues={initialValues}quantities={quantities}diff --git a/apps/carbon/app/routes/x+/consumable+/$itemId.suppliers.new.tsx b/apps/carbon/app/routes/x+/consumable+/$itemId.suppliers.new.tsxindex 9b670e7b55..f238b35b99 100644--- a/apps/carbon/app/routes/x+/consumable+/$itemId.suppliers.new.tsx+++ b/apps/carbon/app/routes/x+/consumable+/$itemId.suppliers.new.tsx@@ -3,9 +3,9 @@ import type { ActionFunctionArgs } from "@remix-run/node";import { redirect } from "@remix-run/node";import { useParams } from "@remix-run/react";import {- ItemSupplierForm,- itemSupplierValidator,- upsertItemSupplier,+ BuyMethodForm,+ buyMethodValidator,+ upsertBuyMethod,} from "~/modules/items";import { requirePermissions } from "~/services/auth/auth.server";import { flash } from "~/services/session.server";@@ -24,7 +24,7 @@ export async function action({ request, params }: ActionFunctionArgs) {if (!itemId) throw new Error("Could not find itemId");const formData = await request.formData();- const validation = await validator(itemSupplierValidator).validate(formData);+ const validation = await validator(buyMethodValidator).validate(formData);if (validation.error) {return validationError(validation.error);@@ -32,7 +32,7 @@ export async function action({ request, params }: ActionFunctionArgs) {const { id, ...data } = validation.data;- const createConsumableSupplier = await upsertItemSupplier(client, {+ const createConsumableSupplier = await upsertBuyMethod(client, {...data,companyId,createdBy: userId,@@ -70,5 +70,5 @@ export default function NewConsumableSupplierRoute() {conversionFactor: 1,};- return <ItemSupplierForm type="Consumable" initialValues={initialValues} />;+ return <BuyMethodForm type="Consumable" initialValues={initialValues} />;}diff --git a/apps/carbon/app/routes/x+/consumable+/$itemId.suppliers.tsx b/apps/carbon/app/routes/x+/consumable+/$itemId.suppliers.tsxindex 120898e410..573da9f518 100644--- a/apps/carbon/app/routes/x+/consumable+/$itemId.suppliers.tsx+++ b/apps/carbon/app/routes/x+/consumable+/$itemId.suppliers.tsx@@ -1,7 +1,7 @@import type { LoaderFunctionArgs } from "@remix-run/node";import { json, redirect } from "@remix-run/node";import { useLoaderData } from "@remix-run/react";-import { ItemSuppliers, getItemSuppliers } from "~/modules/items";+import { BuyMethods, getBuyMethods } from "~/modules/items";import { requirePermissions } from "~/services/auth/auth.server";import { flash } from "~/services/session.server";import { path } from "~/utils/path";@@ -16,7 +16,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {if (!itemId) throw new Error("Could not find itemId");const [suppliers] = await Promise.all([- getItemSuppliers(client, itemId, companyId),+ getBuyMethods(client, itemId, companyId),]);if (suppliers.error) {@@ -37,5 +37,5 @@ export async function loader({ request, params }: LoaderFunctionArgs) {export default function ConsumableSuppliersRoute() {const { suppliers } = useLoaderData<typeof loader>();- return <ItemSuppliers suppliers={suppliers} />;+ return <BuyMethods buyMethods={suppliers} />;}diff --git a/apps/carbon/app/routes/x+/consumable+/$itemId.tsx b/apps/carbon/app/routes/x+/consumable+/$itemId.tsxindex 73060543a0..64ae1da224 100644--- a/apps/carbon/app/routes/x+/consumable+/$itemId.tsx+++ b/apps/carbon/app/routes/x+/consumable+/$itemId.tsx@@ -8,9 +8,16 @@ import {} from "~/modules/items";import { requirePermissions } from "~/services/auth/auth.server";import { flash } from "~/services/session.server";+import type { Handle } from "~/utils/handle";import { path } from "~/utils/path";import { error } from "~/utils/result";+export const handle: Handle = {+ breadcrumb: "Consumables",+ to: path.to.consumables,+ module: "parts",+};+export async function loader({ request, params }: LoaderFunctionArgs) {const { client, companyId } = await requirePermissions(request, {view: "parts",diff --git a/apps/carbon/app/routes/x+/fixture+/$itemId.inventory.tsx b/apps/carbon/app/routes/x+/fixture+/$itemId.inventory.tsxindex 6db6913b7e..6378b59e0c 100644--- a/apps/carbon/app/routes/x+/fixture+/$itemId.inventory.tsx+++ b/apps/carbon/app/routes/x+/fixture+/$itemId.inventory.tsx@@ -4,12 +4,12 @@ import { json, redirect } from "@remix-run/node";import { useLoaderData } from "@remix-run/react";import { useRouteData } from "~/hooks";import {- ItemInventoryForm,- getItemInventory,+ PickMethodForm,getItemQuantities,+ getPickMethod,getShelvesList,- itemInventoryValidator,- upsertItemInventory,+ pickMethodValidator,+ upsertPickMethod,} from "~/modules/items";import { getLocationsList } from "~/modules/resources";import { getUserDefaults } from "~/modules/users/users.server";@@ -63,12 +63,12 @@ export async function loader({ request, params }: LoaderFunctionArgs) {}let [fixtureInventory, shelves] = await Promise.all([- getItemInventory(client, itemId, companyId, locationId),+ getPickMethod(client, itemId, companyId, locationId),getShelvesList(client, locationId),]);if (fixtureInventory.error || !fixtureInventory.data) {- const insertItemInventory = await upsertItemInventory(client, {+ const insertPickMethod = await upsertPickMethod(client, {itemId,companyId,locationId,@@ -76,17 +76,17 @@ export async function loader({ request, params }: LoaderFunctionArgs) {createdBy: userId,});- if (insertItemInventory.error) {+ if (insertPickMethod.error) {throw redirect(path.to.fixture(itemId),await flash(request,- error(insertItemInventory.error, "Failed to insert fixture inventory")+ error(insertPickMethod.error, "Failed to insert fixture inventory")));}- fixtureInventory = await getItemInventory(+ fixtureInventory = await getPickMethod(client,itemId,companyId,@@ -144,7 +144,7 @@ export async function action({ request, params }: ActionFunctionArgs) {const formData = await request.formData();// validate with fixturesValidator- const validation = await validator(itemInventoryValidator).validate(formData);+ const validation = await validator(pickMethodValidator).validate(formData);if (validation.error) {return validationError(validation.error);@@ -152,18 +152,18 @@ export async function action({ request, params }: ActionFunctionArgs) {const { ...update } = validation.data;- const updateItemInventory = await upsertItemInventory(client, {+ const updatePickMethod = await upsertPickMethod(client, {...update,itemId,customFields: setCustomFields(formData),updatedBy: userId,});- if (updateItemInventory.error) {+ if (updatePickMethod.error) {throw redirect(path.to.fixture(itemId),await flash(request,- error(updateItemInventory.error, "Failed to update fixture inventory")+ error(updatePickMethod.error, "Failed to update fixture inventory")));}@@ -187,7 +187,7 @@ export default function FixtureInventoryRoute() {...getCustomFields(fixtureInventory.customFields ?? {}),};return (- <ItemInventoryForm+ <PickMethodFormkey={initialValues.itemId}initialValues={initialValues}quantities={quantities}diff --git a/apps/carbon/app/routes/x+/fixture+/$itemId.suppliers.new.tsx b/apps/carbon/app/routes/x+/fixture+/$itemId.suppliers.new.tsxindex 158ddfeff4..da9d92dbdf 100644--- a/apps/carbon/app/routes/x+/fixture+/$itemId.suppliers.new.tsx+++ b/apps/carbon/app/routes/x+/fixture+/$itemId.suppliers.new.tsx@@ -3,9 +3,9 @@ import type { ActionFunctionArgs } from "@remix-run/node";import { redirect } from "@remix-run/node";import { useParams } from "@remix-run/react";import {- ItemSupplierForm,- itemSupplierValidator,- upsertItemSupplier,+ BuyMethodForm,+ buyMethodValidator,+ upsertBuyMethod,} from "~/modules/items";import { requirePermissions } from "~/services/auth/auth.server";import { flash } from "~/services/session.server";@@ -24,7 +24,7 @@ export async function action({ request, params }: ActionFunctionArgs) {if (!itemId) throw new Error("Could not find itemId");const formData = await request.formData();- const validation = await validator(itemSupplierValidator).validate(formData);+ const validation = await validator(buyMethodValidator).validate(formData);if (validation.error) {return validationError(validation.error);@@ -32,7 +32,7 @@ export async function action({ request, params }: ActionFunctionArgs) {const { id, ...data } = validation.data;- const createFixtureSupplier = await upsertItemSupplier(client, {+ const createFixtureSupplier = await upsertBuyMethod(client, {...data,companyId,createdBy: userId,@@ -67,5 +67,5 @@ export default function NewFixtureSupplierRoute() {conversionFactor: 1,};- return <ItemSupplierForm type="Fixture" initialValues={initialValues} />;+ return <BuyMethodForm type="Fixture" initialValues={initialValues} />;}diff --git a/apps/carbon/app/routes/x+/fixture+/$itemId.suppliers.tsx b/apps/carbon/app/routes/x+/fixture+/$itemId.suppliers.tsxindex 1f8c58b296..98faa27725 100644--- a/apps/carbon/app/routes/x+/fixture+/$itemId.suppliers.tsx+++ b/apps/carbon/app/routes/x+/fixture+/$itemId.suppliers.tsx@@ -1,7 +1,7 @@import type { LoaderFunctionArgs } from "@remix-run/node";import { json, redirect } from "@remix-run/node";import { useLoaderData } from "@remix-run/react";-import { ItemSuppliers, getItemSuppliers } from "~/modules/items";+import { BuyMethods, getBuyMethods } from "~/modules/items";import { requirePermissions } from "~/services/auth/auth.server";import { flash } from "~/services/session.server";import { path } from "~/utils/path";@@ -16,7 +16,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {if (!itemId) throw new Error("Could not find itemId");const [suppliers] = await Promise.all([- getItemSuppliers(client, itemId, companyId),+ getBuyMethods(client, itemId, companyId),]);if (suppliers.error) {@@ -37,5 +37,5 @@ export async function loader({ request, params }: LoaderFunctionArgs) {export default function ConsumableSuppliersRoute() {const { suppliers } = useLoaderData<typeof loader>();- return <ItemSuppliers suppliers={suppliers} />;+ return <BuyMethods buyMethods={suppliers} />;}diff --git a/apps/carbon/app/routes/x+/items+/forms.$formId.tsx b/apps/carbon/app/routes/x+/items+/forms.$formId.tsxindex a7c5d192f6..62c2ca34e6 100644--- a/apps/carbon/app/routes/x+/items+/forms.$formId.tsx+++ b/apps/carbon/app/routes/x+/items+/forms.$formId.tsx@@ -3,7 +3,7 @@ import type { ActionFunctionArgs, LoaderFunctionArgs } from "@remix-run/node";import { json, redirect } from "@remix-run/node";import { useLoaderData, useNavigate } from "@remix-run/react";import {- MaterialFormForm,+ MaterialShapeForm,getMaterialForm,materialFormValidator,upsertMaterialForm,@@ -81,7 +81,7 @@ export default function EditMaterialFormsRoute() {};return (- <MaterialFormForm+ <MaterialShapeFormkey={initialValues.id}initialValues={initialValues}onClose={() => navigate(-1)}diff --git a/apps/carbon/app/routes/x+/items+/forms.new.tsx b/apps/carbon/app/routes/x+/items+/forms.new.tsxindex 3b25736ee1..a67d436093 100644--- a/apps/carbon/app/routes/x+/items+/forms.new.tsx+++ b/apps/carbon/app/routes/x+/items+/forms.new.tsx@@ -3,7 +3,7 @@ import type { ActionFunctionArgs, LoaderFunctionArgs } from "@remix-run/node";import { json, redirect } from "@remix-run/node";import { useNavigate } from "@remix-run/react";import {- MaterialFormForm,+ MaterialShapeForm,materialFormValidator,upsertMaterialForm,} from "~/modules/items";@@ -82,7 +82,7 @@ export default function NewMaterialFormsRoute() {};return (- <MaterialFormForm+ <MaterialShapeFormonClose={() => navigate(-1)}initialValues={initialValues}/>diff --git a/apps/carbon/app/routes/x+/items+/forms.tsx b/apps/carbon/app/routes/x+/items+/forms.tsxindex 2f2a829671..92919aa8cb 100644--- a/apps/carbon/app/routes/x+/items+/forms.tsx+++ b/apps/carbon/app/routes/x+/items+/forms.tsx@@ -11,7 +11,7 @@ import { getGenericQueryFilters } from "~/utils/query";import { error } from "~/utils/result";export const handle: Handle = {- breadcrumb: "Forms",+ breadcrumb: "Shapes",to: path.to.materialForms,};diff --git a/apps/carbon/app/routes/x+/material+/$itemId.inventory.tsx b/apps/carbon/app/routes/x+/material+/$itemId.inventory.tsxindex c131aea5bc..6a9a29cfa8 100644--- a/apps/carbon/app/routes/x+/material+/$itemId.inventory.tsx+++ b/apps/carbon/app/routes/x+/material+/$itemId.inventory.tsx@@ -4,12 +4,12 @@ import { json, redirect } from "@remix-run/node";import { useLoaderData } from "@remix-run/react";import { useRouteData } from "~/hooks";import {- ItemInventoryForm,- getItemInventory,+ PickMethodForm,getItemQuantities,+ getPickMethod,getShelvesList,- itemInventoryValidator,- upsertItemInventory,+ pickMethodValidator,+ upsertPickMethod,} from "~/modules/items";import { getLocationsList } from "~/modules/resources";import { getUserDefaults } from "~/modules/users/users.server";@@ -63,12 +63,12 @@ export async function loader({ request, params }: LoaderFunctionArgs) {}let [materialInventory, shelves] = await Promise.all([- getItemInventory(client, itemId, companyId, locationId),+ getPickMethod(client, itemId, companyId, locationId),getShelvesList(client, locationId),]);if (materialInventory.error || !materialInventory.data) {- const insertItemInventory = await upsertItemInventory(client, {+ const insertPickMethod = await upsertPickMethod(client, {itemId,companyId,locationId,@@ -76,20 +76,17 @@ export async function loader({ request, params }: LoaderFunctionArgs) {createdBy: userId,});- if (insertItemInventory.error) {+ if (insertPickMethod.error) {throw redirect(path.to.material(itemId),await flash(request,- error(- insertItemInventory.error,- "Failed to insert material inventory"- )+ error(insertPickMethod.error, "Failed to insert material inventory")));}- materialInventory = await getItemInventory(+ materialInventory = await getPickMethod(client,itemId,companyId,@@ -147,7 +144,7 @@ export async function action({ request, params }: ActionFunctionArgs) {const formData = await request.formData();// validate with materialsValidator- const validation = await validator(itemInventoryValidator).validate(formData);+ const validation = await validator(pickMethodValidator).validate(formData);if (validation.error) {return validationError(validation.error);@@ -155,18 +152,18 @@ export async function action({ request, params }: ActionFunctionArgs) {const { ...update } = validation.data;- const updateItemInventory = await upsertItemInventory(client, {+ const updatePickMethod = await upsertPickMethod(client, {...update,itemId,customFields: setCustomFields(formData),updatedBy: userId,});- if (updateItemInventory.error) {+ if (updatePickMethod.error) {throw redirect(path.to.material(itemId),await flash(request,- error(updateItemInventory.error, "Failed to update material inventory")+ error(updatePickMethod.error, "Failed to update material inventory")));}@@ -190,7 +187,7 @@ export default function MaterialInventoryRoute() {...getCustomFields(materialInventory.customFields ?? {}),};return (- <ItemInventoryForm+ <PickMethodFormkey={initialValues.itemId}initialValues={initialValues}quantities={quantities}diff --git a/apps/carbon/app/routes/x+/material+/$itemId.suppliers.new.tsx b/apps/carbon/app/routes/x+/material+/$itemId.suppliers.new.tsxindex c13e77d161..bb43396dde 100644--- a/apps/carbon/app/routes/x+/material+/$itemId.suppliers.new.tsx+++ b/apps/carbon/app/routes/x+/material+/$itemId.suppliers.new.tsx@@ -3,9 +3,9 @@ import type { ActionFunctionArgs } from "@remix-run/node";import { redirect } from "@remix-run/node";import { useParams } from "@remix-run/react";import {- ItemSupplierForm,- itemSupplierValidator,- upsertItemSupplier,+ BuyMethodForm,+ buyMethodValidator,+ upsertBuyMethod,} from "~/modules/items";import { requirePermissions } from "~/services/auth/auth.server";import { flash } from "~/services/session.server";@@ -24,7 +24,7 @@ export async function action({ request, params }: ActionFunctionArgs) {if (!itemId) throw new Error("Could not find itemId");const formData = await request.formData();- const validation = await validator(itemSupplierValidator).validate(formData);+ const validation = await validator(buyMethodValidator).validate(formData);if (validation.error) {return validationError(validation.error);@@ -32,7 +32,7 @@ export async function action({ request, params }: ActionFunctionArgs) {const { id, ...data } = validation.data;- const createMaterialSupplier = await upsertItemSupplier(client, {+ const createMaterialSupplier = await upsertBuyMethod(client, {...data,companyId,createdBy: userId,@@ -70,5 +70,5 @@ export default function NewMaterialSupplierRoute() {conversionFactor: 1,};- return <ItemSupplierForm type="Material" initialValues={initialValues} />;+ return <BuyMethodForm type="Material" initialValues={initialValues} />;}diff --git a/apps/carbon/app/routes/x+/material+/$itemId.suppliers.tsx b/apps/carbon/app/routes/x+/material+/$itemId.suppliers.tsxindex 7ee6555172..b6742c13af 100644--- a/apps/carbon/app/routes/x+/material+/$itemId.suppliers.tsx+++ b/apps/carbon/app/routes/x+/material+/$itemId.suppliers.tsx@@ -1,7 +1,7 @@import type { LoaderFunctionArgs } from "@remix-run/node";import { json, redirect } from "@remix-run/node";import { useLoaderData } from "@remix-run/react";-import { ItemSuppliers, getItemSuppliers } from "~/modules/items";+import { BuyMethods, getBuyMethods } from "~/modules/items";import { requirePermissions } from "~/services/auth/auth.server";import { flash } from "~/services/session.server";import { path } from "~/utils/path";@@ -16,7 +16,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {if (!itemId) throw new Error("Could not find itemId");const [suppliers] = await Promise.all([- getItemSuppliers(client, itemId, companyId),+ getBuyMethods(client, itemId, companyId),]);if (suppliers.error) {@@ -37,5 +37,5 @@ export async function loader({ request, params }: LoaderFunctionArgs) {export default function MaterialSuppliersRoute() {const { suppliers } = useLoaderData<typeof loader>();- return <ItemSuppliers suppliers={suppliers} />;+ return <BuyMethods buyMethods={suppliers} />;}diff --git a/apps/carbon/app/routes/x+/material+/$itemId.tsx b/apps/carbon/app/routes/x+/material+/$itemId.tsxindex 55485f03c6..4a527a2321 100644--- a/apps/carbon/app/routes/x+/material+/$itemId.tsx+++ b/apps/carbon/app/routes/x+/material+/$itemId.tsx@@ -8,9 +8,16 @@ import {} from "~/modules/items";import { requirePermissions } from "~/services/auth/auth.server";import { flash } from "~/services/session.server";+import type { Handle } from "~/utils/handle";import { path } from "~/utils/path";import { error } from "~/utils/result";+export const handle: Handle = {+ breadcrumb: "Materials",+ to: path.to.materials,+ module: "parts",+};+export async function loader({ request, params }: LoaderFunctionArgs) {const { client, companyId } = await requirePermissions(request, {view: "parts",diff --git a/apps/carbon/app/routes/x+/part+/$itemId.costing.tsx b/apps/carbon/app/routes/x+/part+/$itemId.costing.tsxindex ef4d410f36..2d886b72f2 100644--- a/apps/carbon/app/routes/x+/part+/$itemId.costing.tsx+++ b/apps/carbon/app/routes/x+/part+/$itemId.costing.tsx@@ -1,3 +1,4 @@+import { VStack } from "@carbon/react";import { validationError, validator } from "@carbon/remix-validated-form";import type { ActionFunctionArgs, LoaderFunctionArgs } from "@remix-run/node";import { json, redirect } from "@remix-run/node";@@ -89,9 +90,14 @@ export async function action({ request, params }: ActionFunctionArgs) {export default function PartCostingRoute() {const { itemCost } = useLoaderData<typeof loader>();return (- <ItemCostingForm- key={itemCost.itemId}- initialValues={{ ...itemCost, ...getCustomFields(itemCost.customFields) }}- />+ <VStack spacing={2} className="p-2">+ <ItemCostingForm+ key={itemCost.itemId}+ initialValues={{+ ...itemCost,+ ...getCustomFields(itemCost.customFields),+ }}+ />+ </VStack>);}diff --git a/apps/carbon/app/routes/x+/part+/$itemId.details.tsx b/apps/carbon/app/routes/x+/part+/$itemId.details.tsxindex e0bce46545..441f4834b4 100644--- a/apps/carbon/app/routes/x+/part+/$itemId.details.tsx+++ b/apps/carbon/app/routes/x+/part+/$itemId.details.tsx@@ -71,7 +71,7 @@ export default function PartDetailsRoute() {};return (- <VStack spacing={4}>+ <VStack spacing={2} className="p-2"><PartForm key={partInitialValues.id} initialValues={partInitialValues} /></VStack>);diff --git a/apps/carbon/app/routes/x+/part+/$itemId.inventory.tsx b/apps/carbon/app/routes/x+/part+/$itemId.inventory.tsxindex a35b6a43a2..091de99e81 100644--- a/apps/carbon/app/routes/x+/part+/$itemId.inventory.tsx+++ b/apps/carbon/app/routes/x+/part+/$itemId.inventory.tsx@@ -1,15 +1,16 @@+import { VStack } from "@carbon/react";import { validationError, validator } from "@carbon/remix-validated-form";import type { ActionFunctionArgs, LoaderFunctionArgs } from "@remix-run/node";import { json, redirect } from "@remix-run/node";import { useLoaderData } from "@remix-run/react";import { useRouteData } from "~/hooks";import {- ItemInventoryForm,- getItemInventory,+ PickMethodForm,getItemQuantities,+ getPickMethod,getShelvesList,- itemInventoryValidator,- upsertItemInventory,+ pickMethodValidator,+ upsertPickMethod,} from "~/modules/items";import { getLocationsList } from "~/modules/resources";import { getUserDefaults } from "~/modules/users/users.server";@@ -63,12 +64,12 @@ export async function loader({ request, params }: LoaderFunctionArgs) {}let [partInventory, shelves] = await Promise.all([- getItemInventory(client, itemId, companyId, locationId),+ getPickMethod(client, itemId, companyId, locationId),getShelvesList(client, locationId),]);if (partInventory.error || !partInventory.data) {- const insertItemInventory = await upsertItemInventory(client, {+ const insertPickMethod = await upsertPickMethod(client, {itemId,companyId,locationId,@@ -76,22 +77,17 @@ export async function loader({ request, params }: LoaderFunctionArgs) {createdBy: userId,});- if (insertItemInventory.error) {+ if (insertPickMethod.error) {throw redirect(path.to.part(itemId),await flash(request,- error(insertItemInventory.error, "Failed to insert part inventory")+ error(insertPickMethod.error, "Failed to insert part inventory")));}- partInventory = await getItemInventory(- client,- itemId,- companyId,- locationId- );+ partInventory = await getPickMethod(client, itemId, companyId, locationId);if (partInventory.error || !partInventory.data) {throw redirect(path.to.part(itemId),@@ -141,7 +137,7 @@ export async function action({ request, params }: ActionFunctionArgs) {const formData = await request.formData();// validate with partsValidator- const validation = await validator(itemInventoryValidator).validate(formData);+ const validation = await validator(pickMethodValidator).validate(formData);if (validation.error) {return validationError(validation.error);@@ -149,18 +145,18 @@ export async function action({ request, params }: ActionFunctionArgs) {const { ...update } = validation.data;- const updateItemInventory = await upsertItemInventory(client, {+ const updatePickMethod = await upsertPickMethod(client, {...update,itemId,customFields: setCustomFields(formData),updatedBy: userId,});- if (updateItemInventory.error) {+ if (updatePickMethod.error) {throw redirect(path.to.part(itemId),await flash(request,- error(updateItemInventory.error, "Failed to update part inventory")+ error(updatePickMethod.error, "Failed to update part inventory")));}@@ -172,7 +168,7 @@ export async function action({ request, params }: ActionFunctionArgs) {}export default function PartInventoryRoute() {- const sharedPartssData = useRouteData<{ locations: ListItem[] }>(+ const sharedPartsData = useRouteData<{ locations: ListItem[] }>(path.to.partRoot);const { partInventory, quantities, shelves } = useLoaderData<typeof loader>();@@ -183,13 +179,15 @@ export default function PartInventoryRoute() {...getCustomFields(partInventory.customFields ?? {}),};return (- <ItemInventoryForm- key={initialValues.itemId}- initialValues={initialValues}- quantities={quantities}- locations={sharedPartssData?.locations ?? []}- shelves={shelves}- type="Part"- />+ <VStack spacing={2} className="p-2">+ <PickMethodForm+ key={initialValues.itemId}+ initialValues={initialValues}+ quantities={quantities}+ locations={sharedPartsData?.locations ?? []}+ shelves={shelves}+ type="Part"+ />+ </VStack>);}diff --git a/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.tsx b/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.tsxindex e5a89a4dc4..c926028035 100644--- a/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.tsx+++ b/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.tsx@@ -1,13 +1,39 @@+import {+ Badge,+ Button,+ Card,+ CardAction,+ CardContent,+ CardHeader,+ CardTitle,+ ClientOnly,+ HStack,+ IconButton,+ Input,+ InputGroup,+ InputLeftElement,+ ResizableHandle,+ ResizablePanel,+ ResizablePanelGroup,+ VStack,+ cn,+} from "@carbon/react";+import { TreeView, useTree } from "~/components/TreeView/TreeView";+import { validationError, validator } from "@carbon/remix-validated-form";import type { ActionFunctionArgs, LoaderFunctionArgs } from "@remix-run/node";-import { json, redirect } from "@remix-run/node";-import { useLoaderData } from "@remix-run/react";+import { useParams } from "@remix-run/react";+import { useRef, useState } from "react";+import { LuChevronDown, LuChevronUp, LuPlus, LuSearch } from "react-icons/lu";+import { redirect, typedjson, useTypedLoaderData } from "remix-typedjson";import {+ MethodIcon,PartManufacturingForm,getItemManufacturing,partManufacturingValidator,upsertItemManufacturing,} from "~/modules/items";+import type { StandardFactor } from "~/modules/shared";import { requirePermissions } from "~/services/auth/auth.server";import { flash } from "~/services/session.server";import { getCustomFields, setCustomFields } from "~/utils/form";@@ -15,6 +41,23 @@ import { assertIsPost } from "~/utils/http";import { path } from "~/utils/path";import { error, success } from "~/utils/result";+type Method = {+ id: string;+ parentId: string | undefined;+ children: string[];+ hasChildren: boolean;+ level: number;+ data: {+ itemId: string;+ readableId: string;+ description: string;+ quantity: number;+ fulfillmentMethod: "Buy" | "Make" | "Pick";+ isInherited: boolean;+ isRoot: boolean;+ };+};+export async function loader({ request, params }: LoaderFunctionArgs) {const { client, companyId } = await requirePermissions(request, {view: "parts",@@ -34,16 +77,80 @@ export async function loader({ request, params }: LoaderFunctionArgs) {path.to.items,await flash(request,- error(- partManufacturing.error,- "Failed to load part manufacturingturing"- )+ error(partManufacturing.error, "Failed to load part manufacturing")));}- return json({+ return typedjson({partManufacturing: partManufacturing.data,+ methods: [+ {+ id: "1",+ parentId: undefined,+ hasChildren: true,+ children: ["2", "3"],+ level: 0,+ data: {+ itemId: "1",+ readableId: "F02134",+ description: '1/2" x 3" x 4" Bracket',+ quantity: 1,+ fulfillmentMethod: "Make",+ isInherited: false,+ isRoot: true,+ },+ },+ {+ id: "2",+ parentId: "1",+ hasChildren: true,+ children: ["4"],+ level: 1,+ data: {+ itemId: "2",+ readableId: "F501932",+ description: '1/2" x 3" x 4" Cutout',+ quantity: 1,+ fulfillmentMethod: "Make",+ isInherited: false,+ isRoot: false,+ },+ },++ {+ id: "4",+ parentId: "2",+ hasChildren: false,+ children: [],+ level: 2,+ data: {+ itemId: "4",+ readableId: "F41858",+ description: "1/8 X 5/8 6061-T6511 Aluminum Flat",+ quantity: 2.8,+ fulfillmentMethod: "Pick",+ isInherited: true,+ isRoot: false,+ },+ },+ {+ id: "3",+ parentId: "1",+ hasChildren: false,+ children: [],+ level: 1,+ data: {+ itemId: "3",+ readableId: "91772A061",+ description: '5/16" Threaded Machine Screw',+ quantity: 4,+ fulfillmentMethod: "Buy",+ isInherited: false,+ isRoot: false,+ },+ },+ ] satisfies Method[],});}@@ -90,19 +197,275 @@ export async function action({ request, params }: ActionFunctionArgs) {);}-export default function PartManufacturingRoute() {- const { partManufacturing } = useLoaderData<typeof loader>();+export default function Item() {+ const { methods, partManufacturing } = useTypedLoaderData<typeof loader>();+ const { itemId } = useParams();+ if (!itemId) throw new Error("Could not find itemId");- const initialValues = {+ const manufacturingInitialValues = {...partManufacturing,lotSize: partManufacturing.lotSize ?? 0,...getCustomFields(partManufacturing.customFields),};return (- <PartManufacturingForm- key={initialValues.itemId}- initialValues={initialValues}+ <div className="flex flex-grow overflow-hidden">+ <ClientOnly fallback={null}>+ {() => (+ <ResizablePanelGroup direction="horizontal">+ <ResizablePanel+ order={1}+ minSize={20}+ defaultSize={20}+ className="bg-card"+ >+ <div className="grid h-full overflow-hidden p-2">+ <BoMExplorer+ methods={methods}+ onSelectedIdChanged={(selectedId) => {+ console.log(selectedId);+ }}+ />+ </div>+ </ResizablePanel>+ <ResizableHandle withHandle />++ <ResizablePanel+ order={2}+ minSize={40}+ defaultSize={60}+ className="border-t border-border"+ >+ <VStack spacing={2} className="p-2">+ <PartManufacturingForm+ key={itemId}+ initialValues={manufacturingInitialValues}+ />+ <BillOfProcesses key={itemId} processes={[]} />+ </VStack>+ </ResizablePanel>+ <ResizableHandle withHandle />+ <ResizablePanel+ order={3}+ minSize={20}+ defaultSize={20}+ className="bg-card p-4 overflow-y-auto flex flex-col gap-4"+ >+ <VStack spacing={2}>+ <h3 className="text-xs text-muted-foreground">Properties</h3>+ </VStack>+ </ResizablePanel>+ </ResizablePanelGroup>+ )}+ </ClientOnly>+ </div>+ );+}++type Process = {+ workCenterTypeId: string;+ equipmentTypeId?: string;+ setupHours: number;+ standardFactor: StandardFactor;+ productionStandard: number;+};++function BillOfProcesses({ processes }: { processes: Process[] }) {+ return (+ <Card>+ <HStack className="justify-between">+ <CardHeader>+ <CardTitle>Bill of Processes</CardTitle>+ </CardHeader>++ <CardAction>+ <Button variant="secondary">Add Process</Button>+ </CardAction>+ </HStack>+ <CardContent></CardContent>+ </Card>+ );+}++type BoMExplorerProps = {+ methods: Method[];+ selectedId?: string;+ onSelectedIdChanged: (selectedId: string | undefined) => void;+};++function BoMExplorer({+ methods,+ selectedId,+ onSelectedIdChanged,+}: BoMExplorerProps) {+ const [filterText, setFilterText] = useState("");+ const parentRef = useRef<HTMLDivElement>(null);++ const {+ nodes,+ getTreeProps,+ getNodeProps,+ toggleNodeSelection,+ toggleExpandNode,+ expandAllBelowDepth,+ toggleExpandLevel,+ collapseAllBelowDepth,+ selectNode,+ scrollToNode,+ virtualizer,+ } = useTree({+ tree: methods,+ selectedId,+ // collapsedIds,+ onSelectedIdChanged,+ estimatedRowHeight: () => 32,+ parentRef,+ filter: {+ value: { text: filterText },+ fn: (value, node) => {+ if (value.text === "") return true;+ if (+ node.data.readableId.toLowerCase().includes(value.text.toLowerCase())+ ) {+ return true;+ }+ return false;+ },+ },+ });++ return (+ <VStack>+ <HStack className="w-full">+ <InputGroup size="sm" className="flex flex-grow">+ <InputLeftElement>+ <LuSearch className="h-4 w-4" />+ </InputLeftElement>+ <Input+ placeholder="Search..."+ value={filterText}+ onChange={(e) => setFilterText(e.target.value)}+ />+ </InputGroup>+ <IconButton+ aria-label="Add"+ variant="secondary"+ icon={<LuPlus className="h-4 w-4" />}+ />+ </HStack>+ <TreeView+ parentRef={parentRef}+ virtualizer={virtualizer}+ autoFocus+ tree={methods}+ nodes={nodes}+ getNodeProps={getNodeProps}+ getTreeProps={getTreeProps}+ renderNode={({ node, state }) => (+ <>+ <div+ className={cn(+ "flex h-8 cursor-pointer items-center overflow-hidden rounded-sm pr-2",+ state.selected+ ? "bg-muted hover:bg-muted/90"+ : "bg-transparent hover:bg-muted/90"+ )}+ onClick={() => {+ selectNode(node.id);+ }}+ >+ <div className="flex h-8 items-center">+ {Array.from({ length: node.level }).map((_, index) => (+ <TaskLine key={index} isSelected={state.selected} />+ ))}+ <div+ className={cn(+ "flex h-8 w-4 items-center",+ node.hasChildren && "hover:bg-accent"+ )}+ onClick={(e) => {+ e.stopPropagation();+ if (e.altKey) {+ if (state.expanded) {+ collapseAllBelowDepth(node.level);+ } else {+ expandAllBelowDepth(node.level);+ }+ } else {+ toggleExpandNode(node.id);+ }+ scrollToNode(node.id);+ }}+ >+ {node.hasChildren ? (+ state.expanded ? (+ <LuChevronDown className="h-4 w-4 text-gray-400" />+ ) : (+ <LuChevronUp className="h-4 w-4 text-gray-400" />+ )+ ) : (+ <div className="h-8 w-4" />+ )}+ </div>+ </div>++ <div className="flex w-full items-center justify-between gap-2">+ <div+ className={cn(+ "flex items-center gap-2 overflow-x-hidden",+ node.data.isInherited && "opacity-50"+ )}+ >+ <MethodIcon+ type={+ // node.data.isRoot ? "Method" :+ node.data.fulfillmentMethod+ }+ className="h-4 min-h-4 w-4 min-w-4"+ />+ <NodeText node={node} />+ </div>+ <div className="flex items-center gap-1">+ {node.data.isRoot ? (+ <Badge variant="outline" className="text-xs">+ Method+ </Badge>+ ) : (+ <NodeQuantity node={node} />+ )}+ </div>+ </div>+ </div>+ </>+ )}+ />+ </VStack>+ );+}++function NodeText({ node }: { node: Method }) {+ return (+ <div className="flex items-center gap-1">+ <span className="text-sm font-mono">{node.data.readableId}</span>+ </div>+ );+}++function NodeQuantity({ node }: { node: Method }) {+ return (+ <Badge className="text-xs" variant="outline">+ {node.data.quantity}+ </Badge>+ );+}++function TaskLine({ isSelected }: { isSelected: boolean }) {+ return (+ <div+ className={cn(+ "h-8 w-2 border-r border-border",+ isSelected && "border-foreground/30"+ )}/>);}diff --git a/apps/carbon/app/routes/x+/part+/$itemId.planning.tsx b/apps/carbon/app/routes/x+/part+/$itemId.planning.tsxindex 0d0924ce76..14cccc6d7f 100644--- a/apps/carbon/app/routes/x+/part+/$itemId.planning.tsx+++ b/apps/carbon/app/routes/x+/part+/$itemId.planning.tsx@@ -1,3 +1,4 @@+import { VStack } from "@carbon/react";import { validationError, validator } from "@carbon/remix-validated-form";import type { ActionFunctionArgs, LoaderFunctionArgs } from "@remix-run/node";import { json, redirect } from "@remix-run/node";@@ -150,14 +151,16 @@ export default function PartPlanningRoute() {if (!sharedPartsData) throw new Error("Could not load shared parts data");return (- <ItemPlanningForm- key={partPlanning.itemId}- initialValues={{- ...partPlanning,- ...getCustomFields(partPlanning.customFields),- }}- locations={sharedPartsData.locations ?? []}- type="Part"- />+ <VStack spacing={2} className="p-2">+ <ItemPlanningForm+ key={partPlanning.itemId}+ initialValues={{+ ...partPlanning,+ ...getCustomFields(partPlanning.customFields),+ }}+ locations={sharedPartsData.locations ?? []}+ type="Part"+ />+ </VStack>);}diff --git a/apps/carbon/app/routes/x+/part+/$itemId.suppliers.new.tsx b/apps/carbon/app/routes/x+/part+/$itemId.purchasing.new.tsxsimilarity index 81%rename from apps/carbon/app/routes/x+/part+/$itemId.suppliers.new.tsxrename to apps/carbon/app/routes/x+/part+/$itemId.purchasing.new.tsxindex b54ff8bc90..dde0d15894 100644--- a/apps/carbon/app/routes/x+/part+/$itemId.suppliers.new.tsx+++ b/apps/carbon/app/routes/x+/part+/$itemId.purchasing.new.tsx@@ -3,9 +3,9 @@ import type { ActionFunctionArgs } from "@remix-run/node";import { redirect } from "@remix-run/node";import { useParams } from "@remix-run/react";import {- ItemSupplierForm,- itemSupplierValidator,- upsertItemSupplier,+ BuyMethodForm,+ buyMethodValidator,+ upsertBuyMethod,} from "~/modules/items";import { requirePermissions } from "~/services/auth/auth.server";import { flash } from "~/services/session.server";@@ -24,7 +24,7 @@ export async function action({ request, params }: ActionFunctionArgs) {if (!itemId) throw new Error("Could not find itemId");const formData = await request.formData();- const validation = await validator(itemSupplierValidator).validate(formData);+ const validation = await validator(buyMethodValidator).validate(formData);if (validation.error) {return validationError(validation.error);@@ -32,7 +32,7 @@ export async function action({ request, params }: ActionFunctionArgs) {const { id, ...data } = validation.data;- const createPartSupplier = await upsertItemSupplier(client, {+ const createPartSupplier = await upsertBuyMethod(client, {...data,companyId,createdBy: userId,@@ -41,7 +41,7 @@ export async function action({ request, params }: ActionFunctionArgs) {if (createPartSupplier.error) {throw redirect(- path.to.partSuppliers(itemId),+ path.to.partPurchasing(itemId),await flash(request,error(createPartSupplier.error, "Failed to create part supplier")@@ -49,7 +49,7 @@ export async function action({ request, params }: ActionFunctionArgs) {);}- throw redirect(path.to.partSuppliers(itemId));+ throw redirect(path.to.partPurchasing(itemId));}export default function NewPartSupplierRoute() {@@ -67,5 +67,5 @@ export default function NewPartSupplierRoute() {conversionFactor: 1,};- return <ItemSupplierForm type="Part" initialValues={initialValues} />;+ return <BuyMethodForm type="Part" initialValues={initialValues} />;}diff --git a/apps/carbon/app/routes/x+/part+/$itemId.purchasing.tsx b/apps/carbon/app/routes/x+/part+/$itemId.purchasing.tsxindex a9688c2523..171ba7db07 100644--- a/apps/carbon/app/routes/x+/part+/$itemId.purchasing.tsx+++ b/apps/carbon/app/routes/x+/part+/$itemId.purchasing.tsx@@ -1,8 +1,12 @@+import { VStack } from "@carbon/react";import { validationError, validator } from "@carbon/remix-validated-form";import type { ActionFunctionArgs, LoaderFunctionArgs } from "@remix-run/node";import { json, redirect } from "@remix-run/node";-import { useLoaderData } from "@remix-run/react";+import { useLoaderData, useParams } from "@remix-run/react";+import { useRouteData } from "~/hooks";+import type { BuyMethod } from "~/modules/items";import {+ BuyMethods,ItemPurchasingForm,getItemReplenishment,itemPurchasingValidator,@@ -22,7 +26,9 @@ export async function loader({ request, params }: LoaderFunctionArgs) {const { itemId } = params;if (!itemId) throw new Error("Could not find itemId");- const partPurchasing = await getItemReplenishment(client, itemId, companyId);+ const [partPurchasing] = await Promise.all([+ getItemReplenishment(client, itemId, companyId),+ ]);if (partPurchasing.error) {throw redirect(@@ -81,6 +87,13 @@ export async function action({ request, params }: ActionFunctionArgs) {export default function PartPurchasingRoute() {const { partPurchasing } = useLoaderData<typeof loader>();+ const { itemId } = useParams();+ if (!itemId) throw new Error("Could not find itemId");+ const routeData = useRouteData<{ buyMethods: BuyMethod[] }>(+ path.to.part(itemId)+ );+ const buyMethods = routeData?.buyMethods ?? [];+const initialValues = {...partPurchasing,preferredSupplierId: partPurchasing?.preferredSupplierId ?? undefined,@@ -92,9 +105,15 @@ export default function PartPurchasingRoute() {};return (- <ItemPurchasingForm- key={initialValues.itemId}- initialValues={initialValues}- />+ <VStack spacing={2} className="p-2">+ <ItemPurchasingForm+ key={initialValues.itemId}+ initialValues={initialValues}+ allowedSuppliers={+ buyMethods.map((s) => s.supplier?.id).filter(Boolean) as string[]+ }+ />+ <BuyMethods buyMethods={buyMethods} />+ </VStack>);}diff --git a/apps/carbon/app/routes/x+/part+/$itemId.sale-price.tsx b/apps/carbon/app/routes/x+/part+/$itemId.sale-price.tsxindex d7c662988b..82770c8545 100644--- a/apps/carbon/app/routes/x+/part+/$itemId.sale-price.tsx+++ b/apps/carbon/app/routes/x+/part+/$itemId.sale-price.tsx@@ -1,3 +1,4 @@+import { VStack } from "@carbon/react";import { validationError, validator } from "@carbon/remix-validated-form";import type { ActionFunctionArgs, LoaderFunctionArgs } from "@remix-run/node";import { json, redirect } from "@remix-run/node";@@ -92,9 +93,11 @@ export default function PartSalePriceRoute() {};return (- <ItemSalePriceForm- key={initialValues.itemId}- initialValues={initialValues}- />+ <VStack spacing={2} className="p-2">+ <ItemSalePriceForm+ key={initialValues.itemId}+ initialValues={initialValues}+ />+ </VStack>);}diff --git a/apps/carbon/app/routes/x+/part+/$itemId.suppliers.tsx b/apps/carbon/app/routes/x+/part+/$itemId.suppliers.tsxdeleted file mode 100644index d70d7ea8a4..0000000000--- a/apps/carbon/app/routes/x+/part+/$itemId.suppliers.tsx+++ /dev/null@@ -1,41 +0,0 @@-import type { LoaderFunctionArgs } from "@remix-run/node";-import { json, redirect } from "@remix-run/node";-import { useLoaderData } from "@remix-run/react";-import { ItemSuppliers, getItemSuppliers } from "~/modules/items";-import { requirePermissions } from "~/services/auth/auth.server";-import { flash } from "~/services/session.server";-import { path } from "~/utils/path";-import { error } from "~/utils/result";--export async function loader({ request, params }: LoaderFunctionArgs) {- const { client, companyId } = await requirePermissions(request, {- view: "parts",- });-- const { itemId } = params;- if (!itemId) throw new Error("Could not find itemId");-- const [suppliers] = await Promise.all([- getItemSuppliers(client, itemId, companyId),- ]);-- if (suppliers.error) {- throw redirect(- path.to.part(itemId),- await flash(- request,- error(suppliers.error, "Failed to load part suppliers")- )- );- }-- return json({- suppliers: suppliers.data ?? [],- });-}--export default function PartSuppliersRoute() {- const { suppliers } = useLoaderData<typeof loader>();-- return <ItemSuppliers suppliers={suppliers} />;-}diff --git a/apps/carbon/app/routes/x+/part+/$itemId.tsx b/apps/carbon/app/routes/x+/part+/$itemId.tsxindex 8b394e9554..574b4d63f5 100644--- a/apps/carbon/app/routes/x+/part+/$itemId.tsx+++ b/apps/carbon/app/routes/x+/part+/$itemId.tsx@@ -1,12 +1,41 @@+import {+ Badge,+ Button,+ Enumerable,+ HStack,+ Tooltip,+ TooltipContent,+ TooltipTrigger,+ VStack,+ cn,+} from "@carbon/react";import type { LoaderFunctionArgs } from "@remix-run/node";import { json, redirect } from "@remix-run/node";-import { Outlet } from "@remix-run/react";-import { PartHeader, PartNavigation, getPart } from "~/modules/items";+import { Link, Outlet, useMatches, useParams } from "@remix-run/react";+import { LuCopy, LuExternalLink, LuLink } from "react-icons/lu";+import Assignee, { useOptimisticAssignment } from "~/components/Assignee";+import { useRouteData } from "~/hooks";+import type { BuyMethod, PartSummary, PickMethod } from "~/modules/items";+import {+ MethodIcon,+ PartHeader,+ getBuyMethods,+ getPart,+ getPickMethods,+} from "~/modules/items";import { requirePermissions } from "~/services/auth/auth.server";import { flash } from "~/services/session.server";+import type { ListItem } from "~/types";+import type { Handle } from "~/utils/handle";import { path } from "~/utils/path";import { error } from "~/utils/result";+export const handle: Handle = {+ breadcrumb: "Parts",+ to: path.to.parts,+ module: "parts",+};+export async function loader({ request, params }: LoaderFunctionArgs) {const { client, companyId } = await requirePermissions(request, {view: "parts",@@ -15,7 +44,11 @@ export async function loader({ request, params }: LoaderFunctionArgs) {const { itemId } = params;if (!itemId) throw new Error("Could not find itemId");- const [partSummary] = await Promise.all([getPart(client, itemId, companyId)]);+ const [partSummary, buyMethods, pickMethods] = await Promise.all([+ getPart(client, itemId, companyId),+ getBuyMethods(client, itemId, companyId),+ getPickMethods(client, itemId, companyId),+ ]);if (partSummary.error) {throw redirect(@@ -29,17 +62,201 @@ export async function loader({ request, params }: LoaderFunctionArgs) {return json({partSummary: partSummary.data,+ buyMethods: buyMethods.data ?? [],+ pickMethods: pickMethods.data ?? [],});}export default function PartRoute() {+ const matches = useMatches();+ const isManufacturing = matches.some(+ (match) => match.id === "routes/x+/part+/$itemId.manufacturing"+ );+return (- <>+ <div className="flex flex-col h-[calc(100vh-49px)] w-full"><PartHeader />- <div className="grid grid-cols-1 md:grid-cols-[1fr_4fr] h-full w-full gap-4">- <PartNavigation />- <Outlet />+ <div className="flex h-[calc(100vh-99px)] w-full">+ <div className="flex h-full w-full overflow-y-auto">+ <Outlet />+ </div>+ {!isManufacturing && <PartProperties />}</div>- </>+ </div>+ );+}++export const PartProperties = () => {+ const { itemId } = useParams();+ if (!itemId) throw new Error("itemId not found");++ const sharedPartsData = useRouteData<{ locations: ListItem[] }>(+ path.to.partRoot);+ const routeData = useRouteData<{+ partSummary: PartSummary;+ buyMethods: BuyMethod[];+ pickMethods: PickMethod[];+ }>(path.to.part(itemId));++ const locations = sharedPartsData?.locations ?? [];+ const buyMethods = routeData?.buyMethods ?? [];+ const pickMethods = routeData?.pickMethods ?? [];++ const optimisticAssignment = useOptimisticAssignment({+ id: itemId,+ table: "item",+ });+ const assignee =+ optimisticAssignment !== undefined+ ? optimisticAssignment+ : routeData?.partSummary?.assignee;++ return (+ <VStack+ spacing={4}+ className="w-96 bg-card h-full overflow-y-auto border-l border-border p-4"+ >+ <VStack spacing={2}>+ <HStack className="w-full justify-between">+ <h3 className="text-xs text-muted-foreground">Properties</h3>+ <HStack spacing={1}>+ <Tooltip>+ <TooltipTrigger asChild>+ <Button+ variant="ghost"+ aria-label="Link"+ size="sm"+ className="p-1"+ onClick={() =>+ navigator.clipboard.writeText(+ window.location.origin + path.to.part(itemId)+ )+ }+ >+ <LuLink className="w-3 h-3" />+ </Button>+ </TooltipTrigger>+ <TooltipContent>+ <span>Copy link to part</span>+ </TooltipContent>+ </Tooltip>+ <Tooltip>+ <TooltipTrigger asChild>+ <Button+ variant="ghost"+ aria-label="Copy"+ size="sm"+ className="p-1"+ onClick={() =>+ navigator.clipboard.writeText(+ routeData?.partSummary?.id ?? ""+ )+ }+ >+ <LuCopy className="w-3 h-3" />+ </Button>+ </TooltipTrigger>+ <TooltipContent>+ <span>Copy part number</span>+ </TooltipContent>+ </Tooltip>+ </HStack>+ </HStack>+ <span className="text-sm">{routeData?.partSummary?.name}</span>+ </VStack>+ <VStack spacing={2}>+ <h3 className="text-xs text-muted-foreground">Assignee</h3>+ <Assignee id={itemId} table="item" value={assignee ?? ""} />+ </VStack>++ <VStack spacing={2}>+ <h3 className="text-xs text-muted-foreground">Replenishment</h3>+ <Enumerable+ className={cn(+ (routeData?.partSummary?.active === false ||+ routeData?.partSummary?.blocked) &&+ "opacity-50"+ )}+ value={routeData?.partSummary?.replenishmentSystem ?? null}+ />+ </VStack>++ <VStack spacing={2}>+ <h3 className="text-xs text-muted-foreground">Inventory Type</h3>+ <Enumerable+ className={cn(+ (routeData?.partSummary?.active === false ||+ routeData?.partSummary?.blocked) &&+ "opacity-50"+ )}+ value={routeData?.partSummary?.itemInventoryType ?? null}+ />+ </VStack>++ <VStack spacing={2}>+ <h3 className="text-xs text-muted-foreground">Unit of Measure</h3>+ <Enumerable value={routeData?.partSummary?.unitOfMeasure ?? null} />+ </VStack>++ <VStack spacing={2}>+ <HStack className="w-full justify-between">+ <h3 className="text-xs text-muted-foreground">Methods</h3>+ </HStack>+ {buyMethods.map((method) => (+ <MethodBadge+ key={method.id}+ type="Buy"+ text={method?.supplier?.name ?? ""}+ to={path.to.partPurchasing(itemId)}+ />+ ))}+ {pickMethods.map((method) => (+ <MethodBadge+ key={method.locationId}+ type="Pick"+ text={+ method.defaultShelfId ??+ locations.find((l) => l.id === method.locationId)?.name ??+ ""+ }+ to={path.to.partInventoryLocation(itemId, method.locationId)}+ />+ ))}+ </VStack>+ </VStack>+ );+};++type MethodBadgeProps = {+ type: "Buy" | "Make" | "Pick";+ text: string;+ to: string;+ className?: string;+};++function MethodBadge({ type, text, to, className }: MethodBadgeProps) {+ return (+ <HStack className="group" spacing={1}>+ <Badge className={cn(getBadgeColor(type), className)}>+ <MethodIcon type={type} className="w-3 h-3 mr-1 text-white" />+ {text}+ </Badge>+ <Link+ className="group-hover:opacity-100 opacity-0 transition-opacity duration-200 w-4 h-4 text-foreground"+ to={to}+ prefetch="intent"+ >+ <LuExternalLink />+ </Link>+ </HStack>+ );+}++function getBadgeColor(type: "Buy" | "Make" | "Pick") {+ return type === "Buy"+ ? "bg-blue-500 hover:bg-blue-600 text-white"+ : type === "Make"+ ? "bg-green-500 hover:bg-green-600 text-white"+ : "bg-orange-500 hover:bg-orange-600 text-white";}diff --git a/apps/carbon/app/routes/x+/part+/_layout.tsx b/apps/carbon/app/routes/x+/part+/_layout.tsxindex 1a4d0aba1f..db5d566ffe 100644--- a/apps/carbon/app/routes/x+/part+/_layout.tsx+++ b/apps/carbon/app/routes/x+/part+/_layout.tsx@@ -1,4 +1,3 @@-import { VStack } from "@carbon/react";import type { LoaderFunctionArgs, MetaFunction } from "@remix-run/node";import { Outlet } from "@remix-run/react";import { getUnitOfMeasuresList } from "~/modules/items";@@ -34,9 +33,5 @@ export async function loader({ request }: LoaderFunctionArgs) {}export default function PartRoute() {- return (- <VStack spacing={4} className="h-full p-4">- <Outlet />- </VStack>- );+ return <Outlet />;}diff --git a/apps/carbon/app/routes/x+/service+/$itemId.suppliers.new.tsx b/apps/carbon/app/routes/x+/service+/$itemId.suppliers.new.tsxindex 5b7e459460..4c409a25bd 100644--- a/apps/carbon/app/routes/x+/service+/$itemId.suppliers.new.tsx+++ b/apps/carbon/app/routes/x+/service+/$itemId.suppliers.new.tsx@@ -3,9 +3,9 @@ import type { ActionFunctionArgs } from "@remix-run/node";import { redirect } from "@remix-run/node";import { useParams } from "@remix-run/react";import {- ItemSupplierForm,- itemSupplierValidator,- upsertItemSupplier,+ BuyMethodForm,+ buyMethodValidator,+ upsertBuyMethod,} from "~/modules/items";import { requirePermissions } from "~/services/auth/auth.server";import { flash } from "~/services/session.server";@@ -24,7 +24,7 @@ export async function action({ request, params }: ActionFunctionArgs) {if (!itemId) throw new Error("Could not find itemId");const formData = await request.formData();- const validation = await validator(itemSupplierValidator).validate(formData);+ const validation = await validator(buyMethodValidator).validate(formData);if (validation.error) {return validationError(validation.error);@@ -32,7 +32,7 @@ export async function action({ request, params }: ActionFunctionArgs) {const { id, ...data } = validation.data;- const createPartSupplier = await upsertItemSupplier(client, {+ const createPartSupplier = await upsertBuyMethod(client, {...data,companyId,createdBy: userId,@@ -67,5 +67,5 @@ export default function NewPartSupplierRoute() {conversionFactor: 1,};- return <ItemSupplierForm type="Service" initialValues={initialValues} />;+ return <BuyMethodForm type="Service" initialValues={initialValues} />;}diff --git a/apps/carbon/app/routes/x+/service+/$itemId.suppliers.tsx b/apps/carbon/app/routes/x+/service+/$itemId.suppliers.tsxindex 95cfe1e457..868d77c260 100644--- a/apps/carbon/app/routes/x+/service+/$itemId.suppliers.tsx+++ b/apps/carbon/app/routes/x+/service+/$itemId.suppliers.tsx@@ -1,8 +1,8 @@import type { LoaderFunctionArgs } from "@remix-run/node";import { json, redirect } from "@remix-run/node";import { useLoaderData } from "@remix-run/react";-import { getItemSuppliers } from "~/modules/items";-import ItemSuppliers from "~/modules/items/ui/Item/ItemSuppliers/ItemSuppliers";+import { getBuyMethods } from "~/modules/items";+import BuyMethods from "~/modules/items/ui/Item/BuyMethods/BuyMethods";import { requirePermissions } from "~/services/auth/auth.server";import { flash } from "~/services/session.server";import { path } from "~/utils/path";@@ -17,7 +17,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {if (!itemId) throw new Error("Could not find itemId");const [suppliers] = await Promise.all([- getItemSuppliers(client, itemId, companyId),+ getBuyMethods(client, itemId, companyId),]);if (suppliers.error) {@@ -38,5 +38,5 @@ export async function loader({ request, params }: LoaderFunctionArgs) {export default function ServiceSuppliersRoute() {const { suppliers } = useLoaderData<typeof loader>();- return <ItemSuppliers suppliers={suppliers} />;+ return <BuyMethods buyMethods={suppliers} />;}diff --git a/apps/carbon/app/routes/x+/tool+/$itemId.inventory.tsx b/apps/carbon/app/routes/x+/tool+/$itemId.inventory.tsxindex bb76ae2133..493901e010 100644--- a/apps/carbon/app/routes/x+/tool+/$itemId.inventory.tsx+++ b/apps/carbon/app/routes/x+/tool+/$itemId.inventory.tsx@@ -4,12 +4,12 @@ import { json, redirect } from "@remix-run/node";import { useLoaderData } from "@remix-run/react";import { useRouteData } from "~/hooks";import {- ItemInventoryForm,- getItemInventory,+ PickMethodForm,getItemQuantities,+ getPickMethod,getShelvesList,- itemInventoryValidator,- upsertItemInventory,+ pickMethodValidator,+ upsertPickMethod,} from "~/modules/items";import { getLocationsList } from "~/modules/resources";import { getUserDefaults } from "~/modules/users/users.server";@@ -63,12 +63,12 @@ export async function loader({ request, params }: LoaderFunctionArgs) {}let [toolInventory, shelves] = await Promise.all([- getItemInventory(client, itemId, companyId, locationId),+ getPickMethod(client, itemId, companyId, locationId),getShelvesList(client, locationId),]);if (toolInventory.error || !toolInventory.data) {- const insertItemInventory = await upsertItemInventory(client, {+ const insertPickMethod = await upsertPickMethod(client, {itemId,companyId,locationId,@@ -76,22 +76,17 @@ export async function loader({ request, params }: LoaderFunctionArgs) {createdBy: userId,});- if (insertItemInventory.error) {+ if (insertPickMethod.error) {throw redirect(path.to.tool(itemId),await flash(request,- error(insertItemInventory.error, "Failed to insert tool inventory")+ error(insertPickMethod.error, "Failed to insert tool inventory")));}- toolInventory = await getItemInventory(- client,- itemId,- companyId,- locationId- );+ toolInventory = await getPickMethod(client, itemId, companyId, locationId);if (toolInventory.error || !toolInventory.data) {throw redirect(path.to.tool(itemId),@@ -141,7 +136,7 @@ export async function action({ request, params }: ActionFunctionArgs) {const formData = await request.formData();// validate with toolsValidator- const validation = await validator(itemInventoryValidator).validate(formData);+ const validation = await validator(pickMethodValidator).validate(formData);if (validation.error) {return validationError(validation.error);@@ -149,18 +144,18 @@ export async function action({ request, params }: ActionFunctionArgs) {const { ...update } = validation.data;- const updateItemInventory = await upsertItemInventory(client, {+ const updatePickMethod = await upsertPickMethod(client, {...update,itemId,customFields: setCustomFields(formData),updatedBy: userId,});- if (updateItemInventory.error) {+ if (updatePickMethod.error) {throw redirect(path.to.tool(itemId),await flash(request,- error(updateItemInventory.error, "Failed to update tool inventory")+ error(updatePickMethod.error, "Failed to update tool inventory")));}@@ -183,7 +178,7 @@ export default function ToolInventoryRoute() {...getCustomFields(toolInventory.customFields ?? {}),};return (- <ItemInventoryForm+ <PickMethodFormkey={initialValues.itemId}initialValues={initialValues}quantities={quantities}diff --git a/apps/carbon/app/routes/x+/tool+/$itemId.suppliers.new.tsx b/apps/carbon/app/routes/x+/tool+/$itemId.suppliers.new.tsxindex 2a3f9f7584..401a03f48b 100644--- a/apps/carbon/app/routes/x+/tool+/$itemId.suppliers.new.tsx+++ b/apps/carbon/app/routes/x+/tool+/$itemId.suppliers.new.tsx@@ -3,9 +3,9 @@ import type { ActionFunctionArgs } from "@remix-run/node";import { redirect } from "@remix-run/node";import { useParams } from "@remix-run/react";import {- ItemSupplierForm,- itemSupplierValidator,- upsertItemSupplier,+ BuyMethodForm,+ buyMethodValidator,+ upsertBuyMethod,} from "~/modules/items";import { requirePermissions } from "~/services/auth/auth.server";import { flash } from "~/services/session.server";@@ -24,7 +24,7 @@ export async function action({ request, params }: ActionFunctionArgs) {if (!itemId) throw new Error("Could not find itemId");const formData = await request.formData();- const validation = await validator(itemSupplierValidator).validate(formData);+ const validation = await validator(buyMethodValidator).validate(formData);if (validation.error) {return validationError(validation.error);@@ -32,7 +32,7 @@ export async function action({ request, params }: ActionFunctionArgs) {const { id, ...data } = validation.data;- const createToolSupplier = await upsertItemSupplier(client, {+ const createToolSupplier = await upsertBuyMethod(client, {...data,companyId,createdBy: userId,@@ -67,5 +67,5 @@ export default function NewToolSupplierRoute() {conversionFactor: 1,};- return <ItemSupplierForm type="Tool" initialValues={initialValues} />;+ return <BuyMethodForm type="Tool" initialValues={initialValues} />;}diff --git a/apps/carbon/app/routes/x+/tool+/$itemId.suppliers.tsx b/apps/carbon/app/routes/x+/tool+/$itemId.suppliers.tsxindex 145dbc0b18..714e879e46 100644--- a/apps/carbon/app/routes/x+/tool+/$itemId.suppliers.tsx+++ b/apps/carbon/app/routes/x+/tool+/$itemId.suppliers.tsx@@ -1,7 +1,7 @@import type { LoaderFunctionArgs } from "@remix-run/node";import { json, redirect } from "@remix-run/node";import { useLoaderData } from "@remix-run/react";-import { ItemSuppliers, getItemSuppliers } from "~/modules/items";+import { BuyMethods, getBuyMethods } from "~/modules/items";import { requirePermissions } from "~/services/auth/auth.server";import { flash } from "~/services/session.server";import { path } from "~/utils/path";@@ -16,7 +16,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {if (!itemId) throw new Error("Could not find itemId");const [suppliers] = await Promise.all([- getItemSuppliers(client, itemId, companyId),+ getBuyMethods(client, itemId, companyId),]);if (suppliers.error) {@@ -37,5 +37,5 @@ export async function loader({ request, params }: LoaderFunctionArgs) {export default function ToolSuppliersRoute() {const { suppliers } = useLoaderData<typeof loader>();- return <ItemSuppliers suppliers={suppliers} />;+ return <BuyMethods buyMethods={suppliers} />;}diff --git a/apps/carbon/app/routes/x+/tool+/$itemId.tsx b/apps/carbon/app/routes/x+/tool+/$itemId.tsxindex 29865d75a0..8eb566c562 100644--- a/apps/carbon/app/routes/x+/tool+/$itemId.tsx+++ b/apps/carbon/app/routes/x+/tool+/$itemId.tsx@@ -4,9 +4,16 @@ import { Outlet } from "@remix-run/react";import { ToolHeader, ToolNavigation, getTool } from "~/modules/items";import { requirePermissions } from "~/services/auth/auth.server";import { flash } from "~/services/session.server";+import type { Handle } from "~/utils/handle";import { path } from "~/utils/path";import { error } from "~/utils/result";+export const handle: Handle = {+ breadcrumb: "Tools",+ to: path.to.tools,+ module: "parts",+};+export async function loader({ request, params }: LoaderFunctionArgs) {const { client, companyId } = await requirePermissions(request, {view: "parts",diff --git a/apps/carbon/app/routes/x+/wip+/index.tsx b/apps/carbon/app/routes/x+/wip+/index.tsxdeleted file mode 100644index 388de147bc..0000000000--- a/apps/carbon/app/routes/x+/wip+/index.tsx+++ /dev/null@@ -1,417 +0,0 @@-import {- Badge,- ClientOnly,- Enumerable,- HStack,- Heading,- IconButton,- Input,- InputGroup,- InputLeftElement,- ResizableHandle,- ResizablePanel,- ResizablePanelGroup,- VStack,- cn,-} from "@carbon/react";-import { Link, type LinkProps } from "@remix-run/react";-import { TreeView, useTree } from "~/components/TreeView/TreeView";--import type { LoaderFunctionArgs } from "@remix-run/node";-import { useRef, useState } from "react";-import { AiOutlinePartition } from "react-icons/ai";-import { FaCodePullRequest } from "react-icons/fa6";-import { HiSquares2X2 } from "react-icons/hi2";-import {- LuChevronDown,- LuChevronUp,- LuHammer,- LuPlus,- LuSearch,- LuShoppingCart,-} from "react-icons/lu";-import { typedjson, useTypedLoaderData } from "remix-typedjson";--type Method = {- id: string;- parentId: string | undefined;- children: string[];- hasChildren: boolean;- level: number;- data: {- itemId: string;- readableId: string;- description: string;- quantity: number;- fulfillmentMethod: "Buy" | "Make" | "Pick";- isInherited: boolean;- isRoot: boolean;- };-};--export async function loader({ request }: LoaderFunctionArgs) {- return typedjson({- methods: [- {- id: "1",- parentId: undefined,- hasChildren: true,- children: ["2", "3"],- level: 0,- data: {- itemId: "1",- readableId: "F02134",- description: '1/2" x 3" x 4" Bracket',- quantity: 1,- fulfillmentMethod: "Make",- isInherited: false,- isRoot: true,- },- },- {- id: "2",- parentId: "1",- hasChildren: true,- children: ["4"],- level: 1,- data: {- itemId: "2",- readableId: "F501932",- description: '1/2" x 3" x 4" Cutout',- quantity: 1,- fulfillmentMethod: "Make",- isInherited: false,- isRoot: false,- },- },-- {- id: "4",- parentId: "2",- hasChildren: false,- children: [],- level: 2,- data: {- itemId: "4",- readableId: "F41858",- description: "1/8 X 5/8 6061-T6511 Aluminum Flat",- quantity: 2.8,- fulfillmentMethod: "Pick",- isInherited: true,- isRoot: false,- },- },- {- id: "3",- parentId: "1",- hasChildren: false,- children: [],- level: 1,- data: {- itemId: "3",- readableId: "91772A061",- description: '5/16" Threaded Machine Screw',- quantity: 4,- fulfillmentMethod: "Buy",- isInherited: false,- isRoot: false,- },- },- ] satisfies Method[],- });-}--export default function Item() {- const { methods } = useTypedLoaderData<typeof loader>();-- return (- <div className="flex flex-col w-full h-full">- <div className="flex flex-shrink-0 items-center justify-between px-4 py-2 bg-card border-b border-border">- <div className="flex flex-col flex-grow">- <HStack>- <Heading size="h2">F02134</Heading>- <Enumerable value="Part" />- </HStack>- <p className="text-sm text-muted-foreground">- 1/2" x 3" x 4" Bracket- </p>- </div>- <div className="flex flex-col flex-shrink justify-center items-end">- <Tabs>- <TabTrigger to="details">Details</TabTrigger>- <TabTrigger to="purchasing">Purchasing</TabTrigger>- <TabTrigger to="sales">Sales</TabTrigger>- <TabTrigger isActive to="purchasing">- Production- </TabTrigger>- <TabTrigger to="inventory">Inventory</TabTrigger>- </Tabs>- </div>- </div>- <div className="flex flex-grow overflow-hidden">- <ClientOnly fallback={null}>- {() => (- <ResizablePanelGroup direction="horizontal">- {/* Tree list */}- <ResizablePanel- order={1}- minSize={20}- defaultSize={20}- className="bg-card"- >- <div className="grid h-full overflow-hidden p-2">- <BoMExplorer- methods={methods}- onSelectedIdChanged={(selectedId) => {- console.log(selectedId);- }}- />- </div>- </ResizablePanel>- <ResizableHandle withHandle />-- <ResizablePanel order={2} minSize={40} defaultSize={60}>- {/* Details */}- </ResizablePanel>- {/* <ResizableHandle withHandle />- <ResizablePanel- order={3}- minSize={20}- defaultSize={20}- className="bg-card"- >- <div className="grid h-full overflow-hidden p-2"></div>- </ResizablePanel> */}- </ResizablePanelGroup>- )}- </ClientOnly>- </div>- </div>- );-}--type BoMExplorerProps = {- methods: Method[];- selectedId?: string;- onSelectedIdChanged: (selectedId: string | undefined) => void;-};--function BoMExplorer({- methods,- selectedId,- onSelectedIdChanged,-}: BoMExplorerProps) {- const [filterText, setFilterText] = useState("");- const parentRef = useRef<HTMLDivElement>(null);-- const {- nodes,- getTreeProps,- getNodeProps,- toggleNodeSelection,- toggleExpandNode,- expandAllBelowDepth,- toggleExpandLevel,- collapseAllBelowDepth,- selectNode,- scrollToNode,- virtualizer,- } = useTree({- tree: methods,- selectedId,- // collapsedIds,- onSelectedIdChanged,- estimatedRowHeight: () => 32,- parentRef,- filter: {- value: { text: filterText },- fn: (value, node) => {- if (value.text === "") return true;- if (- node.data.readableId.toLowerCase().includes(value.text.toLowerCase())- ) {- return true;- }- return false;- },- },- });-- return (- <VStack>- <HStack className="w-full">- <InputGroup size="sm" className="flex flex-grow">- <InputLeftElement>- <LuSearch className="h-4 w-4" />- </InputLeftElement>- <Input- placeholder="Search..."- value={filterText}- onChange={(e) => setFilterText(e.target.value)}- />- </InputGroup>- <IconButton- aria-label="Add"- variant="secondary"- icon={<LuPlus className="h-4 w-4" />}- />- </HStack>- <TreeView- parentRef={parentRef}- virtualizer={virtualizer}- autoFocus- tree={methods}- nodes={nodes}- getNodeProps={getNodeProps}- getTreeProps={getTreeProps}- renderNode={({ node, state }) => (- <>- <div- className={cn(- "flex h-8 cursor-pointer items-center overflow-hidden rounded-sm pr-2",- state.selected- ? "bg-muted hover:bg-muted/90"- : "bg-transparent hover:bg-muted/90"- )}- onClick={() => {- selectNode(node.id);- }}- >- <div className="flex h-8 items-center">- {Array.from({ length: node.level }).map((_, index) => (- <TaskLine key={index} isSelected={state.selected} />- ))}- <div- className={cn(- "flex h-8 w-4 items-center",- node.hasChildren && "hover:bg-accent"- )}- onClick={(e) => {- e.stopPropagation();- if (e.altKey) {- if (state.expanded) {- collapseAllBelowDepth(node.level);- } else {- expandAllBelowDepth(node.level);- }- } else {- toggleExpandNode(node.id);- }- scrollToNode(node.id);- }}- >- {node.hasChildren ? (- state.expanded ? (- <LuChevronDown className="h-4 w-4 text-gray-400" />- ) : (- <LuChevronUp className="h-4 w-4 text-gray-400" />- )- ) : (- <div className="h-8 w-4" />- )}- </div>- </div>-- <div className="flex w-full items-center justify-between gap-2">- <div- className={cn(- "flex items-center gap-2 overflow-x-hidden",- node.data.isInherited && "opacity-50"- )}- >- <MethodIcon- type={- // node.data.isRoot ? "Method" :- node.data.fulfillmentMethod- }- className="h-4 min-h-4 w-4 min-w-4"- />- <NodeText node={node} />- </div>- <div className="flex items-center gap-1">- {node.data.isRoot ? (- <Badge variant="outline" className="text-xs">- Method- </Badge>- ) : (- <NodeQuantity node={node} />- )}- </div>- </div>- </div>- </>- )}- />- </VStack>- );-}--function MethodIcon({ type, className }: { type: string; className?: string }) {- switch (type) {- case "Method":- return (- <AiOutlinePartition className={cn(className, "text-foreground")} />- );- case "Buy":- return <LuShoppingCart className={cn(className, "text-blue-500")} />;- case "Make":- return <LuHammer className={cn(className, "text-green-500")} />;- case "Pick":- return <FaCodePullRequest className={cn(className, "text-yellow-500")} />;- }-- return <HiSquares2X2 className={cn(className, "text-muted-foreground")} />;-}--function NodeText({ node }: { node: Method }) {- return (- <div className="flex items-center gap-1">- <span className="text-sm font-mono">{node.data.readableId}</span>- </div>- );-}--function NodeQuantity({ node }: { node: Method }) {- return (- <Badge className="text-xs" variant="outline">- {node.data.quantity}- </Badge>- );-}--function TaskLine({ isSelected }: { isSelected: boolean }) {- return (- <div- className={cn(- "h-8 w-2 border-r border-border",- isSelected && "border-foreground/30"- )}- />- );-}--function Tabs({ children }: { children?: React.ReactNode }) {- return (- <div className="inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground">- {children}- </div>- );-}--function TabTrigger({- children,- isActive,- ...props-}: LinkProps & { isActive?: boolean }) {- return (- <Link- {...props}- className={cn(- "inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",- isActive && "bg-background text-foreground shadow"- )}- >- {children}- </Link>- );-}diff --git a/apps/carbon/app/utils/path.ts b/apps/carbon/app/utils/path.tsindex 9ce0a45d77..b36da70812 100644--- a/apps/carbon/app/utils/path.ts+++ b/apps/carbon/app/utils/path.ts@@ -364,7 +364,7 @@ export const path = {newCompany: `${x}/settings/company/new`,newConsumable: `${x}/consumable/new`,newConsumableSupplier: (id: string) =>- generatePath(`${x}/consumable/${id}/suppliers/new`),+ generatePath(`${x}/consumable/${id}/purchasing/new`),newContractor: `${x}/resources/contractors/new`,newCurrency: `${x}/accounting/currencies/new`,newCustomer: `${x}/customer/new`,@@ -389,7 +389,7 @@ export const path = {newEquipmentType: `${x}/resources/equipment/new`,newFixture: `${x}/fixture/new`,newFixtureSupplier: (id: string) =>- generatePath(`${x}/fixture/${id}/suppliers/new`),+ generatePath(`${x}/fixture/${id}/purchasing/new`),newGroup: `${x}/users/groups/new`,newHoliday: `${x}/resources/holidays/new`,newLocation: `${x}/resources/locations/new`,@@ -400,9 +400,9 @@ export const path = {newMaterialForm: `${x}/items/forms/new`,newMaterialSubstance: `${x}/items/substances/new`,newMaterialSupplier: (id: string) =>- generatePath(`${x}/material/${id}/suppliers/new`),+ generatePath(`${x}/material/${id}/purchasing/new`),newPartSupplier: (id: string) =>- generatePath(`${x}/part/${id}/suppliers/new`),+ generatePath(`${x}/part/${id}/purchasing/new`),newPartner: `${x}/resources/partners/new`,newPaymentTerm: `${x}/accounting/payment-terms/new`,newPurchaseInvoice: `${x}/purchase-invoice/new`,@@ -440,9 +440,9 @@ export const path = {newShippingMethod: `${x}/inventory/shipping-methods/new`,newService: `${x}/service/new`,newServiceSupplier: (id: string) =>- generatePath(`${x}/service/${id}/suppliers/new`),+ generatePath(`${x}/service/${id}/purchasing/new`),newSupplier: `${x}/supplier/new`,- newSupplierAccount: `${x}/users/suppliers/new`,+ newSupplierAccount: `${x}/users/purchasing/new`,newSupplierContact: (id: string) =>generatePath(`${x}/supplier/${id}/contacts/new`),newSupplierLocation: (id: string) =>@@ -451,7 +451,7 @@ export const path = {newSupplierType: `${x}/purchasing/supplier-types/new`,newTool: `${x}/tool/new`,newToolSupplier: (id: string) =>- generatePath(`${x}/tool/${id}/suppliers/new`),+ generatePath(`${x}/tool/${id}/purchasing/new`),newUom: `${x}/items/uom/new`,newWorkCell: `${x}/resources/work-cells/cell/new`,newWorkCellUnit: (id: string) =>@@ -474,7 +474,6 @@ export const path = {partSalePrice: (id: string) => generatePath(`${x}/part/${id}/sale-price`),partSupplier: (itemId: string, id: string) =>generatePath(`${x}/part/${itemId}/suppliers/${id}`),- partSuppliers: (id: string) => generatePath(`${x}/part/${id}/suppliers`),parts: `${x}/items/parts`,partner: (id: string, abilityId: string) =>generatePath(`${x}/resources/partners/${id}/${abilityId}`),diff --git a/apps/carbon/app/utils/string.ts b/apps/carbon/app/utils/string.tsindex ef49cd3cf0..2a922f7497 100644--- a/apps/carbon/app/utils/string.ts+++ b/apps/carbon/app/utils/string.ts@@ -3,6 +3,37 @@ export const capitalize = (words: string) => {return [first.toLocaleUpperCase(), ...otherLetters].join("");};+/**+ * Copy text content (string or Promise<string>) into Clipboard.+ * Safari doesn't support write text into clipboard async, so if you need to load+ * text content async before coping, please use Promise<string> for the 1st arg.+ */+export const copyToClipboard = async (+ str: string | Promise<string>,+ callback = () => {}+) => {+ const focused = window.document.hasFocus();+ if (focused) {+ if (+ navigator.clipboard &&+ typeof navigator.clipboard.writeText === "function"+ ) {+ const text = await Promise.resolve(str);+ Promise.resolve(window.navigator?.clipboard?.writeText(text)).then(+ callback+ );++ return;+ }++ Promise.resolve(str)+ .then((text) => window.navigator?.clipboard?.writeText(text))+ .then(callback);+ } else {+ console.warn("Unable to copy to clipboard");+ }+};+// used to generate sequencesexport const interpolateSequenceDate = (value: string | null) => {// replace all instances of %{year} with the current yeardiff --git a/packages/database/src/types.ts b/packages/database/src/types.tsindex 10206a411b..5044e66b70 100644--- a/packages/database/src/types.ts+++ b/packages/database/src/types.ts@@ -1622,6 +1622,208 @@ export type Database = {}Relationships: []}+ buyMethod: {+ Row: {+ active: boolean+ companyId: string+ conversionFactor: number+ createdAt: string+ createdBy: string+ customFields: Json | null+ id: string+ itemId: string+ minimumOrderQuantity: number | null+ supplierId: string+ supplierPartId: string | null+ supplierUnitOfMeasureCode: string | null+ unitPrice: number | null+ updatedAt: string | null+ updatedBy: string | null+ }+ Insert: {+ active?: boolean+ companyId: string+ conversionFactor?: number+ createdAt?: string+ createdBy: string+ customFields?: Json | null+ id?: string+ itemId: string+ minimumOrderQuantity?: number | null+ supplierId: string+ supplierPartId?: string | null+ supplierUnitOfMeasureCode?: string | null+ unitPrice?: number | null+ updatedAt?: string | null+ updatedBy?: string | null+ }+ Update: {+ active?: boolean+ companyId?: string+ conversionFactor?: number+ createdAt?: string+ createdBy?: string+ customFields?: Json | null+ id?: string+ itemId?: string+ minimumOrderQuantity?: number | null+ supplierId?: string+ supplierPartId?: string | null+ supplierUnitOfMeasureCode?: string | null+ unitPrice?: number | null+ updatedAt?: string | null+ updatedBy?: string | null+ }+ Relationships: [+ {+ foreignKeyName: "buyMethod_companyId_fkey"+ columns: ["companyId"]+ isOneToOne: false+ referencedRelation: "companies"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "buyMethod_companyId_fkey"+ columns: ["companyId"]+ isOneToOne: false+ referencedRelation: "company"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "buyMethod_companyId_fkey"+ columns: ["companyId"]+ isOneToOne: false+ referencedRelation: "customFieldTables"+ referencedColumns: ["companyId"]+ },+ {+ foreignKeyName: "buyMethod_companyId_fkey"+ columns: ["companyId"]+ isOneToOne: false+ referencedRelation: "integrations"+ referencedColumns: ["companyId"]+ },+ {+ foreignKeyName: "buyMethod_createdBy_fkey"+ columns: ["createdBy"]+ isOneToOne: false+ referencedRelation: "employees"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "buyMethod_createdBy_fkey"+ columns: ["createdBy"]+ isOneToOne: false+ referencedRelation: "employeesAcrossCompanies"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "buyMethod_createdBy_fkey"+ columns: ["createdBy"]+ isOneToOne: false+ referencedRelation: "employeeSummary"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "buyMethod_createdBy_fkey"+ columns: ["createdBy"]+ isOneToOne: false+ referencedRelation: "user"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "buyMethod_createdBy_fkey"+ columns: ["createdBy"]+ isOneToOne: false+ referencedRelation: "userDefaults"+ referencedColumns: ["userId"]+ },+ {+ foreignKeyName: "buyMethod_itemId_fkey"+ columns: ["itemId"]+ isOneToOne: false+ referencedRelation: "item"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "buyMethod_itemId_fkey"+ columns: ["itemId"]+ isOneToOne: false+ referencedRelation: "itemQuantities"+ referencedColumns: ["itemId"]+ },+ {+ foreignKeyName: "buyMethod_supplierId_fkey"+ columns: ["supplierId"]+ isOneToOne: false+ referencedRelation: "contractors"+ referencedColumns: ["supplierId"]+ },+ {+ foreignKeyName: "buyMethod_supplierId_fkey"+ columns: ["supplierId"]+ isOneToOne: false+ referencedRelation: "partners"+ referencedColumns: ["supplierId"]+ },+ {+ foreignKeyName: "buyMethod_supplierId_fkey"+ columns: ["supplierId"]+ isOneToOne: false+ referencedRelation: "purchaseOrderSuppliers"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "buyMethod_supplierId_fkey"+ columns: ["supplierId"]+ isOneToOne: false+ referencedRelation: "supplier"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "buyMethod_supplierId_fkey"+ columns: ["supplierId"]+ isOneToOne: false+ referencedRelation: "suppliers"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "buyMethod_updatedBy_fkey"+ columns: ["updatedBy"]+ isOneToOne: false+ referencedRelation: "employees"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "buyMethod_updatedBy_fkey"+ columns: ["updatedBy"]+ isOneToOne: false+ referencedRelation: "employeesAcrossCompanies"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "buyMethod_updatedBy_fkey"+ columns: ["updatedBy"]+ isOneToOne: false+ referencedRelation: "employeeSummary"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "buyMethod_updatedBy_fkey"+ columns: ["updatedBy"]+ isOneToOne: false+ referencedRelation: "user"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "buyMethod_updatedBy_fkey"+ columns: ["updatedBy"]+ isOneToOne: false+ referencedRelation: "userDefaults"+ referencedColumns: ["userId"]+ },+ ]+ }company: {Row: {addressLine1: string | null@@ -6311,263 +6513,79 @@ export type Database = {},]}- itemInventory: {+ itemLedger: {Row: {companyId: stringcreatedAt: string- createdBy: string- customFields: Json | null- defaultShelfId: string | null+ documentId: string | null+ documentType:+ | Database["public"]["Enums"]["itemLedgerDocumentType"]+ | null+ entryNumber: number+ entryType: Database["public"]["Enums"]["itemLedgerType"]+ externalDocumentId: string | null+ id: stringitemId: string- locationId: string- updatedAt: string | null- updatedBy: string | null+ itemReadableId: string | null+ locationId: string | null+ postingDate: string+ quantity: number+ shelfId: string | null}Insert: {companyId: stringcreatedAt?: string- createdBy: string- customFields?: Json | null- defaultShelfId?: string | null+ documentId?: string | null+ documentType?:+ | Database["public"]["Enums"]["itemLedgerDocumentType"]+ | null+ entryNumber?: number+ entryType: Database["public"]["Enums"]["itemLedgerType"]+ externalDocumentId?: string | null+ id?: stringitemId: string- locationId: string- updatedAt?: string | null- updatedBy?: string | null+ itemReadableId?: string | null+ locationId?: string | null+ postingDate?: string+ quantity: number+ shelfId?: string | null}Update: {companyId?: stringcreatedAt?: string- createdBy?: string- customFields?: Json | null- defaultShelfId?: string | null+ documentId?: string | null+ documentType?:+ | Database["public"]["Enums"]["itemLedgerDocumentType"]+ | null+ entryNumber?: number+ entryType?: Database["public"]["Enums"]["itemLedgerType"]+ externalDocumentId?: string | null+ id?: stringitemId?: string- locationId?: string- updatedAt?: string | null- updatedBy?: string | null+ itemReadableId?: string | null+ locationId?: string | null+ postingDate?: string+ quantity?: number+ shelfId?: string | null}Relationships: [{- foreignKeyName: "itemInventory_companyId_fkey"- columns: ["companyId"]+ foreignKeyName: "itemLedger_itemId_fkey"+ columns: ["itemId"]isOneToOne: false- referencedRelation: "companies"+ referencedRelation: "item"referencedColumns: ["id"]},{- foreignKeyName: "itemInventory_companyId_fkey"- columns: ["companyId"]+ foreignKeyName: "itemLedger_itemId_fkey"+ columns: ["itemId"]isOneToOne: false- referencedRelation: "company"- referencedColumns: ["id"]+ referencedRelation: "itemQuantities"+ referencedColumns: ["itemId"]},{- foreignKeyName: "itemInventory_companyId_fkey"- columns: ["companyId"]- isOneToOne: false- referencedRelation: "customFieldTables"- referencedColumns: ["companyId"]- },- {- foreignKeyName: "itemInventory_companyId_fkey"- columns: ["companyId"]- isOneToOne: false- referencedRelation: "integrations"- referencedColumns: ["companyId"]- },- {- foreignKeyName: "itemInventory_createdBy_fkey"- columns: ["createdBy"]- isOneToOne: false- referencedRelation: "employees"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemInventory_createdBy_fkey"- columns: ["createdBy"]- isOneToOne: false- referencedRelation: "employeesAcrossCompanies"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemInventory_createdBy_fkey"- columns: ["createdBy"]- isOneToOne: false- referencedRelation: "employeeSummary"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemInventory_createdBy_fkey"- columns: ["createdBy"]- isOneToOne: false- referencedRelation: "user"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemInventory_createdBy_fkey"- columns: ["createdBy"]- isOneToOne: false- referencedRelation: "userDefaults"- referencedColumns: ["userId"]- },- {- foreignKeyName: "itemInventory_itemId_fkey"- columns: ["itemId"]- isOneToOne: false- referencedRelation: "item"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemInventory_itemId_fkey"- columns: ["itemId"]- isOneToOne: false- referencedRelation: "itemQuantities"- referencedColumns: ["itemId"]- },- {- foreignKeyName: "itemInventory_locationId_fkey"- columns: ["locationId"]- isOneToOne: false- referencedRelation: "itemQuantities"- referencedColumns: ["locationId"]- },- {- foreignKeyName: "itemInventory_locationId_fkey"- columns: ["locationId"]- isOneToOne: false- referencedRelation: "location"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemInventory_locationId_fkey"- columns: ["locationId"]- isOneToOne: false- referencedRelation: "purchaseOrders"- referencedColumns: ["locationId"]- },- {- foreignKeyName: "itemInventory_locationId_fkey"- columns: ["locationId"]- isOneToOne: false- referencedRelation: "salesOrders"- referencedColumns: ["locationId"]- },- {- foreignKeyName: "itemInventory_shelfId_fkey"- columns: ["defaultShelfId", "locationId"]- isOneToOne: false- referencedRelation: "shelf"- referencedColumns: ["id", "locationId"]- },- {- foreignKeyName: "itemInventory_updatedBy_fkey"- columns: ["updatedBy"]- isOneToOne: false- referencedRelation: "employees"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemInventory_updatedBy_fkey"- columns: ["updatedBy"]- isOneToOne: false- referencedRelation: "employeesAcrossCompanies"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemInventory_updatedBy_fkey"- columns: ["updatedBy"]- isOneToOne: false- referencedRelation: "employeeSummary"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemInventory_updatedBy_fkey"- columns: ["updatedBy"]- isOneToOne: false- referencedRelation: "user"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemInventory_updatedBy_fkey"- columns: ["updatedBy"]- isOneToOne: false- referencedRelation: "userDefaults"- referencedColumns: ["userId"]- },- ]- }- itemLedger: {- Row: {- companyId: string- createdAt: string- documentId: string | null- documentType:- | Database["public"]["Enums"]["itemLedgerDocumentType"]- | null- entryNumber: number- entryType: Database["public"]["Enums"]["itemLedgerType"]- externalDocumentId: string | null- id: string- itemId: string- itemReadableId: string | null- locationId: string | null- postingDate: string- quantity: number- shelfId: string | null- }- Insert: {- companyId: string- createdAt?: string- documentId?: string | null- documentType?:- | Database["public"]["Enums"]["itemLedgerDocumentType"]- | null- entryNumber?: number- entryType: Database["public"]["Enums"]["itemLedgerType"]- externalDocumentId?: string | null- id?: string- itemId: string- itemReadableId?: string | null- locationId?: string | null- postingDate?: string- quantity: number- shelfId?: string | null- }- Update: {- companyId?: string- createdAt?: string- documentId?: string | null- documentType?:- | Database["public"]["Enums"]["itemLedgerDocumentType"]- | null- entryNumber?: number- entryType?: Database["public"]["Enums"]["itemLedgerType"]- externalDocumentId?: string | null- id?: string- itemId?: string- itemReadableId?: string | null- locationId?: string | null- postingDate?: string- quantity?: number- shelfId?: string | null- }- Relationships: [- {- foreignKeyName: "itemLedger_itemId_fkey"- columns: ["itemId"]- isOneToOne: false- referencedRelation: "item"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemLedger_itemId_fkey"- columns: ["itemId"]- isOneToOne: false- referencedRelation: "itemQuantities"- referencedColumns: ["itemId"]- },- {- foreignKeyName: "itemLedger_locationId_fkey"- columns: ["locationId"]+ foreignKeyName: "itemLedger_locationId_fkey"+ columns: ["locationId"]isOneToOne: falsereferencedRelation: "itemQuantities"referencedColumns: ["locationId"]@@ -6843,419 +6861,217 @@ export type Database = {},]}- itemReplenishment: {- Row: {- companyId: string- conversionFactor: number- createdAt: string- createdBy: string- customFields: Json | null- itemId: string- lotSize: number | null- manufacturingBlocked: boolean- manufacturingLeadTime: number- manufacturingPolicy: Database["public"]["Enums"]["partManufacturingPolicy"]- preferredSupplierId: string | null- purchasingBlocked: boolean- purchasingLeadTime: number- purchasingUnitOfMeasureCode: string | null- requiresConfiguration: boolean- scrapPercentage: number- updatedAt: string | null- updatedBy: string | null- }- Insert: {- companyId: string- conversionFactor?: number- createdAt?: string- createdBy: string- customFields?: Json | null- itemId: string- lotSize?: number | null- manufacturingBlocked?: boolean- manufacturingLeadTime?: number- manufacturingPolicy?: Database["public"]["Enums"]["partManufacturingPolicy"]- preferredSupplierId?: string | null- purchasingBlocked?: boolean- purchasingLeadTime?: number- purchasingUnitOfMeasureCode?: string | null- requiresConfiguration?: boolean- scrapPercentage?: number- updatedAt?: string | null- updatedBy?: string | null- }- Update: {- companyId?: string- conversionFactor?: number- createdAt?: string- createdBy?: string- customFields?: Json | null- itemId?: string- lotSize?: number | null- manufacturingBlocked?: boolean- manufacturingLeadTime?: number- manufacturingPolicy?: Database["public"]["Enums"]["partManufacturingPolicy"]- preferredSupplierId?: string | null- purchasingBlocked?: boolean- purchasingLeadTime?: number- purchasingUnitOfMeasureCode?: string | null- requiresConfiguration?: boolean- scrapPercentage?: number- updatedAt?: string | null- updatedBy?: string | null- }- Relationships: [- {- foreignKeyName: "itemReplenishment_companyId_fkey"- columns: ["companyId"]- isOneToOne: false- referencedRelation: "companies"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemReplenishment_companyId_fkey"- columns: ["companyId"]- isOneToOne: false- referencedRelation: "company"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemReplenishment_companyId_fkey"- columns: ["companyId"]- isOneToOne: false- referencedRelation: "customFieldTables"- referencedColumns: ["companyId"]- },- {- foreignKeyName: "itemReplenishment_companyId_fkey"- columns: ["companyId"]- isOneToOne: false- referencedRelation: "integrations"- referencedColumns: ["companyId"]- },- {- foreignKeyName: "itemReplenishment_createdBy_fkey"- columns: ["createdBy"]- isOneToOne: false- referencedRelation: "employees"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemReplenishment_createdBy_fkey"- columns: ["createdBy"]- isOneToOne: false- referencedRelation: "employeesAcrossCompanies"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemReplenishment_createdBy_fkey"- columns: ["createdBy"]- isOneToOne: false- referencedRelation: "employeeSummary"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemReplenishment_createdBy_fkey"- columns: ["createdBy"]- isOneToOne: false- referencedRelation: "user"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemReplenishment_createdBy_fkey"- columns: ["createdBy"]- isOneToOne: false- referencedRelation: "userDefaults"- referencedColumns: ["userId"]- },- {- foreignKeyName: "itemReplenishment_itemId_fkey"- columns: ["itemId"]- isOneToOne: false- referencedRelation: "item"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemReplenishment_itemId_fkey"- columns: ["itemId"]- isOneToOne: false- referencedRelation: "itemQuantities"- referencedColumns: ["itemId"]- },- {- foreignKeyName: "itemReplenishment_preferredSupplierId_fkey"- columns: ["preferredSupplierId"]- isOneToOne: false- referencedRelation: "contractors"- referencedColumns: ["supplierId"]- },- {- foreignKeyName: "itemReplenishment_preferredSupplierId_fkey"- columns: ["preferredSupplierId"]- isOneToOne: false- referencedRelation: "partners"- referencedColumns: ["supplierId"]- },- {- foreignKeyName: "itemReplenishment_preferredSupplierId_fkey"- columns: ["preferredSupplierId"]- isOneToOne: false- referencedRelation: "purchaseOrderSuppliers"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemReplenishment_preferredSupplierId_fkey"- columns: ["preferredSupplierId"]- isOneToOne: false- referencedRelation: "supplier"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemReplenishment_preferredSupplierId_fkey"- columns: ["preferredSupplierId"]- isOneToOne: false- referencedRelation: "suppliers"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemReplenishment_purchaseUnitOfMeasureCode_fkey"- columns: ["purchasingUnitOfMeasureCode", "companyId"]- isOneToOne: false- referencedRelation: "unitOfMeasure"- referencedColumns: ["code", "companyId"]- },- {- foreignKeyName: "itemReplenishment_updatedBy_fkey"- columns: ["updatedBy"]- isOneToOne: false- referencedRelation: "employees"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemReplenishment_updatedBy_fkey"- columns: ["updatedBy"]- isOneToOne: false- referencedRelation: "employeesAcrossCompanies"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemReplenishment_updatedBy_fkey"- columns: ["updatedBy"]- isOneToOne: false- referencedRelation: "employeeSummary"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemReplenishment_updatedBy_fkey"- columns: ["updatedBy"]- isOneToOne: false- referencedRelation: "user"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemReplenishment_updatedBy_fkey"- columns: ["updatedBy"]- isOneToOne: false- referencedRelation: "userDefaults"- referencedColumns: ["userId"]- },- ]- }- itemSupplier: {+ itemReplenishment: {Row: {- active: booleancompanyId: stringconversionFactor: numbercreatedAt: stringcreatedBy: stringcustomFields: Json | null- id: stringitemId: string- minimumOrderQuantity: number | null- supplierId: string- supplierPartId: string | null- supplierUnitOfMeasureCode: string | null- unitPrice: number | null+ lotSize: number | null+ manufacturingBlocked: boolean+ manufacturingLeadTime: number+ manufacturingPolicy: Database["public"]["Enums"]["partManufacturingPolicy"]+ preferredSupplierId: string | null+ purchasingBlocked: boolean+ purchasingLeadTime: number+ purchasingUnitOfMeasureCode: string | null+ requiresConfiguration: boolean+ scrapPercentage: numberupdatedAt: string | nullupdatedBy: string | null}Insert: {- active?: booleancompanyId: stringconversionFactor?: numbercreatedAt?: stringcreatedBy: stringcustomFields?: Json | null- id?: stringitemId: string- minimumOrderQuantity?: number | null- supplierId: string- supplierPartId?: string | null- supplierUnitOfMeasureCode?: string | null- unitPrice?: number | null+ lotSize?: number | null+ manufacturingBlocked?: boolean+ manufacturingLeadTime?: number+ manufacturingPolicy?: Database["public"]["Enums"]["partManufacturingPolicy"]+ preferredSupplierId?: string | null+ purchasingBlocked?: boolean+ purchasingLeadTime?: number+ purchasingUnitOfMeasureCode?: string | null+ requiresConfiguration?: boolean+ scrapPercentage?: numberupdatedAt?: string | nullupdatedBy?: string | null}Update: {- active?: booleancompanyId?: stringconversionFactor?: numbercreatedAt?: stringcreatedBy?: stringcustomFields?: Json | null- id?: stringitemId?: string- minimumOrderQuantity?: number | null- supplierId?: string- supplierPartId?: string | null- supplierUnitOfMeasureCode?: string | null- unitPrice?: number | null+ lotSize?: number | null+ manufacturingBlocked?: boolean+ manufacturingLeadTime?: number+ manufacturingPolicy?: Database["public"]["Enums"]["partManufacturingPolicy"]+ preferredSupplierId?: string | null+ purchasingBlocked?: boolean+ purchasingLeadTime?: number+ purchasingUnitOfMeasureCode?: string | null+ requiresConfiguration?: boolean+ scrapPercentage?: numberupdatedAt?: string | nullupdatedBy?: string | null}Relationships: [{- foreignKeyName: "itemSupplier_companyId_fkey"+ foreignKeyName: "itemReplenishment_companyId_fkey"columns: ["companyId"]isOneToOne: falsereferencedRelation: "companies"referencedColumns: ["id"]},{- foreignKeyName: "itemSupplier_companyId_fkey"+ foreignKeyName: "itemReplenishment_companyId_fkey"columns: ["companyId"]isOneToOne: falsereferencedRelation: "company"referencedColumns: ["id"]},{- foreignKeyName: "itemSupplier_companyId_fkey"+ foreignKeyName: "itemReplenishment_companyId_fkey"columns: ["companyId"]isOneToOne: falsereferencedRelation: "customFieldTables"referencedColumns: ["companyId"]},{- foreignKeyName: "itemSupplier_companyId_fkey"+ foreignKeyName: "itemReplenishment_companyId_fkey"columns: ["companyId"]isOneToOne: falsereferencedRelation: "integrations"referencedColumns: ["companyId"]},{- foreignKeyName: "itemSupplier_createdBy_fkey"+ foreignKeyName: "itemReplenishment_createdBy_fkey"columns: ["createdBy"]isOneToOne: falsereferencedRelation: "employees"referencedColumns: ["id"]},{- foreignKeyName: "itemSupplier_createdBy_fkey"+ foreignKeyName: "itemReplenishment_createdBy_fkey"columns: ["createdBy"]isOneToOne: falsereferencedRelation: "employeesAcrossCompanies"referencedColumns: ["id"]},{- foreignKeyName: "itemSupplier_createdBy_fkey"+ foreignKeyName: "itemReplenishment_createdBy_fkey"columns: ["createdBy"]isOneToOne: falsereferencedRelation: "employeeSummary"referencedColumns: ["id"]},{- foreignKeyName: "itemSupplier_createdBy_fkey"+ foreignKeyName: "itemReplenishment_createdBy_fkey"columns: ["createdBy"]isOneToOne: falsereferencedRelation: "user"referencedColumns: ["id"]},{- foreignKeyName: "itemSupplier_createdBy_fkey"+ foreignKeyName: "itemReplenishment_createdBy_fkey"columns: ["createdBy"]isOneToOne: falsereferencedRelation: "userDefaults"referencedColumns: ["userId"]},{- foreignKeyName: "itemSupplier_itemId_fkey"+ foreignKeyName: "itemReplenishment_itemId_fkey"columns: ["itemId"]isOneToOne: falsereferencedRelation: "item"referencedColumns: ["id"]},{- foreignKeyName: "itemSupplier_itemId_fkey"+ foreignKeyName: "itemReplenishment_itemId_fkey"columns: ["itemId"]isOneToOne: falsereferencedRelation: "itemQuantities"referencedColumns: ["itemId"]},{- foreignKeyName: "itemSupplier_supplierId_fkey"- columns: ["supplierId"]+ foreignKeyName: "itemReplenishment_preferredSupplierId_fkey"+ columns: ["preferredSupplierId"]isOneToOne: falsereferencedRelation: "contractors"referencedColumns: ["supplierId"]},{- foreignKeyName: "itemSupplier_supplierId_fkey"- columns: ["supplierId"]+ foreignKeyName: "itemReplenishment_preferredSupplierId_fkey"+ columns: ["preferredSupplierId"]isOneToOne: falsereferencedRelation: "partners"referencedColumns: ["supplierId"]},{- foreignKeyName: "itemSupplier_supplierId_fkey"- columns: ["supplierId"]+ foreignKeyName: "itemReplenishment_preferredSupplierId_fkey"+ columns: ["preferredSupplierId"]isOneToOne: falsereferencedRelation: "purchaseOrderSuppliers"referencedColumns: ["id"]},{- foreignKeyName: "itemSupplier_supplierId_fkey"- columns: ["supplierId"]+ foreignKeyName: "itemReplenishment_preferredSupplierId_fkey"+ columns: ["preferredSupplierId"]isOneToOne: falsereferencedRelation: "supplier"referencedColumns: ["id"]},{- foreignKeyName: "itemSupplier_supplierId_fkey"- columns: ["supplierId"]+ foreignKeyName: "itemReplenishment_preferredSupplierId_fkey"+ columns: ["preferredSupplierId"]isOneToOne: falsereferencedRelation: "suppliers"referencedColumns: ["id"]},{- foreignKeyName: "itemSupplier_updatedBy_fkey"+ foreignKeyName: "itemReplenishment_purchaseUnitOfMeasureCode_fkey"+ columns: ["purchasingUnitOfMeasureCode", "companyId"]+ isOneToOne: false+ referencedRelation: "unitOfMeasure"+ referencedColumns: ["code", "companyId"]+ },+ {+ foreignKeyName: "itemReplenishment_updatedBy_fkey"columns: ["updatedBy"]isOneToOne: falsereferencedRelation: "employees"referencedColumns: ["id"]},{- foreignKeyName: "itemSupplier_updatedBy_fkey"+ foreignKeyName: "itemReplenishment_updatedBy_fkey"columns: ["updatedBy"]isOneToOne: falsereferencedRelation: "employeesAcrossCompanies"referencedColumns: ["id"]},{- foreignKeyName: "itemSupplier_updatedBy_fkey"+ foreignKeyName: "itemReplenishment_updatedBy_fkey"columns: ["updatedBy"]isOneToOne: falsereferencedRelation: "employeeSummary"referencedColumns: ["id"]},{- foreignKeyName: "itemSupplier_updatedBy_fkey"+ foreignKeyName: "itemReplenishment_updatedBy_fkey"columns: ["updatedBy"]isOneToOne: falsereferencedRelation: "user"referencedColumns: ["id"]},{- foreignKeyName: "itemSupplier_updatedBy_fkey"+ foreignKeyName: "itemReplenishment_updatedBy_fkey"columns: ["updatedBy"]isOneToOne: falsereferencedRelation: "userDefaults"@@ -8842,6 +8658,190 @@ export type Database = {},]}+ pickMethod: {+ Row: {+ companyId: string+ createdAt: string+ createdBy: string+ customFields: Json | null+ defaultShelfId: string | null+ itemId: string+ locationId: string+ updatedAt: string | null+ updatedBy: string | null+ }+ Insert: {+ companyId: string+ createdAt?: string+ createdBy: string+ customFields?: Json | null+ defaultShelfId?: string | null+ itemId: string+ locationId: string+ updatedAt?: string | null+ updatedBy?: string | null+ }+ Update: {+ companyId?: string+ createdAt?: string+ createdBy?: string+ customFields?: Json | null+ defaultShelfId?: string | null+ itemId?: string+ locationId?: string+ updatedAt?: string | null+ updatedBy?: string | null+ }+ Relationships: [+ {+ foreignKeyName: "pickMethod_companyId_fkey"+ columns: ["companyId"]+ isOneToOne: false+ referencedRelation: "companies"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "pickMethod_companyId_fkey"+ columns: ["companyId"]+ isOneToOne: false+ referencedRelation: "company"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "pickMethod_companyId_fkey"+ columns: ["companyId"]+ isOneToOne: false+ referencedRelation: "customFieldTables"+ referencedColumns: ["companyId"]+ },+ {+ foreignKeyName: "pickMethod_companyId_fkey"+ columns: ["companyId"]+ isOneToOne: false+ referencedRelation: "integrations"+ referencedColumns: ["companyId"]+ },+ {+ foreignKeyName: "pickMethod_createdBy_fkey"+ columns: ["createdBy"]+ isOneToOne: false+ referencedRelation: "employees"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "pickMethod_createdBy_fkey"+ columns: ["createdBy"]+ isOneToOne: false+ referencedRelation: "employeesAcrossCompanies"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "pickMethod_createdBy_fkey"+ columns: ["createdBy"]+ isOneToOne: false+ referencedRelation: "employeeSummary"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "pickMethod_createdBy_fkey"+ columns: ["createdBy"]+ isOneToOne: false+ referencedRelation: "user"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "pickMethod_createdBy_fkey"+ columns: ["createdBy"]+ isOneToOne: false+ referencedRelation: "userDefaults"+ referencedColumns: ["userId"]+ },+ {+ foreignKeyName: "pickMethod_itemId_fkey"+ columns: ["itemId"]+ isOneToOne: false+ referencedRelation: "item"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "pickMethod_itemId_fkey"+ columns: ["itemId"]+ isOneToOne: false+ referencedRelation: "itemQuantities"+ referencedColumns: ["itemId"]+ },+ {+ foreignKeyName: "pickMethod_locationId_fkey"+ columns: ["locationId"]+ isOneToOne: false+ referencedRelation: "itemQuantities"+ referencedColumns: ["locationId"]+ },+ {+ foreignKeyName: "pickMethod_locationId_fkey"+ columns: ["locationId"]+ isOneToOne: false+ referencedRelation: "location"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "pickMethod_locationId_fkey"+ columns: ["locationId"]+ isOneToOne: false+ referencedRelation: "purchaseOrders"+ referencedColumns: ["locationId"]+ },+ {+ foreignKeyName: "pickMethod_locationId_fkey"+ columns: ["locationId"]+ isOneToOne: false+ referencedRelation: "salesOrders"+ referencedColumns: ["locationId"]+ },+ {+ foreignKeyName: "pickMethod_shelfId_fkey"+ columns: ["defaultShelfId", "locationId"]+ isOneToOne: false+ referencedRelation: "shelf"+ referencedColumns: ["id", "locationId"]+ },+ {+ foreignKeyName: "pickMethod_updatedBy_fkey"+ columns: ["updatedBy"]+ isOneToOne: false+ referencedRelation: "employees"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "pickMethod_updatedBy_fkey"+ columns: ["updatedBy"]+ isOneToOne: false+ referencedRelation: "employeesAcrossCompanies"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "pickMethod_updatedBy_fkey"+ columns: ["updatedBy"]+ isOneToOne: false+ referencedRelation: "employeeSummary"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "pickMethod_updatedBy_fkey"+ columns: ["updatedBy"]+ isOneToOne: false+ referencedRelation: "user"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "pickMethod_updatedBy_fkey"+ columns: ["updatedBy"]+ isOneToOne: false+ referencedRelation: "userDefaults"+ referencedColumns: ["userId"]+ },+ ]+ }postingGroupInventory: {Row: {capacityVarianceAccount: string@@ -21195,14 +21195,14 @@ export type Database = {},{foreignKeyName: "partner_id_fkey"- columns: ["id"]+ columns: ["supplierLocationId"]isOneToOne: falsereferencedRelation: "supplierLocation"referencedColumns: ["id"]},{foreignKeyName: "partner_id_fkey"- columns: ["supplierLocationId"]+ columns: ["id"]isOneToOne: falsereferencedRelation: "supplierLocation"referencedColumns: ["id"]diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.tsindex 10206a411b..5044e66b70 100644--- a/packages/database/supabase/functions/lib/types.ts+++ b/packages/database/supabase/functions/lib/types.ts@@ -1622,6 +1622,208 @@ export type Database = {}Relationships: []}+ buyMethod: {+ Row: {+ active: boolean+ companyId: string+ conversionFactor: number+ createdAt: string+ createdBy: string+ customFields: Json | null+ id: string+ itemId: string+ minimumOrderQuantity: number | null+ supplierId: string+ supplierPartId: string | null+ supplierUnitOfMeasureCode: string | null+ unitPrice: number | null+ updatedAt: string | null+ updatedBy: string | null+ }+ Insert: {+ active?: boolean+ companyId: string+ conversionFactor?: number+ createdAt?: string+ createdBy: string+ customFields?: Json | null+ id?: string+ itemId: string+ minimumOrderQuantity?: number | null+ supplierId: string+ supplierPartId?: string | null+ supplierUnitOfMeasureCode?: string | null+ unitPrice?: number | null+ updatedAt?: string | null+ updatedBy?: string | null+ }+ Update: {+ active?: boolean+ companyId?: string+ conversionFactor?: number+ createdAt?: string+ createdBy?: string+ customFields?: Json | null+ id?: string+ itemId?: string+ minimumOrderQuantity?: number | null+ supplierId?: string+ supplierPartId?: string | null+ supplierUnitOfMeasureCode?: string | null+ unitPrice?: number | null+ updatedAt?: string | null+ updatedBy?: string | null+ }+ Relationships: [+ {+ foreignKeyName: "buyMethod_companyId_fkey"+ columns: ["companyId"]+ isOneToOne: false+ referencedRelation: "companies"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "buyMethod_companyId_fkey"+ columns: ["companyId"]+ isOneToOne: false+ referencedRelation: "company"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "buyMethod_companyId_fkey"+ columns: ["companyId"]+ isOneToOne: false+ referencedRelation: "customFieldTables"+ referencedColumns: ["companyId"]+ },+ {+ foreignKeyName: "buyMethod_companyId_fkey"+ columns: ["companyId"]+ isOneToOne: false+ referencedRelation: "integrations"+ referencedColumns: ["companyId"]+ },+ {+ foreignKeyName: "buyMethod_createdBy_fkey"+ columns: ["createdBy"]+ isOneToOne: false+ referencedRelation: "employees"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "buyMethod_createdBy_fkey"+ columns: ["createdBy"]+ isOneToOne: false+ referencedRelation: "employeesAcrossCompanies"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "buyMethod_createdBy_fkey"+ columns: ["createdBy"]+ isOneToOne: false+ referencedRelation: "employeeSummary"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "buyMethod_createdBy_fkey"+ columns: ["createdBy"]+ isOneToOne: false+ referencedRelation: "user"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "buyMethod_createdBy_fkey"+ columns: ["createdBy"]+ isOneToOne: false+ referencedRelation: "userDefaults"+ referencedColumns: ["userId"]+ },+ {+ foreignKeyName: "buyMethod_itemId_fkey"+ columns: ["itemId"]+ isOneToOne: false+ referencedRelation: "item"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "buyMethod_itemId_fkey"+ columns: ["itemId"]+ isOneToOne: false+ referencedRelation: "itemQuantities"+ referencedColumns: ["itemId"]+ },+ {+ foreignKeyName: "buyMethod_supplierId_fkey"+ columns: ["supplierId"]+ isOneToOne: false+ referencedRelation: "contractors"+ referencedColumns: ["supplierId"]+ },+ {+ foreignKeyName: "buyMethod_supplierId_fkey"+ columns: ["supplierId"]+ isOneToOne: false+ referencedRelation: "partners"+ referencedColumns: ["supplierId"]+ },+ {+ foreignKeyName: "buyMethod_supplierId_fkey"+ columns: ["supplierId"]+ isOneToOne: false+ referencedRelation: "purchaseOrderSuppliers"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "buyMethod_supplierId_fkey"+ columns: ["supplierId"]+ isOneToOne: false+ referencedRelation: "supplier"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "buyMethod_supplierId_fkey"+ columns: ["supplierId"]+ isOneToOne: false+ referencedRelation: "suppliers"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "buyMethod_updatedBy_fkey"+ columns: ["updatedBy"]+ isOneToOne: false+ referencedRelation: "employees"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "buyMethod_updatedBy_fkey"+ columns: ["updatedBy"]+ isOneToOne: false+ referencedRelation: "employeesAcrossCompanies"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "buyMethod_updatedBy_fkey"+ columns: ["updatedBy"]+ isOneToOne: false+ referencedRelation: "employeeSummary"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "buyMethod_updatedBy_fkey"+ columns: ["updatedBy"]+ isOneToOne: false+ referencedRelation: "user"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "buyMethod_updatedBy_fkey"+ columns: ["updatedBy"]+ isOneToOne: false+ referencedRelation: "userDefaults"+ referencedColumns: ["userId"]+ },+ ]+ }company: {Row: {addressLine1: string | null@@ -6311,263 +6513,79 @@ export type Database = {},]}- itemInventory: {+ itemLedger: {Row: {companyId: stringcreatedAt: string- createdBy: string- customFields: Json | null- defaultShelfId: string | null+ documentId: string | null+ documentType:+ | Database["public"]["Enums"]["itemLedgerDocumentType"]+ | null+ entryNumber: number+ entryType: Database["public"]["Enums"]["itemLedgerType"]+ externalDocumentId: string | null+ id: stringitemId: string- locationId: string- updatedAt: string | null- updatedBy: string | null+ itemReadableId: string | null+ locationId: string | null+ postingDate: string+ quantity: number+ shelfId: string | null}Insert: {companyId: stringcreatedAt?: string- createdBy: string- customFields?: Json | null- defaultShelfId?: string | null+ documentId?: string | null+ documentType?:+ | Database["public"]["Enums"]["itemLedgerDocumentType"]+ | null+ entryNumber?: number+ entryType: Database["public"]["Enums"]["itemLedgerType"]+ externalDocumentId?: string | null+ id?: stringitemId: string- locationId: string- updatedAt?: string | null- updatedBy?: string | null+ itemReadableId?: string | null+ locationId?: string | null+ postingDate?: string+ quantity: number+ shelfId?: string | null}Update: {companyId?: stringcreatedAt?: string- createdBy?: string- customFields?: Json | null- defaultShelfId?: string | null+ documentId?: string | null+ documentType?:+ | Database["public"]["Enums"]["itemLedgerDocumentType"]+ | null+ entryNumber?: number+ entryType?: Database["public"]["Enums"]["itemLedgerType"]+ externalDocumentId?: string | null+ id?: stringitemId?: string- locationId?: string- updatedAt?: string | null- updatedBy?: string | null+ itemReadableId?: string | null+ locationId?: string | null+ postingDate?: string+ quantity?: number+ shelfId?: string | null}Relationships: [{- foreignKeyName: "itemInventory_companyId_fkey"- columns: ["companyId"]+ foreignKeyName: "itemLedger_itemId_fkey"+ columns: ["itemId"]isOneToOne: false- referencedRelation: "companies"+ referencedRelation: "item"referencedColumns: ["id"]},{- foreignKeyName: "itemInventory_companyId_fkey"- columns: ["companyId"]+ foreignKeyName: "itemLedger_itemId_fkey"+ columns: ["itemId"]isOneToOne: false- referencedRelation: "company"- referencedColumns: ["id"]+ referencedRelation: "itemQuantities"+ referencedColumns: ["itemId"]},{- foreignKeyName: "itemInventory_companyId_fkey"- columns: ["companyId"]- isOneToOne: false- referencedRelation: "customFieldTables"- referencedColumns: ["companyId"]- },- {- foreignKeyName: "itemInventory_companyId_fkey"- columns: ["companyId"]- isOneToOne: false- referencedRelation: "integrations"- referencedColumns: ["companyId"]- },- {- foreignKeyName: "itemInventory_createdBy_fkey"- columns: ["createdBy"]- isOneToOne: false- referencedRelation: "employees"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemInventory_createdBy_fkey"- columns: ["createdBy"]- isOneToOne: false- referencedRelation: "employeesAcrossCompanies"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemInventory_createdBy_fkey"- columns: ["createdBy"]- isOneToOne: false- referencedRelation: "employeeSummary"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemInventory_createdBy_fkey"- columns: ["createdBy"]- isOneToOne: false- referencedRelation: "user"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemInventory_createdBy_fkey"- columns: ["createdBy"]- isOneToOne: false- referencedRelation: "userDefaults"- referencedColumns: ["userId"]- },- {- foreignKeyName: "itemInventory_itemId_fkey"- columns: ["itemId"]- isOneToOne: false- referencedRelation: "item"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemInventory_itemId_fkey"- columns: ["itemId"]- isOneToOne: false- referencedRelation: "itemQuantities"- referencedColumns: ["itemId"]- },- {- foreignKeyName: "itemInventory_locationId_fkey"- columns: ["locationId"]- isOneToOne: false- referencedRelation: "itemQuantities"- referencedColumns: ["locationId"]- },- {- foreignKeyName: "itemInventory_locationId_fkey"- columns: ["locationId"]- isOneToOne: false- referencedRelation: "location"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemInventory_locationId_fkey"- columns: ["locationId"]- isOneToOne: false- referencedRelation: "purchaseOrders"- referencedColumns: ["locationId"]- },- {- foreignKeyName: "itemInventory_locationId_fkey"- columns: ["locationId"]- isOneToOne: false- referencedRelation: "salesOrders"- referencedColumns: ["locationId"]- },- {- foreignKeyName: "itemInventory_shelfId_fkey"- columns: ["defaultShelfId", "locationId"]- isOneToOne: false- referencedRelation: "shelf"- referencedColumns: ["id", "locationId"]- },- {- foreignKeyName: "itemInventory_updatedBy_fkey"- columns: ["updatedBy"]- isOneToOne: false- referencedRelation: "employees"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemInventory_updatedBy_fkey"- columns: ["updatedBy"]- isOneToOne: false- referencedRelation: "employeesAcrossCompanies"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemInventory_updatedBy_fkey"- columns: ["updatedBy"]- isOneToOne: false- referencedRelation: "employeeSummary"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemInventory_updatedBy_fkey"- columns: ["updatedBy"]- isOneToOne: false- referencedRelation: "user"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemInventory_updatedBy_fkey"- columns: ["updatedBy"]- isOneToOne: false- referencedRelation: "userDefaults"- referencedColumns: ["userId"]- },- ]- }- itemLedger: {- Row: {- companyId: string- createdAt: string- documentId: string | null- documentType:- | Database["public"]["Enums"]["itemLedgerDocumentType"]- | null- entryNumber: number- entryType: Database["public"]["Enums"]["itemLedgerType"]- externalDocumentId: string | null- id: string- itemId: string- itemReadableId: string | null- locationId: string | null- postingDate: string- quantity: number- shelfId: string | null- }- Insert: {- companyId: string- createdAt?: string- documentId?: string | null- documentType?:- | Database["public"]["Enums"]["itemLedgerDocumentType"]- | null- entryNumber?: number- entryType: Database["public"]["Enums"]["itemLedgerType"]- externalDocumentId?: string | null- id?: string- itemId: string- itemReadableId?: string | null- locationId?: string | null- postingDate?: string- quantity: number- shelfId?: string | null- }- Update: {- companyId?: string- createdAt?: string- documentId?: string | null- documentType?:- | Database["public"]["Enums"]["itemLedgerDocumentType"]- | null- entryNumber?: number- entryType?: Database["public"]["Enums"]["itemLedgerType"]- externalDocumentId?: string | null- id?: string- itemId?: string- itemReadableId?: string | null- locationId?: string | null- postingDate?: string- quantity?: number- shelfId?: string | null- }- Relationships: [- {- foreignKeyName: "itemLedger_itemId_fkey"- columns: ["itemId"]- isOneToOne: false- referencedRelation: "item"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemLedger_itemId_fkey"- columns: ["itemId"]- isOneToOne: false- referencedRelation: "itemQuantities"- referencedColumns: ["itemId"]- },- {- foreignKeyName: "itemLedger_locationId_fkey"- columns: ["locationId"]+ foreignKeyName: "itemLedger_locationId_fkey"+ columns: ["locationId"]isOneToOne: falsereferencedRelation: "itemQuantities"referencedColumns: ["locationId"]@@ -6843,419 +6861,217 @@ export type Database = {},]}- itemReplenishment: {- Row: {- companyId: string- conversionFactor: number- createdAt: string- createdBy: string- customFields: Json | null- itemId: string- lotSize: number | null- manufacturingBlocked: boolean- manufacturingLeadTime: number- manufacturingPolicy: Database["public"]["Enums"]["partManufacturingPolicy"]- preferredSupplierId: string | null- purchasingBlocked: boolean- purchasingLeadTime: number- purchasingUnitOfMeasureCode: string | null- requiresConfiguration: boolean- scrapPercentage: number- updatedAt: string | null- updatedBy: string | null- }- Insert: {- companyId: string- conversionFactor?: number- createdAt?: string- createdBy: string- customFields?: Json | null- itemId: string- lotSize?: number | null- manufacturingBlocked?: boolean- manufacturingLeadTime?: number- manufacturingPolicy?: Database["public"]["Enums"]["partManufacturingPolicy"]- preferredSupplierId?: string | null- purchasingBlocked?: boolean- purchasingLeadTime?: number- purchasingUnitOfMeasureCode?: string | null- requiresConfiguration?: boolean- scrapPercentage?: number- updatedAt?: string | null- updatedBy?: string | null- }- Update: {- companyId?: string- conversionFactor?: number- createdAt?: string- createdBy?: string- customFields?: Json | null- itemId?: string- lotSize?: number | null- manufacturingBlocked?: boolean- manufacturingLeadTime?: number- manufacturingPolicy?: Database["public"]["Enums"]["partManufacturingPolicy"]- preferredSupplierId?: string | null- purchasingBlocked?: boolean- purchasingLeadTime?: number- purchasingUnitOfMeasureCode?: string | null- requiresConfiguration?: boolean- scrapPercentage?: number- updatedAt?: string | null- updatedBy?: string | null- }- Relationships: [- {- foreignKeyName: "itemReplenishment_companyId_fkey"- columns: ["companyId"]- isOneToOne: false- referencedRelation: "companies"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemReplenishment_companyId_fkey"- columns: ["companyId"]- isOneToOne: false- referencedRelation: "company"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemReplenishment_companyId_fkey"- columns: ["companyId"]- isOneToOne: false- referencedRelation: "customFieldTables"- referencedColumns: ["companyId"]- },- {- foreignKeyName: "itemReplenishment_companyId_fkey"- columns: ["companyId"]- isOneToOne: false- referencedRelation: "integrations"- referencedColumns: ["companyId"]- },- {- foreignKeyName: "itemReplenishment_createdBy_fkey"- columns: ["createdBy"]- isOneToOne: false- referencedRelation: "employees"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemReplenishment_createdBy_fkey"- columns: ["createdBy"]- isOneToOne: false- referencedRelation: "employeesAcrossCompanies"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemReplenishment_createdBy_fkey"- columns: ["createdBy"]- isOneToOne: false- referencedRelation: "employeeSummary"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemReplenishment_createdBy_fkey"- columns: ["createdBy"]- isOneToOne: false- referencedRelation: "user"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemReplenishment_createdBy_fkey"- columns: ["createdBy"]- isOneToOne: false- referencedRelation: "userDefaults"- referencedColumns: ["userId"]- },- {- foreignKeyName: "itemReplenishment_itemId_fkey"- columns: ["itemId"]- isOneToOne: false- referencedRelation: "item"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemReplenishment_itemId_fkey"- columns: ["itemId"]- isOneToOne: false- referencedRelation: "itemQuantities"- referencedColumns: ["itemId"]- },- {- foreignKeyName: "itemReplenishment_preferredSupplierId_fkey"- columns: ["preferredSupplierId"]- isOneToOne: false- referencedRelation: "contractors"- referencedColumns: ["supplierId"]- },- {- foreignKeyName: "itemReplenishment_preferredSupplierId_fkey"- columns: ["preferredSupplierId"]- isOneToOne: false- referencedRelation: "partners"- referencedColumns: ["supplierId"]- },- {- foreignKeyName: "itemReplenishment_preferredSupplierId_fkey"- columns: ["preferredSupplierId"]- isOneToOne: false- referencedRelation: "purchaseOrderSuppliers"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemReplenishment_preferredSupplierId_fkey"- columns: ["preferredSupplierId"]- isOneToOne: false- referencedRelation: "supplier"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemReplenishment_preferredSupplierId_fkey"- columns: ["preferredSupplierId"]- isOneToOne: false- referencedRelation: "suppliers"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemReplenishment_purchaseUnitOfMeasureCode_fkey"- columns: ["purchasingUnitOfMeasureCode", "companyId"]- isOneToOne: false- referencedRelation: "unitOfMeasure"- referencedColumns: ["code", "companyId"]- },- {- foreignKeyName: "itemReplenishment_updatedBy_fkey"- columns: ["updatedBy"]- isOneToOne: false- referencedRelation: "employees"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemReplenishment_updatedBy_fkey"- columns: ["updatedBy"]- isOneToOne: false- referencedRelation: "employeesAcrossCompanies"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemReplenishment_updatedBy_fkey"- columns: ["updatedBy"]- isOneToOne: false- referencedRelation: "employeeSummary"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemReplenishment_updatedBy_fkey"- columns: ["updatedBy"]- isOneToOne: false- referencedRelation: "user"- referencedColumns: ["id"]- },- {- foreignKeyName: "itemReplenishment_updatedBy_fkey"- columns: ["updatedBy"]- isOneToOne: false- referencedRelation: "userDefaults"- referencedColumns: ["userId"]- },- ]- }- itemSupplier: {+ itemReplenishment: {Row: {- active: booleancompanyId: stringconversionFactor: numbercreatedAt: stringcreatedBy: stringcustomFields: Json | null- id: stringitemId: string- minimumOrderQuantity: number | null- supplierId: string- supplierPartId: string | null- supplierUnitOfMeasureCode: string | null- unitPrice: number | null+ lotSize: number | null+ manufacturingBlocked: boolean+ manufacturingLeadTime: number+ manufacturingPolicy: Database["public"]["Enums"]["partManufacturingPolicy"]+ preferredSupplierId: string | null+ purchasingBlocked: boolean+ purchasingLeadTime: number+ purchasingUnitOfMeasureCode: string | null+ requiresConfiguration: boolean+ scrapPercentage: numberupdatedAt: string | nullupdatedBy: string | null}Insert: {- active?: booleancompanyId: stringconversionFactor?: numbercreatedAt?: stringcreatedBy: stringcustomFields?: Json | null- id?: stringitemId: string- minimumOrderQuantity?: number | null- supplierId: string- supplierPartId?: string | null- supplierUnitOfMeasureCode?: string | null- unitPrice?: number | null+ lotSize?: number | null+ manufacturingBlocked?: boolean+ manufacturingLeadTime?: number+ manufacturingPolicy?: Database["public"]["Enums"]["partManufacturingPolicy"]+ preferredSupplierId?: string | null+ purchasingBlocked?: boolean+ purchasingLeadTime?: number+ purchasingUnitOfMeasureCode?: string | null+ requiresConfiguration?: boolean+ scrapPercentage?: numberupdatedAt?: string | nullupdatedBy?: string | null}Update: {- active?: booleancompanyId?: stringconversionFactor?: numbercreatedAt?: stringcreatedBy?: stringcustomFields?: Json | null- id?: stringitemId?: string- minimumOrderQuantity?: number | null- supplierId?: string- supplierPartId?: string | null- supplierUnitOfMeasureCode?: string | null- unitPrice?: number | null+ lotSize?: number | null+ manufacturingBlocked?: boolean+ manufacturingLeadTime?: number+ manufacturingPolicy?: Database["public"]["Enums"]["partManufacturingPolicy"]+ preferredSupplierId?: string | null+ purchasingBlocked?: boolean+ purchasingLeadTime?: number+ purchasingUnitOfMeasureCode?: string | null+ requiresConfiguration?: boolean+ scrapPercentage?: numberupdatedAt?: string | nullupdatedBy?: string | null}Relationships: [{- foreignKeyName: "itemSupplier_companyId_fkey"+ foreignKeyName: "itemReplenishment_companyId_fkey"columns: ["companyId"]isOneToOne: falsereferencedRelation: "companies"referencedColumns: ["id"]},{- foreignKeyName: "itemSupplier_companyId_fkey"+ foreignKeyName: "itemReplenishment_companyId_fkey"columns: ["companyId"]isOneToOne: falsereferencedRelation: "company"referencedColumns: ["id"]},{- foreignKeyName: "itemSupplier_companyId_fkey"+ foreignKeyName: "itemReplenishment_companyId_fkey"columns: ["companyId"]isOneToOne: falsereferencedRelation: "customFieldTables"referencedColumns: ["companyId"]},{- foreignKeyName: "itemSupplier_companyId_fkey"+ foreignKeyName: "itemReplenishment_companyId_fkey"columns: ["companyId"]isOneToOne: falsereferencedRelation: "integrations"referencedColumns: ["companyId"]},{- foreignKeyName: "itemSupplier_createdBy_fkey"+ foreignKeyName: "itemReplenishment_createdBy_fkey"columns: ["createdBy"]isOneToOne: falsereferencedRelation: "employees"referencedColumns: ["id"]},{- foreignKeyName: "itemSupplier_createdBy_fkey"+ foreignKeyName: "itemReplenishment_createdBy_fkey"columns: ["createdBy"]isOneToOne: falsereferencedRelation: "employeesAcrossCompanies"referencedColumns: ["id"]},{- foreignKeyName: "itemSupplier_createdBy_fkey"+ foreignKeyName: "itemReplenishment_createdBy_fkey"columns: ["createdBy"]isOneToOne: falsereferencedRelation: "employeeSummary"referencedColumns: ["id"]},{- foreignKeyName: "itemSupplier_createdBy_fkey"+ foreignKeyName: "itemReplenishment_createdBy_fkey"columns: ["createdBy"]isOneToOne: falsereferencedRelation: "user"referencedColumns: ["id"]},{- foreignKeyName: "itemSupplier_createdBy_fkey"+ foreignKeyName: "itemReplenishment_createdBy_fkey"columns: ["createdBy"]isOneToOne: falsereferencedRelation: "userDefaults"referencedColumns: ["userId"]},{- foreignKeyName: "itemSupplier_itemId_fkey"+ foreignKeyName: "itemReplenishment_itemId_fkey"columns: ["itemId"]isOneToOne: falsereferencedRelation: "item"referencedColumns: ["id"]},{- foreignKeyName: "itemSupplier_itemId_fkey"+ foreignKeyName: "itemReplenishment_itemId_fkey"columns: ["itemId"]isOneToOne: falsereferencedRelation: "itemQuantities"referencedColumns: ["itemId"]},{- foreignKeyName: "itemSupplier_supplierId_fkey"- columns: ["supplierId"]+ foreignKeyName: "itemReplenishment_preferredSupplierId_fkey"+ columns: ["preferredSupplierId"]isOneToOne: falsereferencedRelation: "contractors"referencedColumns: ["supplierId"]},{- foreignKeyName: "itemSupplier_supplierId_fkey"- columns: ["supplierId"]+ foreignKeyName: "itemReplenishment_preferredSupplierId_fkey"+ columns: ["preferredSupplierId"]isOneToOne: falsereferencedRelation: "partners"referencedColumns: ["supplierId"]},{- foreignKeyName: "itemSupplier_supplierId_fkey"- columns: ["supplierId"]+ foreignKeyName: "itemReplenishment_preferredSupplierId_fkey"+ columns: ["preferredSupplierId"]isOneToOne: falsereferencedRelation: "purchaseOrderSuppliers"referencedColumns: ["id"]},{- foreignKeyName: "itemSupplier_supplierId_fkey"- columns: ["supplierId"]+ foreignKeyName: "itemReplenishment_preferredSupplierId_fkey"+ columns: ["preferredSupplierId"]isOneToOne: falsereferencedRelation: "supplier"referencedColumns: ["id"]},{- foreignKeyName: "itemSupplier_supplierId_fkey"- columns: ["supplierId"]+ foreignKeyName: "itemReplenishment_preferredSupplierId_fkey"+ columns: ["preferredSupplierId"]isOneToOne: falsereferencedRelation: "suppliers"referencedColumns: ["id"]},{- foreignKeyName: "itemSupplier_updatedBy_fkey"+ foreignKeyName: "itemReplenishment_purchaseUnitOfMeasureCode_fkey"+ columns: ["purchasingUnitOfMeasureCode", "companyId"]+ isOneToOne: false+ referencedRelation: "unitOfMeasure"+ referencedColumns: ["code", "companyId"]+ },+ {+ foreignKeyName: "itemReplenishment_updatedBy_fkey"columns: ["updatedBy"]isOneToOne: falsereferencedRelation: "employees"referencedColumns: ["id"]},{- foreignKeyName: "itemSupplier_updatedBy_fkey"+ foreignKeyName: "itemReplenishment_updatedBy_fkey"columns: ["updatedBy"]isOneToOne: falsereferencedRelation: "employeesAcrossCompanies"referencedColumns: ["id"]},{- foreignKeyName: "itemSupplier_updatedBy_fkey"+ foreignKeyName: "itemReplenishment_updatedBy_fkey"columns: ["updatedBy"]isOneToOne: falsereferencedRelation: "employeeSummary"referencedColumns: ["id"]},{- foreignKeyName: "itemSupplier_updatedBy_fkey"+ foreignKeyName: "itemReplenishment_updatedBy_fkey"columns: ["updatedBy"]isOneToOne: falsereferencedRelation: "user"referencedColumns: ["id"]},{- foreignKeyName: "itemSupplier_updatedBy_fkey"+ foreignKeyName: "itemReplenishment_updatedBy_fkey"columns: ["updatedBy"]isOneToOne: falsereferencedRelation: "userDefaults"@@ -8842,6 +8658,190 @@ export type Database = {},]}+ pickMethod: {+ Row: {+ companyId: string+ createdAt: string+ createdBy: string+ customFields: Json | null+ defaultShelfId: string | null+ itemId: string+ locationId: string+ updatedAt: string | null+ updatedBy: string | null+ }+ Insert: {+ companyId: string+ createdAt?: string+ createdBy: string+ customFields?: Json | null+ defaultShelfId?: string | null+ itemId: string+ locationId: string+ updatedAt?: string | null+ updatedBy?: string | null+ }+ Update: {+ companyId?: string+ createdAt?: string+ createdBy?: string+ customFields?: Json | null+ defaultShelfId?: string | null+ itemId?: string+ locationId?: string+ updatedAt?: string | null+ updatedBy?: string | null+ }+ Relationships: [+ {+ foreignKeyName: "pickMethod_companyId_fkey"+ columns: ["companyId"]+ isOneToOne: false+ referencedRelation: "companies"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "pickMethod_companyId_fkey"+ columns: ["companyId"]+ isOneToOne: false+ referencedRelation: "company"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "pickMethod_companyId_fkey"+ columns: ["companyId"]+ isOneToOne: false+ referencedRelation: "customFieldTables"+ referencedColumns: ["companyId"]+ },+ {+ foreignKeyName: "pickMethod_companyId_fkey"+ columns: ["companyId"]+ isOneToOne: false+ referencedRelation: "integrations"+ referencedColumns: ["companyId"]+ },+ {+ foreignKeyName: "pickMethod_createdBy_fkey"+ columns: ["createdBy"]+ isOneToOne: false+ referencedRelation: "employees"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "pickMethod_createdBy_fkey"+ columns: ["createdBy"]+ isOneToOne: false+ referencedRelation: "employeesAcrossCompanies"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "pickMethod_createdBy_fkey"+ columns: ["createdBy"]+ isOneToOne: false+ referencedRelation: "employeeSummary"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "pickMethod_createdBy_fkey"+ columns: ["createdBy"]+ isOneToOne: false+ referencedRelation: "user"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "pickMethod_createdBy_fkey"+ columns: ["createdBy"]+ isOneToOne: false+ referencedRelation: "userDefaults"+ referencedColumns: ["userId"]+ },+ {+ foreignKeyName: "pickMethod_itemId_fkey"+ columns: ["itemId"]+ isOneToOne: false+ referencedRelation: "item"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "pickMethod_itemId_fkey"+ columns: ["itemId"]+ isOneToOne: false+ referencedRelation: "itemQuantities"+ referencedColumns: ["itemId"]+ },+ {+ foreignKeyName: "pickMethod_locationId_fkey"+ columns: ["locationId"]+ isOneToOne: false+ referencedRelation: "itemQuantities"+ referencedColumns: ["locationId"]+ },+ {+ foreignKeyName: "pickMethod_locationId_fkey"+ columns: ["locationId"]+ isOneToOne: false+ referencedRelation: "location"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "pickMethod_locationId_fkey"+ columns: ["locationId"]+ isOneToOne: false+ referencedRelation: "purchaseOrders"+ referencedColumns: ["locationId"]+ },+ {+ foreignKeyName: "pickMethod_locationId_fkey"+ columns: ["locationId"]+ isOneToOne: false+ referencedRelation: "salesOrders"+ referencedColumns: ["locationId"]+ },+ {+ foreignKeyName: "pickMethod_shelfId_fkey"+ columns: ["defaultShelfId", "locationId"]+ isOneToOne: false+ referencedRelation: "shelf"+ referencedColumns: ["id", "locationId"]+ },+ {+ foreignKeyName: "pickMethod_updatedBy_fkey"+ columns: ["updatedBy"]+ isOneToOne: false+ referencedRelation: "employees"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "pickMethod_updatedBy_fkey"+ columns: ["updatedBy"]+ isOneToOne: false+ referencedRelation: "employeesAcrossCompanies"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "pickMethod_updatedBy_fkey"+ columns: ["updatedBy"]+ isOneToOne: false+ referencedRelation: "employeeSummary"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "pickMethod_updatedBy_fkey"+ columns: ["updatedBy"]+ isOneToOne: false+ referencedRelation: "user"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "pickMethod_updatedBy_fkey"+ columns: ["updatedBy"]+ isOneToOne: false+ referencedRelation: "userDefaults"+ referencedColumns: ["userId"]+ },+ ]+ }postingGroupInventory: {Row: {capacityVarianceAccount: string@@ -21195,14 +21195,14 @@ export type Database = {},{foreignKeyName: "partner_id_fkey"- columns: ["id"]+ columns: ["supplierLocationId"]isOneToOne: falsereferencedRelation: "supplierLocation"referencedColumns: ["id"]},{foreignKeyName: "partner_id_fkey"- columns: ["supplierLocationId"]+ columns: ["id"]isOneToOne: falsereferencedRelation: "supplierLocation"referencedColumns: ["id"]diff --git a/packages/database/supabase/functions/update-purchased-prices/index.ts b/packages/database/supabase/functions/update-purchased-prices/index.tsindex 70e0af687b..dc999e2494 100644--- a/packages/database/supabase/functions/update-purchased-prices/index.ts+++ b/packages/database/supabase/functions/update-purchased-prices/index.ts@@ -42,7 +42,7 @@ serve(async (req: Request) => {const companyId = purchaseInvoice.data.companyId;- const [costLedgers, itemSuppliers] = await Promise.all([+ const [costLedgers, buyMethods] = await Promise.all([client.from("costLedger").select("*")@@ -50,7 +50,7 @@ serve(async (req: Request) => {.eq("companyId", companyId).gte("postingDate", dateOneYearAgo),client- .from("itemSupplier")+ .from("buyMethod").select("*").eq("supplierId", purchaseInvoice.data?.supplierId ?? "")@@ -60,9 +60,9 @@ serve(async (req: Request) => {const itemCostUpdates: Database["public"]["Tables"]["itemCost"]["Update"][] =[];- const itemSupplierInserts: Database["public"]["Tables"]["itemSupplier"]["Insert"][] =+ const buyMethodInserts: Database["public"]["Tables"]["buyMethod"]["Insert"][] =[];- const itemSupplierUpdates: Database["public"]["Tables"]["itemSupplier"]["Update"][] =+ const buyMethodUpdates: Database["public"]["Tables"]["buyMethod"]["Update"][] =[];const historicalPartCosts: Record<@@ -94,22 +94,22 @@ serve(async (req: Request) => {updatedBy: "system",});- const itemSupplier = itemSuppliers.data?.find(- (itemSupplier) =>- itemSupplier.itemId === line.itemId &&- itemSupplier.supplierId === purchaseInvoice.data?.supplierId+ const buyMethod = buyMethods.data?.find(+ (buyMethod) =>+ buyMethod.itemId === line.itemId &&+ buyMethod.supplierId === purchaseInvoice.data?.supplierId);- if (itemSupplier && itemSupplier.id) {- itemSupplierUpdates.push({- id: itemSupplier.id,+ if (buyMethod && buyMethod.id) {+ buyMethodUpdates.push({+ id: buyMethod.id,unitPrice: line.unitPrice,conversionFactor: line.conversionFactor ?? 1,supplierUnitOfMeasureCode: line.purchaseUnitOfMeasureCode,updatedBy: "system",});} else {- itemSupplierInserts.push({+ buyMethodInserts.push({itemId: line.itemId,supplierId: purchaseInvoice.data?.supplierId!,unitPrice: line.unitPrice,@@ -134,19 +134,16 @@ serve(async (req: Request) => {}}- if (itemSupplierInserts.length > 0) {- await trx- .insertInto("itemSupplier")- .values(itemSupplierInserts)- .execute();+ if (buyMethodInserts.length > 0) {+ await trx.insertInto("buyMethod").values(buyMethodInserts).execute();}- if (itemSupplierUpdates.length > 0) {- for await (const itemSupplierUpdate of itemSupplierUpdates) {+ if (buyMethodUpdates.length > 0) {+ for await (const buyMethodUpdate of buyMethodUpdates) {await trx- .updateTable("itemSupplier")- .set(itemSupplierUpdate)- .where("id", "=", itemSupplierUpdate.id!)+ .updateTable("buyMethod")+ .set(buyMethodUpdate)+ .where("id", "=", buyMethodUpdate.id!).execute();}}diff --git a/packages/database/supabase/migrations/20230330024716_parts.sql b/packages/database/supabase/migrations/20230330024716_parts.sqlindex c328d61c18..52fc7ae8dc 100644--- a/packages/database/supabase/migrations/20230330024716_parts.sql+++ b/packages/database/supabase/migrations/20230330024716_parts.sql@@ -418,7 +418,7 @@ CREATE POLICY "Employees with parts_update can update part sale prices" ON "itemhas_company_permission('parts_update', "companyId"));-CREATE TABLE "itemSupplier" (+CREATE TABLE "buyMethod" ("id" TEXT NOT NULL DEFAULT xid(),"itemId" TEXT NOT NULL,"supplierId" TEXT NOT NULL,@@ -434,21 +434,21 @@ CREATE TABLE "itemSupplier" ("updatedAt" TIMESTAMP WITH TIME ZONE,"customFields" JSONB,- CONSTRAINT "itemSupplier_id_pkey" PRIMARY KEY ("id", "companyId"),- CONSTRAINT "itemSupplier_itemId_fkey" FOREIGN KEY ("itemId") REFERENCES "item"("id") ON DELETE CASCADE ON UPDATE CASCADE,- CONSTRAINT "itemSupplier_supplierId_fkey" FOREIGN KEY ("supplierId") REFERENCES "supplier"("id") ON DELETE CASCADE,- CONSTRAINT "itemSupplier_part_supplier_unique" UNIQUE ("itemId", "supplierId", "companyId"),- CONSTRAINT "itemSupplier_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company"("id") ON DELETE CASCADE ON UPDATE CASCADE,- CONSTRAINT "itemSupplier_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id"),- CONSTRAINT "itemSupplier_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id")+ CONSTRAINT "buyMethod_id_pkey" PRIMARY KEY ("id", "companyId"),+ CONSTRAINT "buyMethod_itemId_fkey" FOREIGN KEY ("itemId") REFERENCES "item"("id") ON DELETE CASCADE ON UPDATE CASCADE,+ CONSTRAINT "buyMethod_supplierId_fkey" FOREIGN KEY ("supplierId") REFERENCES "supplier"("id") ON DELETE CASCADE,+ CONSTRAINT "buyMethod_part_supplier_unique" UNIQUE ("itemId", "supplierId", "companyId"),+ CONSTRAINT "buyMethod_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company"("id") ON DELETE CASCADE ON UPDATE CASCADE,+ CONSTRAINT "buyMethod_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id"),+ CONSTRAINT "buyMethod_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id"));-CREATE INDEX "itemSupplier_itemId_idx" ON "itemSupplier"("itemId");-CREATE INDEX "itemSupplier_companyId_idx" ON "itemSupplier"("companyId");+CREATE INDEX "buyMethod_itemId_idx" ON "buyMethod"("itemId");+CREATE INDEX "buyMethod_companyId_idx" ON "buyMethod"("companyId");-ALTER TABLE "itemSupplier" ENABLE ROW LEVEL SECURITY;+ALTER TABLE "buyMethod" ENABLE ROW LEVEL SECURITY;-CREATE POLICY "Employees with part/purchasing_view can view part suppliers" ON "itemSupplier"+CREATE POLICY "Employees with part/purchasing_view can view part suppliers" ON "buyMethod"FOR SELECTUSING ((@@ -458,28 +458,28 @@ CREATE POLICY "Employees with part/purchasing_view can view part suppliers" ON "AND has_role('employee'));-CREATE POLICY "Employees with parts_create can create part suppliers" ON "itemSupplier"+CREATE POLICY "Employees with parts_create can create part suppliers" ON "buyMethod"FOR INSERTWITH CHECK (has_role('employee') ANDhas_company_permission('parts_create', "companyId"));-CREATE POLICY "Employees with parts_update can update part suppliers" ON "itemSupplier"+CREATE POLICY "Employees with parts_update can update part suppliers" ON "buyMethod"FOR UPDATEUSING (has_role('employee') ANDhas_company_permission('parts_update', "companyId"));-CREATE POLICY "Employees with parts_delete can delete part suppliers" ON "itemSupplier"+CREATE POLICY "Employees with parts_delete can delete part suppliers" ON "buyMethod"FOR DELETEUSING (has_role('employee') ANDhas_company_permission('parts_delete', "companyId"));-CREATE POLICY "Suppliers with parts_view can view their own part suppliers" ON "itemSupplier"+CREATE POLICY "Suppliers with parts_view can view their own part suppliers" ON "buyMethod"FOR SELECTUSING (has_role('supplier') AND@@ -489,7 +489,7 @@ CREATE POLICY "Suppliers with parts_view can view their own part suppliers" ON "));-CREATE POLICY "Suppliers with parts_update can update their own part suppliers" ON "itemSupplier"+CREATE POLICY "Suppliers with parts_update can update their own part suppliers" ON "buyMethod"FOR UPDATEUSING (has_role('supplier') AND@@ -558,7 +558,7 @@ CREATE POLICY "Suppliers with parts can view parts they created or supply" ON "p"createdBy" = auth.uid()::textOR (id IN (- SELECT "itemId" FROM "itemSupplier" WHERE "supplierId" IN (+ SELECT "itemId" FROM "buyMethod" WHERE "supplierId" IN (SELECT "supplierId" FROM "supplierAccount" WHERE id::uuid = auth.uid()))@@ -582,7 +582,7 @@ CREATE POLICY "Suppliers with parts_update can update parts that they created or"createdBy" = auth.uid()::textOR (id IN (- SELECT "itemId" FROM "itemSupplier" WHERE "supplierId" IN (+ SELECT "itemId" FROM "buyMethod" WHERE "supplierId" IN (SELECT "supplierId" FROM "supplierAccount" WHERE id::uuid = auth.uid()))@@ -599,7 +599,7 @@ CREATE POLICY "Suppliers with parts_delete can delete parts that they created or"createdBy" = auth.uid()::textOR (id IN (- SELECT "itemId" FROM "itemSupplier" WHERE "supplierId" IN (+ SELECT "itemId" FROM "buyMethod" WHERE "supplierId" IN (SELECT "supplierId" FROM "supplierAccount" WHERE id::uuid = auth.uid()))@@ -614,7 +614,7 @@ CREATE POLICY "Suppliers with parts_view can view part costs they supply" ON "ithas_company_permission('parts_view', "companyId")AND ("itemId" IN (- SELECT "itemId" FROM "itemSupplier" WHERE "supplierId" IN (+ SELECT "itemId" FROM "buyMethod" WHERE "supplierId" IN (SELECT "supplierId" FROM "supplierAccount" WHERE id::uuid = auth.uid()))@@ -628,7 +628,7 @@ CREATE POLICY "Suppliers with parts_update can update parts costs that they supphas_company_permission('parts_update', "companyId")AND ("itemId" IN (- SELECT "itemId" FROM "itemSupplier" WHERE "supplierId" IN (+ SELECT "itemId" FROM "buyMethod" WHERE "supplierId" IN (SELECT "supplierId" FROM "supplierAccount" WHERE id::uuid = auth.uid()))@@ -642,7 +642,7 @@ CREATE POLICY "Suppliers with parts_view can view part replenishments they supplhas_company_permission('parts_create', "companyId")AND ("itemId" IN (- SELECT "itemId" FROM "itemSupplier" WHERE "supplierId" IN (+ SELECT "itemId" FROM "buyMethod" WHERE "supplierId" IN (SELECT "supplierId" FROM "supplierAccount" WHERE id::uuid = auth.uid()))@@ -656,7 +656,7 @@ CREATE POLICY "Suppliers with parts_update can update parts replenishments thathas_company_permission('parts_update', "companyId")AND ("itemId" IN (- SELECT "itemId" FROM "itemSupplier" WHERE "supplierId" IN (+ SELECT "itemId" FROM "buyMethod" WHERE "supplierId" IN (SELECT "supplierId" FROM "supplierAccount" WHERE id::uuid = auth.uid()))@@ -805,7 +805,7 @@ CREATE POLICY "Employees with parts_update can update part planning" ON "itemPla);-CREATE TABLE "itemInventory" (+CREATE TABLE "pickMethod" ("itemId" TEXT NOT NULL,"locationId" TEXT NOT NULL,"defaultShelfId" TEXT,@@ -816,21 +816,21 @@ CREATE TABLE "itemInventory" ("updatedAt" TIMESTAMP WITH TIME ZONE,"customFields" JSONB,- CONSTRAINT "itemInventory_itemId_locationId_key" UNIQUE ("itemId", "locationId"),- CONSTRAINT "itemInventory_itemId_fkey" FOREIGN KEY ("itemId") REFERENCES "item"("id") ON DELETE CASCADE ON UPDATE CASCADE,- CONSTRAINT "itemInventory_locationId_fkey" FOREIGN KEY ("locationId") REFERENCES "location"("id") ON DELETE CASCADE ON UPDATE CASCADE,- CONSTRAINT "itemInventory_shelfId_fkey" FOREIGN KEY ("defaultShelfId", "locationId") REFERENCES "shelf"("id", "locationId") ON DELETE SET NULL,- CONSTRAINT "itemInventory_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company"("id") ON DELETE CASCADE ON UPDATE CASCADE,- CONSTRAINT "itemInventory_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id"),- CONSTRAINT "itemInventory_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id")+ CONSTRAINT "pickMethod_itemId_locationId_key" UNIQUE ("itemId", "locationId"),+ CONSTRAINT "pickMethod_itemId_fkey" FOREIGN KEY ("itemId") REFERENCES "item"("id") ON DELETE CASCADE ON UPDATE CASCADE,+ CONSTRAINT "pickMethod_locationId_fkey" FOREIGN KEY ("locationId") REFERENCES "location"("id") ON DELETE CASCADE ON UPDATE CASCADE,+ CONSTRAINT "pickMethod_shelfId_fkey" FOREIGN KEY ("defaultShelfId", "locationId") REFERENCES "shelf"("id", "locationId") ON DELETE SET NULL,+ CONSTRAINT "pickMethod_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company"("id") ON DELETE CASCADE ON UPDATE CASCADE,+ CONSTRAINT "pickMethod_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id"),+ CONSTRAINT "pickMethod_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id"));-CREATE INDEX "itemInventory_itemId_locationId_idx" ON "itemInventory" ("itemId", "locationId");-CREATE INDEX "itemInventory_shelfId_idx" ON "itemInventory" ("defaultShelfId");+CREATE INDEX "pickMethod_itemId_locationId_idx" ON "pickMethod" ("itemId", "locationId");+CREATE INDEX "pickMethod_shelfId_idx" ON "pickMethod" ("defaultShelfId");-ALTER TABLE "itemInventory" ENABLE ROW LEVEL SECURITY;+ALTER TABLE "pickMethod" ENABLE ROW LEVEL SECURITY;-CREATE POLICY "Employees with part_view can view part planning" ON "itemInventory"+CREATE POLICY "Employees with part_view can view part planning" ON "pickMethod"FOR SELECTUSING (has_role('employee') AND@@ -838,14 +838,14 @@ CREATE POLICY "Employees with part_view can view part planning" ON "itemInventor);-- these are records are created lazily when a user attempts to view them-CREATE POLICY "Employees with part_view can insert part planning" ON "itemInventory"+CREATE POLICY "Employees with part_view can insert part planning" ON "pickMethod"FOR INSERTWITH CHECK (has_role('employee') ANDhas_company_permission('parts_view', "companyId"));-CREATE POLICY "Employees with parts_update can update part planning" ON "itemInventory"+CREATE POLICY "Employees with parts_update can update part planning" ON "pickMethod"FOR UPDATEUSING (has_role('employee') ANDdiff --git a/packages/database/supabase/migrations/20230704160029_supplier-view.sql b/packages/database/supabase/migrations/20230704160029_supplier-view.sqlindex a6ab9a8470..30d8ca3b5a 100644--- a/packages/database/supabase/migrations/20230704160029_supplier-view.sql+++ b/packages/database/supabase/migrations/20230704160029_supplier-view.sql@@ -24,7 +24,7 @@ CREATE OR REPLACE VIEW "suppliers" ASSELECT"supplierId",COUNT(*) AS "count"- FROM "itemSupplier"+ FROM "buyMethod"GROUP BY "supplierId") i ON i."supplierId" = s.id;diff --git a/packages/database/supabase/migrations/20230704161623_parts-view.sql b/packages/database/supabase/migrations/20230704161623_parts-view.sqlindex 0a09fe976e..3470fae533 100644--- a/packages/database/supabase/migrations/20230704161623_parts-view.sql+++ b/packages/database/supabase/migrations/20230704161623_parts-view.sql@@ -18,7 +18,7 @@ CREATE OR REPLACE VIEW "parts" ASFROM "part" pINNER JOIN "item" i ON i.id = p."itemId"LEFT JOIN "itemGroup" pg ON pg.id = i."itemGroupId"- LEFT JOIN "itemSupplier" s ON s."itemId" = p."itemId"+ 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,diff --git a/packages/database/supabase/migrations/20231222200612_purchase-order-document.sql b/packages/database/supabase/migrations/20231222200612_purchase-order-document.sqlindex 9b4fea500e..e1653eaf4e 100644--- a/packages/database/supabase/migrations/20231222200612_purchase-order-document.sql+++ b/packages/database/supabase/migrations/20231222200612_purchase-order-document.sql@@ -9,7 +9,7 @@ CREATE OR REPLACE VIEW "purchaseOrderLines" WITH(SECURITY_INVOKER=true) ASON po.id = pol."purchaseOrderId"LEFT OUTER JOIN "item" iON i.id = pol."itemId"- LEFT OUTER JOIN "itemSupplier" sup+ LEFT OUTER JOIN "buyMethod" supON i.id = sup."itemId" AND po."supplierId" = sup."supplierId";CREATE OR REPLACE VIEW "purchaseOrderLocations" WITH(SECURITY_INVOKER=true) ASdiff --git a/packages/database/supabase/migrations/20240324175747_assignee.sql b/packages/database/supabase/migrations/20240324175747_assignee.sqlindex 62b165256f..b74669d4c1 100644--- a/packages/database/supabase/migrations/20240324175747_assignee.sql+++ b/packages/database/supabase/migrations/20240324175747_assignee.sql@@ -28,7 +28,7 @@ CREATE OR REPLACE VIEW "parts" WITH(SECURITY_INVOKER=true) ASSELECT"itemId",array_agg(ps."supplierId") AS "supplierIds"- FROM "itemSupplier" ps+ FROM "buyMethod" psGROUP BY "itemId") ps ON ps."itemId" = p."itemId"LEFT JOIN "unitOfMeasure" uom ON uom.code = i."unitOfMeasureCode" AND uom."companyId" = i."companyId";@@ -190,6 +190,6 @@ CREATE OR REPLACE VIEW "suppliers" WITH(SECURITY_INVOKER=true) ASSELECT"supplierId",COUNT(*) AS "count"- FROM "itemSupplier"+ FROM "buyMethod"GROUP BY "supplierId") p ON p."supplierId" = s.id;\ No newline at end of filediff --git a/packages/database/supabase/migrations/20240402052512_purchasing-conversion-factors.sql b/packages/database/supabase/migrations/20240402052512_purchasing-conversion-factors.sqlindex e03a457afc..a76508ff39 100644--- a/packages/database/supabase/migrations/20240402052512_purchasing-conversion-factors.sql+++ b/packages/database/supabase/migrations/20240402052512_purchasing-conversion-factors.sql@@ -1,7 +1,7 @@ALTER TABLE "purchaseOrderLine" ADD COLUMN "conversionFactor" NUMERIC(10, 2) DEFAULT 1;ALTER TABLE "purchaseInvoiceLine" ADD COLUMN "conversionFactor" NUMERIC(10, 2) DEFAULT 1;-ALTER TABLE "itemSupplier" ADD COLUMN "unitPrice" NUMERIC(10, 2) DEFAULT 0;+ALTER TABLE "buyMethod" ADD COLUMN "unitPrice" NUMERIC(10, 2) DEFAULT 0;ALTER TABLE "unitOfMeasure" DROP CONSTRAINT "unitOfMeasure_code_check";@@ -19,7 +19,7 @@ CREATE OR REPLACE VIEW "purchaseOrderLines" WITH(SECURITY_INVOKER=true) AS-- TODO: this is an unnecessary join, we should remove it after replacing PO line with item instead of partLEFT OUTER JOIN "item" iON i.id = pol."itemId"- LEFT OUTER JOIN "itemSupplier" ps+ LEFT OUTER JOIN "buyMethod" psON i.id = ps."itemId" AND po."supplierId" = ps."supplierId";ALTER TABLE "receiptLine" ADD COLUMN "conversionFactor" NUMERIC(10, 2) DEFAULT 1;diff --git a/packages/database/supabase/migrations/20240511125727_seed_custom_fields.sql b/packages/database/supabase/migrations/20240511125727_seed_custom_fields.sqlindex 189d63708d..6a65c2dbfb 100644--- a/packages/database/supabase/migrations/20240511125727_seed_custom_fields.sql+++ b/packages/database/supabase/migrations/20240511125727_seed_custom_fields.sql@@ -23,10 +23,10 @@ VALUES('part', 'Part', 'Parts'),('itemCost', 'Item Cost', 'Parts'),('itemGroup', 'Item Group', 'Parts'),-('itemInventory', 'Item Inventory', 'Parts'),+('pickMethod', 'Item Inventory', 'Parts'),('itemPlanning', 'Item Planning', 'Parts'),('itemReplenishment', 'Item Replenishment', 'Parts'),-('itemSupplier', 'Item Supplier', 'Parts'),+('buyMethod', 'Item Supplier', 'Parts'),('itemUnitSalePrice', 'Item Unit Sale Price', 'Parts'),('partner', 'Partner', 'Resources'),('paymentTerm', 'Payment Term', 'Accounting'),diff --git a/packages/database/supabase/migrations/20240601210618_assignee-to-item.sql b/packages/database/supabase/migrations/20240601210618_assignee-to-item.sqlindex 96ed4f454f..37507260c8 100644--- a/packages/database/supabase/migrations/20240601210618_assignee-to-item.sql+++ b/packages/database/supabase/migrations/20240601210618_assignee-to-item.sql@@ -30,7 +30,7 @@ CREATE OR REPLACE VIEW "parts" WITH(SECURITY_INVOKER=true) ASSELECT"itemId",array_agg(ps."supplierId") AS "supplierIds"- FROM "itemSupplier" ps+ FROM "buyMethod" psGROUP BY "itemId") ps ON ps."itemId" = p."itemId"LEFT JOIN "unitOfMeasure" uom ON uom.code = i."unitOfMeasureCode" AND uom."companyId" = i."companyId";@@ -54,7 +54,7 @@ CREATE OR REPLACE VIEW "services" WITH(SECURITY_INVOKER=true) ASSELECT"itemId",array_agg(ss."supplierId") AS "supplierIds"- FROM "itemSupplier" ss+ FROM "buyMethod" ssGROUP BY "itemId") ss ON ss."itemId" = s."itemId";diff --git a/packages/database/supabase/migrations/20240608103855_tools.sql b/packages/database/supabase/migrations/20240608103855_tools.sqlindex be2637d116..2611d153cf 100644--- a/packages/database/supabase/migrations/20240608103855_tools.sql+++ b/packages/database/supabase/migrations/20240608103855_tools.sql@@ -81,7 +81,7 @@ CREATE OR REPLACE VIEW "tools" WITH(SECURITY_INVOKER=true) ASSELECT"itemId",array_agg(s."supplierId") AS "supplierIds"- FROM "itemSupplier" s+ FROM "buyMethod" sGROUP BY "itemId") s ON s."itemId" = t."itemId"LEFT JOIN "unitOfMeasure" uom ON uom.code = i."unitOfMeasureCode" AND uom."companyId" = i."companyId";diff --git a/packages/database/supabase/migrations/20240608105638_consumables.sql b/packages/database/supabase/migrations/20240608105638_consumables.sqlindex 08529ce6ca..e15764245c 100644--- a/packages/database/supabase/migrations/20240608105638_consumables.sql+++ b/packages/database/supabase/migrations/20240608105638_consumables.sql@@ -77,7 +77,7 @@ CREATE OR REPLACE VIEW "consumables" WITH(SECURITY_INVOKER=true) ASSELECT"itemId",array_agg(s."supplierId") AS "supplierIds"- FROM "itemSupplier" s+ FROM "buyMethod" sGROUP BY "itemId") s ON s."itemId" = c."itemId"LEFT JOIN "unitOfMeasure" uom ON uom.code = i."unitOfMeasureCode" AND uom."companyId" = i."companyId";diff --git a/packages/database/supabase/migrations/20240608111319_fixtures.sql b/packages/database/supabase/migrations/20240608111319_fixtures.sqlindex d000c3c06e..ee70b68f1b 100644--- a/packages/database/supabase/migrations/20240608111319_fixtures.sql+++ b/packages/database/supabase/migrations/20240608111319_fixtures.sql@@ -78,7 +78,7 @@ CREATE OR REPLACE VIEW "fixtures" WITH(SECURITY_INVOKER=true) ASSELECT"itemId",array_agg(s."supplierId") AS "supplierIds"- FROM "itemSupplier" s+ FROM "buyMethod" sGROUP BY "itemId") s ON s."itemId" = f."itemId"LEFT JOIN "customer" c ON c.id = f."customerId";diff --git a/packages/database/supabase/migrations/20240608114413_materials.sql b/packages/database/supabase/migrations/20240608114413_materials.sqlindex 8c24aaa5e1..7e8ddeeff5 100644--- a/packages/database/supabase/migrations/20240608114413_materials.sql+++ b/packages/database/supabase/migrations/20240608114413_materials.sql@@ -214,7 +214,7 @@ CREATE OR REPLACE VIEW "materials" WITH(SECURITY_INVOKER=true) ASSELECT"itemId",array_agg(s."supplierId") AS "supplierIds"- FROM "itemSupplier" s+ FROM "buyMethod" sGROUP BY "itemId") s ON s."itemId" = m."itemId"LEFT JOIN "materialForm" mf ON mf.id = m."materialFormId"diff --git a/packages/react/src/Card.tsx b/packages/react/src/Card.tsxindex d5d6cc8019..6b845b39cd 100644--- a/packages/react/src/Card.tsx+++ b/packages/react/src/Card.tsx@@ -34,7 +34,7 @@ const CardAttribute = forwardRef<<divref={ref}className={cn(- "flex flex-row md:flex-col items-start justify-between gap-2",+ "flex flex-row md:flex-col items-start justify-between gap-1",className)}{...props}@@ -60,7 +60,7 @@ const CardAttributeLabel = forwardRef<>(({ className, ...props }, ref) => (<divref={ref}- className={cn("text-sm text-muted-foreground", className)}+ className={cn("text-xs text-muted-foreground", className)}{...props}/>));