Skip to content

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

Replace pick, buy, make with pull from inventory, purchase to order, and make to order (#585)

Brad Barbine764fbf82fd2
diff --git a/apps/erp/app/components/Form/CustomFormFields.tsx b/apps/erp/app/components/Form/CustomFormFields.tsx
index 8c3e8ea64c..0844fb394e 100644
--- a/apps/erp/app/components/Form/CustomFormFields.tsx
+++ b/apps/erp/app/components/Form/CustomFormFields.tsx
@@ -1,4 +1,3 @@
-// biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
import { Boolean, DatePicker, Input, Number, Select } from "@carbon/form";
import { useCustomFieldsSchema } from "~/hooks/useCustomFieldsSchema";
import { DataType } from "~/modules/shared";
diff --git a/apps/erp/app/components/Form/CustomFormInlineFields.tsx b/apps/erp/app/components/Form/CustomFormInlineFields.tsx
index e0ccd4a6da..b8c4af53e8 100644
--- a/apps/erp/app/components/Form/CustomFormInlineFields.tsx
+++ b/apps/erp/app/components/Form/CustomFormInlineFields.tsx
@@ -1,6 +1,5 @@
import type { Json } from "@carbon/database";
import {
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Boolean,
DatePicker,
InputControlled,
diff --git a/apps/erp/app/components/Form/DefaultMethodType.tsx b/apps/erp/app/components/Form/DefaultMethodType.tsx
index 18004e2d51..4a68a958f6 100644
--- a/apps/erp/app/components/Form/DefaultMethodType.tsx
+++ b/apps/erp/app/components/Form/DefaultMethodType.tsx
@@ -1,5 +1,6 @@
import type { SelectProps } from "@carbon/form";
import { SelectControlled } from "@carbon/form";
+import { getValidMethodTypes } from "~/modules/shared/shared.models";
import { MethodIcon } from "../Icons";
export type DefaultMethodTypeSelectProps = Omit<SelectProps, "options"> & {
@@ -10,13 +11,7 @@ const DefaultMethodType = ({
replenishmentSystem,
...props
}: DefaultMethodTypeSelectProps) => {
- const options = (
- replenishmentSystem === "Buy"
- ? ["Buy", "Pick"]
- : replenishmentSystem === "Make"
- ? ["Make", "Pick"]
- : ["Buy", "Make", "Pick"]
- ).map((t) => ({
+ const options = getValidMethodTypes(replenishmentSystem).map((t) => ({
value: t,
label: (
<span className="flex items-center gap-2">
diff --git a/apps/erp/app/components/Form/Item.tsx b/apps/erp/app/components/Form/Item.tsx
index 108ee373df..779b81f042 100644
--- a/apps/erp/app/components/Form/Item.tsx
+++ b/apps/erp/app/components/Form/Item.tsx
@@ -351,7 +351,9 @@ const Item = ({
replenishmentSystem: props?.replenishmentSystem ?? "Make",
unitOfMeasureCode: "EA",
defaultMethodType:
- props?.replenishmentSystem === "Buy" ? "Pick" : "Make",
+ props?.replenishmentSystem === "Buy"
+ ? "Pull from Inventory"
+ : "Make to Order",
unitCost: 0,
lotSize: 0,
tags: []
@@ -373,7 +375,7 @@ const Item = ({
itemTrackingType: "Non-Inventory",
unitOfMeasureCode: "EA",
replenishmentSystem: "Buy",
- defaultMethodType: "Buy",
+ defaultMethodType: "Pull from Inventory",
unitCost: 0,
tags: []
}}
@@ -396,7 +398,7 @@ const Item = ({
itemTrackingType: "Inventory",
unitOfMeasureCode: "EA",
replenishmentSystem: "Buy",
- defaultMethodType: "Buy",
+ defaultMethodType: "Pull from Inventory",
unitCost: 0,
tags: []
}}
@@ -420,7 +422,9 @@ const Item = ({
unitOfMeasureCode: "EA",
replenishmentSystem: props?.replenishmentSystem ?? "Buy",
defaultMethodType:
- props?.replenishmentSystem === "Buy" ? "Pick" : "Make",
+ props?.replenishmentSystem === "Buy"
+ ? "Pull from Inventory"
+ : "Make to Order",
unitCost: 0,
tags: []
}}
diff --git a/apps/erp/app/components/Form/Part.tsx b/apps/erp/app/components/Form/Part.tsx
index a294426f3b..7a9914623c 100644
--- a/apps/erp/app/components/Form/Part.tsx
+++ b/apps/erp/app/components/Form/Part.tsx
@@ -53,7 +53,7 @@ const Part = ({ itemReplenishmentSystem, ...props }: PartSelectProps) => {
description: "",
itemTrackingType: "Inventory" as "Inventory",
replenishmentSystem: itemReplenishmentSystem ?? "Buy and Make",
- defaultMethodType: "Buy",
+ defaultMethodType: "Pull from Inventory",
unitOfMeasureCode: "EA",
unitCost: 0,
lotSize: 0
diff --git a/apps/erp/app/components/Form/Tool.tsx b/apps/erp/app/components/Form/Tool.tsx
index d7df52b002..83092a294c 100644
--- a/apps/erp/app/components/Form/Tool.tsx
+++ b/apps/erp/app/components/Form/Tool.tsx
@@ -128,7 +128,7 @@ const Tool = ({ name, label, helperText, ...props }: ToolSelectProps) => {
itemTrackingType: "Inventory",
unitOfMeasureCode: "EA",
replenishmentSystem: "Buy",
- defaultMethodType: "Buy",
+ defaultMethodType: "Pull from Inventory",
unitCost: 0,
tags: []
}}
diff --git a/apps/erp/app/components/Form/index.ts b/apps/erp/app/components/Form/index.ts
index f0ea1d6003..99e3955cf7 100644
--- a/apps/erp/app/components/Form/index.ts
+++ b/apps/erp/app/components/Form/index.ts
@@ -1,8 +1,6 @@
import {
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Array,
ArrayNumeric,
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Boolean,
Combobox,
CreatableCombobox,
@@ -14,7 +12,6 @@ import {
Input,
InputControlled,
MultiSelect,
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Number,
NumberControlled,
Password,
diff --git a/apps/erp/app/components/Icons.tsx b/apps/erp/app/components/Icons.tsx
index 8c1ffb2c49..a8116636f5 100644
--- a/apps/erp/app/components/Icons.tsx
+++ b/apps/erp/app/components/Icons.tsx
@@ -32,16 +32,16 @@ import {
LuHammer,
LuHardHat,
LuHeadphones,
- LuHexagon,
LuImage,
LuList,
LuPizza,
LuQrCode,
LuShoppingCart,
LuSquare,
- LuSwords,
+ LuTarget,
LuTimer,
LuToggleLeft,
+ LuTruck,
LuUser
} from "react-icons/lu";
import { RxCodesandboxLogo } from "react-icons/rx";
@@ -85,6 +85,25 @@ export const MethodItemTypeIcon = ({
return <LuSquare className={cn("text-muted-foreground", className)} />;
};
+export const SourcingTypeIcon = ({
+ type,
+ className
+}: {
+ type: string;
+ className?: string;
+}) => {
+ switch (type) {
+ case "Specified":
+ return <LuTarget className={cn("text-red-500", className)} />;
+ case "Drop Ship":
+ return <LuShoppingCart className={cn("text-blue-500", className)} />;
+ case "Ship from Inventory":
+ return <LuTruck className={cn("text-cyan-500", className)} />;
+ }
+
+ return <LuSquare className={cn("text-muted-foreground", className)} />;
+};
+
export const MethodIcon = ({
type,
className,
@@ -99,15 +118,13 @@ export const MethodIcon = ({
return (
<AiOutlinePartition className={cn(className, "text-foreground")} />
);
- case "Buy":
+ case "Purchase to Order":
return <LuShoppingCart className={cn("text-blue-500", className)} />;
- case "Make":
- return isKit ? (
- <LuHexagon className={cn("text-emerald-500", className)} />
- ) : (
+ case "Make to Order":
+ return (
<RxCodesandboxLogo className={cn("text-emerald-500", className)} />
);
- case "Pick":
+ case "Pull from Inventory":
return <FaCodePullRequest className={cn("text-yellow-500", className)} />;
}
@@ -115,7 +132,7 @@ export const MethodIcon = ({
};
type MethodBadgeProps = {
- type: "Buy" | "Make" | "Pick" | "Make Inactive";
+ type: MethodType;
text: string;
to: string;
className?: string;
@@ -127,10 +144,7 @@ export function MethodBadge({ type, text, to, className }: MethodBadgeProps) {
return (
<Link to={to} prefetch="intent" className="group flex items-center gap-1">
<Badge style={style} className={className}>
- <MethodIcon
- type={type === "Make Inactive" ? "Make" : type}
- className="w-3 h-3 mr-1 "
- />
+ <MethodIcon type={type} className="w-3 h-3 mr-1 " />
{text}
</Badge>
<span className="group-hover:opacity-100 opacity-0 transition-opacity duration-200 w-4 h-4 text-foreground">
@@ -140,17 +154,12 @@ export function MethodBadge({ type, text, to, className }: MethodBadgeProps) {
);
}
-function getReplenishmentBadgeColor(
- type: MethodType | "Make Inactive",
- mode: "light" | "dark"
-) {
- return type === "Buy"
+function getReplenishmentBadgeColor(type: MethodType, mode: "light" | "dark") {
+ return type === "Purchase to Order"
? getColor("blue", mode)
- : type === "Make"
+ : type === "Make to Order"
? getColor("green", mode)
- : type === "Make Inactive"
- ? getColor("gray", mode)
- : getColor("orange", mode);
+ : getColor("orange", mode);
}
export const OnshapeStatus = ({
@@ -359,7 +368,7 @@ export const ReplenishmentSystemIcon = ({
<RxCodesandboxLogo className={cn("text-emerald-500", className)} />
);
case "Buy and Make":
- return <LuSwords className={cn("text-yellow-500", className)} />;
+ return <LuFlaskConical className={cn("text-teal-500", className)} />;
}
return <LuSquare className={cn("text-muted-foreground", className)} />;
diff --git a/apps/erp/app/components/index.ts b/apps/erp/app/components/index.ts
index f3d480ae97..bb13f6f294 100644
--- a/apps/erp/app/components/index.ts
+++ b/apps/erp/app/components/index.ts
@@ -20,6 +20,7 @@ import {
MethodItemTypeIcon,
ModuleIcon,
OperationStatusIcon,
+ SourcingTypeIcon,
TimeTypeIcon,
TrackingTypeIcon
} from "./Icons";
@@ -62,6 +63,7 @@ export {
RealtimeDataProvider,
SearchFilter,
Select,
+ SourcingTypeIcon,
SupplierAvatar,
Table,
TimeTypeIcon,
diff --git a/apps/erp/app/modules/accounting/ui/ChartOfAccounts/ChartOfAccountForm.tsx b/apps/erp/app/modules/accounting/ui/ChartOfAccounts/ChartOfAccountForm.tsx
index c2c25e0920..6b861d31c5 100644
--- a/apps/erp/app/modules/accounting/ui/ChartOfAccounts/ChartOfAccountForm.tsx
+++ b/apps/erp/app/modules/accounting/ui/ChartOfAccounts/ChartOfAccountForm.tsx
@@ -16,7 +16,6 @@ import type { z } from "zod";
import {
AccountCategory,
AccountSubcategory,
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Boolean,
Combobox,
CustomFormFields,
diff --git a/apps/erp/app/modules/accounting/ui/Currencies/CurrencyForm.tsx b/apps/erp/app/modules/accounting/ui/Currencies/CurrencyForm.tsx
index a18b7a0020..889d1f0a32 100644
--- a/apps/erp/app/modules/accounting/ui/Currencies/CurrencyForm.tsx
+++ b/apps/erp/app/modules/accounting/ui/Currencies/CurrencyForm.tsx
@@ -17,7 +17,6 @@ import {
CustomFormFields,
Hidden,
Input,
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Number,
Submit
} from "~/components/Form";
diff --git a/apps/erp/app/modules/accounting/ui/PaymentTerms/PaymentTermForm.tsx b/apps/erp/app/modules/accounting/ui/PaymentTerms/PaymentTermForm.tsx
index 9fd61cb5e9..bef8058492 100644
--- a/apps/erp/app/modules/accounting/ui/PaymentTerms/PaymentTermForm.tsx
+++ b/apps/erp/app/modules/accounting/ui/PaymentTerms/PaymentTermForm.tsx
@@ -19,7 +19,6 @@ import {
CustomFormFields,
Hidden,
Input,
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Number,
Select,
Submit
diff --git a/apps/erp/app/modules/inventory/ui/Kanbans/KanbanForm.tsx b/apps/erp/app/modules/inventory/ui/Kanbans/KanbanForm.tsx
index 0031699be6..695597765a 100644
--- a/apps/erp/app/modules/inventory/ui/Kanbans/KanbanForm.tsx
+++ b/apps/erp/app/modules/inventory/ui/Kanbans/KanbanForm.tsx
@@ -1,5 +1,4 @@
import { useCarbon } from "@carbon/auth";
-// biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
import { Boolean, Hidden, SelectControlled, ValidatedForm } from "@carbon/form";
import {
Button,
@@ -21,7 +20,6 @@ import {
ConversionFactor,
Item,
Location,
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Number,
SequenceOrCustomId,
Shelf,
diff --git a/apps/erp/app/modules/inventory/ui/Receipts/ReceiptLines.tsx b/apps/erp/app/modules/inventory/ui/Receipts/ReceiptLines.tsx
index 5732d636df..1c57c59cd6 100644
--- a/apps/erp/app/modules/inventory/ui/Receipts/ReceiptLines.tsx
+++ b/apps/erp/app/modules/inventory/ui/Receipts/ReceiptLines.tsx
@@ -1,5 +1,4 @@
import { useCarbon } from "@carbon/auth";
-// biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
import { Number, Submit, ValidatedForm } from "@carbon/form";
import {
Button,
diff --git a/apps/erp/app/modules/inventory/ui/Shipments/ShipmentLines.tsx b/apps/erp/app/modules/inventory/ui/Shipments/ShipmentLines.tsx
index 6bef59f45d..693b50d15e 100644
--- a/apps/erp/app/modules/inventory/ui/Shipments/ShipmentLines.tsx
+++ b/apps/erp/app/modules/inventory/ui/Shipments/ShipmentLines.tsx
@@ -1,5 +1,4 @@
import { useCarbon } from "@carbon/auth";
-// biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
import { Number, Submit, ValidatedForm } from "@carbon/form";
import {
Button,
diff --git a/apps/erp/app/modules/inventory/ui/StockTransfers/StockTransferLineForm.tsx b/apps/erp/app/modules/inventory/ui/StockTransfers/StockTransferLineForm.tsx
index 92b0226738..e88257ce71 100644
--- a/apps/erp/app/modules/inventory/ui/StockTransfers/StockTransferLineForm.tsx
+++ b/apps/erp/app/modules/inventory/ui/StockTransfers/StockTransferLineForm.tsx
@@ -15,7 +15,6 @@ import type { PostgrestResponse } from "@supabase/supabase-js";
import { useEffect, useState } from "react";
import { useFetcher, useParams } from "react-router";
import type { z } from "zod";
-// biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
import { Hidden, Item, Number, Shelf, Submit } from "~/components/Form";
import { usePermissions, useRouteData } from "~/hooks";
import {
diff --git a/apps/erp/app/modules/inventory/ui/WarehouseTransfers/WarehouseTransferLineForm.tsx b/apps/erp/app/modules/inventory/ui/WarehouseTransfers/WarehouseTransferLineForm.tsx
index b228a44571..d4dc16c63b 100644
--- a/apps/erp/app/modules/inventory/ui/WarehouseTransfers/WarehouseTransferLineForm.tsx
+++ b/apps/erp/app/modules/inventory/ui/WarehouseTransfers/WarehouseTransferLineForm.tsx
@@ -19,7 +19,6 @@ import {
CustomFormFields,
Hidden,
Item,
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Number,
Shelf,
Submit,
diff --git a/apps/erp/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceDeliveryForm.tsx b/apps/erp/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceDeliveryForm.tsx
index fe11f8da7c..c5242f8a15 100644
--- a/apps/erp/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceDeliveryForm.tsx
+++ b/apps/erp/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceDeliveryForm.tsx
@@ -13,7 +13,6 @@ import {
CustomFormFields,
Hidden,
Location,
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Number,
ShippingMethod,
Submit
diff --git a/apps/erp/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceSummary.tsx b/apps/erp/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceSummary.tsx
index 086557ad98..fdec3b286b 100644
--- a/apps/erp/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceSummary.tsx
+++ b/apps/erp/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceSummary.tsx
@@ -170,8 +170,10 @@ const LineItems = ({
className="flex items-center gap-2"
>
{line.quantity}
- {/* @ts-expect-error TS2339 */}
- <MethodIcon type={line.methodType ?? "Pick"} />
+ <MethodIcon
+ // @ts-ignore
+ type={line.methodType ?? "Pull from Inventory"}
+ />
</Badge>
<Badge variant="green">
{formatter.format(line.unitPrice ?? 0)}{" "}
diff --git a/apps/erp/app/modules/invoicing/ui/SalesInvoice/SalesInvoiceLineForm.tsx b/apps/erp/app/modules/invoicing/ui/SalesInvoice/SalesInvoiceLineForm.tsx
index ad05fcdd96..9a882a4285 100644
--- a/apps/erp/app/modules/invoicing/ui/SalesInvoice/SalesInvoiceLineForm.tsx
+++ b/apps/erp/app/modules/invoicing/ui/SalesInvoice/SalesInvoiceLineForm.tsx
@@ -34,7 +34,6 @@ import {
Hidden,
Item,
Location,
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Number,
NumberControlled,
SelectControlled,
@@ -138,7 +137,7 @@ const SalesInvoiceLineForm = ({
const costsDisclosure = useDisclosure();
const isEditing = initialValues.id !== undefined;
const hasInvalidMethodType =
- itemData.methodType === "Make" && !isSalesOrderLine;
+ itemData.methodType === "Make to Order" && !isSalesOrderLine;
const isDisabled = !isEditable
? true
: hasInvalidMethodType
diff --git a/apps/erp/app/modules/invoicing/ui/SalesInvoice/SalesInvoiceShipmentForm.tsx b/apps/erp/app/modules/invoicing/ui/SalesInvoice/SalesInvoiceShipmentForm.tsx
index fc7c97bbcf..fcbb5fce45 100644
--- a/apps/erp/app/modules/invoicing/ui/SalesInvoice/SalesInvoiceShipmentForm.tsx
+++ b/apps/erp/app/modules/invoicing/ui/SalesInvoice/SalesInvoiceShipmentForm.tsx
@@ -13,7 +13,6 @@ import {
CustomFormFields,
Hidden,
Location,
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Number,
ShippingMethod,
Submit
diff --git a/apps/erp/app/modules/invoicing/ui/SalesInvoice/SalesInvoiceSummary.tsx b/apps/erp/app/modules/invoicing/ui/SalesInvoice/SalesInvoiceSummary.tsx
index e4e62e1a52..f96be8ae8c 100644
--- a/apps/erp/app/modules/invoicing/ui/SalesInvoice/SalesInvoiceSummary.tsx
+++ b/apps/erp/app/modules/invoicing/ui/SalesInvoice/SalesInvoiceSummary.tsx
@@ -181,7 +181,9 @@ const LineItems = ({
className="flex items-center gap-2"
>
{line.quantity}
- <MethodIcon type={line.methodType ?? "Pick"} />
+ <MethodIcon
+ type={line.methodType ?? "Pull from Inventory"}
+ />
</Badge>
<Badge variant="green">
{formatter.format(line.unitPrice ?? 0)}{" "}
diff --git a/apps/erp/app/modules/items/items.models.ts b/apps/erp/app/modules/items/items.models.ts
index b8fd191322..b5bc634917 100644
--- a/apps/erp/app/modules/items/items.models.ts
+++ b/apps/erp/app/modules/items/items.models.ts
@@ -5,6 +5,7 @@ import {
methodOperationOrders,
methodType,
operationTypes,
+ sourcingType,
standardFactorType
} from "../shared";
@@ -216,6 +217,11 @@ export const methodMaterialValidator = z.object({
message: "Method type is required"
})
}),
+ sourcingType: z.enum(sourcingType, {
+ errorMap: (issue, ctx) => ({
+ message: "Sourcing type is required"
+ })
+ }),
itemId: z.string().optional(),
methodOperationId: zfd.text(z.string().optional()),
// description: z.string().min(1, { message: "Description is required" }),
diff --git a/apps/erp/app/modules/items/items.service.ts b/apps/erp/app/modules/items/items.service.ts
index 90049e366a..cb40ff3e1e 100644
--- a/apps/erp/app/modules/items/items.service.ts
+++ b/apps/erp/app/modules/items/items.service.ts
@@ -2492,7 +2492,7 @@ export async function upsertMethodMaterial(
})
) {
let materialMakeMethodId: string | null = null;
- if (methodMaterial.methodType === "Make") {
+ if (methodMaterial.methodType === "Make to Order") {
const makeMethod = await client
.from("activeMakeMethods")
.select("id, version")
@@ -3059,7 +3059,10 @@ export async function upsertService(
type: "Service",
replenishmentSystem:
service.serviceType === "External" ? "Buy" : "Make",
- defaultMethodType: service.serviceType === "External" ? "Buy" : "Make",
+ defaultMethodType:
+ service.serviceType === "External"
+ ? "Purchase to Order"
+ : "Make to Order",
itemTrackingType: service.itemTrackingType,
unitOfMeasureCode: "EA",
active: true,
@@ -3109,7 +3112,9 @@ export async function upsertService(
replenishmentSystem:
service.serviceType === "External" ? "Buy" : ("Make" as "Buy"),
defaultMethodType:
- service.serviceType === "External" ? "Buy" : ("Make" as "Buy"),
+ service.serviceType === "External"
+ ? "Purchase to Order"
+ : ("Make to Order" as "Purchase to Order"),
itemTrackingType: service.itemTrackingType,
unitOfMeasureCode: null,
active: true
diff --git a/apps/erp/app/modules/items/ui/Consumables/ConsumableForm.tsx b/apps/erp/app/modules/items/ui/Consumables/ConsumableForm.tsx
index 0033fe4f5f..7f344abe86 100644
--- a/apps/erp/app/modules/items/ui/Consumables/ConsumableForm.tsx
+++ b/apps/erp/app/modules/items/ui/Consumables/ConsumableForm.tsx
@@ -22,7 +22,6 @@ import {
Input,
InputControlled,
ItemPostingGroup,
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Number,
Select,
Submit,
@@ -70,7 +69,7 @@ const ConsumableForm = ({
const isEditing = !!initialValues.id;
const [defaultMethodType, setDefaultMethodType] = useState<string>(
- initialValues.defaultMethodType ?? "Buy"
+ initialValues.defaultMethodType ?? "Purchase to Order"
);
const itemTrackingTypeOptions = itemTrackingTypes.map((itemTrackingType) => ({
@@ -151,7 +150,7 @@ const ConsumableForm = ({
replenishmentSystem="Buy"
value={defaultMethodType}
onChange={(newValue) =>
- setDefaultMethodType(newValue?.value ?? "Buy")
+ setDefaultMethodType(newValue?.value ?? "Purchase to Order")
}
/>
<UnitOfMeasure
diff --git a/apps/erp/app/modules/items/ui/Consumables/ConsumableProperties.tsx b/apps/erp/app/modules/items/ui/Consumables/ConsumableProperties.tsx
index 3bedef57b4..2b404f1a5a 100644
--- a/apps/erp/app/modules/items/ui/Consumables/ConsumableProperties.tsx
+++ b/apps/erp/app/modules/items/ui/Consumables/ConsumableProperties.tsx
@@ -333,7 +333,7 @@ const ConsumableProperties = () => {
</Badge>
)}
options={methodType
- .filter((type) => type !== "Make")
+ .filter((type) => type !== "Make to Order")
.map((type) => ({
value: type,
label: (
@@ -365,7 +365,7 @@ const ConsumableProperties = () => {
supplierParts.map((method) => (
<MethodBadge
key={method.id}
- type="Buy"
+ type="Purchase to Order"
text={
suppliers.find((s) => s.id === method.supplierId)?.name ?? ""
}
@@ -375,7 +375,7 @@ const ConsumableProperties = () => {
{pickMethods.map((method) => (
<MethodBadge
key={method.locationId}
- type="Pick"
+ type="Pull from Inventory"
text={locations.find((l) => l.id === method.locationId)?.name ?? ""}
to={path.to.consumableInventoryLocation(itemId, method.locationId)}
/>
diff --git a/apps/erp/app/modules/items/ui/Consumables/ConsumablesTable.tsx b/apps/erp/app/modules/items/ui/Consumables/ConsumablesTable.tsx
index dd88f577ac..1cc5b39390 100644
--- a/apps/erp/app/modules/items/ui/Consumables/ConsumablesTable.tsx
+++ b/apps/erp/app/modules/items/ui/Consumables/ConsumablesTable.tsx
@@ -362,23 +362,17 @@ const ConsumablesTable = memo(
</DropdownMenuSubTrigger>
<DropdownMenuPortal>
<DropdownMenuSubContent>
- {methodType
- .filter((type) => type !== "Make")
- .map((type) => (
- <DropdownMenuItem
- key={type}
- onClick={() =>
- onBulkUpdate(
- selectedRows,
- "defaultMethodType",
- type
- )
- }
- >
- <DropdownMenuIcon icon={<MethodIcon type={type} />} />
- <span>{type}</span>
- </DropdownMenuItem>
- ))}
+ {methodType.map((type) => (
+ <DropdownMenuItem
+ key={type}
+ onClick={() =>
+ onBulkUpdate(selectedRows, "defaultMethodType", type)
+ }
+ >
+ <DropdownMenuIcon icon={<MethodIcon type={type} />} />
+ <span>{type}</span>
+ </DropdownMenuItem>
+ ))}
</DropdownMenuSubContent>
</DropdownMenuPortal>
</DropdownMenuSub>
diff --git a/apps/erp/app/modules/items/ui/Item/BillOfMaterial.tsx b/apps/erp/app/modules/items/ui/Item/BillOfMaterial.tsx
index 755153e5de..b7ef8b6b39 100644
--- a/apps/erp/app/modules/items/ui/Item/BillOfMaterial.tsx
+++ b/apps/erp/app/modules/items/ui/Item/BillOfMaterial.tsx
@@ -45,6 +45,7 @@ import {
LuLock,
LuSettings2,
LuSquareFunction,
+ LuTruck,
LuX
} from "react-icons/lu";
import {
@@ -55,7 +56,12 @@ import {
useSearchParams
} from "react-router";
import type { z } from "zod";
-import { MethodIcon, MethodItemTypeIcon, TrackingTypeIcon } from "~/components";
+import {
+ MethodIcon,
+ MethodItemTypeIcon,
+ SourcingTypeIcon,
+ TrackingTypeIcon
+} from "~/components";
import { ConfigurationEditor } from "~/components/Configurator/ConfigurationEditor";
import type { Configuration } from "~/components/Configurator/types";
import {
@@ -63,7 +69,6 @@ import {
Hidden,
Item,
Location,
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Number,
Select,
Shelf,
@@ -78,8 +83,12 @@ import type {
} from "~/components/SortableList";
import { SortableList, SortableListItem } from "~/components/SortableList";
import { usePermissions, useUrlParams, useUser } from "~/hooks";
-import type { MethodItemType, MethodType } from "~/modules/shared";
-import { methodType } from "~/modules/shared";
+import type {
+ MethodItemType,
+ MethodType,
+ SourcingType
+} from "~/modules/shared";
+import { methodType, sourcingType } from "~/modules/shared";
import type { Item as ItemType } from "~/stores";
import { useItems } from "~/stores";
@@ -115,6 +124,7 @@ type BillOfMaterialProps = {
operations: Operation[];
parameters?: ConfigurationParameter[];
configurationRules?: ConfigurationRule[];
+ replenishmentSystem?: string;
};
type OrderState = {
@@ -135,7 +145,8 @@ const initialMethodMaterial: Omit<Material, "makeMethodId" | "order"> & {
itemId: "",
// @ts-expect-error
itemType: "Item" as const,
- methodType: "Buy" as const,
+ methodType: "Purchase to Order" as const,
+ sourcingType: "Specified" as const,
description: "",
quantity: 1,
unitOfMeasureCode: "EA",
@@ -148,7 +159,8 @@ const BillOfMaterial = ({
makeMethod,
materials: initialMaterials,
operations,
- parameters
+ parameters,
+ replenishmentSystem
}: BillOfMaterialProps) => {
const permissions = usePermissions();
const isReadOnly =
@@ -217,7 +229,8 @@ const BillOfMaterial = ({
Array.from(materialsById.values()),
orderState,
checkedState,
- rulesByField
+ rulesByField,
+ replenishmentSystem
).sort((a, b) => a.data.order - b.data.order);
const onToggleItem = (id: string) => {
@@ -446,6 +459,7 @@ const BillOfMaterial = ({
temporaryItems={temporaryItems}
rulesByField={rulesByField}
onConfigure={onConfigure}
+ replenishmentSystem={replenishmentSystem}
setOrderState={setOrderState}
setSelectedItemId={setSelectedItemId}
setTemporaryItems={setTemporaryItems}
@@ -566,6 +580,7 @@ function MaterialForm({
temporaryItems,
rulesByField,
onConfigure,
+ replenishmentSystem,
setOrderState,
setSelectedItemId,
setTemporaryItems,
@@ -578,6 +593,7 @@ function MaterialForm({
orderState: OrderState;
temporaryItems: TemporaryItems;
rulesByField: Map<string, ConfigurationRule>;
+ replenishmentSystem?: string;
setSelectedItemId: Dispatch<SetStateAction<string | null>>;
setTemporaryItems: Dispatch<SetStateAction<TemporaryItems>>;
setOrderState: Dispatch<SetStateAction<OrderState>>;
@@ -609,6 +625,7 @@ function MaterialForm({
const sourceDisclosure = useDisclosure({
defaultIsOpen: true
});
+ const sourcingDisclosure = useDisclosure();
const backflushDisclosure = useDisclosure();
useEffect(() => {
@@ -631,6 +648,7 @@ function MaterialForm({
const [itemData, setItemData] = useState<{
itemId: string;
methodType: MethodType;
+ sourcingType: SourcingType;
description: string;
unitOfMeasureCode: string;
methodOperationId: string | undefined;
@@ -639,7 +657,8 @@ function MaterialForm({
shelfIds: Record<string, string>;
}>({
itemId: item.data.itemId ?? "",
- methodType: item.data.methodType ?? "Buy",
+ methodType: item.data.methodType ?? "Pull from Inventory",
+ sourcingType: item.data.sourcingType ?? "Specified",
description: item.data.description ?? "",
unitOfMeasureCode: item.data.unitOfMeasureCode ?? "EA",
methodOperationId: item.data.methodOperationId ?? undefined,
@@ -654,7 +673,8 @@ function MaterialForm({
setItemData({
itemId: "",
- methodType: "" as "Buy",
+ methodType: "" as "Pull from Inventory",
+ sourcingType: "Specified",
quantity: 1,
description: "",
unitOfMeasureCode: "EA",
@@ -690,7 +710,7 @@ function MaterialForm({
itemId,
description: item.data?.name ?? "",
unitOfMeasureCode: item.data?.unitOfMeasureCode ?? "EA",
- methodType: item.data?.defaultMethodType ?? "Buy",
+ methodType: item.data?.defaultMethodType ?? "Pull from Inventory",
kit: false
}));
if (item.data?.type) {
@@ -721,6 +741,9 @@ function MaterialForm({
<Hidden name="order" />
<Hidden name="kit" value={itemData.kit.toString()} />
<Hidden name="shelfIds" value={JSON.stringify(itemData.shelfIds)} />
+ {replenishmentSystem !== "Buy and Make" && (
+ <Hidden name="sourcingType" value={itemData.sourcingType} />
+ )}
</div>
<div className="grid w-full gap-x-8 gap-y-4 grid-cols-1 lg:grid-cols-3">
@@ -798,13 +821,87 @@ function MaterialForm({
}
/>
</div>
+ {replenishmentSystem === "Buy and Make" && (
+ <div className="border border-border rounded-md shadow-sm p-4 flex flex-col gap-4 w-full">
+ <HStack
+ className="w-full justify-between cursor-pointer"
+ onClick={sourcingDisclosure.onToggle}
+ >
+ <HStack>
+ <LuTruck className="text-foreground" />
+ <Label>Sourcing</Label>
+ </HStack>
+ <HStack>
+ <Badge variant="secondary">
+ <SourcingTypeIcon
+ type={itemData.sourcingType}
+ className="size-3 mr-1"
+ />
+ {itemData.sourcingType}
+ </Badge>
+ <IconButton
+ icon={<LuChevronRight />}
+ aria-label={
+ sourcingDisclosure.isOpen
+ ? "Collapse Sourcing"
+ : "Expand Sourcing"
+ }
+ variant="ghost"
+ size="md"
+ onClick={(e) => {
+ e.stopPropagation();
+ sourcingDisclosure.onToggle();
+ }}
+ className={`transition-transform ${
+ sourcingDisclosure.isOpen ? "rotate-90" : ""
+ }`}
+ />
+ </HStack>
+ </HStack>
+ <div
+ className={`grid w-full gap-x-8 gap-y-4 grid-cols-1 lg:grid-cols-3 pb-4 ${
+ sourcingDisclosure.isOpen ? "" : "hidden"
+ }`}
+ >
+ <Select
+ name="sourcingType"
+ label="Sourcing Type"
+ value={itemData.sourcingType}
+ options={sourcingType.map((s) => ({
+ value: s,
+ label: (
+ <span className="flex items-center gap-2">
+ <SourcingTypeIcon type={s} />
+ {s}
+ </span>
+ )
+ }))}
+ onChange={(value) => {
+ const newSourcingType = value?.value as SourcingType;
+ setItemData((d) => {
+ const updates: Partial<typeof d> = {
+ sourcingType: newSourcingType
+ };
+ if (newSourcingType === "Drop Ship") {
+ updates.methodType = "Purchase to Order";
+ } else if (newSourcingType === "Ship from Inventory") {
+ updates.methodType = "Pull from Inventory";
+ }
+ return { ...d, ...updates };
+ });
+ }}
+ />
+ </div>
+ </div>
+ )}
+
<div className="border border-border rounded-md shadow-sm p-4 flex flex-col gap-4 w-full">
<HStack
className="w-full justify-between cursor-pointer"
onClick={sourceDisclosure.onToggle}
>
<HStack>
- {itemData.methodType === "Make" ? (
+ {itemData.methodType === "Make to Order" ? (
<>
<LuGitPullRequestCreate />
<Label>Finish To</Label>
@@ -822,14 +919,20 @@ function MaterialForm({
{itemData.methodType}
</Badge>
<LuArrowLeft
- className={cn(itemData.methodType !== "Pick" ? "rotate-180" : "")}
+ className={cn(
+ itemData.methodType !== "Pull from Inventory"
+ ? "rotate-180"
+ : ""
+ )}
/>
<Badge variant="secondary">
<LuGitPullRequest className="size-3 mr-1" />
{shelves.options?.find(
(s) => s.value === itemData.shelfIds[locationId ?? ""]
)?.label ??
- (itemData.methodType === "Make" ? "WIP" : "Default Shelf")}
+ (itemData.methodType === "Make to Order"
+ ? "WIP"
+ : "Default Shelf")}
</Badge>
<IconButton
icon={<LuChevronRight />}
@@ -985,11 +1088,13 @@ function MaterialForm({
layout
className="flex items-center justify-between gap-2 w-full"
>
- {itemData.methodType === "Make" ? (
+ {itemData.methodType === "Make to Order" ? (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
- leftIcon={<MethodIcon type={"Make"} isKit={itemData.kit} />}
+ leftIcon={
+ <MethodIcon type={"Make to Order"} isKit={itemData.kit} />
+ }
variant="secondary"
size="sm"
rightIcon={<LuChevronDown />}
@@ -1037,14 +1142,22 @@ function makeItems(
materials: Material[],
orderState: OrderState,
checkedState: CheckedState,
- rulesByField?: Map<string, ConfigurationRule>
+ rulesByField?: Map<string, ConfigurationRule>,
+ replenishmentSystem?: string
): ItemWithData[] {
return materials.map((material) => {
const order = material.id
? (orderState[material.id] ?? material.order)
: material.order;
const checked = material.id ? (checkedState[material.id] ?? false) : false;
- return makeItem(items, material, order, checked, rulesByField);
+ return makeItem(
+ items,
+ material,
+ order,
+ checked,
+ rulesByField,
+ replenishmentSystem
+ );
});
}
@@ -1064,7 +1177,8 @@ function makeItem(
material: Material,
order: number,
checked: boolean,
- rulesByField?: Map<string, ConfigurationRule>
+ rulesByField?: Map<string, ConfigurationRule>,
+ replenishmentSystem?: string
): ItemWithData {
const hasRules = material.id
? materialHasRules(material.id, rulesByField)
@@ -1126,6 +1240,17 @@ function makeItem(
<TooltipContent>{material.methodType}</TooltipContent>
</Tooltip>
+ {replenishmentSystem === "Buy and Make" && (
+ <Tooltip>
+ <TooltipTrigger>
+ <Badge variant="secondary">
+ <SourcingTypeIcon type={material.sourcingType} />
+ </Badge>
+ </TooltipTrigger>
+ <TooltipContent>{material.sourcingType}</TooltipContent>
+ </Tooltip>
+ )}
+
<Badge variant="secondary">{material.quantity}</Badge>
<Tooltip>
diff --git a/apps/erp/app/modules/items/ui/Item/BillOfProcess.tsx b/apps/erp/app/modules/items/ui/Item/BillOfProcess.tsx
index 2616f8ea03..374422b8ac 100644
--- a/apps/erp/app/modules/items/ui/Item/BillOfProcess.tsx
+++ b/apps/erp/app/modules/items/ui/Item/BillOfProcess.tsx
@@ -81,7 +81,6 @@ import type { Configuration } from "~/components/Configurator/types";
import {
Hidden,
InputControlled,
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Number,
NumberControlled,
Process,
diff --git a/apps/erp/app/modules/items/ui/Item/BoMExplorer.tsx b/apps/erp/app/modules/items/ui/Item/BoMExplorer.tsx
index 00859c357b..42ed6f5528 100644
--- a/apps/erp/app/modules/items/ui/Item/BoMExplorer.tsx
+++ b/apps/erp/app/modules/items/ui/Item/BoMExplorer.tsx
@@ -298,7 +298,7 @@ const BoMExplorer = ({
itemType,
itemId,
methodId,
- node.data.methodType === "Make"
+ node.data.methodType === "Make to Order"
? node.data.materialMakeMethodId
: node.data.makeMethodId,
node
@@ -586,7 +586,7 @@ function NodePreview({ node }: { node: FlatTreeItem<Method> }) {
<span>{node.data.itemType}</span>
</HStack>
</VStack>
- {node.data.methodType === "Make" && node.data.version && (
+ {node.data.methodType === "Make to Order" && node.data.version && (
<VStack spacing={1}>
<span className="text-xs text-muted-foreground font-medium">
Make Method Version
diff --git a/apps/erp/app/modules/items/ui/Item/ItemCostingForm.tsx b/apps/erp/app/modules/items/ui/Item/ItemCostingForm.tsx
index 2b26033295..c07584d3dc 100644
--- a/apps/erp/app/modules/items/ui/Item/ItemCostingForm.tsx
+++ b/apps/erp/app/modules/items/ui/Item/ItemCostingForm.tsx
@@ -11,7 +11,6 @@ import {
CustomFormFields,
Hidden,
ItemPostingGroup,
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Number,
Submit
} from "~/components/Form";
diff --git a/apps/erp/app/modules/items/ui/Item/ItemForm.tsx b/apps/erp/app/modules/items/ui/Item/ItemForm.tsx
index d1b07b1821..e7b15822f6 100644
--- a/apps/erp/app/modules/items/ui/Item/ItemForm.tsx
+++ b/apps/erp/app/modules/items/ui/Item/ItemForm.tsx
@@ -22,7 +22,6 @@ import { Link, useFetcher } from "react-router";
import type { z } from "zod";
import { TrackingTypeIcon } from "~/components";
import {
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Boolean,
DefaultMethodType,
Hidden,
@@ -70,7 +69,7 @@ const ItemForm = ({ initialValues, type }: ItemFormProps) => {
initialValues.replenishmentSystem ?? "Buy"
);
const [defaultMethodType, setDefaultMethodType] = useState<string>(
- initialValues.defaultMethodType ?? "Buy"
+ initialValues.defaultMethodType ?? "Purchase to Order"
);
const itemReplenishmentSystemOptions =
itemReplenishmentSystems.map((itemReplenishmentSystem) => ({
diff --git a/apps/erp/app/modules/items/ui/Item/ItemManufacturingForm.tsx b/apps/erp/app/modules/items/ui/Item/ItemManufacturingForm.tsx
index 88b710ea1e..666680727e 100644
--- a/apps/erp/app/modules/items/ui/Item/ItemManufacturingForm.tsx
+++ b/apps/erp/app/modules/items/ui/Item/ItemManufacturingForm.tsx
@@ -9,11 +9,9 @@ import {
import { useFetcher, useParams } from "react-router";
import type { z } from "zod";
import {
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Boolean,
CustomFormFields,
Hidden,
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Number,
Submit
} from "~/components/Form";
diff --git a/apps/erp/app/modules/items/ui/Item/ItemPlanningForm.tsx b/apps/erp/app/modules/items/ui/Item/ItemPlanningForm.tsx
index c07da9a8c5..1a94cba219 100644
--- a/apps/erp/app/modules/items/ui/Item/ItemPlanningForm.tsx
+++ b/apps/erp/app/modules/items/ui/Item/ItemPlanningForm.tsx
@@ -14,7 +14,6 @@ import type { z } from "zod";
import {
CustomFormFields,
Hidden,
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Number,
Select as SelectForm,
Submit
diff --git a/apps/erp/app/modules/items/ui/Item/ItemPurchasingForm.tsx b/apps/erp/app/modules/items/ui/Item/ItemPurchasingForm.tsx
index cc167f2998..bf9dc5e173 100644
--- a/apps/erp/app/modules/items/ui/Item/ItemPurchasingForm.tsx
+++ b/apps/erp/app/modules/items/ui/Item/ItemPurchasingForm.tsx
@@ -12,7 +12,6 @@ import type { z } from "zod";
import {
ConversionFactor,
Hidden,
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Number,
Submit,
UnitOfMeasure
diff --git a/apps/erp/app/modules/items/ui/Item/ItemSalePriceForm.tsx b/apps/erp/app/modules/items/ui/Item/ItemSalePriceForm.tsx
index c26d22a007..3c0d9097c8 100644
--- a/apps/erp/app/modules/items/ui/Item/ItemSalePriceForm.tsx
+++ b/apps/erp/app/modules/items/ui/Item/ItemSalePriceForm.tsx
@@ -7,7 +7,6 @@ import {
CardTitle
} from "@carbon/react";
import type { z } from "zod";
-// biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
import { CustomFormFields, Hidden, Number, Submit } from "~/components/Form";
import { usePermissions, useUser } from "~/hooks";
import { itemUnitSalePriceValidator } from "../../items.models";
diff --git a/apps/erp/app/modules/items/ui/Item/MakeMethodTools.tsx b/apps/erp/app/modules/items/ui/Item/MakeMethodTools.tsx
index bba7694837..0757edbd8d 100644
--- a/apps/erp/app/modules/items/ui/Item/MakeMethodTools.tsx
+++ b/apps/erp/app/modules/items/ui/Item/MakeMethodTools.tsx
@@ -1,4 +1,3 @@
-// biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
import { Number, Submit, ValidatedForm } from "@carbon/form";
import {
Alert,
diff --git a/apps/erp/app/modules/items/ui/Item/SupplierPartForm.tsx b/apps/erp/app/modules/items/ui/Item/SupplierPartForm.tsx
index 9ff2d13ae6..6730d39436 100644
--- a/apps/erp/app/modules/items/ui/Item/SupplierPartForm.tsx
+++ b/apps/erp/app/modules/items/ui/Item/SupplierPartForm.tsx
@@ -47,7 +47,6 @@ import {
CustomFormFields,
Hidden,
Input,
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Number,
Submit,
Supplier,
diff --git a/apps/erp/app/modules/items/ui/Materials/MaterialForm.tsx b/apps/erp/app/modules/items/ui/Materials/MaterialForm.tsx
index 399d144f7e..644016e7c8 100644
--- a/apps/erp/app/modules/items/ui/Materials/MaterialForm.tsx
+++ b/apps/erp/app/modules/items/ui/Materials/MaterialForm.tsx
@@ -18,14 +18,12 @@ import { useFetcher } from "react-router";
import type { z } from "zod";
import { TrackingTypeIcon } from "~/components";
import {
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Array,
CustomFormFields,
DefaultMethodType,
Hidden,
InputControlled,
ItemPostingGroup,
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Number,
Select,
Submit,
@@ -117,7 +115,7 @@ const MaterialForm = ({
const useCustomId = companySettings.materialGeneratedIds === false;
const [defaultMethodType, setDefaultMethodType] = useState<string>(
- initialValues.defaultMethodType ?? "Buy"
+ initialValues.defaultMethodType ?? "Purchase to Order"
);
const itemTrackingTypeOptions = itemTrackingTypes.map((itemTrackingType) => ({
diff --git a/apps/erp/app/modules/items/ui/Materials/MaterialProperties.tsx b/apps/erp/app/modules/items/ui/Materials/MaterialProperties.tsx
index a5324389f0..88094ebcee 100644
--- a/apps/erp/app/modules/items/ui/Materials/MaterialProperties.tsx
+++ b/apps/erp/app/modules/items/ui/Materials/MaterialProperties.tsx
@@ -455,7 +455,7 @@ const MaterialProperties = () => {
</Badge>
)}
options={methodType
- .filter((type) => type !== "Make")
+ .filter((type) => type !== "Make to Order")
.map((type) => ({
value: type,
label: (
@@ -626,7 +626,7 @@ const MaterialProperties = () => {
supplierParts.map((method) => (
<MethodBadge
key={method.id}
- type="Buy"
+ type="Purchase to Order"
text={
suppliers.find((s) => s.id === method.supplierId)?.name ?? ""
}
@@ -636,7 +636,7 @@ const MaterialProperties = () => {
{pickMethods.map((method) => (
<MethodBadge
key={method.locationId}
- type="Pick"
+ type="Pull from Inventory"
text={
locations.find((l) => l.id === method.locationId)?.name ?? ""
}
diff --git a/apps/erp/app/modules/items/ui/Materials/MaterialsTable.tsx b/apps/erp/app/modules/items/ui/Materials/MaterialsTable.tsx
index 49d37d6783..98a3e897be 100644
--- a/apps/erp/app/modules/items/ui/Materials/MaterialsTable.tsx
+++ b/apps/erp/app/modules/items/ui/Materials/MaterialsTable.tsx
@@ -493,19 +493,17 @@ const MaterialsTable = memo(({ data, tags, count }: MaterialsTableProps) => {
</DropdownMenuSubTrigger>
<DropdownMenuPortal>
<DropdownMenuSubContent>
- {methodType
- .filter((type) => type !== "Make")
- .map((type) => (
- <DropdownMenuItem
- key={type}
- onClick={() =>
- onBulkUpdate(selectedRows, "defaultMethodType", type)
- }
- >
- <DropdownMenuIcon icon={<MethodIcon type={type} />} />
- <span>{type}</span>
- </DropdownMenuItem>
- ))}
+ {methodType.map((type) => (
+ <DropdownMenuItem
+ key={type}
+ onClick={() =>
+ onBulkUpdate(selectedRows, "defaultMethodType", type)
+ }
+ >
+ <DropdownMenuIcon icon={<MethodIcon type={type} />} />
+ <span>{type}</span>
+ </DropdownMenuItem>
+ ))}
</DropdownMenuSubContent>
</DropdownMenuPortal>
</DropdownMenuSub>
diff --git a/apps/erp/app/modules/items/ui/Parts/PartForm.tsx b/apps/erp/app/modules/items/ui/Parts/PartForm.tsx
index 4f60ea509f..4425972494 100644
--- a/apps/erp/app/modules/items/ui/Parts/PartForm.tsx
+++ b/apps/erp/app/modules/items/ui/Parts/PartForm.tsx
@@ -36,7 +36,6 @@ import {
Input,
InputControlled,
ItemPostingGroup,
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Number,
Select,
Submit,
@@ -178,7 +177,7 @@ const PartForm = ({ initialValues, type = "card", onClose }: PartFormProps) => {
initialValues.replenishmentSystem ?? "Buy"
);
const [defaultMethodType, setDefaultMethodType] = useState<string>(
- initialValues.defaultMethodType ?? "Pick"
+ initialValues.defaultMethodType ?? "Pull from Inventory"
);
const itemReplenishmentSystemOptions =
itemReplenishmentSystems.map((itemReplenishmentSystem) => ({
@@ -268,9 +267,9 @@ const PartForm = ({ initialValues, type = "card", onClose }: PartFormProps) => {
onChange={(newValue) => {
setReplenishmentSystem(newValue?.value ?? "Buy");
if (newValue?.value === "Buy") {
- setDefaultMethodType("Pick");
+ setDefaultMethodType("Pull from Inventory");
} else {
- setDefaultMethodType("Make");
+ setDefaultMethodType("Make to Order");
}
}}
/>
@@ -280,7 +279,9 @@ const PartForm = ({ initialValues, type = "card", onClose }: PartFormProps) => {
replenishmentSystem={replenishmentSystem}
value={defaultMethodType}
onChange={(newValue) =>
- setDefaultMethodType(newValue?.value ?? "Buy")
+ setDefaultMethodType(
+ newValue?.value ?? "Pull from Inventory"
+ )
}
/>
<UnitOfMeasure
diff --git a/apps/erp/app/modules/items/ui/Parts/PartProperties.tsx b/apps/erp/app/modules/items/ui/Parts/PartProperties.tsx
index 3f72d7f101..c698d75b98 100644
--- a/apps/erp/app/modules/items/ui/Parts/PartProperties.tsx
+++ b/apps/erp/app/modules/items/ui/Parts/PartProperties.tsx
@@ -316,102 +316,109 @@ const PartProperties = () => {
<ValidatedForm
defaultValues={{
- itemTrackingType:
- routeData?.partSummary?.itemTrackingType ?? undefined
+ replenishmentSystem:
+ routeData?.partSummary?.replenishmentSystem ?? undefined
}}
validator={z.object({
- itemTrackingType: z.string()
+ replenishmentSystem: z.string()
})}
className="w-full"
>
<Select
- name="itemTrackingType"
- label="Tracking Type"
+ name="replenishmentSystem"
+ label="Replenishment"
inline={(value) => (
<Badge variant="secondary">
- <TrackingTypeIcon type={value} className="mr-2" />
+ <ReplenishmentSystemIcon type={value} className="mr-2" />
<span>{value}</span>
</Badge>
)}
- options={itemTrackingTypes.map((type) => ({
- value: type,
+ options={itemReplenishmentSystems.map((system) => ({
+ value: system,
label: (
<span className="flex items-center gap-2">
- <TrackingTypeIcon type={type} />
- {type}
+ <ReplenishmentSystemIcon type={system} />
+ {system}
</span>
)
}))}
onChange={(value) => {
- onUpdate("itemTrackingType", value?.value ?? null);
+ onUpdate("replenishmentSystem", value?.value ?? null);
}}
/>
</ValidatedForm>
<ValidatedForm
defaultValues={{
- defaultMethodType:
- routeData?.partSummary?.defaultMethodType ?? undefined
+ itemTrackingType:
+ routeData?.partSummary?.itemTrackingType ?? undefined
}}
validator={z.object({
- defaultMethodType: z.string()
+ itemTrackingType: z.string()
})}
className="w-full"
>
<Select
- name="defaultMethodType"
- label="Default Method Type"
+ name="itemTrackingType"
+ label="Tracking Type"
inline={(value) => (
<Badge variant="secondary">
- <MethodIcon type={value} className="mr-2" />
+ <TrackingTypeIcon type={value} className="mr-2" />
<span>{value}</span>
</Badge>
)}
- options={methodType.map((type) => ({
+ options={itemTrackingTypes.map((type) => ({
value: type,
label: (
<span className="flex items-center gap-2">
- <MethodIcon type={type} />
+ <TrackingTypeIcon type={type} />
{type}
</span>
)
}))}
onChange={(value) => {
- onUpdate("defaultMethodType", value?.value ?? null);
+ onUpdate("itemTrackingType", value?.value ?? null);
}}
/>
</ValidatedForm>
<ValidatedForm
defaultValues={{
- replenishmentSystem:
- routeData?.partSummary?.replenishmentSystem ?? undefined
+ defaultMethodType:
+ routeData?.partSummary?.defaultMethodType ?? undefined
}}
validator={z.object({
- replenishmentSystem: z.string()
+ defaultMethodType: z.string()
})}
className="w-full"
>
<Select
- name="replenishmentSystem"
- label="Replenishment"
+ name="defaultMethodType"
+ label="Default Method Type"
inline={(value) => (
<Badge variant="secondary">
- <ReplenishmentSystemIcon type={value} className="mr-2" />
+ <MethodIcon type={value} className="mr-2" />
<span>{value}</span>
</Badge>
)}
- options={itemReplenishmentSystems.map((system) => ({
- value: system,
- label: (
- <span className="flex items-center gap-2">
- <ReplenishmentSystemIcon type={system} />
- {system}
- </span>
- )
- }))}
+ options={methodType
+ .filter((type) => {
+ const replenishment = routeData?.partSummary?.replenishmentSystem;
+ if (replenishment === "Buy") return type !== "Make to Order";
+ if (replenishment === "Make") return type !== "Purchase to Order";
+ return true;
+ })
+ .map((type) => ({
+ value: type,
+ label: (
+ <span className="flex items-center gap-2">
+ <MethodIcon type={type} />
+ {type}
+ </span>
+ )
+ }))}
onChange={(value) => {
- onUpdate("replenishmentSystem", value?.value ?? null);
+ onUpdate("defaultMethodType", value?.value ?? null);
}}
/>
</ValidatedForm>
@@ -455,9 +462,10 @@ const PartProperties = () => {
return (
<MethodBadge
key={method.id}
- type={isActive ? "Make" : "Make Inactive"}
+ type="Make to Order"
text={`Version ${method.version}`}
to={`${path.to.partDetails(itemId)}?methodId=${method.id}`}
+ className={isActive ? undefined : "opacity-50"}
/>
);
})
@@ -469,7 +477,7 @@ const PartProperties = () => {
supplierParts.map((method) => (
<MethodBadge
key={method.id}
- type="Buy"
+ type="Purchase to Order"
text={
suppliers.find((s) => s.id === method.supplierId)?.name ?? ""
}
@@ -479,7 +487,7 @@ const PartProperties = () => {
{pickMethods.map((method) => (
<MethodBadge
key={method.locationId}
- type="Pick"
+ type="Pull from Inventory"
text={locations.find((l) => l.id === method.locationId)?.name ?? ""}
to={path.to.partInventoryLocation(itemId, method.locationId)}
/>
diff --git a/apps/erp/app/modules/items/ui/Parts/PartsTable.tsx b/apps/erp/app/modules/items/ui/Parts/PartsTable.tsx
index dc1ede5b7a..95639149cb 100644
--- a/apps/erp/app/modules/items/ui/Parts/PartsTable.tsx
+++ b/apps/erp/app/modules/items/ui/Parts/PartsTable.tsx
@@ -50,8 +50,8 @@ import {
Table,
TrackingTypeIcon
} from "~/components";
-import { Enumerable } from "~/components/Enumerable";
import { useItemPostingGroups } from "~/components/Form/ItemPostingGroup";
+import { ReplenishmentSystemIcon } from "~/components/Icons";
import { ConfirmDelete } from "~/components/Modals";
import { usePermissions } from "~/hooks";
import { useCustomColumns } from "~/hooks/useCustomColumns";
@@ -128,14 +128,15 @@ const PartsTable = memo(({ data, tags, count }: PartsTableProps) => {
const itemPostingGroup = itemPostingGroups.find(
(group) => group.value === itemPostingGroupId
);
- return <Enumerable value={itemPostingGroup?.label ?? null} />;
+ const label = itemPostingGroup?.label;
+ return label ? <Badge variant="secondary">{label}</Badge> : null;
},
meta: {
filter: {
type: "static",
options: itemPostingGroups.map((group) => ({
value: group.value,
- label: <Enumerable value={group.label} />
+ label: <Badge variant="secondary">{group.label}</Badge>
}))
},
icon: <LuGroup />
@@ -195,13 +196,26 @@ const PartsTable = memo(({ data, tags, count }: PartsTableProps) => {
{
accessorKey: "replenishmentSystem",
header: "Replenishment",
- cell: (item) => <Enumerable value={item.getValue<string>()} />,
+ cell: (item) => (
+ <Badge variant="secondary">
+ <ReplenishmentSystemIcon
+ type={item.getValue<string>()}
+ className="mr-2"
+ />
+ <span>{item.getValue<string>()}</span>
+ </Badge>
+ ),
meta: {
filter: {
type: "static",
options: itemReplenishmentSystems.map((type) => ({
value: type,
- label: <Enumerable value={type} />
+ label: (
+ <Badge variant="secondary">
+ <ReplenishmentSystemIcon type={type} className="mr-2" />
+ <span>{type}</span>
+ </Badge>
+ )
}))
},
icon: <LuLoaderCircle />
@@ -357,7 +371,7 @@ const PartsTable = memo(({ data, tags, count }: PartsTableProps) => {
)
}
>
- <Enumerable value={group.label} />
+ <span>{group.label}</span>
</DropdownMenuItem>
))}
</DropdownMenuSubContent>
@@ -378,7 +392,10 @@ const PartsTable = memo(({ data, tags, count }: PartsTableProps) => {
)
}
>
- <Enumerable value={system} />
+ <DropdownMenuIcon
+ icon={<ReplenishmentSystemIcon type={system} />}
+ />
+ <span>{system}</span>
</DropdownMenuItem>
))}
</DropdownMenuSubContent>
diff --git a/apps/erp/app/modules/items/ui/Tools/ToolForm.tsx b/apps/erp/app/modules/items/ui/Tools/ToolForm.tsx
index 4ec2e26af4..485b696d5c 100644
--- a/apps/erp/app/modules/items/ui/Tools/ToolForm.tsx
+++ b/apps/erp/app/modules/items/ui/Tools/ToolForm.tsx
@@ -35,7 +35,6 @@ import {
Input,
InputControlled,
ItemPostingGroup,
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Number,
Select,
Submit,
@@ -177,7 +176,7 @@ const ToolForm = ({ initialValues, type = "card", onClose }: ToolFormProps) => {
initialValues.replenishmentSystem ?? "Buy"
);
const [defaultMethodType, setDefaultMethodType] = useState<string>(
- initialValues.defaultMethodType ?? "Buy"
+ initialValues.defaultMethodType ?? "Purchase to Order"
);
const itemReplenishmentSystemOptions =
itemReplenishmentSystems.map((itemReplenishmentSystem) => ({
@@ -263,9 +262,9 @@ const ToolForm = ({ initialValues, type = "card", onClose }: ToolFormProps) => {
onChange={(newValue) => {
setReplenishmentSystem(newValue?.value ?? "Buy");
if (newValue?.value === "Buy") {
- setDefaultMethodType("Buy");
+ setDefaultMethodType("Purchase to Order");
} else {
- setDefaultMethodType("Make");
+ setDefaultMethodType("Make to Order");
}
}}
/>
@@ -275,7 +274,7 @@ const ToolForm = ({ initialValues, type = "card", onClose }: ToolFormProps) => {
replenishmentSystem={replenishmentSystem}
value={defaultMethodType}
onChange={(newValue) =>
- setDefaultMethodType(newValue?.value ?? "Buy")
+ setDefaultMethodType(newValue?.value ?? "Purchase to Order")
}
/>
diff --git a/apps/erp/app/modules/items/ui/Tools/ToolProperties.tsx b/apps/erp/app/modules/items/ui/Tools/ToolProperties.tsx
index b5e834c6eb..ce95106810 100644
--- a/apps/erp/app/modules/items/ui/Tools/ToolProperties.tsx
+++ b/apps/erp/app/modules/items/ui/Tools/ToolProperties.tsx
@@ -17,7 +17,6 @@ import { Await, useFetcher, useParams } from "react-router";
import { z } from "zod";
import { zfd } from "zod-form-data";
import { MethodBadge, MethodIcon, TrackingTypeIcon } from "~/components";
-import { Enumerable } from "~/components/Enumerable";
// biome-ignore lint/suspicious/noShadowRestrictedNames: Boolean is a component name
import { Boolean, ItemPostingGroup, Tags } from "~/components/Form";
import CustomFormInlineFields from "~/components/Form/CustomFormInlineFields";
@@ -293,6 +292,40 @@ const ToolProperties = () => {
/>
</ValidatedForm>
+ <ValidatedForm
+ defaultValues={{
+ replenishmentSystem:
+ routeData?.toolSummary?.replenishmentSystem ?? undefined
+ }}
+ validator={z.object({
+ replenishmentSystem: z.string()
+ })}
+ className="w-full"
+ >
+ <Select
+ name="replenishmentSystem"
+ label="Replenishment"
+ inline={(value) => (
+ <Badge variant="secondary">
+ <ReplenishmentSystemIcon type={value} className="mr-2" />
+ <span>{value}</span>
+ </Badge>
+ )}
+ options={itemReplenishmentSystems.map((system) => ({
+ value: system,
+ label: (
+ <span className="flex items-center gap-2">
+ <ReplenishmentSystemIcon type={system} />
+ {system}
+ </span>
+ )
+ }))}
+ onChange={(value) => {
+ onUpdate("replenishmentSystem", value?.value ?? null);
+ }}
+ />
+ </ValidatedForm>
+
<ValidatedForm
defaultValues={{
itemTrackingType:
@@ -347,7 +380,12 @@ const ToolProperties = () => {
</Badge>
)}
options={methodType
- .filter((type) => type !== "Make")
+ .filter((type) => {
+ const replenishment = routeData?.toolSummary?.replenishmentSystem;
+ if (replenishment === "Buy") return type !== "Make to Order";
+ if (replenishment === "Make") return type !== "Purchase to Order";
+ return true;
+ })
.map((type) => ({
value: type,
label: (
@@ -363,43 +401,13 @@ const ToolProperties = () => {
/>
</ValidatedForm>
- <ValidatedForm
- defaultValues={{
- replenishmentSystem:
- routeData?.toolSummary?.replenishmentSystem ?? undefined
- }}
- validator={z.object({
- replenishmentSystem: z.string()
- })}
- className="w-full"
- >
- <Select
- name="replenishmentSystem"
- label="Replenishment"
- inline={(value) => (
- <Badge variant="secondary">
- <ReplenishmentSystemIcon type={value} className="mr-2" />
- <span>{value}</span>
- </Badge>
- )}
- options={itemReplenishmentSystems.map((system) => ({
- value: system,
- label: (
- <span className="flex items-center gap-2">
- <ReplenishmentSystemIcon type={system} />
- {system}
- </span>
- )
- }))}
- onChange={(value) => {
- onUpdate("replenishmentSystem", value?.value ?? null);
- }}
- />
- </ValidatedForm>
-
<VStack spacing={2}>
<h3 className="text-xs text-muted-foreground">Unit of Measure</h3>
- <Enumerable value={routeData?.toolSummary?.unitOfMeasure ?? null} />
+ {routeData?.toolSummary?.unitOfMeasure && (
+ <Badge variant="secondary">
+ {routeData.toolSummary.unitOfMeasure}
+ </Badge>
+ )}
</VStack>
<VStack spacing={2}>
@@ -413,13 +421,10 @@ const ToolProperties = () => {
makeMethods.data
?.sort((a, b) => b.version - a.version)
.map((method) => {
- const isActive =
- method.status === "Active" ||
- makeMethods.data?.length === 1;
return (
<MethodBadge
key={method.id}
- type={isActive ? "Make" : "Make Inactive"}
+ type="Make to Order"
text={`Version ${method.version}`}
to={`${path.to.toolDetails(itemId)}?methodId=${method.id}`}
/>
@@ -433,7 +438,7 @@ const ToolProperties = () => {
supplierParts.map((method) => (
<MethodBadge
key={method.id}
- type="Buy"
+ type="Purchase to Order"
text={
suppliers.find((s) => s.id === method.supplierId)?.name ?? ""
}
@@ -443,7 +448,7 @@ const ToolProperties = () => {
{pickMethods.map((method) => (
<MethodBadge
key={method.locationId}
- type="Pick"
+ type="Pull from Inventory"
text={locations.find((l) => l.id === method.locationId)?.name ?? ""}
to={path.to.partInventoryLocation(itemId, method.locationId)}
/>
diff --git a/apps/erp/app/modules/items/ui/Tools/ToolsTable.tsx b/apps/erp/app/modules/items/ui/Tools/ToolsTable.tsx
index 15ae7d01f0..c37fcc12c1 100644
--- a/apps/erp/app/modules/items/ui/Tools/ToolsTable.tsx
+++ b/apps/erp/app/modules/items/ui/Tools/ToolsTable.tsx
@@ -50,8 +50,8 @@ import {
Table,
TrackingTypeIcon
} from "~/components";
-import { Enumerable } from "~/components/Enumerable";
import { useItemPostingGroups } from "~/components/Form/ItemPostingGroup";
+import { ReplenishmentSystemIcon } from "~/components/Icons";
import { ConfirmDelete } from "~/components/Modals";
import { usePermissions } from "~/hooks";
import { useCustomColumns } from "~/hooks/useCustomColumns";
@@ -128,14 +128,15 @@ const ToolsTable = memo(({ data, tags, count }: ToolsTableProps) => {
const itemPostingGroup = itemPostingGroups.find(
(group) => group.value === itemPostingGroupId
);
- return <Enumerable value={itemPostingGroup?.label ?? null} />;
+ const label = itemPostingGroup?.label;
+ return label ? <Badge variant="secondary">{label}</Badge> : null;
},
meta: {
filter: {
type: "static",
options: itemPostingGroups.map((group) => ({
value: group.value,
- label: <Enumerable value={group.label} />
+ label: <Badge variant="secondary">{group.label}</Badge>
}))
},
icon: <LuGroup />
@@ -195,13 +196,26 @@ const ToolsTable = memo(({ data, tags, count }: ToolsTableProps) => {
{
accessorKey: "replenishmentSystem",
header: "Replenishment",
- cell: (item) => <Enumerable value={item.getValue<string>()} />,
+ cell: (item) => (
+ <Badge variant="secondary">
+ <ReplenishmentSystemIcon
+ type={item.getValue<string>()}
+ className="mr-2"
+ />
+ <span>{item.getValue<string>()}</span>
+ </Badge>
+ ),
meta: {
filter: {
type: "static",
options: itemReplenishmentSystems.map((type) => ({
value: type,
- label: <Enumerable value={type} />
+ label: (
+ <Badge variant="secondary">
+ <ReplenishmentSystemIcon type={type} className="mr-2" />
+ <span>{type}</span>
+ </Badge>
+ )
}))
},
icon: <LuLoaderCircle />
@@ -372,7 +386,7 @@ const ToolsTable = memo(({ data, tags, count }: ToolsTableProps) => {
)
}
>
- <Enumerable value={group.label} />
+ <span>{group.label}</span>
</DropdownMenuItem>
))}
</DropdownMenuSubContent>
@@ -384,19 +398,17 @@ const ToolsTable = memo(({ data, tags, count }: ToolsTableProps) => {
</DropdownMenuSubTrigger>
<DropdownMenuPortal>
<DropdownMenuSubContent>
- {methodType
- .filter((type) => type !== "Make")
- .map((type) => (
- <DropdownMenuItem
- key={type}
- onClick={() =>
- onBulkUpdate(selectedRows, "defaultMethodType", type)
- }
- >
- <DropdownMenuIcon icon={<MethodIcon type={type} />} />
- <span>{type}</span>
- </DropdownMenuItem>
- ))}
+ {methodType.map((type) => (
+ <DropdownMenuItem
+ key={type}
+ onClick={() =>
+ onBulkUpdate(selectedRows, "defaultMethodType", type)
+ }
+ >
+ <DropdownMenuIcon icon={<MethodIcon type={type} />} />
+ <span>{type}</span>
+ </DropdownMenuItem>
+ ))}
</DropdownMenuSubContent>
</DropdownMenuPortal>
</DropdownMenuSub>
diff --git a/apps/erp/app/modules/people/ui/Attributes/AttributeCategoryForm.tsx b/apps/erp/app/modules/people/ui/Attributes/AttributeCategoryForm.tsx
index f8b6d64384..49da736f9d 100644
--- a/apps/erp/app/modules/people/ui/Attributes/AttributeCategoryForm.tsx
+++ b/apps/erp/app/modules/people/ui/Attributes/AttributeCategoryForm.tsx
@@ -11,7 +11,6 @@ import {
VStack
} from "@carbon/react";
import type { z } from "zod";
-// biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
import { Boolean, EmojiPicker, Hidden, Input, Submit } from "~/components/Form";
import { usePermissions } from "~/hooks";
diff --git a/apps/erp/app/modules/people/ui/Attributes/AttributeForm.tsx b/apps/erp/app/modules/people/ui/Attributes/AttributeForm.tsx
index 6734d65a8d..3c408ea4ce 100644
--- a/apps/erp/app/modules/people/ui/Attributes/AttributeForm.tsx
+++ b/apps/erp/app/modules/people/ui/Attributes/AttributeForm.tsx
@@ -13,9 +13,7 @@ import {
import { useState } from "react";
import type { z } from "zod";
import {
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Array,
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Boolean,
Hidden,
Input,
diff --git a/apps/erp/app/modules/people/ui/Shifts/ShiftForm.tsx b/apps/erp/app/modules/people/ui/Shifts/ShiftForm.tsx
index 844a7698cb..c73a4ca502 100644
--- a/apps/erp/app/modules/people/ui/Shifts/ShiftForm.tsx
+++ b/apps/erp/app/modules/people/ui/Shifts/ShiftForm.tsx
@@ -15,7 +15,6 @@ import {
import { useNavigate } from "react-router";
import type { z } from "zod";
import {
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Boolean,
CustomFormFields,
Hidden,
diff --git a/apps/erp/app/modules/production/production.service.ts b/apps/erp/app/modules/production/production.service.ts
index 67537fa5ca..4aee33490b 100644
--- a/apps/erp/app/modules/production/production.service.ts
+++ b/apps/erp/app/modules/production/production.service.ts
@@ -94,7 +94,7 @@ export async function convertSalesOrderLinesToJobs(
let jobsCreated = 0;
for await (const line of lines) {
- if (line.methodType === "Make" && line.itemId) {
+ if (line.methodType === "Make to Order" && line.itemId) {
const itemManufacturing = await client
.from("itemReplenishment")
.select("*")
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobBillOfMaterial.tsx b/apps/erp/app/modules/production/ui/Jobs/JobBillOfMaterial.tsx
index e44b47730e..11193c3b00 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobBillOfMaterial.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobBillOfMaterial.tsx
@@ -51,7 +51,6 @@ import {
Hidden,
InputControlled,
Item,
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Number,
NumberControlled,
Select,
@@ -207,7 +206,7 @@ const initialMethodMaterial: Omit<Material, "jobMakeMethodId" | "order"> & {
itemId: "",
// @ts-ignore
itemType: "Item" as const,
- methodType: "Buy" as const,
+ methodType: "Purchase to Order" as const,
description: "",
quantity: 1,
unitCost: 0,
@@ -678,7 +677,7 @@ function MaterialForm({
shelfId?: string;
}>({
itemId: item.data.itemId ?? "",
- methodType: item.data.methodType ?? "Buy",
+ methodType: item.data.methodType ?? "Pull from Inventory",
description: item.data.description ?? "",
jobOperationId: item.data.jobOperationId ?? "",
unitCost: item.data.unitCost ?? 0,
@@ -696,7 +695,7 @@ function MaterialForm({
setItemData({
itemId: "",
- methodType: "" as "Buy",
+ methodType: "" as "Pull from Inventory",
quantity: 1,
unitCost: 0,
description: "",
@@ -746,7 +745,7 @@ function MaterialForm({
description: item.data?.name ?? "",
unitCost: itemCost.data?.unitCost ?? 0,
unitOfMeasureCode: item.data?.unitOfMeasureCode ?? "EA",
- methodType: item.data?.defaultMethodType ?? "Buy",
+ methodType: item.data?.defaultMethodType ?? "Pull from Inventory",
requiresBatchTracking: item.data?.itemTrackingType === "Batch",
requiresSerialTracking: item.data?.itemTrackingType === "Serial",
shelfId: pickMethod.data?.defaultShelfId ?? ""
@@ -798,7 +797,7 @@ function MaterialForm({
name="requiresSerialTracking"
value={itemData.requiresSerialTracking.toString()}
/>
- {itemData.methodType === "Make" && (
+ {itemData.methodType === "Make to Order" && (
<Hidden name="unitCost" value={itemData.unitCost} />
)}
</div>
@@ -838,7 +837,7 @@ function MaterialForm({
}}
className="col-span-2"
/>
- {itemData.methodType !== "Make" && (
+ {itemData.methodType !== "Make to Order" && (
<NumberControlled
name="unitCost"
label="Unit Cost"
@@ -858,7 +857,7 @@ function MaterialForm({
onClick={sourceDisclosure.onToggle}
>
<HStack>
- {itemData.methodType === "Make" ? (
+ {itemData.methodType === "Make to Order" ? (
<>
<LuGitPullRequestCreate />
<Label>Finish To</Label>
@@ -876,13 +875,19 @@ function MaterialForm({
{itemData.methodType}
</Badge>
<LuArrowLeft
- className={cn(itemData.methodType !== "Pick" ? "rotate-180" : "")}
+ className={cn(
+ itemData.methodType !== "Pull from Inventory"
+ ? "rotate-180"
+ : ""
+ )}
/>
<Badge variant="secondary">
<LuGitPullRequest className="size-3 mr-1" />
{shelves.options?.find((s) => s.value === itemData.shelfId)
?.label ??
- (itemData.methodType === "Make" ? "WIP" : "Default Shelf")}
+ (itemData.methodType === "Make to Order"
+ ? "WIP"
+ : "Default Shelf")}
</Badge>
<IconButton
icon={<LuChevronRight />}
@@ -1008,11 +1013,13 @@ function MaterialForm({
layout
className="flex items-center justify-between gap-2 w-full"
>
- {itemData.methodType === "Make" ? (
+ {itemData.methodType === "Make to Order" ? (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
- leftIcon={<MethodIcon type={"Make"} isKit={itemData.kit} />}
+ leftIcon={
+ <MethodIcon type={"Make to Order"} isKit={itemData.kit} />
+ }
variant="secondary"
size="sm"
rightIcon={<LuChevronDown />}
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobBillOfProcess.tsx b/apps/erp/app/modules/production/ui/Jobs/JobBillOfProcess.tsx
index 04e95e4f3a..c9a4b32444 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobBillOfProcess.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobBillOfProcess.tsx
@@ -100,7 +100,6 @@ import Activity from "~/components/Activity";
import {
Hidden,
InputControlled,
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Number,
NumberControlled,
Process,
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobBoMExplorer.tsx b/apps/erp/app/modules/production/ui/Jobs/JobBoMExplorer.tsx
index ff68d477ed..d6408d7e9f 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobBoMExplorer.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobBoMExplorer.tsx
@@ -446,7 +446,7 @@ function NodePreview({ node }: { node: FlatTreeItem<JobMethod> }) {
<span>{node.data.itemType}</span>
</HStack>
</VStack>
- {node.data.methodType === "Make" && (
+ {node.data.methodType === "Make to Order" && (
<VStack spacing={1}>
<span className="text-xs text-muted-foreground font-medium">
Make Method Version
@@ -474,7 +474,7 @@ function NodePreview({ node }: { node: FlatTreeItem<JobMethod> }) {
function getNodePath(node: FlatTreeItem<JobMethod>) {
return node.data.isRoot
? path.to.jobDetails(node.data.jobId)
- : node.data.methodType === "Make"
+ : node.data.methodType === "Make to Order"
? path.to.jobMakeMethod(
node.data.jobId,
node.data.jobMaterialMakeMethodId
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobEstimatesVsActuals.tsx b/apps/erp/app/modules/production/ui/Jobs/JobEstimatesVsActuals.tsx
index 5a0d3296d6..bb29e401d7 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobEstimatesVsActuals.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobEstimatesVsActuals.tsx
@@ -556,15 +556,15 @@ const JobEstimatesVsActuals = ({
</Td>
<Td>{material.estimatedQuantity}</Td>
<Td className={cn(exceedsEstimate && "text-red-500")}>
- {material.methodType === "Make" ? (
- <MethodIcon type="Make" />
+ {material.methodType === "Make to Order" ? (
+ <MethodIcon type="Make to Order" />
) : (
material.quantityIssued
)}
</Td>
<Td className={cn(exceedsEstimate && "text-red-500")}>
- {material.methodType !== "Make" &&
+ {material.methodType !== "Make to Order" &&
material.estimatedQuantity &&
material.quantityIssued
? percentFormatter.format(
@@ -574,7 +574,7 @@ const JobEstimatesVsActuals = ({
: null}
</Td>
<Td>
- {material.methodType === "Make" ? null : (
+ {material.methodType === "Make to Order" ? null : (
<VStack spacing={0} className="py-1">
<span className="text-sm">
{currencyFormatter.format(estimatedTotalCost)}
@@ -586,7 +586,7 @@ const JobEstimatesVsActuals = ({
)}
</Td>
<Td>
- {material.methodType === "Make" ? null : (
+ {material.methodType === "Make to Order" ? null : (
<VStack spacing={0} className="py-1">
<span
className={cn(
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobHeader.tsx b/apps/erp/app/modules/production/ui/Jobs/JobHeader.tsx
index 2380dbc2d2..6f66e6d6ac 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobHeader.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobHeader.tsx
@@ -609,7 +609,7 @@ export function JobStartModal({
?.filter(
(m) =>
m.jobMaterialMakeMethodId &&
- m.methodType === "Make" &&
+ m.methodType === "Make to Order" &&
!kittedMakeMethodIds.has(m.jobMaterialMakeMethodId)
)
.map((m) => m.jobMaterialMakeMethodId) ?? []
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobMakeMethodTools.tsx b/apps/erp/app/modules/production/ui/Jobs/JobMakeMethodTools.tsx
index 8842bced49..e18bf7faae 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobMakeMethodTools.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobMakeMethodTools.tsx
@@ -555,12 +555,7 @@ const JobMakeMethodTools = ({ makeMethod }: { makeMethod?: JobMakeMethod }) => {
}}
>
<ModalContent>
- <ValidatedForm
- validator={getJobMethodValidator}
- onSubmit={() => {
- /* form handled via fetcher */
- }}
- >
+ <ValidatedForm validator={getJobMethodValidator}>
<ModalHeader>
<ModalTitle>Configure Item</ModalTitle>
<ModalDescription>Select an item to configure</ModalDescription>
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobMaterialForm.tsx b/apps/erp/app/modules/production/ui/Jobs/JobMaterialForm.tsx
index f0442c8329..88b5342424 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobMaterialForm.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobMaterialForm.tsx
@@ -20,7 +20,6 @@ import {
Hidden,
InputControlled,
Item,
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Number,
NumberControlled,
Select,
@@ -70,7 +69,7 @@ const JobMaterialForm = ({
quantity: number;
}>({
itemId: initialValues.itemId ?? "",
- methodType: initialValues.methodType ?? "Buy",
+ methodType: initialValues.methodType ?? "Pull from Inventory",
description: initialValues.description ?? "",
unitCost: initialValues.unitCost ?? 0,
unitOfMeasureCode: initialValues.unitOfMeasureCode ?? "EA",
@@ -82,7 +81,7 @@ const JobMaterialForm = ({
setItemType(value as MethodItemType);
setItemData({
itemId: "",
- methodType: "" as "Buy",
+ methodType: "" as "Pull from Inventory",
quantity: 1,
description: "",
unitCost: 0,
@@ -115,7 +114,7 @@ const JobMaterialForm = ({
description: item.data?.name ?? "",
unitCost: itemCost.data?.unitCost ?? 0,
unitOfMeasureCode: item.data?.unitOfMeasureCode ?? "EA",
- methodType: item.data?.defaultMethodType ?? "Buy"
+ methodType: item.data?.defaultMethodType ?? "Purchase to Order"
}));
if (item.data?.type) {
@@ -167,7 +166,7 @@ const JobMaterialForm = ({
</CardHeader>
<CardContent>
<Hidden name="jobMakeMethodId" />
- {itemData.methodType === "Make" && (
+ {itemData.methodType === "Make to Order" && (
<Hidden name="unitCost" value={itemData.unitCost} />
)}
<Hidden name="order" />
@@ -219,7 +218,7 @@ const JobMaterialForm = ({
}))
}
/>
- {itemData.methodType !== "Make" && (
+ {itemData.methodType !== "Make to Order" && (
<NumberControlled
name="unitCost"
label="Unit Cost"
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobMaterialsTable.tsx b/apps/erp/app/modules/production/ui/Jobs/JobMaterialsTable.tsx
index 8b0732bea0..e2f6d52121 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobMaterialsTable.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobMaterialsTable.tsx
@@ -90,7 +90,7 @@ const JobMaterialsTable = memo(({ data, count }: JobMaterialsTableProps) => {
data.forEach((material) => {
if (
material.itemTrackingType === "Non-Inventory" ||
- material.methodType === "Make" ||
+ material.methodType === "Make to Order" ||
!material.id
) {
return;
@@ -218,7 +218,9 @@ const JobMaterialsTable = memo(({ data, count }: JobMaterialsTableProps) => {
className="size-3 mr-1"
/>
{row.original.shelfName ??
- (row.original.methodType === "Make" ? "WIP" : "Default Shelf")}
+ (row.original.methodType === "Make to Order"
+ ? "WIP"
+ : "Default Shelf")}
</Badge>
</HStack>
)
@@ -243,7 +245,7 @@ const JobMaterialsTable = memo(({ data, count }: JobMaterialsTableProps) => {
: row.original.quantityFromProductionOrderInShelf +
row.original.estimatedQuantity;
- if (row.original.methodType === "Make") {
+ if (row.original.methodType === "Make to Order") {
return null;
}
@@ -279,7 +281,7 @@ const JobMaterialsTable = memo(({ data, count }: JobMaterialsTableProps) => {
cell: ({ row }) => {
if (
row.original.itemTrackingType === "Non-Inventory" ||
- row.original.methodType === "Make"
+ row.original.methodType === "Make to Order"
) {
return null;
}
@@ -359,7 +361,7 @@ const JobMaterialsTable = memo(({ data, count }: JobMaterialsTableProps) => {
// Skip non-inventory items and make items
if (
row.itemTrackingType === "Non-Inventory" ||
- row.methodType === "Make" ||
+ row.methodType === "Make to Order" ||
!row.id
) {
return null;
diff --git a/apps/erp/app/modules/production/ui/Jobs/ProductionQuantityForm.tsx b/apps/erp/app/modules/production/ui/Jobs/ProductionQuantityForm.tsx
index b31f34f93c..329d36c250 100644
--- a/apps/erp/app/modules/production/ui/Jobs/ProductionQuantityForm.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/ProductionQuantityForm.tsx
@@ -16,7 +16,6 @@ import type { z } from "zod";
import {
Employee,
Hidden,
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Number,
Select,
Submit,
diff --git a/apps/erp/app/modules/production/ui/Procedures/ProcedureExplorer.tsx b/apps/erp/app/modules/production/ui/Procedures/ProcedureExplorer.tsx
index 763fbf955a..6998473aea 100644
--- a/apps/erp/app/modules/production/ui/Procedures/ProcedureExplorer.tsx
+++ b/apps/erp/app/modules/production/ui/Procedures/ProcedureExplorer.tsx
@@ -3,7 +3,6 @@ import {
Array as ArrayInput,
Hidden,
Input,
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Number,
SelectControlled,
Submit,
diff --git a/apps/erp/app/modules/production/ui/Procedures/ProcedureForm.tsx b/apps/erp/app/modules/production/ui/Procedures/ProcedureForm.tsx
index abfed53e96..91d8473d17 100644
--- a/apps/erp/app/modules/production/ui/Procedures/ProcedureForm.tsx
+++ b/apps/erp/app/modules/production/ui/Procedures/ProcedureForm.tsx
@@ -13,7 +13,6 @@ import {
import type { PostgrestResponse } from "@supabase/supabase-js";
import { useFetcher } from "react-router";
import type { z } from "zod";
-// biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
import { Hidden, Input, Number, Process, Submit } from "~/components/Form";
import { usePermissions } from "~/hooks";
import { path } from "~/utils/path";
diff --git a/apps/erp/app/modules/production/ui/Projection/DemandProjectionForm.tsx b/apps/erp/app/modules/production/ui/Projection/DemandProjectionForm.tsx
index b768d74ad8..f12c0549db 100644
--- a/apps/erp/app/modules/production/ui/Projection/DemandProjectionForm.tsx
+++ b/apps/erp/app/modules/production/ui/Projection/DemandProjectionForm.tsx
@@ -13,7 +13,6 @@ import {
import { getLocalTimeZone, startOfWeek, today } from "@internationalized/date";
import { useFetcher, useLoaderData } from "react-router";
import type { z } from "zod";
-// biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
import { Hidden, Item, Location, Number, Submit } from "~/components/Form";
import { usePermissions } from "~/hooks";
import { path } from "~/utils/path";
diff --git a/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderDeliveryForm.tsx b/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderDeliveryForm.tsx
index 7f040f012b..c252718be5 100644
--- a/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderDeliveryForm.tsx
+++ b/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderDeliveryForm.tsx
@@ -10,7 +10,6 @@ import { forwardRef, useImperativeHandle, useRef, useState } from "react";
import { useFetcher, useParams } from "react-router";
import type { z } from "zod";
import {
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Boolean,
Customer,
CustomerLocation,
@@ -19,7 +18,6 @@ import {
Hidden,
Input,
Location,
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Number,
ShippingMethod,
Submit
diff --git a/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderPaymentForm.tsx b/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderPaymentForm.tsx
index 1274c35653..a9e8babd54 100644
--- a/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderPaymentForm.tsx
+++ b/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderPaymentForm.tsx
@@ -10,7 +10,6 @@ import { useState } from "react";
import { useFetcher, useParams } from "react-router";
import type { z } from "zod";
import {
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Boolean,
CustomFormFields,
Hidden,
diff --git a/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderSummary.tsx b/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderSummary.tsx
index 4fa6d12e7f..0277ff0522 100644
--- a/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderSummary.tsx
+++ b/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderSummary.tsx
@@ -168,8 +168,10 @@ const LineItems = ({
className="flex items-center gap-2"
>
{line.purchaseQuantity}
- {/* @ts-expect-error TS2339 */}
- <MethodIcon type={line.methodType ?? "Pick"} />
+ <MethodIcon
+ // @ts-ignore
+ type={line.methodType ?? "Pull from Inventory"}
+ />
</Badge>
<Badge variant="green">
{formatter.format(line.unitPrice ?? 0)}{" "}
diff --git a/apps/erp/app/modules/purchasing/ui/Supplier/SupplierProcessForm.tsx b/apps/erp/app/modules/purchasing/ui/Supplier/SupplierProcessForm.tsx
index 26a2dc4fc7..458fe2ea92 100644
--- a/apps/erp/app/modules/purchasing/ui/Supplier/SupplierProcessForm.tsx
+++ b/apps/erp/app/modules/purchasing/ui/Supplier/SupplierProcessForm.tsx
@@ -19,7 +19,6 @@ import type { z } from "zod";
import {
CustomFormFields,
Hidden,
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Number,
Process,
Submit,
diff --git a/apps/erp/app/modules/quality/ui/Calibrations/GaugeCalibrationRecordForm.tsx b/apps/erp/app/modules/quality/ui/Calibrations/GaugeCalibrationRecordForm.tsx
index 10711c9720..bb6a74e389 100644
--- a/apps/erp/app/modules/quality/ui/Calibrations/GaugeCalibrationRecordForm.tsx
+++ b/apps/erp/app/modules/quality/ui/Calibrations/GaugeCalibrationRecordForm.tsx
@@ -1,11 +1,9 @@
import { useCarbon } from "@carbon/auth";
import type { Database } from "@carbon/database";
import {
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Boolean,
DatePicker,
Input,
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Number,
ValidatedForm
} from "@carbon/form";
diff --git a/apps/erp/app/modules/quality/ui/Documents/QualityDocumentExplorer.tsx b/apps/erp/app/modules/quality/ui/Documents/QualityDocumentExplorer.tsx
index 73ddca67e2..c2023f1ecb 100644
--- a/apps/erp/app/modules/quality/ui/Documents/QualityDocumentExplorer.tsx
+++ b/apps/erp/app/modules/quality/ui/Documents/QualityDocumentExplorer.tsx
@@ -3,7 +3,6 @@ import {
Array as ArrayInput,
Hidden,
Input,
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Number,
SelectControlled,
Submit,
diff --git a/apps/erp/app/modules/quality/ui/Documents/QualityDocumentForm.tsx b/apps/erp/app/modules/quality/ui/Documents/QualityDocumentForm.tsx
index 2013113770..036bc6180a 100644
--- a/apps/erp/app/modules/quality/ui/Documents/QualityDocumentForm.tsx
+++ b/apps/erp/app/modules/quality/ui/Documents/QualityDocumentForm.tsx
@@ -13,7 +13,6 @@ import {
import type { PostgrestResponse } from "@supabase/supabase-js";
import { useFetcher } from "react-router";
import type { z } from "zod";
-// biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
import { Hidden, Input, Number, Submit } from "~/components/Form";
import { usePermissions } from "~/hooks";
import { path } from "~/utils/path";
diff --git a/apps/erp/app/modules/quality/ui/Issue/AssociatedItemsList.tsx b/apps/erp/app/modules/quality/ui/Issue/AssociatedItemsList.tsx
index 00ce19865e..dda82c947c 100644
--- a/apps/erp/app/modules/quality/ui/Issue/AssociatedItemsList.tsx
+++ b/apps/erp/app/modules/quality/ui/Issue/AssociatedItemsList.tsx
@@ -1,4 +1,3 @@
-// biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
import { Number, Select, ValidatedForm } from "@carbon/form";
import { Card, CardContent, CardHeader, CardTitle, toast } from "@carbon/react";
import { useCallback, useEffect } from "react";
diff --git a/apps/erp/app/modules/quality/ui/Issue/IssueAssociations.tsx b/apps/erp/app/modules/quality/ui/Issue/IssueAssociations.tsx
index b8ae75c897..11ae035e40 100644
--- a/apps/erp/app/modules/quality/ui/Issue/IssueAssociations.tsx
+++ b/apps/erp/app/modules/quality/ui/Issue/IssueAssociations.tsx
@@ -1,5 +1,4 @@
import { useCarbon } from "@carbon/auth";
-// biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
import { Combobox, Hidden, Number, Submit, ValidatedForm } from "@carbon/form";
import {
Button,
diff --git a/apps/erp/app/modules/quality/ui/RequiredActions/RequiredActionForm.tsx b/apps/erp/app/modules/quality/ui/RequiredActions/RequiredActionForm.tsx
index e25c221da2..017c566938 100644
--- a/apps/erp/app/modules/quality/ui/RequiredActions/RequiredActionForm.tsx
+++ b/apps/erp/app/modules/quality/ui/RequiredActions/RequiredActionForm.tsx
@@ -17,7 +17,6 @@ import { useEffect } from "react";
import { useFetcher } from "react-router";
import type { z } from "zod";
import {
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Boolean,
CustomFormFields,
Hidden,
diff --git a/apps/erp/app/modules/resources/ui/Contractors/ContractorForm.tsx b/apps/erp/app/modules/resources/ui/Contractors/ContractorForm.tsx
index 8a6e555654..647c945e1b 100644
--- a/apps/erp/app/modules/resources/ui/Contractors/ContractorForm.tsx
+++ b/apps/erp/app/modules/resources/ui/Contractors/ContractorForm.tsx
@@ -16,7 +16,6 @@ import { useLocation, useNavigate } from "react-router";
import type { z } from "zod";
import {
CustomFormFields,
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Number,
Submit,
Supplier,
diff --git a/apps/erp/app/modules/resources/ui/Processes/ProcessForm.tsx b/apps/erp/app/modules/resources/ui/Processes/ProcessForm.tsx
index 87baad51d2..0368a3fd4b 100644
--- a/apps/erp/app/modules/resources/ui/Processes/ProcessForm.tsx
+++ b/apps/erp/app/modules/resources/ui/Processes/ProcessForm.tsx
@@ -31,7 +31,6 @@ import { useFetcher, useNavigate } from "react-router";
import type { z } from "zod";
import { SupplierAvatar } from "~/components";
import {
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Boolean,
CustomFormFields,
Hidden,
diff --git a/apps/erp/app/modules/resources/ui/Training/TrainingExplorer.tsx b/apps/erp/app/modules/resources/ui/Training/TrainingExplorer.tsx
index b84c52829f..fc81f1faf4 100644
--- a/apps/erp/app/modules/resources/ui/Training/TrainingExplorer.tsx
+++ b/apps/erp/app/modules/resources/ui/Training/TrainingExplorer.tsx
@@ -3,7 +3,6 @@ import {
Hidden,
Input,
MultiSelect,
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Number,
Select,
SelectControlled,
diff --git a/apps/erp/app/modules/resources/ui/WorkCenters/WorkCenterForm.tsx b/apps/erp/app/modules/resources/ui/WorkCenters/WorkCenterForm.tsx
index ae37d6e30d..4854536a58 100644
--- a/apps/erp/app/modules/resources/ui/WorkCenters/WorkCenterForm.tsx
+++ b/apps/erp/app/modules/resources/ui/WorkCenters/WorkCenterForm.tsx
@@ -22,7 +22,6 @@ import {
Hidden,
Input,
Location,
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Number,
Processes,
StandardFactor,
diff --git a/apps/erp/app/modules/sales/sales.service.ts b/apps/erp/app/modules/sales/sales.service.ts
index 53425d66fa..deb56213e4 100644
--- a/apps/erp/app/modules/sales/sales.service.ts
+++ b/apps/erp/app/modules/sales/sales.service.ts
@@ -2359,7 +2359,7 @@ async function buildCostEffects(
.from("quoteMaterial")
.select("id, itemId, unitCost")
.eq("quoteLineId", quoteLineId)
- .eq("methodType", "Buy");
+ .eq("methodType", "Purchase to Order");
const buyItemIds = [
...new Set((buyMaterials.data ?? []).map((m) => m.itemId))
@@ -2511,9 +2511,9 @@ async function buildCostEffects(
const d = node.data;
const qty = d.quantity * parentQuantity;
- if (d.methodType === "Buy") {
+ if (d.methodType === "Purchase to Order") {
pushBuyCostEffect(d.itemId, d.itemType, qty, d.unitCost);
- } else if (d.methodType === "Pick") {
+ } else if (d.methodType === "Pull from Inventory") {
const costFn = (outerQty: number) => d.unitCost * qty * outerQty;
const key =
d.itemType === "Material"
diff --git a/apps/erp/app/modules/sales/ui/Customer/CustomerForm.tsx b/apps/erp/app/modules/sales/ui/Customer/CustomerForm.tsx
index dfc8d2af94..b405eabf54 100644
--- a/apps/erp/app/modules/sales/ui/Customer/CustomerForm.tsx
+++ b/apps/erp/app/modules/sales/ui/Customer/CustomerForm.tsx
@@ -25,7 +25,6 @@ import {
Employee,
Hidden,
Input,
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Number,
Submit
} from "~/components/Form";
diff --git a/apps/erp/app/modules/sales/ui/Customer/CustomerHeader.tsx b/apps/erp/app/modules/sales/ui/Customer/CustomerHeader.tsx
index d03ae0981b..a9dd580fe9 100644
--- a/apps/erp/app/modules/sales/ui/Customer/CustomerHeader.tsx
+++ b/apps/erp/app/modules/sales/ui/Customer/CustomerHeader.tsx
@@ -84,7 +84,7 @@ const CustomerHeader = () => {
});
},
- [customerId]
+ [customerId, fetcher.submit]
);
return (
diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfMaterial.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfMaterial.tsx
index 75529f780c..bab2b8cb19 100644
--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfMaterial.tsx
+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfMaterial.tsx
@@ -205,7 +205,7 @@ const initialMethodMaterial: Omit<Material, "quoteMakeMethodId" | "order"> & {
itemReadableId: "",
// @ts-ignore
itemType: "Item" as const,
- methodType: "Buy" as const,
+ methodType: "Purchase to Order" as const,
description: "",
quantity: 1,
unitCost: 0,
@@ -667,7 +667,7 @@ function MaterialForm({
quoteOperationId?: string;
}>({
itemId: item.data.itemId ?? "",
- methodType: item.data.methodType ?? "Buy",
+ methodType: item.data.methodType ?? "Pull from Inventory",
description: item.data.description ?? "",
unitCost: item.data.unitCost ?? 0,
unitOfMeasureCode: item.data.unitOfMeasureCode ?? "EA",
@@ -682,7 +682,7 @@ function MaterialForm({
setItemType(value as MethodItemType);
setItemData({
itemId: "",
- methodType: "Buy",
+ methodType: "Pull from Inventory",
quantity: 1,
unitCost: 0,
description: "",
@@ -724,7 +724,7 @@ function MaterialForm({
}
let unitCost = itemCost.data?.unitCost ?? 0;
- const isBuyPart = item.data?.defaultMethodType === "Buy";
+ const isBuyPart = item.data?.defaultMethodType === "Purchase to Order";
if (isBuyPart) {
unitCost = await lookupBuyPriceFn(
@@ -740,7 +740,7 @@ function MaterialForm({
description: item.data?.name ?? "",
unitCost,
unitOfMeasureCode: item.data?.unitOfMeasureCode ?? "EA",
- methodType: item.data?.defaultMethodType ?? "Buy",
+ methodType: item.data?.defaultMethodType ?? "Pull from Inventory",
requiresBatchTracking: item.data?.itemTrackingType === "Batch",
requiresSerialTracking: item.data?.itemTrackingType === "Serial"
}));
@@ -754,7 +754,8 @@ function MaterialForm({
async (newQty: number) => {
setItemData((d) => ({ ...d, quantity: newQty }));
- if (itemData.methodType !== "Buy" || !itemData.itemId) return;
+ if (itemData.methodType !== "Purchase to Order" || !itemData.itemId)
+ return;
if (!carbon) return;
const itemCost = await carbon
@@ -799,7 +800,7 @@ function MaterialForm({
<Hidden name="kit" value={itemData.kit.toString()} />
<Hidden name="order" />
- {itemData.methodType === "Make" && (
+ {itemData.methodType === "Make to Order" && (
<Hidden name="unitCost" value={itemData.unitCost} />
)}
</div>
@@ -843,7 +844,7 @@ function MaterialForm({
}}
className="col-span-2"
/>
- {itemData.methodType !== "Make" && (
+ {itemData.methodType !== "Make to Order" && (
<NumberControlled
name="unitCost"
label="Unit Cost"
@@ -862,7 +863,7 @@ function MaterialForm({
onClick={sourceDisclosure.onToggle}
>
<HStack>
- {itemData.methodType === "Make" ? (
+ {itemData.methodType === "Make to Order" ? (
<>
<LuGitPullRequestCreate />
<Label>Finish To</Label>
@@ -880,13 +881,19 @@ function MaterialForm({
{itemData.methodType}
</Badge>
<LuArrowLeft
- className={cn(itemData.methodType !== "Pick" ? "rotate-180" : "")}
+ className={cn(
+ itemData.methodType !== "Pull from Inventory"
+ ? "rotate-180"
+ : ""
+ )}
/>
<Badge variant="secondary">
<LuGitPullRequest className="size-3 mr-1" />
{shelves.options?.find((s) => s.value === itemData.shelfId)
?.label ??
- (itemData.methodType === "Make" ? "WIP" : "Default Shelf")}
+ (itemData.methodType === "Make to Order"
+ ? "WIP"
+ : "Default Shelf")}
</Badge>
<IconButton
icon={<LuChevronRight />}
@@ -1005,11 +1012,13 @@ function MaterialForm({
layout
className="flex items-center justify-between gap-2 w-full"
>
- {itemData.methodType === "Make" ? (
+ {itemData.methodType === "Make to Order" ? (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
- leftIcon={<MethodIcon type={"Make"} isKit={itemData.kit} />}
+ leftIcon={
+ <MethodIcon type={"Make to Order"} isKit={itemData.kit} />
+ }
variant="secondary"
size="sm"
rightIcon={<LuChevronDown />}
diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfProcess.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfProcess.tsx
index a718e00351..2cc008a163 100644
--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfProcess.tsx
+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfProcess.tsx
@@ -71,7 +71,6 @@ import { DirectionAwareTabs, EmployeeAvatar, TimeTypeIcon } from "~/components";
import {
Hidden,
InputControlled,
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Number,
NumberControlled,
Process,
diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteBoMExplorer.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteBoMExplorer.tsx
index f55e9a75ef..dbb866524c 100644
--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteBoMExplorer.tsx
+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteBoMExplorer.tsx
@@ -387,7 +387,7 @@ function NodePreview({ node }: { node: FlatTreeItem<QuoteMethod> }) {
<span>{node.data.itemType}</span>
</HStack>
</VStack>
- {node.data.methodType === "Make" && (
+ {node.data.methodType === "Make to Order" && (
<VStack spacing={1}>
<span className="text-xs text-muted-foreground font-medium">
Make Method Version
@@ -415,7 +415,7 @@ function NodePreview({ node }: { node: FlatTreeItem<QuoteMethod> }) {
function getNodePath(node: FlatTreeItem<QuoteMethod>) {
return node.data.isRoot
? path.to.quoteLine(node.data.quoteId, node.data.quoteLineId)
- : node.data.methodType === "Make"
+ : node.data.methodType === "Make to Order"
? path.to.quoteLineMakeMethod(
node.data.quoteId,
node.data.quoteLineId,
diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteExplorer.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteExplorer.tsx
index 77aa352fe4..33fd6d3135 100644
--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteExplorer.tsx
+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteExplorer.tsx
@@ -85,7 +85,7 @@ export default function QuoteExplorer({ methods }: QuoteExplorerProps) {
estimatorId: userId,
itemId: "",
locationId: quoteData?.quote?.locationId ?? defaults.locationId ?? "",
- methodType: "Make" as const,
+ methodType: "Make to Order" as const,
status: "Not Started" as const,
quantity: [1],
unitOfMeasureCode: "",
@@ -368,7 +368,7 @@ function QuoteLineItem({
const isSelected = lineId === line.id;
const onLineClick = (line: QuotationLine) => {
- if (line.methodType === "Make") {
+ if (line.methodType === "Make to Order") {
disclosure.onOpen();
}
@@ -410,7 +410,7 @@ function QuoteLineItem({
</HStack>
<div className="absolute right-2">
<HStack spacing={1}>
- {line.methodType === "Make" &&
+ {line.methodType === "Make to Order" &&
permissions.can("update", "sales") &&
line.status !== "No Quote" && (
<IconButton
@@ -457,7 +457,7 @@ function QuoteLineItem({
View Item Master
</Link>
</DropdownMenuItem>
- {line.methodType === "Make" && (
+ {line.methodType === "Make to Order" && (
<>
<DropdownMenuItem onClick={searchDisclosure.onOpen}>
<DropdownMenuIcon icon={<LuSearch />} />
@@ -563,7 +563,7 @@ function QuoteLineItem({
</div>
</HStack>
{disclosure.isOpen &&
- line.methodType === "Make" &&
+ line.methodType === "Make to Order" &&
permissions.can("update", "sales") &&
line.status !== "No Quote" && (
<VStack className="border-b border-border p-1">
diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteLineForm.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteLineForm.tsx
index 28fb7e8768..c457345b2e 100644
--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteLineForm.tsx
+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteLineForm.tsx
@@ -37,7 +37,6 @@ import {
Hidden,
InputControlled,
Item,
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Number,
Select,
SelectControlled,
diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteLinePricing.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteLinePricing.tsx
index 667ee93799..342d32e6e8 100644
--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteLinePricing.tsx
+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteLinePricing.tsx
@@ -87,7 +87,7 @@ const QuoteLinePricing = ({
}) => {
const permissions = usePermissions();
- const hasCalculatedCost = line.methodType !== "Pick";
+ const hasCalculatedCost = line.methodType !== "Pull from Inventory";
const quantities = line.quantity ?? [1];
const { quoteId, lineId } = useParams();
@@ -315,16 +315,19 @@ const QuoteLinePricing = ({
Object.values(costs).reduce((sum, v) => sum + v, 0)
);
- const computeUnitPriceFromMarkups = (
- categoryCosts: Record<CostCategoryKey, number>,
- markups: Record<string, number>
- ): number => {
- return costCategoryKeys.reduce((sum, key) => {
- const cost = categoryCosts[key] ?? 0;
- const markup = markups[key] ?? 0;
- return sum + cost * (1 + markup / 100);
- }, 0);
- };
+ const computeUnitPriceFromMarkups = useCallback(
+ (
+ categoryCosts: Record<CostCategoryKey, number>,
+ markups: Record<string, number>
+ ): number => {
+ return costCategoryKeys.reduce((sum, key) => {
+ const cost = categoryCosts[key] ?? 0;
+ const markup = markups[key] ?? 0;
+ return sum + cost * (1 + markup / 100);
+ }, 0);
+ },
+ []
+ );
const visibleCategories = costCategoryKeys.filter((key: CostCategoryKey) =>
costsByQuantity.some((costs) => costs[key] > 0)
@@ -452,7 +455,7 @@ const QuoteLinePricing = ({
lineId,
costsByQuantity,
quantities,
- quoteId
+ computeUnitPriceFromMarkups
]
);
diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteMakeMethodTools.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteMakeMethodTools.tsx
index 913c5570c1..7bfcab8c15 100644
--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteMakeMethodTools.tsx
+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteMakeMethodTools.tsx
@@ -529,12 +529,7 @@ const QuoteMakeMethodTools = () => {
}}
>
<ModalContent>
- <ValidatedForm
- validator={getMethodValidator}
- onSubmit={() => {
- /* form handled via fetcher */
- }}
- >
+ <ValidatedForm validator={getMethodValidator}>
<ModalHeader>
<ModalTitle>Configure Item</ModalTitle>
<ModalDescription>Select an item to configure</ModalDescription>
diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteMaterialForm.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteMaterialForm.tsx
index e2f3de2e9e..7f396dbd54 100644
--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteMaterialForm.tsx
+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteMaterialForm.tsx
@@ -67,7 +67,7 @@ const QuoteMaterialForm = ({
quantity: number;
}>({
itemId: initialValues.itemId ?? "",
- methodType: initialValues.methodType ?? "Buy",
+ methodType: initialValues.methodType ?? "Pull from Inventory",
description: initialValues.description ?? "",
unitCost: initialValues.unitCost ?? 0,
unitOfMeasureCode: initialValues.unitOfMeasureCode ?? "EA",
@@ -79,7 +79,7 @@ const QuoteMaterialForm = ({
setItemType(value as MethodItemType);
setItemData({
itemId: "",
- methodType: "" as "Buy",
+ methodType: "" as "Pull from Inventory",
quantity: 1,
description: "",
unitCost: 0,
@@ -114,7 +114,7 @@ const QuoteMaterialForm = ({
}
let unitCost = itemCost.data?.unitCost ?? 0;
- const isBuyPart = item.data?.defaultMethodType === "Buy";
+ const isBuyPart = item.data?.defaultMethodType === "Purchase to Order";
if (isBuyPart) {
unitCost = await lookupBuyPrice(itemId, itemData.quantity ?? 1, unitCost);
@@ -126,7 +126,7 @@ const QuoteMaterialForm = ({
description: item.data?.name ?? "",
unitCost,
unitOfMeasureCode: item.data?.unitOfMeasureCode ?? "EA",
- methodType: item.data?.defaultMethodType ?? "Buy"
+ methodType: item.data?.defaultMethodType ?? "Purchase to Order"
}));
};
@@ -134,7 +134,8 @@ const QuoteMaterialForm = ({
async (newQty: number) => {
setItemData((d) => ({ ...d, quantity: newQty }));
- if (itemData.methodType !== "Buy" || !itemData.itemId) return;
+ if (itemData.methodType !== "Purchase to Order" || !itemData.itemId)
+ return;
if (!carbon) return;
const itemCost = await carbon
@@ -200,7 +201,7 @@ const QuoteMaterialForm = ({
<CardContent>
<Hidden name="quoteMakeMethodId" />
- {itemData.methodType === "Make" && (
+ {itemData.methodType === "Make to Order" && (
<Hidden name="unitCost" value={itemData.unitCost} />
)}
<Hidden name="order" />
@@ -256,7 +257,7 @@ const QuoteMaterialForm = ({
}))
}
/>
- {itemData.methodType !== "Make" && (
+ {itemData.methodType !== "Make to Order" && (
<NumberControlled
name="unitCost"
label="Unit Cost"
diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteShipmentForm.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteShipmentForm.tsx
index 04878ff967..0d8aabafe1 100644
--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteShipmentForm.tsx
+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteShipmentForm.tsx
@@ -13,7 +13,6 @@ import {
DatePicker,
Hidden,
Location,
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Number,
ShippingMethod,
Submit
diff --git a/apps/erp/app/modules/sales/ui/Quotes/useLineCosts.tsx b/apps/erp/app/modules/sales/ui/Quotes/useLineCosts.tsx
index 9d3dae64e4..4ba41f3cd7 100644
--- a/apps/erp/app/modules/sales/ui/Quotes/useLineCosts.tsx
+++ b/apps/erp/app/modules/sales/ui/Quotes/useLineCosts.tsx
@@ -115,7 +115,7 @@ export function useLineCosts({
function walkTree(tree: EnhancedTree) {
const { data } = tree;
- if (data.methodType === "Buy") {
+ if (data.methodType === "Purchase to Order") {
pushBuyCostEffect(
data.itemId,
data.itemType,
@@ -123,7 +123,7 @@ export function useLineCosts({
data.unitCost,
supplierPriceMap
);
- } else if (data.methodType === "Pick") {
+ } else if (data.methodType === "Pull from Inventory") {
// Pick items use static average cost
const costFn = (quantity: number) =>
data.unitCost * data.quantity * quantity;
@@ -373,9 +373,9 @@ export function useLineCosts({
}
}
- if (methodTree && line.methodType === "Make") {
+ if (methodTree && line.methodType === "Make to Order") {
walkTree(methodTree);
- } else if (line.methodType === "Buy") {
+ } else if (line.methodType === "Purchase to Order") {
pushBuyCostEffect(
line.itemId ?? "",
"Material",
diff --git a/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderExplorer.tsx b/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderExplorer.tsx
index 9649579f83..037b4624f9 100644
--- a/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderExplorer.tsx
+++ b/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderExplorer.tsx
@@ -542,7 +542,7 @@ function RelatedItemLink({
const getIcon = () => {
switch (nodeType) {
case "jobs":
- return <MethodIcon type="Make" />;
+ return <MethodIcon type="Make to Order" />;
case "shipments":
return <LuTruck className="text-indigo-600" />;
default:
diff --git a/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderHeader.tsx b/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderHeader.tsx
index b3282717e7..b9d1c51cb7 100644
--- a/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderHeader.tsx
+++ b/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderHeader.tsx
@@ -200,7 +200,8 @@ const SalesOrderHeader = () => {
// Check if there are any lines with "Make" method type that would require jobs
const hasMakeItems =
- routeData?.lines?.some((line) => line.methodType === "Make") ?? false;
+ routeData?.lines?.some((line) => line.methodType === "Make to Order") ??
+ false;
const salesOrderToJobsModal = useDisclosure();
const confirmDisclosure = useDisclosure();
@@ -326,7 +327,10 @@ const SalesOrderHeader = () => {
lines={
routeData?.salesOrder?.lines as Array<{
id: string;
- methodType: "Buy" | "Make" | "Pick";
+ methodType:
+ | "Purchase to Order"
+ | "Make to Order"
+ | "Pull from Inventory";
saleQuantity: number;
}>
}
diff --git a/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderLineForm.tsx b/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderLineForm.tsx
index 7a53f3051d..1285f545a9 100644
--- a/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderLineForm.tsx
+++ b/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderLineForm.tsx
@@ -38,7 +38,6 @@ import {
InputControlled,
Item,
Location,
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Number,
NumberControlled,
SelectControlled,
diff --git a/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderShipmentForm.tsx b/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderShipmentForm.tsx
index 03aba516a0..8e24e58605 100644
--- a/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderShipmentForm.tsx
+++ b/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderShipmentForm.tsx
@@ -10,7 +10,6 @@ import { forwardRef, useImperativeHandle, useRef, useState } from "react";
import { useFetcher, useParams } from "react-router";
import type { z } from "zod";
import {
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Boolean,
Customer,
CustomerLocation,
@@ -19,7 +18,6 @@ import {
Hidden,
Input,
Location,
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Number,
ShippingMethod,
Submit
diff --git a/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderSummary.tsx b/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderSummary.tsx
index 641a4cfd85..b2e956aa6a 100644
--- a/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderSummary.tsx
+++ b/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderSummary.tsx
@@ -117,7 +117,8 @@ const SalesOrderSummary = ({
// Check if there are any lines with "Make" method type that would require jobs
const hasMakeItems =
- routeData?.lines?.some((line) => line.methodType === "Make") ?? false;
+ routeData?.lines?.some((line) => line.methodType === "Make to Order") ??
+ false;
return (
<>
@@ -339,7 +340,7 @@ function LineItems({
{lines.map((line) => {
if (!line.id) return null;
- const isMade = line.methodType === "Make";
+ const isMade = line.methodType === "Make to Order";
const { jobLabel, jobVariant, jobs } = getSalesOrderJobStatus(
// @ts-expect-error TS2345 - TODO: fix type
@@ -436,7 +437,9 @@ function LineItems({
className="flex items-center gap-2"
>
{line.saleQuantity}
- <MethodIcon type={line.methodType ?? "Pick"} />
+ <MethodIcon
+ type={line.methodType ?? "Pull from Inventory"}
+ />
</Badge>
<Badge variant="green">
{formatter.format(line.unitPrice ?? 0)}{" "}
diff --git a/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrdersTable.tsx b/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrdersTable.tsx
index b341198fc0..ff69f71586 100644
--- a/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrdersTable.tsx
+++ b/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrdersTable.tsx
@@ -158,7 +158,10 @@ const SalesOrdersTable = memo(({ data, count }: SalesOrdersTableProps) => {
(row.original.lines as {
id: string;
saleQuantity: number;
- methodType: "Buy" | "Make" | "Pick";
+ methodType:
+ | "Purchase to Order"
+ | "Make to Order"
+ | "Pull from Inventory";
}[]) ?? [];
return (
<SalesStatus
@@ -198,18 +201,21 @@ const SalesOrdersTable = memo(({ data, count }: SalesOrdersTableProps) => {
(row.original.lines as {
id: string;
saleQuantity: number;
- methodType: "Buy" | "Make" | "Pick";
+ methodType:
+ | "Purchase to Order"
+ | "Make to Order"
+ | "Pull from Inventory";
}[]) ?? [];
if (
lines.length === 0 ||
- lines.every((line) => line.methodType !== "Make")
+ lines.every((line) => line.methodType !== "Make to Order")
) {
return null;
}
const everyMadeLineHasSufficientJobs = lines.every((line) => {
- if (line.methodType !== "Make") return true;
+ if (line.methodType !== "Make to Order") return true;
const relevantJobs =
jobs.filter?.((job) => job.salesOrderLineId === line.id) ?? [];
const totalJobQuantity = relevantJobs.reduce(
@@ -221,7 +227,7 @@ const SalesOrdersTable = memo(({ data, count }: SalesOrdersTableProps) => {
});
const everyMadeLineIsCompleted = lines.every((line) => {
- if (line.methodType !== "Make") return true;
+ if (line.methodType !== "Make to Order") return true;
const relevantJobs =
jobs.filter?.((job) => job.salesOrderLineId === line.id) ?? [];
const totalJobQuantity = relevantJobs.reduce(
diff --git a/apps/erp/app/modules/sales/ui/SalesOrder/SalesStatus.tsx b/apps/erp/app/modules/sales/ui/SalesOrder/SalesStatus.tsx
index f263ca92c4..8a89232dfc 100644
--- a/apps/erp/app/modules/sales/ui/SalesOrder/SalesStatus.tsx
+++ b/apps/erp/app/modules/sales/ui/SalesOrder/SalesStatus.tsx
@@ -12,7 +12,7 @@ type SalesOrderStatusProps = {
}>;
lines?: Array<{
id: string;
- methodType: "Buy" | "Make" | "Pick";
+ methodType: "Purchase to Order" | "Make to Order" | "Pull from Inventory";
saleQuantity: number;
}>;
};
diff --git a/apps/erp/app/modules/settings/ui/ApiKeys/ApiKeysForm.tsx b/apps/erp/app/modules/settings/ui/ApiKeys/ApiKeysForm.tsx
index 8c265a569a..a4c0cadfb3 100644
--- a/apps/erp/app/modules/settings/ui/ApiKeys/ApiKeysForm.tsx
+++ b/apps/erp/app/modules/settings/ui/ApiKeys/ApiKeysForm.tsx
@@ -60,7 +60,7 @@ const ApiKeyForm = ({
? fromApiKeyScopes(existingScopes, apiKeyPermissionModules)
: fromApiKeyScopes(null, apiKeyPermissionModules),
// eslint-disable-next-line react-hooks/exhaustive-deps
- []
+ [existingScopes, isEditing]
);
const matrix = usePermissionMatrix({
diff --git a/apps/erp/app/modules/settings/ui/CustomFields/CustomFieldForm.tsx b/apps/erp/app/modules/settings/ui/CustomFields/CustomFieldForm.tsx
index a7c6213d5c..096fe53604 100644
--- a/apps/erp/app/modules/settings/ui/CustomFields/CustomFieldForm.tsx
+++ b/apps/erp/app/modules/settings/ui/CustomFields/CustomFieldForm.tsx
@@ -25,7 +25,6 @@ import {
} from "react-icons/lu";
import { useParams } from "react-router";
import type { z } from "zod";
-// biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
import { Array, Hidden, Input, Submit, Tags } from "~/components/Form";
import { usePermissions, useRouteData } from "~/hooks";
import type { AttributeDataType } from "~/modules/people";
diff --git a/apps/erp/app/modules/settings/ui/Integrations/IntegrationForm.tsx b/apps/erp/app/modules/settings/ui/Integrations/IntegrationForm.tsx
index 6a4f5fd38e..4fa6724429 100644
--- a/apps/erp/app/modules/settings/ui/Integrations/IntegrationForm.tsx
+++ b/apps/erp/app/modules/settings/ui/Integrations/IntegrationForm.tsx
@@ -6,9 +6,7 @@ import type {
} from "@carbon/ee";
import { integrations as availableIntegrations } from "@carbon/ee";
import {
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Array,
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Boolean,
Input,
Select,
diff --git a/apps/erp/app/modules/settings/ui/Sequences/SequenceForm.tsx b/apps/erp/app/modules/settings/ui/Sequences/SequenceForm.tsx
index c9dfbd7416..0fa06972f9 100644
--- a/apps/erp/app/modules/settings/ui/Sequences/SequenceForm.tsx
+++ b/apps/erp/app/modules/settings/ui/Sequences/SequenceForm.tsx
@@ -14,7 +14,6 @@ import {
import { useState } from "react";
import { useNavigate } from "react-router";
import type { z } from "zod";
-// biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
import { Hidden, Input, Number, Submit } from "~/components/Form";
import { usePermissions } from "~/hooks";
import { sequenceValidator } from "~/modules/settings";
diff --git a/apps/erp/app/modules/settings/ui/Webhooks/WebhookForm.tsx b/apps/erp/app/modules/settings/ui/Webhooks/WebhookForm.tsx
index beefbfeff8..003bd7c23e 100644
--- a/apps/erp/app/modules/settings/ui/Webhooks/WebhookForm.tsx
+++ b/apps/erp/app/modules/settings/ui/Webhooks/WebhookForm.tsx
@@ -1,4 +1,3 @@
-// biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
import { Boolean, Input, Select, ValidatedForm } from "@carbon/form";
import {
Badge,
diff --git a/apps/erp/app/modules/shared/imports.models.ts b/apps/erp/app/modules/shared/imports.models.ts
index 4b5909f43f..92471a2038 100644
--- a/apps/erp/app/modules/shared/imports.models.ts
+++ b/apps/erp/app/modules/shared/imports.models.ts
@@ -3,7 +3,11 @@ import type { SupabaseClient } from "@supabase/supabase-js";
import { z } from "zod";
// to avoid a circular dependency
-const methodType = ["Buy", "Make", "Pick"] as const;
+const methodType = [
+ "Purchase to Order",
+ "Pull from Inventory",
+ "Make to Order"
+] as const;
const itemReplenishmentSystems = ["Buy", "Make", "Buy and Make"] as const;
const itemTrackingTypes = [
"Inventory",
@@ -685,8 +689,8 @@ export const fieldMappings = {
enumData: {
description:
"How a part should be produced when it is required in production",
- options: ["Buy", "Pick"],
- default: "Buy"
+ options: ["Purchase to Order", "Pull from Inventory", "Make to Order"],
+ default: "Purchase to Order"
}
},
itemTrackingType: {
@@ -768,7 +772,7 @@ export const fieldMappings = {
description:
"The method type of the part, which describes whether it is bought or made",
options: methodType,
- default: "Pick"
+ default: "Pull from Inventory"
}
},
quantity: {
diff --git a/apps/erp/app/modules/shared/shared.models.ts b/apps/erp/app/modules/shared/shared.models.ts
index c8951c62db..a1dc698608 100644
--- a/apps/erp/app/modules/shared/shared.models.ts
+++ b/apps/erp/app/modules/shared/shared.models.ts
@@ -131,7 +131,32 @@ export const months = [
"December"
] as const;
-export const methodType = ["Buy", "Make", "Pick"] as const;
+export const methodType = [
+ "Purchase to Order",
+ "Pull from Inventory",
+ "Make to Order"
+] as const;
+
+export const sourcingType = [
+ "Specified",
+ "Drop Ship",
+ "Ship from Inventory"
+] as const;
+
+export const validMethodTypesByReplenishment: Record<
+ string,
+ readonly (typeof methodType)[number][]
+> = {
+ Buy: ["Pull from Inventory", "Purchase to Order"],
+ Make: ["Pull from Inventory", "Make to Order"],
+ "Buy and Make": ["Pull from Inventory", "Purchase to Order"]
+};
+
+export function getValidMethodTypes(
+ replenishmentSystem: string
+): readonly (typeof methodType)[number][] {
+ return validMethodTypesByReplenishment[replenishmentSystem] ?? [];
+}
export const noteValidator = z.object({
id: zfd.text(z.string().optional()),
diff --git a/apps/erp/app/modules/shared/types.ts b/apps/erp/app/modules/shared/types.ts
index 7f6c294a7b..641955b07c 100644
--- a/apps/erp/app/modules/shared/types.ts
+++ b/apps/erp/app/modules/shared/types.ts
@@ -11,6 +11,7 @@ import type {
operationParameterValidator,
operationStepValidator,
operationToolValidator,
+ sourcingType,
standardFactorType
} from "./shared.models";
import type {
@@ -92,6 +93,7 @@ export enum DataType {
export type MethodItemType = (typeof methodItemType)[number];
export type MethodType = (typeof methodType)[number];
+export type SourcingType = (typeof sourcingType)[number];
export type Note = NonNullable<
Awaited<ReturnType<typeof getNotes>>["data"]
diff --git a/apps/erp/app/modules/users/ui/EmployeeTypes/EmployeeTypeForm.tsx b/apps/erp/app/modules/users/ui/EmployeeTypes/EmployeeTypeForm.tsx
index 5b39440b84..55e2097e35 100644
--- a/apps/erp/app/modules/users/ui/EmployeeTypes/EmployeeTypeForm.tsx
+++ b/apps/erp/app/modules/users/ui/EmployeeTypes/EmployeeTypeForm.tsx
@@ -46,7 +46,7 @@ const EmployeeTypeForm = ({ initialValues }: EmployeeTypeFormProps) => {
const { state: initialState, modules } = useMemo(
() => fromEmployeeTypePermissions(initialValues.permissions),
// eslint-disable-next-line react-hooks/exhaustive-deps
- []
+ [initialValues.permissions]
);
const matrix = usePermissionMatrix({
diff --git a/apps/erp/app/modules/users/ui/Employees/BulkEditPermissionsForm.tsx b/apps/erp/app/modules/users/ui/Employees/BulkEditPermissionsForm.tsx
index 512a25c0b6..0049633101 100644
--- a/apps/erp/app/modules/users/ui/Employees/BulkEditPermissionsForm.tsx
+++ b/apps/erp/app/modules/users/ui/Employees/BulkEditPermissionsForm.tsx
@@ -73,7 +73,7 @@ const BulkEditPermissions = ({
matrix.setPermissions(state);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
- }, [emptyPermissionsFetcher.data]);
+ }, [emptyPermissionsFetcher.data, matrix.setPermissions]);
// Serialize permissions to the format expected by the action
const permissionsData = JSON.stringify(
diff --git a/apps/erp/app/modules/users/ui/Employees/EmployeePermissionsForm.tsx b/apps/erp/app/modules/users/ui/Employees/EmployeePermissionsForm.tsx
index b4daef376a..fa4662f923 100644
--- a/apps/erp/app/modules/users/ui/Employees/EmployeePermissionsForm.tsx
+++ b/apps/erp/app/modules/users/ui/Employees/EmployeePermissionsForm.tsx
@@ -51,7 +51,7 @@ const EmployeePermissionsForm = ({
const { state: initialState, modules } = useMemo(
() => fromCompanyPermissions(initialValues.permissions),
// eslint-disable-next-line react-hooks/exhaustive-deps
- []
+ [initialValues.permissions]
);
const matrix = usePermissionMatrix({
diff --git a/apps/erp/app/routes/api+/integrations.onshape.d.$did.v.$vid.e.$eid.bom.ts b/apps/erp/app/routes/api+/integrations.onshape.d.$did.v.$vid.e.$eid.bom.ts
index 35087ed1dc..f84dbba790 100644
--- a/apps/erp/app/routes/api+/integrations.onshape.d.$did.v.$vid.e.$eid.bom.ts
+++ b/apps/erp/app/routes/api+/integrations.onshape.d.$did.v.$vid.e.$eid.bom.ts
@@ -142,7 +142,9 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
if (!defaultMethodType) {
defaultMethodType =
- row["Purchasing Level"] === "Purchased" ? "Pick" : "Make";
+ row["Purchasing Level"] === "Purchased"
+ ? "Pull from Inventory"
+ : "Make to Order";
}
return {
diff --git a/apps/erp/app/routes/share+/customer.$id.tsx b/apps/erp/app/routes/share+/customer.$id.tsx
index 8328547e74..2cd1a71fd4 100644
--- a/apps/erp/app/routes/share+/customer.$id.tsx
+++ b/apps/erp/app/routes/share+/customer.$id.tsx
@@ -282,7 +282,7 @@ export default function CustomerPortal() {
cell: ({ row }) =>
row.original?.jobProductionQuantity ? (
<div className="flex items-center gap-1.5">
- <MethodIcon type="Make" />
+ <MethodIcon type="Make to Order" />
<span>
{`${formatter.format(
row.original.jobQuantityComplete
@@ -291,7 +291,7 @@ export default function CustomerPortal() {
</div>
) : (
<div className="flex items-center gap-1.5">
- <MethodIcon type="Pick" />
+ <MethodIcon type="Pull from Inventory" />
<span>{formatter.format(row.original.saleQuantity ?? 0)}</span>
</div>
)
diff --git a/apps/erp/app/routes/x+/consumable+/$itemId.tsx b/apps/erp/app/routes/x+/consumable+/$itemId.tsx
index 989a723df0..bc8607e5f6 100644
--- a/apps/erp/app/routes/x+/consumable+/$itemId.tsx
+++ b/apps/erp/app/routes/x+/consumable+/$itemId.tsx
@@ -141,7 +141,7 @@ export default function ConsumableRoute() {
module: "purchasing",
children: purchaseOrderLines.map((po) => ({
...po,
- methodType: "Buy"
+ methodType: "Purchase to Order"
}))
},
{
@@ -150,7 +150,7 @@ export default function ConsumableRoute() {
module: "inventory",
children: receiptLines.map((receipt) => ({
...receipt,
- methodType: "Pick"
+ methodType: "Pull from Inventory"
}))
},
diff --git a/apps/erp/app/routes/x+/consumable+/new.tsx b/apps/erp/app/routes/x+/consumable+/new.tsx
index 2473cff526..42296656ba 100644
--- a/apps/erp/app/routes/x+/consumable+/new.tsx
+++ b/apps/erp/app/routes/x+/consumable+/new.tsx
@@ -70,7 +70,7 @@ export default function ConsumablesNewRoute() {
description: "",
itemTrackingType: "Non-Inventory" as "Non-Inventory",
replenishmentSystem: "Buy" as const,
- defaultMethodType: "Buy" as const,
+ defaultMethodType: "Purchase to Order" as const,
unitOfMeasureCode: "EA",
unitCost: 0,
active: true,
diff --git a/apps/erp/app/routes/x+/inventory+/quantities+/$itemId.details.tsx b/apps/erp/app/routes/x+/inventory+/quantities+/$itemId.details.tsx
index 584aad4b96..dcc92d148d 100644
--- a/apps/erp/app/routes/x+/inventory+/quantities+/$itemId.details.tsx
+++ b/apps/erp/app/routes/x+/inventory+/quantities+/$itemId.details.tsx
@@ -18,7 +18,6 @@ import {
getPickMethod,
upsertPickMethod
} from "~/modules/items";
-import { BillOfMaterial, BillOfProcess } from "~/modules/items/ui/Item";
import { getLocationsList } from "~/modules/resources";
import type { MethodItemType, MethodType } from "~/modules/shared";
import { getTagsList } from "~/modules/shared";
@@ -197,14 +196,8 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
}
export default function ItemInventoryRoute() {
- const {
- pickMethod,
- quantities,
- itemShelfQuantities,
- item,
- methodData,
- tags
- } = useLoaderData<typeof loader>();
+ const { pickMethod, quantities, itemShelfQuantities, item } =
+ useLoaderData<typeof loader>();
const [items] = useItems();
const itemTrackingType = items.find(
@@ -226,25 +219,6 @@ export default function ItemInventoryRoute() {
quantities={quantities}
shelves={shelves.options}
/>
- {methodData && (
- <>
- <BillOfMaterial
- makeMethod={methodData.makeMethod}
- // @ts-ignore
- materials={methodData.methodMaterials}
- // @ts-ignore
- operations={methodData.methodOperations}
- />
- <BillOfProcess
- makeMethod={methodData.makeMethod}
- // @ts-ignore
- operations={methodData.methodOperations}
- // @ts-ignore
- materials={methodData.methodMaterials}
- tags={tags}
- />
- </>
- )}
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/items+/update.tsx b/apps/erp/app/routes/x+/items+/update.tsx
index faf8b99a96..eabbb37fe4 100644
--- a/apps/erp/app/routes/x+/items+/update.tsx
+++ b/apps/erp/app/routes/x+/items+/update.tsx
@@ -31,22 +31,30 @@ export async function action({ request }: ActionFunctionArgs) {
.update({
// @ts-expect-error
[field]: value,
- // @ts-expect-error
- defaultMethodType: value,
+ defaultMethodType:
+ value === "Make"
+ ? "Make to Order"
+ : value === "Buy"
+ ? "Purchase to Order"
+ : "Pull from Inventory",
updatedBy: userId,
updatedAt: new Date().toISOString()
})
.in("id", items as string[])
.eq("companyId", companyId);
}
- if (field === "defaultMethodType" && value !== "Pick") {
+ if (field === "defaultMethodType" && value !== "Pull from Inventory") {
return await client
.from("item")
.update({
- // @ts-expect-error
+ // @ts-expect-error - value is a valid method type
defaultMethodType: value,
- // @ts-expect-error
- replenishmentSystem: value,
+ replenishmentSystem:
+ value === "Make to Order"
+ ? "Make"
+ : value === "Purchase to Order"
+ ? "Buy"
+ : "Buy and Make",
updatedBy: userId,
updatedAt: new Date().toISOString()
})
@@ -392,9 +400,7 @@ export async function action({ request }: ActionFunctionArgs) {
if (partUpdate.error) {
return partUpdate;
}
- if (itemUpdates.error) {
- // TODO: handle error
- }
+
return itemUpdates;
}
case "consumableId":
@@ -460,9 +466,7 @@ export async function action({ request }: ActionFunctionArgs) {
if (consumableUpdate.error) {
return consumableUpdate;
}
- if (consumableItemUpdates.error) {
- // TODO: handle error
- }
+
return consumableItemUpdates;
}
case "materialId":
@@ -526,9 +530,7 @@ export async function action({ request }: ActionFunctionArgs) {
if (materialUpdate.error) {
return materialUpdate;
}
- if (materialItemUpdates.error) {
- // TODO: handle error
- }
+
return materialItemUpdates;
}
case "toolId":
@@ -589,9 +591,7 @@ export async function action({ request }: ActionFunctionArgs) {
if (toolUpdate.error) {
return toolUpdate;
}
- if (toolItemUpdates.error) {
- // TODO: handle error
- }
+
return toolItemUpdates;
}
default:
diff --git a/apps/erp/app/routes/x+/job+/methods+/$jobId.material.$id.tsx b/apps/erp/app/routes/x+/job+/methods+/$jobId.material.$id.tsx
index 8fb7414611..18256bd5f4 100644
--- a/apps/erp/app/routes/x+/job+/methods+/$jobId.material.$id.tsx
+++ b/apps/erp/app/routes/x+/job+/methods+/$jobId.material.$id.tsx
@@ -68,7 +68,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
);
}
- if (validation.data.methodType === "Make") {
+ if (validation.data.methodType === "Make to Order") {
const promises = [
recalculateJobMakeMethodRequirements(client, {
id: validation.data.jobMakeMethodId,
diff --git a/apps/erp/app/routes/x+/job+/methods+/$jobId.material.new.tsx b/apps/erp/app/routes/x+/job+/methods+/$jobId.material.new.tsx
index 2a9800706e..2e745af4c7 100644
--- a/apps/erp/app/routes/x+/job+/methods+/$jobId.material.new.tsx
+++ b/apps/erp/app/routes/x+/job+/methods+/$jobId.material.new.tsx
@@ -73,7 +73,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
.single();
const isReleased = !["Draft", "Planned"].includes(job.data?.status ?? "");
- if (validation.data.methodType === "Make") {
+ if (validation.data.methodType === "Make to Order") {
const materialMakeMethod = await serviceRole
.from("jobMaterialWithMakeMethodId")
.select("*")
diff --git a/apps/erp/app/routes/x+/material+/$itemId.tsx b/apps/erp/app/routes/x+/material+/$itemId.tsx
index e7cb9c8cde..3b9e88ed7b 100644
--- a/apps/erp/app/routes/x+/material+/$itemId.tsx
+++ b/apps/erp/app/routes/x+/material+/$itemId.tsx
@@ -144,7 +144,7 @@ export default function MaterialRoute() {
module: "purchasing",
children: purchaseOrderLines.map((po) => ({
...po,
- methodType: "Buy"
+ methodType: "Purchase to Order"
}))
},
{
@@ -153,7 +153,7 @@ export default function MaterialRoute() {
module: "inventory",
children: receiptLines.map((receipt) => ({
...receipt,
- methodType: "Pick"
+ methodType: "Pull from Inventory"
}))
},
diff --git a/apps/erp/app/routes/x+/material+/new.tsx b/apps/erp/app/routes/x+/material+/new.tsx
index 2b7f157e1c..c3d76b2915 100644
--- a/apps/erp/app/routes/x+/material+/new.tsx
+++ b/apps/erp/app/routes/x+/material+/new.tsx
@@ -71,7 +71,7 @@ export default function MaterialsNewRoute() {
materialFormId: "",
materialSubstanceId: "",
replenishmentSystem: "Buy" as const,
- defaultMethodType: "Pick" as const,
+ defaultMethodType: "Pull from Inventory" as const,
itemTrackingType: "Inventory" as "Inventory",
unitOfMeasureCode: "EA",
unitCost: 0,
diff --git a/apps/erp/app/routes/x+/part+/$itemId.details.tsx b/apps/erp/app/routes/x+/part+/$itemId.details.tsx
index efa96ec3e2..d61d8e070e 100644
--- a/apps/erp/app/routes/x+/part+/$itemId.details.tsx
+++ b/apps/erp/app/routes/x+/part+/$itemId.details.tsx
@@ -266,29 +266,44 @@ export default function PartDetailsRoute() {
subTitle={partData.partSummary?.readableIdWithRevision ?? ""}
notes={partData.partSummary?.notes as JSONContent}
/>
- <BillOfMaterial
- key={`bom:${itemId}`}
- makeMethod={methodData.makeMethod}
- // @ts-ignore
- materials={methodData.methodMaterials ?? []}
- // @ts-ignore
- operations={methodData.methodOperations}
- configurable={methodData.partManufacturing?.requiresConfiguration}
- configurationRules={methodData.configurationRules}
- parameters={methodData.configurationParametersAndGroups.parameters}
- />
- <BillOfProcess
- key={`bop:${itemId}`}
- makeMethod={methodData.makeMethod}
- // @ts-ignore
- operations={methodData.methodOperations ?? []}
- configurable={methodData.partManufacturing?.requiresConfiguration}
- // @ts-ignore
- materials={methodData.methodMaterials ?? []}
- configurationRules={methodData.configurationRules}
- parameters={methodData.configurationParametersAndGroups.parameters}
- tags={tags}
- />
+ {["Make", "Buy and Make"].includes(
+ partData.partSummary?.replenishmentSystem ?? ""
+ ) && (
+ <>
+ <BillOfMaterial
+ key={`bom:${itemId}`}
+ makeMethod={methodData.makeMethod}
+ // @ts-ignore
+ materials={methodData.methodMaterials ?? []}
+ // @ts-ignore
+ operations={methodData.methodOperations}
+ configurable={
+ methodData.partManufacturing?.requiresConfiguration
+ }
+ configurationRules={methodData.configurationRules}
+ parameters={
+ methodData.configurationParametersAndGroups.parameters
+ }
+ replenishmentSystem={partData.partSummary?.replenishmentSystem}
+ />
+ <BillOfProcess
+ key={`bop:${itemId}`}
+ makeMethod={methodData.makeMethod}
+ // @ts-ignore
+ operations={methodData.methodOperations ?? []}
+ configurable={
+ methodData.partManufacturing?.requiresConfiguration
+ }
+ // @ts-ignore
+ materials={methodData.methodMaterials ?? []}
+ configurationRules={methodData.configurationRules}
+ parameters={
+ methodData.configurationParametersAndGroups.parameters
+ }
+ tags={tags}
+ />
+ </>
+ )}
</>
)}
{permissions.is("employee") && (
diff --git a/apps/erp/app/routes/x+/part+/$itemId.make.$makeMethodId.tsx b/apps/erp/app/routes/x+/part+/$itemId.make.$makeMethodId.tsx
index 55d60e6c1a..de3ca9d63c 100644
--- a/apps/erp/app/routes/x+/part+/$itemId.make.$makeMethodId.tsx
+++ b/apps/erp/app/routes/x+/part+/$itemId.make.$makeMethodId.tsx
@@ -7,7 +7,9 @@ import { Suspense } from "react";
import type { LoaderFunctionArgs } from "react-router";
import { Await, redirect, useLoaderData, useParams } from "react-router";
import { CadModel } from "~/components";
+import { useRouteData } from "~/hooks";
import { usePermissions } from "~/hooks/usePermissions";
+import type { PartSummary } from "~/modules/items";
import {
getConfigurationParameters,
getConfigurationRules,
@@ -146,6 +148,10 @@ export default function PartMakeMethodPage() {
if (!itemId) throw new Error("Could not find itemId");
if (!makeMethodId) throw new Error("Could not find makeMethodId");
+ const partData = useRouteData<{
+ partSummary: PartSummary;
+ }>(path.to.part(itemId));
+
return (
<VStack spacing={2} className="p-2">
<Suspense fallback={<Menubar />}>
@@ -170,6 +176,7 @@ export default function PartMakeMethodPage() {
configurable={partManufacturing?.requiresConfiguration}
configurationRules={configurationRules}
parameters={configurationParametersAndGroups.parameters}
+ replenishmentSystem={partData?.partSummary?.replenishmentSystem}
/>
<BillOfProcess
key={`bop:${makeMethodId}`}
diff --git a/apps/erp/app/routes/x+/part+/$itemId.tsx b/apps/erp/app/routes/x+/part+/$itemId.tsx
index 79d774b01c..21eae642c2 100644
--- a/apps/erp/app/routes/x+/part+/$itemId.tsx
+++ b/apps/erp/app/routes/x+/part+/$itemId.tsx
@@ -273,7 +273,7 @@ export default function PartRoute() {
module: "purchasing",
children: purchaseOrderLines.map((po) => ({
...po,
- methodType: "Buy"
+ methodType: "Purchase to Order"
}))
},
{
@@ -282,7 +282,7 @@ export default function PartRoute() {
module: "inventory",
children: receiptLines.map((receipt) => ({
...receipt,
- methodType: "Pick"
+ methodType: "Pull from Inventory"
}))
},
{
@@ -419,7 +419,7 @@ export default function PartRoute() {
module: "purchasing",
children: purchaseOrderLines.map((po) => ({
...po,
- methodType: "Buy"
+ methodType: "Purchase to Order"
}))
},
{
@@ -428,7 +428,7 @@ export default function PartRoute() {
module: "inventory",
children: receiptLines.map((receipt) => ({
...receipt,
- methodType: "Pick"
+ methodType: "Pull from Inventory"
}))
},
{
diff --git a/apps/erp/app/routes/x+/part+/new.tsx b/apps/erp/app/routes/x+/part+/new.tsx
index a6bd3dbebd..bc44517c80 100644
--- a/apps/erp/app/routes/x+/part+/new.tsx
+++ b/apps/erp/app/routes/x+/part+/new.tsx
@@ -74,7 +74,7 @@ export default function PartsNewRoute() {
description: "",
itemTrackingType: "Inventory" as "Inventory",
replenishmentSystem: "Buy" as "Buy",
- defaultMethodType: "Buy" as "Buy",
+ defaultMethodType: "Pull from Inventory" as "Pull from Inventory",
unitOfMeasureCode: "EA",
unitCost: 0,
lotSize: 0,
diff --git a/apps/erp/app/routes/x+/quality+/_index.tsx b/apps/erp/app/routes/x+/quality+/_index.tsx
index 675d2d9370..7f8dee7cab 100644
--- a/apps/erp/app/routes/x+/quality+/_index.tsx
+++ b/apps/erp/app/routes/x+/quality+/_index.tsx
@@ -46,7 +46,6 @@ import {
LuEllipsisVertical,
LuFile,
LuInbox,
- LuShieldAlert,
LuShieldCheck,
LuShieldX
} from "react-icons/lu";
@@ -271,7 +270,6 @@ function getPriorityVariant(priority: string | null) {
export default function QualityDashboard() {
const {
openIssuesCount,
- uncontainedCount,
containedCount,
openActionsCount,
issueTypes,
@@ -353,7 +351,7 @@ export default function QualityDashboard() {
return (
<div className="flex flex-col gap-4 w-full p-4 h-[calc(100dvh-var(--header-height))] overflow-y-auto scrollbar-thin scrollbar-thumb-rounded-full scrollbar-thumb-muted-foreground">
{/* KPI Cards */}
- <div className="grid w-full gap-4 grid-cols-1 sm:grid-cols-2 lg:grid-cols-5">
+ <div className="grid w-full gap-4 grid-cols-1 sm:grid-cols-2 lg:grid-cols-4">
<Card>
<CardHeader className="flex-row gap-2">
<LuCircleAlert className="text-muted-foreground" />
@@ -379,31 +377,6 @@ export default function QualityDashboard() {
</CardContent>
</Card>
- <Card>
- <CardHeader className="flex-row gap-2">
- <LuShieldAlert className="text-muted-foreground" />
- <CardTitle>Uncontained</CardTitle>
- </CardHeader>
- <CardContent>
- <HStack className="justify-between w-full items-center">
- <h3 className="text-5xl font-medium tracking-tighter">
- {uncontainedCount}
- </h3>
- <Button
- rightIcon={<LuArrowUpRight />}
- variant="secondary"
- asChild
- >
- <Link
- to={`${path.to.issues}?filter=containmentStatus:eq:Uncontained`}
- >
- View
- </Link>
- </Button>
- </HStack>
- </CardContent>
- </Card>
-
<Card>
<CardHeader className="flex-row gap-2">
<LuShieldCheck className="text-muted-foreground" />
diff --git a/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.configure.tsx b/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.configure.tsx
index 2a323d9803..a9d3bdcca1 100644
--- a/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.configure.tsx
+++ b/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.configure.tsx
@@ -69,7 +69,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
.from("quoteMaterial")
.select("id, itemId, unitCost")
.eq("quoteLineId", lineId)
- .eq("methodType", "Buy");
+ .eq("methodType", "Purchase to Order");
const buyItemIds = [
...new Set((buyMaterials.data ?? []).map((m) => m.itemId))
diff --git a/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.details.tsx b/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.details.tsx
index 0db1b27813..526ce7effc 100644
--- a/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.details.tsx
+++ b/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.details.tsx
@@ -194,7 +194,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
);
}
- if (d.methodType === "Make" && d.quantity?.length) {
+ if (d.methodType === "Make to Order" && d.quantity?.length) {
const serviceRole = getCarbonServiceRole();
const existingPrices = await serviceRole
.from("quoteLinePrice")
@@ -273,7 +273,7 @@ export default function QuoteLine() {
description: line.description ?? "",
estimatorId: line.estimatorId ?? "",
itemId: line.itemId ?? "",
- methodType: line.methodType ?? "Make",
+ methodType: line.methodType ?? "Make to Order",
modelUploadId: line.modelUploadId ?? undefined,
noQuoteReason: line.noQuoteReason ?? undefined,
status: line.status ?? "Not Started",
@@ -316,7 +316,7 @@ export default function QuoteLine() {
</VStack>
)}
- {line.methodType === "Make" &&
+ {line.methodType === "Make to Order" &&
line.status !== "No Quote" &&
permissions.is("employee") && (
<QuoteLineCosting
diff --git a/apps/erp/app/routes/x+/quote+/$quoteId.drag.tsx b/apps/erp/app/routes/x+/quote+/$quoteId.drag.tsx
index 852647634c..4d62227257 100644
--- a/apps/erp/app/routes/x+/quote+/$quoteId.drag.tsx
+++ b/apps/erp/app/routes/x+/quote+/$quoteId.drag.tsx
@@ -116,7 +116,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
const partData = {
id: readableId,
name: readableId,
- defaultMethodType: "Make" as const,
+ defaultMethodType: "Make to Order" as const,
itemTrackingType: "Inventory" as const,
replenishmentSystem: "Make" as const,
revision,
@@ -141,7 +141,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
status: "Not Started" as const,
estimatorId: userId,
description: partName,
- methodType: "Make" as const,
+ methodType: "Make to Order" as const,
customerPartId: partName,
customerPartRevision: "",
unitOfMeasureCode: "EA",
diff --git a/apps/erp/app/routes/x+/quote+/$quoteId.new.tsx b/apps/erp/app/routes/x+/quote+/$quoteId.new.tsx
index cedc1bf207..63f3a2a881 100644
--- a/apps/erp/app/routes/x+/quote+/$quoteId.new.tsx
+++ b/apps/erp/app/routes/x+/quote+/$quoteId.new.tsx
@@ -81,7 +81,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
const quoteLineId = createQuotationLine.data.id;
- if (d.methodType === "Buy") {
+ if (d.methodType === "Purchase to Order") {
const quantities = d.quantity ?? [1];
const priceMap = await getSupplierPriceBreaksForItems(serviceRole, [
d.itemId
@@ -101,7 +101,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
);
}
- if (d.methodType === "Make") {
+ if (d.methodType === "Make to Order") {
const upsertMethod = await upsertQuoteLineMethod(serviceRole, {
quoteId,
quoteLineId,
diff --git a/apps/erp/app/routes/x+/quote+/$quoteId.tsx b/apps/erp/app/routes/x+/quote+/$quoteId.tsx
index f7d3268fd1..de84fc885c 100644
--- a/apps/erp/app/routes/x+/quote+/$quoteId.tsx
+++ b/apps/erp/app/routes/x+/quote+/$quoteId.tsx
@@ -147,7 +147,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
const methodTrees = methods.data ?? [];
const buyItemIds = new Set<string>();
function collectBuyItems(tree: (typeof methodTrees)[number]) {
- if (tree.data.methodType === "Buy" && tree.data.itemId) {
+ if (tree.data.methodType === "Purchase to Order" && tree.data.itemId) {
buyItemIds.add(tree.data.itemId);
}
tree.children?.forEach(collectBuyItems);
@@ -155,7 +155,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
methodTrees.forEach(collectBuyItems);
// Also include top-level Buy lines (non-Make lines)
for (const line of lines.data ?? []) {
- if (line.methodType === "Buy" && line.itemId) {
+ if (line.methodType === "Purchase to Order" && line.itemId) {
buyItemIds.add(line.itemId);
}
}
diff --git a/apps/erp/app/routes/x+/quote+/methods+/$quoteId.$lineId.material.new.tsx b/apps/erp/app/routes/x+/quote+/methods+/$quoteId.$lineId.material.new.tsx
index cdd0295c2f..387bf05aa8 100644
--- a/apps/erp/app/routes/x+/quote+/methods+/$quoteId.$lineId.material.new.tsx
+++ b/apps/erp/app/routes/x+/quote+/methods+/$quoteId.$lineId.material.new.tsx
@@ -68,7 +68,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
);
}
- if (validation.data.methodType === "Make") {
+ if (validation.data.methodType === "Make to Order") {
const materialMakeMethod = await serviceRole
.from("quoteMaterialWithMakeMethodId")
.select("*")
diff --git a/apps/erp/app/routes/x+/sales-invoice+/$invoiceId.$lineId.details.tsx b/apps/erp/app/routes/x+/sales-invoice+/$invoiceId.$lineId.details.tsx
index 78ddf3a3f6..906fab3760 100644
--- a/apps/erp/app/routes/x+/sales-invoice+/$invoiceId.$lineId.details.tsx
+++ b/apps/erp/app/routes/x+/sales-invoice+/$invoiceId.$lineId.details.tsx
@@ -151,7 +151,8 @@ export default function EditSalesInvoiceLineRoute() {
id: salesInvoiceLine?.id ?? undefined,
invoiceId: salesInvoiceLine?.invoiceId ?? "",
invoiceLineType: (salesInvoiceLine?.invoiceLineType ?? "Part") as "Part",
- methodType: (salesInvoiceLine?.methodType ?? "Pick") as "Pick",
+ methodType: (salesInvoiceLine?.methodType ??
+ "Pull from Inventory") as "Pull from Inventory",
itemId: salesInvoiceLine?.itemId ?? "",
accountNumber: salesInvoiceLine?.accountNumber ?? "",
addOnCost: salesInvoiceLine?.addOnCost ?? 0,
diff --git a/apps/erp/app/routes/x+/sales-order+/$orderId.$lineId.details.tsx b/apps/erp/app/routes/x+/sales-order+/$orderId.$lineId.details.tsx
index 2638abb4d4..4b14e87f51 100644
--- a/apps/erp/app/routes/x+/sales-order+/$orderId.$lineId.details.tsx
+++ b/apps/erp/app/routes/x+/sales-order+/$orderId.$lineId.details.tsx
@@ -75,7 +75,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
return {
line: line?.data ?? null,
itemReplenishment:
- itemId && line.data.methodType === "Make"
+ itemId && line.data.methodType === "Make to Order"
? getItemReplenishment(serviceRole, itemId, companyId)
: Promise.resolve({ data: null }),
files: getOpportunityLineDocuments(serviceRole, companyId, lineId, itemId),
@@ -179,7 +179,7 @@ export default function EditSalesOrderLineRoute() {
assetId: line?.assetId ?? "",
description: line?.description ?? "",
locationId: line?.locationId ?? "",
- methodType: line?.methodType ?? "Make",
+ methodType: line?.methodType ?? "Make to Order",
nonTaxableAddOnCost: line?.nonTaxableAddOnCost ?? 0,
promisedDate: line?.promisedDate ?? undefined,
saleQuantity: line?.saleQuantity ?? 1,
@@ -209,7 +209,7 @@ export default function EditSalesOrderLineRoute() {
externalNotes={line.externalNotes as JSONContent}
/>
- {line.methodType === "Make" && (
+ {line.methodType === "Make to Order" && (
<Suspense
fallback={
<Card className="min-h-[264px]">
diff --git a/apps/erp/app/routes/x+/tool+/$itemId.details.tsx b/apps/erp/app/routes/x+/tool+/$itemId.details.tsx
index d41c7fde24..5651c3b7de 100644
--- a/apps/erp/app/routes/x+/tool+/$itemId.details.tsx
+++ b/apps/erp/app/routes/x+/tool+/$itemId.details.tsx
@@ -223,21 +223,28 @@ export default function ToolDetailsRoute() {
subTitle={toolData.toolSummary?.readableIdWithRevision ?? ""}
notes={toolData.toolSummary?.notes as JSONContent}
/>
- <BillOfMaterial
- key={`bom:${itemId}`}
- makeMethod={methodData.makeMethod}
- // @ts-ignore
- materials={methodData.methodMaterials ?? []}
- // @ts-ignore
- operations={methodData.methodOperations}
- />
- <BillOfProcess
- key={`bop:${itemId}`}
- makeMethod={methodData.makeMethod}
- // @ts-ignore
- operations={methodData.methodOperations ?? []}
- tags={tags}
- />
+ {["Make", "Buy and Make"].includes(
+ toolData.toolSummary?.replenishmentSystem ?? ""
+ ) && (
+ <>
+ <BillOfMaterial
+ key={`bom:${itemId}`}
+ makeMethod={methodData.makeMethod}
+ // @ts-ignore
+ materials={methodData.methodMaterials ?? []}
+ // @ts-ignore
+ operations={methodData.methodOperations}
+ replenishmentSystem={toolData.toolSummary?.replenishmentSystem}
+ />
+ <BillOfProcess
+ key={`bop:${itemId}`}
+ makeMethod={methodData.makeMethod}
+ // @ts-ignore
+ operations={methodData.methodOperations ?? []}
+ tags={tags}
+ />
+ </>
+ )}
</>
)}
{permissions.is("employee") && (
diff --git a/apps/erp/app/routes/x+/tool+/$itemId.make.$makeMethodId.tsx b/apps/erp/app/routes/x+/tool+/$itemId.make.$makeMethodId.tsx
index 3d3ed4c4e9..1620710707 100644
--- a/apps/erp/app/routes/x+/tool+/$itemId.make.$makeMethodId.tsx
+++ b/apps/erp/app/routes/x+/tool+/$itemId.make.$makeMethodId.tsx
@@ -7,7 +7,9 @@ import { Suspense } from "react";
import type { LoaderFunctionArgs } from "react-router";
import { Await, redirect, useLoaderData, useParams } from "react-router";
import { CadModel } from "~/components";
+import { useRouteData } from "~/hooks";
import { usePermissions } from "~/hooks/usePermissions";
+import type { ToolSummary } from "~/modules/items";
import {
getMakeMethodById,
getMakeMethods,
@@ -109,6 +111,10 @@ export default function ToolMakeMethodPage() {
if (!itemId) throw new Error("Could not find itemId");
if (!makeMethodId) throw new Error("Could not find makeMethodId");
+ const toolData = useRouteData<{
+ toolSummary: ToolSummary;
+ }>(path.to.tool(itemId));
+
return (
<VStack spacing={2} className="p-2">
<Suspense fallback={<Menubar />}>
@@ -130,6 +136,7 @@ export default function ToolMakeMethodPage() {
// @ts-expect-error TS2322 - TODO: fix type
materials={methodMaterials}
operations={methodOperations}
+ replenishmentSystem={toolData?.toolSummary?.replenishmentSystem}
/>
<BillOfProcess
key={`bop:${makeMethodId}`}
diff --git a/apps/erp/app/routes/x+/tool+/$itemId.tsx b/apps/erp/app/routes/x+/tool+/$itemId.tsx
index 41a6e1e8d1..a5d876d406 100644
--- a/apps/erp/app/routes/x+/tool+/$itemId.tsx
+++ b/apps/erp/app/routes/x+/tool+/$itemId.tsx
@@ -269,7 +269,7 @@ export default function ToolRoute() {
module: "purchasing",
children: purchaseOrderLines.map((po) => ({
...po,
- methodType: "Buy"
+ methodType: "Purchase to Order"
}))
},
{
@@ -278,7 +278,7 @@ export default function ToolRoute() {
module: "inventory",
children: receiptLines.map((receipt) => ({
...receipt,
- methodType: "Pick"
+ methodType: "Pull from Inventory"
}))
},
{
@@ -415,7 +415,7 @@ export default function ToolRoute() {
module: "purchasing",
children: purchaseOrderLines.map((po) => ({
...po,
- methodType: "Buy"
+ methodType: "Purchase to Order"
}))
},
{
@@ -424,7 +424,7 @@ export default function ToolRoute() {
module: "inventory",
children: receiptLines.map((receipt) => ({
...receipt,
- methodType: "Pick"
+ methodType: "Pull from Inventory"
}))
},
{
diff --git a/apps/erp/app/routes/x+/tool+/new.tsx b/apps/erp/app/routes/x+/tool+/new.tsx
index b25736493d..d4fdfb2ab1 100644
--- a/apps/erp/app/routes/x+/tool+/new.tsx
+++ b/apps/erp/app/routes/x+/tool+/new.tsx
@@ -64,7 +64,7 @@ export default function ToolsNewRoute() {
name: "",
description: "",
replenishmentSystem: "Buy" as const,
- defaultMethodType: "Buy" as const,
+ defaultMethodType: "Purchase to Order" as const,
itemTrackingType: "Inventory" as "Inventory",
unitOfMeasureCode: "EA",
unitCost: 0,
diff --git a/apps/erp/app/utils/bom.ts b/apps/erp/app/utils/bom.ts
index be0e677851..cff18b30fc 100644
--- a/apps/erp/app/utils/bom.ts
+++ b/apps/erp/app/utils/bom.ts
@@ -119,7 +119,7 @@ export function calculateMadePartCosts<
for (let i = nodes.length - 1; i >= 0; i--) {
const node = nodes[i];
- if (node.data.methodType !== "Make" && !node.hasChildren) {
+ if (node.data.methodType !== "Make to Order" && !node.hasChildren) {
costMap.set(node.id, node.data.unitCost ?? 0);
continue;
}
diff --git a/apps/mes/app/components/AdjustInventory.tsx b/apps/mes/app/components/AdjustInventory.tsx
index 4a7680bd1f..e8164dad66 100644
--- a/apps/mes/app/components/AdjustInventory.tsx
+++ b/apps/mes/app/components/AdjustInventory.tsx
@@ -1,7 +1,6 @@
"use client";
import { useCarbon } from "@carbon/auth";
-// biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
import { Combobox, Hidden, Number, Submit, ValidatedForm } from "@carbon/form";
import {
Button,
diff --git a/apps/mes/app/components/Icons.tsx b/apps/mes/app/components/Icons.tsx
index 65c0562df7..1289ffe566 100644
--- a/apps/mes/app/components/Icons.tsx
+++ b/apps/mes/app/components/Icons.tsx
@@ -150,15 +150,15 @@ export const MethodIcon = ({
return (
<AiOutlinePartition className={cn(className, "text-foreground")} />
);
- case "Buy":
+ case "Purchase to Order":
return <LuShoppingCart className={cn("text-blue-500", className)} />;
- case "Make":
+ case "Make to Order":
return isKit ? (
<LuHexagon className={cn("text-emerald-500", className)} />
) : (
<RxCodesandboxLogo className={cn("text-emerald-500", className)} />
);
- case "Pick":
+ case "Pull from Inventory":
return <FaCodePullRequest className={cn("text-yellow-500", className)} />;
}
diff --git a/apps/mes/app/components/JobOperation/JobOperation.tsx b/apps/mes/app/components/JobOperation/JobOperation.tsx
index 7c2803338d..409ec03a1e 100644
--- a/apps/mes/app/components/JobOperation/JobOperation.tsx
+++ b/apps/mes/app/components/JobOperation/JobOperation.tsx
@@ -1061,14 +1061,15 @@ export const JobOperation = ({
isKit={material.kit ?? false}
className="mr-2"
/>
- {material.methodType === "Make" &&
- material.kit
+ {material.methodType ===
+ "Make to Order" && material.kit
? "Kit"
: material.methodType}
</Badge>
<LuArrowLeft
className={cn(
- material.methodType === "Make"
+ material.methodType ===
+ "Make to Order"
? "rotate-180"
: ""
)}
@@ -1076,7 +1077,8 @@ export const JobOperation = ({
<Badge variant="secondary">
<LuGitPullRequest className="size-3 mr-1" />
{material.shelfName ??
- (material.methodType === "Make"
+ (material.methodType ===
+ "Make to Order"
? "WIP"
: "Default Shelf")}
</Badge>
@@ -1098,13 +1100,14 @@ export const JobOperation = ({
material.quantity)}
</Td>
<Td>
- {material.methodType === "Make" &&
+ {material.methodType ===
+ "Make to Order" &&
material.requiresBatchTracking ===
false &&
material.requiresSerialTracking ===
false ? (
<MethodIcon
- type="Make"
+ type="Make to Order"
isKit={material.kit ?? false}
/>
) : parentIsSerial &&
@@ -1119,7 +1122,8 @@ export const JobOperation = ({
)}
</Td>
<Td className="text-right">
- {material.methodType !== "Make" &&
+ {material.methodType !==
+ "Make to Order" &&
material.requiresBatchTracking ===
false &&
material.requiresSerialTracking ===
@@ -1225,7 +1229,8 @@ export const JobOperation = ({
className="mr-2"
/>
{kittedChild.methodType ===
- "Make" && kittedChild.kit
+ "Make to Order" &&
+ kittedChild.kit
? "Kit"
: kittedChild.methodType}
</Badge>
@@ -1247,13 +1252,13 @@ export const JobOperation = ({
</Td>
<Td>
{kittedChild.methodType ===
- "Make" &&
+ "Make to Order" &&
kittedChild.requiresBatchTracking ===
false &&
kittedChild.requiresSerialTracking ===
false ? (
<MethodIcon
- type="Make"
+ type="Make to Order"
isKit={
kittedChild.kit ?? false
}
@@ -1273,7 +1278,7 @@ export const JobOperation = ({
</Td>
<Td className="text-right">
{kittedChild.methodType !==
- "Make" &&
+ "Make to Order" &&
kittedChild.requiresBatchTracking ===
false &&
kittedChild.requiresSerialTracking ===
diff --git a/apps/mes/app/components/JobOperation/components/Step.tsx b/apps/mes/app/components/JobOperation/components/Step.tsx
index 4b715009a2..3b3c4e465e 100644
--- a/apps/mes/app/components/JobOperation/components/Step.tsx
+++ b/apps/mes/app/components/JobOperation/components/Step.tsx
@@ -4,7 +4,6 @@ import {
DateTimePicker,
Hidden,
Input as InputField,
- // biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
Number,
Select,
Submit,
diff --git a/apps/mes/app/services/operations.service.ts b/apps/mes/app/services/operations.service.ts
index a69abe3c35..940132fd09 100644
--- a/apps/mes/app/services/operations.service.ts
+++ b/apps/mes/app/services/operations.service.ts
@@ -294,7 +294,7 @@ export async function getJobMaterialsByOperationId(
.from("jobMaterialWithMakeMethodId")
.select("*")
.in("jobMakeMethodId", Array.from(kittedMakeMethodIds))
- .neq("methodType", "Make");
+ .neq("methodType", "Make to Order");
// Create a map of parent kit materials by their make method ID
const kitParentMap = new Map();
diff --git a/biome.jsonc b/biome.jsonc
index 7a09711da4..90b3adfb32 100644
--- a/biome.jsonc
+++ b/biome.jsonc
@@ -95,7 +95,7 @@
"noLabelVar": "warn",
"noRedeclare": "error",
"noSelfCompare": "warn",
- "noShadowRestrictedNames": "warn",
+ "noShadowRestrictedNames": "off",
"noSparseArray": "warn",
"noTemplateCurlyInString": "warn",
"noUnsafeNegation": "warn",
diff --git a/examples/quote-configurator/app/lib/carbon.server.ts b/examples/quote-configurator/app/lib/carbon.server.ts
index 12e7a0b596..41d88894f7 100644
--- a/examples/quote-configurator/app/lib/carbon.server.ts
+++ b/examples/quote-configurator/app/lib/carbon.server.ts
@@ -233,7 +233,10 @@ class CarbonClient {
quantity: number[];
itemId: string;
description: string;
- methodType: "Buy" | "Make" | "Pick";
+ methodType:
+ | "Purchase to Order"
+ | "Make to Order"
+ | "Pull from Inventory";
unitOfMeasureCode: string;
configuration?: Record<string, unknown>;
}
@@ -243,7 +246,10 @@ class CarbonClient {
quantity: number[];
itemId: string;
description: string;
- methodType: "Buy" | "Make" | "Pick";
+ methodType:
+ | "Purchase to Order"
+ | "Make to Order"
+ | "Pull from Inventory";
unitOfMeasureCode: string;
configuration?: Record<string, unknown>;
}
diff --git a/llm/tasks/todo.md b/llm/tasks/todo.md
index ffe083b1e2..e69de29bb2 100644
--- a/llm/tasks/todo.md
+++ b/llm/tasks/todo.md
@@ -1,14 +0,0 @@
-# Migrate getCarbonServiceRole imports
-
-## Task
-Update all imports of `getCarbonServiceRole` from `@carbon/auth` to `@carbon/auth/client.server`.
-
-## Plan
-- [x] Find all files importing getCarbonServiceRole from @carbon/auth (~142 files)
-- [x] Write and run a migration script
-- [x] Verify no remaining old imports
-- [x] Clean up migration script
-
-## Review
-- [x] No files still importing getCarbonServiceRole from @carbon/auth (source files)
-- [x] Spot checked 4 files for correctness (solo import, mixed imports, multi-named exports)
diff --git a/packages/database/src/swagger-docs-schema.ts b/packages/database/src/swagger-docs-schema.ts
index 5a03a0af14..e9a4e159a7 100644
--- a/packages/database/src/swagger-docs-schema.ts
+++ b/packages/database/src/swagger-docs-schema.ts
@@ -9204,6 +9204,9 @@ export default {
{
$ref: "#/parameters/rowFilter.jobMaterialWithMakeMethodId.kit",
},
+ {
+ $ref: "#/parameters/rowFilter.jobMaterialWithMakeMethodId.itemScrapPercentage",
+ },
{
$ref: "#/parameters/rowFilter.jobMaterialWithMakeMethodId.shelfName",
},
@@ -10011,6 +10014,9 @@ export default {
{
$ref: "#/parameters/rowFilter.methodMaterial.shelfIds",
},
+ {
+ $ref: "#/parameters/rowFilter.methodMaterial.sourcingType",
+ },
{
$ref: "#/parameters/select",
},
@@ -10133,6 +10139,9 @@ export default {
{
$ref: "#/parameters/rowFilter.methodMaterial.shelfIds",
},
+ {
+ $ref: "#/parameters/rowFilter.methodMaterial.sourcingType",
+ },
{
$ref: "#/parameters/preferReturn",
},
@@ -10209,6 +10218,9 @@ export default {
{
$ref: "#/parameters/rowFilter.methodMaterial.shelfIds",
},
+ {
+ $ref: "#/parameters/rowFilter.methodMaterial.sourcingType",
+ },
{
$ref: "#/parameters/body.methodMaterial",
},
@@ -70532,7 +70544,7 @@ export default {
type: "string",
},
defaultMethodType: {
- enum: ["Buy", "Make", "Pick"],
+ enum: ["Purchase to Order", "Pull from Inventory", "Make to Order"],
format: 'public."methodType"',
type: "string",
},
@@ -70728,8 +70740,8 @@ export default {
type: "string",
},
methodType: {
- default: "Make",
- enum: ["Buy", "Make", "Pick"],
+ default: "Make to Order",
+ enum: ["Purchase to Order", "Pull from Inventory", "Make to Order"],
format: 'public."methodType"',
type: "string",
},
@@ -74095,7 +74107,7 @@ export default {
type: "string",
},
methodType: {
- enum: ["Buy", "Make", "Pick"],
+ enum: ["Purchase to Order", "Pull from Inventory", "Make to Order"],
format: 'public."methodType"',
type: "string",
},
@@ -74198,6 +74210,10 @@ export default {
format: "boolean",
type: "boolean",
},
+ itemScrapPercentage: {
+ format: "numeric",
+ type: "number",
+ },
shelfName: {
format: "text",
type: "string",
@@ -74532,6 +74548,7 @@ export default {
"scrapQuantity",
"kit",
"shelfIds",
+ "sourcingType",
],
properties: {
id: {
@@ -74547,8 +74564,8 @@ export default {
type: "string",
},
methodType: {
- default: "Buy",
- enum: ["Buy", "Make", "Pick"],
+ default: "Pull from Inventory",
+ enum: ["Purchase to Order", "Pull from Inventory", "Make to Order"],
format: 'public."methodType"',
type: "string",
},
@@ -74642,6 +74659,12 @@ export default {
shelfIds: {
format: "jsonb",
},
+ sourcingType: {
+ default: "Specified",
+ enum: ["Specified", "Drop Ship", "Ship from Inventory"],
+ format: 'public."sourcingType"',
+ type: "string",
+ },
},
type: "object",
},
@@ -74729,7 +74752,7 @@ export default {
type: "string",
},
methodType: {
- enum: ["Buy", "Make", "Pick"],
+ enum: ["Purchase to Order", "Pull from Inventory", "Make to Order"],
format: 'public."methodType"',
type: "string",
},
@@ -80281,7 +80304,7 @@ export default {
type: "string",
},
defaultMethodType: {
- enum: ["Buy", "Make", "Pick"],
+ enum: ["Purchase to Order", "Pull from Inventory", "Make to Order"],
format: 'public."methodType"',
type: "string",
},
@@ -85050,8 +85073,8 @@ export default {
type: "string",
},
methodType: {
- default: "Make",
- enum: ["Buy", "Make", "Pick"],
+ default: "Make to Order",
+ enum: ["Purchase to Order", "Pull from Inventory", "Make to Order"],
format: 'public."methodType"',
type: "string",
},
@@ -85966,7 +85989,7 @@ export default {
type: "string",
},
methodType: {
- enum: ["Buy", "Make", "Pick"],
+ enum: ["Purchase to Order", "Pull from Inventory", "Make to Order"],
format: 'public."methodType"',
type: "string",
},
@@ -88920,7 +88943,7 @@ export default {
type: "number",
},
methodType: {
- enum: ["Buy", "Make", "Pick"],
+ enum: ["Purchase to Order", "Pull from Inventory", "Make to Order"],
format: 'public."methodType"',
type: "string",
},
@@ -89420,7 +89443,7 @@ export default {
type: "string",
},
methodType: {
- enum: ["Buy", "Make", "Pick"],
+ enum: ["Purchase to Order", "Pull from Inventory", "Make to Order"],
format: 'public."methodType"',
type: "string",
},
@@ -89602,7 +89625,7 @@ export default {
type: "string",
},
defaultMethodType: {
- enum: ["Buy", "Make", "Pick"],
+ enum: ["Purchase to Order", "Pull from Inventory", "Make to Order"],
format: 'public."methodType"',
type: "string",
},
@@ -89865,7 +89888,7 @@ export default {
type: "string",
},
defaultMethodType: {
- enum: ["Buy", "Make", "Pick"],
+ enum: ["Purchase to Order", "Pull from Inventory", "Make to Order"],
format: 'public."methodType"',
type: "string",
},
@@ -90551,7 +90574,7 @@ export default {
type: "string",
},
defaultMethodType: {
- enum: ["Buy", "Make", "Pick"],
+ enum: ["Purchase to Order", "Pull from Inventory", "Make to Order"],
format: 'public."methodType"',
type: "string",
},
@@ -91161,7 +91184,7 @@ export default {
type: "string",
},
methodType: {
- enum: ["Buy", "Make", "Pick"],
+ enum: ["Purchase to Order", "Pull from Inventory", "Make to Order"],
format: 'public."methodType"',
type: "string",
},
@@ -92029,8 +92052,8 @@ export default {
type: "string",
},
methodType: {
- default: "Make",
- enum: ["Buy", "Make", "Pick"],
+ default: "Make to Order",
+ enum: ["Purchase to Order", "Pull from Inventory", "Make to Order"],
format: 'public."methodType"',
type: "string",
},
@@ -93353,8 +93376,8 @@ export default {
type: "number",
},
methodType: {
- default: "Make",
- enum: ["Buy", "Make", "Pick"],
+ default: "Pull from Inventory",
+ enum: ["Purchase to Order", "Pull from Inventory", "Make to Order"],
format: 'public."methodType"',
type: "string",
},
@@ -96530,7 +96553,7 @@ export default {
type: "string",
},
methodType: {
- enum: ["Buy", "Make", "Pick"],
+ enum: ["Purchase to Order", "Pull from Inventory", "Make to Order"],
format: 'public."methodType"',
type: "string",
},
@@ -97277,8 +97300,8 @@ export default {
type: "string",
},
defaultMethodType: {
- default: "Buy",
- enum: ["Buy", "Make", "Pick"],
+ default: "Pull from Inventory",
+ enum: ["Purchase to Order", "Pull from Inventory", "Make to Order"],
format: 'public."methodType"',
type: "string",
},
@@ -97761,7 +97784,7 @@ export default {
type: "string",
},
methodType: {
- enum: ["Buy", "Make", "Pick"],
+ enum: ["Purchase to Order", "Pull from Inventory", "Make to Order"],
format: 'public."methodType"',
type: "string",
},
@@ -99699,8 +99722,8 @@ export default {
type: "string",
},
methodType: {
- default: "Pick",
- enum: ["Buy", "Make", "Pick"],
+ default: "Pull from Inventory",
+ enum: ["Purchase to Order", "Pull from Inventory", "Make to Order"],
format: 'public."methodType"',
type: "string",
},
@@ -105436,6 +105459,12 @@ export default {
in: "query",
type: "string",
},
+ "rowFilter.jobMaterialWithMakeMethodId.itemScrapPercentage": {
+ name: "itemScrapPercentage",
+ required: false,
+ in: "query",
+ type: "string",
+ },
"rowFilter.jobMaterialWithMakeMethodId.shelfName": {
name: "shelfName",
required: false,
@@ -105979,6 +106008,12 @@ export default {
in: "query",
type: "string",
},
+ "rowFilter.methodMaterial.sourcingType": {
+ name: "sourcingType",
+ required: false,
+ in: "query",
+ type: "string",
+ },
"body.pickMethod": {
name: "pickMethod",
description: "pickMethod",
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index b5e7a18ba2..8caa5568da 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -16274,6 +16274,7 @@ export type Database = {
quantity: number
scrapQuantity: number
shelfIds: Json
+ sourcingType: Database["public"]["Enums"]["sourcingType"]
tags: string[] | null
unitOfMeasureCode: string
updatedAt: string | null
@@ -16297,6 +16298,7 @@ export type Database = {
quantity: number
scrapQuantity?: number
shelfIds?: Json
+ sourcingType?: Database["public"]["Enums"]["sourcingType"]
tags?: string[] | null
unitOfMeasureCode: string
updatedAt?: string | null
@@ -16320,6 +16322,7 @@ export type Database = {
quantity?: number
scrapQuantity?: number
shelfIds?: Json
+ sourcingType?: Database["public"]["Enums"]["sourcingType"]
tags?: string[] | null
unitOfMeasureCode?: string
updatedAt?: string | null
@@ -45257,6 +45260,7 @@ export type Database = {
itemId: string | null
itemReadableId: string | null
itemReadableIdWithoutRevision: string | null
+ itemScrapPercentage: number | null
itemType: string | null
jobId: string | null
jobMakeMethodId: string | null
@@ -49332,14 +49336,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["supplierCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["supplierCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -52475,7 +52479,7 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["shipmentCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -52489,7 +52493,7 @@ export type Database = {
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["shipmentCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -56808,7 +56812,6 @@ export type Database = {
Args: { jid: string }
Returns: {
description: string
- externalId: Json
isRoot: boolean
itemId: string
itemReadableId: string
@@ -58214,7 +58217,7 @@ export type Database = {
maintenanceSource: "Scheduled" | "Reactive" | "Non-Conformance"
makeMethodStatus: "Draft" | "Active" | "Archived"
methodOperationOrder: "After Previous" | "With Previous"
- methodType: "Buy" | "Make" | "Pick"
+ methodType: "Purchase to Order" | "Pull from Inventory" | "Make to Order"
module:
| "Accounting"
| "Documents"
@@ -58424,6 +58427,7 @@ export type Database = {
| "Outbound Transfer"
shipmentStatus: "Draft" | "Pending" | "Posted" | "Voided"
shippingCarrier: "UPS" | "FedEx" | "USPS" | "DHL" | "Other"
+ sourcingType: "Specified" | "Drop Ship" | "Ship from Inventory"
stockTransferStatus: "Draft" | "Released" | "In Progress" | "Completed"
supplierLedgerDocumentType:
| "Payment"
@@ -59357,7 +59361,7 @@ export const Constants = {
maintenanceSource: ["Scheduled", "Reactive", "Non-Conformance"],
makeMethodStatus: ["Draft", "Active", "Archived"],
methodOperationOrder: ["After Previous", "With Previous"],
- methodType: ["Buy", "Make", "Pick"],
+ methodType: ["Purchase to Order", "Pull from Inventory", "Make to Order"],
module: [
"Accounting",
"Documents",
@@ -59587,6 +59591,7 @@ export const Constants = {
],
shipmentStatus: ["Draft", "Pending", "Posted", "Voided"],
shippingCarrier: ["UPS", "FedEx", "USPS", "DHL", "Other"],
+ sourcingType: ["Specified", "Drop Ship", "Ship from Inventory"],
stockTransferStatus: ["Draft", "Released", "In Progress", "Completed"],
supplierLedgerDocumentType: [
"Payment",
diff --git a/packages/database/supabase/functions/convert/index.ts b/packages/database/supabase/functions/convert/index.ts
index d04f32f927..3a62071892 100644
--- a/packages/database/supabase/functions/convert/index.ts
+++ b/packages/database/supabase/functions/convert/index.ts
@@ -830,7 +830,7 @@ serve(async (req: Request) => {
description: "",
itemTrackingType: "Inventory" as const,
replenishmentSystem: "Make" as const,
- defaultMethodType: "Make" as const,
+ defaultMethodType: "Make to Order" as const,
unitOfMeasureCode: "EA",
companyId: companyId,
createdBy: userId,
@@ -894,7 +894,7 @@ serve(async (req: Request) => {
let insertedQuoteLines: {
id?: string;
itemId?: string;
- methodType?: "Buy" | "Make" | "Pick";
+ methodType?: "Purchase to Order" | "Make to Order" | "Pull from Inventory";
}[] = [];
await db.transaction().execute(async (trx) => {
@@ -1109,7 +1109,7 @@ serve(async (req: Request) => {
// get method for each make line
await Promise.all(
insertedQuoteLines
- .filter((line) => line.methodType === "Make")
+ .filter((line) => line.methodType === "Make to Order")
.map((line) =>
client.functions.invoke("get-method", {
body: {
diff --git a/packages/database/supabase/functions/create/index.ts b/packages/database/supabase/functions/create/index.ts
index 97c68e9427..87d68f0b10 100644
--- a/packages/database/supabase/functions/create/index.ts
+++ b/packages/database/supabase/functions/create/index.ts
@@ -2033,7 +2033,7 @@ serve(async (req: Request) => {
const isSerial = serializedItems.has(salesOrderLine.itemId);
const isBatch = batchItems.has(salesOrderLine.itemId);
- if (salesOrderLine.methodType === "Make") {
+ if (salesOrderLine.methodType === "Make to Order") {
for await (const job of jobsBySalesOrderLine[salesOrderLine.id] ??
[]) {
if (!salesOrderLine.itemId) return;
@@ -2322,7 +2322,7 @@ serve(async (req: Request) => {
shipmentIdReadable = newShipment?.[0]?.shipmentId!;
}
- if (salesOrderLine.data.methodType === "Make") {
+ if (salesOrderLine.data.methodType === "Make to Order") {
for await (const job of jobs.data ?? []) {
if (!salesOrderLine.data.itemId) return;
const quantityToShip = Math.max(
diff --git a/packages/database/supabase/functions/get-method/index.ts b/packages/database/supabase/functions/get-method/index.ts
index 0392ade6e0..2885197cdc 100644
--- a/packages/database/supabase/functions/get-method/index.ts
+++ b/packages/database/supabase/functions/get-method/index.ts
@@ -506,7 +506,7 @@ serve(async (req: Request) => {
// For Make: estimatedQuantity is the good quantity (without scrap)
// For Buy/Pick: estimatedQuantity includes scrap since that's what we procure
const estimatedQuantity =
- node.data.methodType === "Make" ? targetQuantity : totalWithScrap;
+ node.data.methodType === "Make to Order" ? targetQuantity : totalWithScrap;
// operationQuantity should be the total (including scrap) since that's what we need to make
const operationQuantity = totalWithScrap;
// Pass total (including scrap) to children so cascade works correctly
@@ -877,7 +877,7 @@ serve(async (req: Request) => {
// For Make: estimatedQuantity is the good quantity (without scrap)
// For Buy/Pick: estimatedQuantity includes scrap since that's what we procure
const childEstimatedQuantity =
- methodType === "Make" ? childTargetQuantity : childTotalWithScrap;
+ methodType === "Make to Order" ? childTargetQuantity : childTotalWithScrap;
return {
jobId,
@@ -945,16 +945,16 @@ serve(async (req: Request) => {
}
const madeMaterials = materialsWithConfiguredFields.filter(
- (material) => material.methodType === "Make"
+ (material) => material.methodType === "Make to Order"
);
const pickedOrBoughtMaterials =
materialsWithConfiguredFields.filter(
- (material) => material.methodType !== "Make"
+ (material) => material.methodType !== "Make to Order"
);
const madeChildren = node.children.filter(
- (child) => child.data.methodType === "Make"
+ (child) => child.data.methodType === "Make to Order"
);
console.log("[traverseMethod] materials", {
@@ -1204,7 +1204,7 @@ serve(async (req: Request) => {
const nodeScrapQuantity = targetQuantity * nodeScrapPercentage;
const totalWithScrap = Math.ceil(targetQuantity + nodeScrapQuantity);
const estimatedQuantity =
- node.data.methodType === "Make" ? targetQuantity : totalWithScrap;
+ node.data.methodType === "Make to Order" ? targetQuantity : totalWithScrap;
const operationQuantity = totalWithScrap;
const totalQuantityForChildren = totalWithScrap;
@@ -1379,7 +1379,7 @@ serve(async (req: Request) => {
// For Make: estimatedQuantity is the good quantity (without scrap)
// For Buy/Pick: estimatedQuantity includes scrap since that's what we procure
const childEstimatedQuantity =
- child.data.methodType === "Make"
+ child.data.methodType === "Make to Order"
? childTargetQuantity
: childTotalWithScrap;
@@ -1423,7 +1423,7 @@ serve(async (req: Request) => {
for await (const child of node.children) {
const material = await mapMethodMaterialToJobMaterial(child);
- if (child.data.methodType === "Make") {
+ if (child.data.methodType === "Make to Order") {
madeMaterials.push(material);
} else {
pickedOrBoughtMaterials.push(material);
@@ -1442,7 +1442,7 @@ serve(async (req: Request) => {
.execute();
const madeChildren = node.children.filter(
- (child) => child.data.methodType === "Make"
+ (child) => child.data.methodType === "Make to Order"
);
for (const [index, child] of madeChildren.entries()) {
@@ -2072,16 +2072,16 @@ serve(async (req: Request) => {
}
const madeMaterials = materialsWithConfiguredFields.filter(
- (material) => material.methodType === "Make"
+ (material) => material.methodType === "Make to Order"
);
const pickedOrBoughtMaterials =
materialsWithConfiguredFields.filter(
- (material) => material.methodType !== "Make"
+ (material) => material.methodType !== "Make to Order"
);
const madeChildren = node.children.filter(
- (child) => child.data.methodType === "Make"
+ (child) => child.data.methodType === "Make to Order"
);
console.log("[traverseMethod] materials", {
@@ -2462,10 +2462,10 @@ serve(async (req: Request) => {
});
const madeChildren = node.children.filter(
- (child) => child.data.methodType === "Make"
+ (child) => child.data.methodType === "Make to Order"
);
const unmadeChildren = node.children.filter(
- (child) => child.data.methodType !== "Make"
+ (child) => child.data.methodType !== "Make to Order"
);
const madeMaterials = madeChildren.map(
@@ -2600,7 +2600,7 @@ serve(async (req: Request) => {
const madeItemIds: string[] = [];
traverseJobMethod(jobMethodTree, (node: JobMethodTreeItem) => {
- if (node.data.itemId && node.data.methodType === "Make") {
+ if (node.data.itemId && node.data.methodType === "Make to Order") {
madeItemIds.push(node.data.itemId);
}
});
@@ -2626,7 +2626,7 @@ serve(async (req: Request) => {
[];
traverseJobMethod(jobMethodTree!, (node: JobMethodTreeItem) => {
- if (node.data.itemId && node.data.methodType === "Make") {
+ if (node.data.itemId && node.data.methodType === "Make to Order") {
makeMethodsToDelete.push(makeMethodByItemId[node.data.itemId]);
}
@@ -2896,7 +2896,7 @@ serve(async (req: Request) => {
const madeItemIds: string[] = [];
traverseJobMethod(jobMethodTree, (node: JobMethodTreeItem) => {
- if (node.data.itemId && node.data.methodType === "Make") {
+ if (node.data.itemId && node.data.methodType === "Make to Order") {
madeItemIds.push(node.data.itemId);
}
});
@@ -2926,7 +2926,7 @@ serve(async (req: Request) => {
[];
traverseJobMethod(jobMethodTree, (node: JobMethodTreeItem) => {
- if (node.data.itemId && node.data.methodType === "Make") {
+ if (node.data.itemId && node.data.methodType === "Make to Order") {
makeMethodsToDelete.push(makeMethodByItemId[node.data.itemId]);
}
@@ -3498,7 +3498,7 @@ serve(async (req: Request) => {
await traverseQuoteMethod(
quoteMethodTree,
(node: QuoteMethodTreeItem) => {
- if (node.data.itemId && node.data.methodType === "Make") {
+ if (node.data.itemId && node.data.methodType === "Make to Order") {
madeItemIds.push(node.data.itemId);
}
}
@@ -3531,7 +3531,7 @@ serve(async (req: Request) => {
await traverseQuoteMethod(
quoteMethodTree,
(node: QuoteMethodTreeItem) => {
- if (node.data.itemId && node.data.methodType === "Make") {
+ if (node.data.itemId && node.data.methodType === "Make to Order") {
makeMethodsToDelete.push(makeMethodByItemId[node.data.itemId]);
}
@@ -3802,7 +3802,7 @@ serve(async (req: Request) => {
const madeItemIds: string[] = [];
traverseQuoteMethod(quoteMethodTree, (node: QuoteMethodTreeItem) => {
- if (node.data.itemId && node.data.methodType === "Make") {
+ if (node.data.itemId && node.data.methodType === "Make to Order") {
madeItemIds.push(node.data.itemId);
}
});
@@ -3834,7 +3834,7 @@ serve(async (req: Request) => {
await traverseQuoteMethod(
quoteMethodTree!,
(node: QuoteMethodTreeItem) => {
- if (node.data.itemId && node.data.methodType === "Make") {
+ if (node.data.itemId && node.data.methodType === "Make to Order") {
makeMethodsToDelete.push(makeMethodByItemId[node.data.itemId]);
}
@@ -4171,7 +4171,7 @@ serve(async (req: Request) => {
);
const rootTarget = job.data?.quantity ?? 1;
const rootScrapQuantity =
- node.data.methodType === "Make"
+ node.data.methodType === "Make to Order"
? rootTarget * rootScrapPercentage
: 0;
const rootTotalWithScrap = Math.ceil(
@@ -4180,7 +4180,7 @@ serve(async (req: Request) => {
// For Make: estimatedQuantity is good quantity (without scrap)
// For Buy/Pick: estimatedQuantity = total (but scrap is 0, so same as target)
const rootEstimatedQuantity =
- node.data.methodType === "Make"
+ node.data.methodType === "Make to Order"
? rootTarget
: rootTotalWithScrap;
@@ -4220,7 +4220,7 @@ serve(async (req: Request) => {
const childTargetQuantity =
nodeTotalForChildren * (child.data.quantity ?? 1);
const childScrapQuantity =
- child.data.methodType === "Make"
+ child.data.methodType === "Make to Order"
? childTargetQuantity * itemScrapPercentage
: 0;
const childTotalWithScrap = Math.ceil(
@@ -4229,7 +4229,7 @@ serve(async (req: Request) => {
// For Make: estimatedQuantity is good quantity (without scrap)
// For Buy/Pick: estimatedQuantity = total (but scrap is 0, so same as target)
const childEstimatedQuantity =
- child.data.methodType === "Make"
+ child.data.methodType === "Make to Order"
? childTargetQuantity
: childTotalWithScrap;
@@ -4936,7 +4936,7 @@ serve(async (req: Request) => {
throw new Error("Failed to insert quote line");
}
- if (line.methodType === "Make") {
+ if (line.methodType === "Make to Order") {
// we only need further processing on make lines
oldLineToNewLineMap[id] = newLine.id;
}
diff --git a/packages/database/supabase/functions/import-csv/index.ts b/packages/database/supabase/functions/import-csv/index.ts
index dc93c14f08..445f33ba4c 100644
--- a/packages/database/supabase/functions/import-csv/index.ts
+++ b/packages/database/supabase/functions/import-csv/index.ts
@@ -384,7 +384,7 @@ serve(async (req: Request) => {
replenishmentSystem: z
.enum(["Buy", "Make", "Buy and Make"])
.optional(),
- defaultMethodType: z.enum(["Buy", "Make", "Pick"]).optional(),
+ defaultMethodType: z.enum(["Purchase to Order", "Make to Order", "Pull from Inventory"]).optional(),
itemTrackingType: z.enum([
"Inventory",
"Non-Inventory",
diff --git a/packages/database/supabase/functions/issue/index.ts b/packages/database/supabase/functions/issue/index.ts
index 6ebea8629b..b291d8fd44 100644
--- a/packages/database/supabase/functions/issue/index.ts
+++ b/packages/database/supabase/functions/issue/index.ts
@@ -341,7 +341,7 @@ serve(async (req: Request) => {
.where("jobOperationId", "=", id)
.where("quantityToIssue", ">", 0)
.where("itemType", "in", ["Material", "Part", "Consumable"])
- .where("methodType", "!=", "Make")
+ .where("methodType", "!=", "Make to Order")
.where("estimatedQuantity", ">", 0)
.where("requiresBatchTracking", "=", false)
.where("requiresSerialTracking", "=", false)
@@ -352,7 +352,7 @@ serve(async (req: Request) => {
.selectFrom("jobMaterialWithMakeMethodId")
.where("jobOperationId", "=", id)
.where("itemType", "in", ["Material", "Part", "Consumable"])
- .where("methodType", "=", "Make")
+ .where("methodType", "=", "Make to Order")
.where("kit", "=", true)
.selectAll()
.execute();
@@ -367,7 +367,7 @@ serve(async (req: Request) => {
.where("jobMakeMethodId", "in", jobMakeMethodIdsOfKittedChildren)
.where("quantityToIssue", ">", 0)
.where("itemType", "in", ["Material", "Part", "Consumable"])
- .where("methodType", "!=", "Make")
+ .where("methodType", "!=", "Make to Order")
.where("estimatedQuantity", ">", 0)
.where("requiresBatchTracking", "=", false)
.where("requiresSerialTracking", "=", false)
@@ -848,7 +848,7 @@ serve(async (req: Request) => {
: Number(quantity) - Number(material?.quantityIssued); // set quantity
if (
- material?.methodType !== "Make" &&
+ material?.methodType !== "Make to Order" &&
item?.itemTrackingType === "Inventory"
) {
itemLedgerInserts.push({
@@ -950,7 +950,7 @@ serve(async (req: Request) => {
jobMakeMethodId: jobOperation?.jobMakeMethodId!,
jobOperationId: id,
shelfId: shelfId ?? undefined,
- methodType: "Pick",
+ methodType: "Pull from Inventory",
quantity: 0,
quantityIssued: Number(quantity ?? 0),
unitCost: itemCost?.unitCost,
@@ -1095,7 +1095,7 @@ serve(async (req: Request) => {
.execute();
// Create item ledger adjustment (negative for scrap)
- if (material.methodType !== "Make") {
+ if (material.methodType !== "Make to Order") {
await trx
.insertInto("itemLedger")
.values({
@@ -1298,7 +1298,7 @@ serve(async (req: Request) => {
jobMakeMethodId: jobOperation.jobMakeMethodId,
jobOperationId: jobOperationId,
itemType: item.type ?? "Part",
- methodType: item.defaultMethodType ?? "Pick",
+ methodType: item.defaultMethodType ?? "Pull from Inventory",
quantity: 0,
quantityIssued: totalChildQuantity,
requiresBatchTracking: item.itemTrackingType === "Batch",
@@ -1518,7 +1518,7 @@ serve(async (req: Request) => {
remainingQuantity,
});
- if (jobMaterial?.methodType !== "Make") {
+ if (jobMaterial?.methodType !== "Make to Order") {
itemLedgerInserts.push(
{
entryType: "Negative Adjmt.",
@@ -1586,7 +1586,7 @@ serve(async (req: Request) => {
createdBy: userId,
});
- if (jobMaterial?.methodType !== "Make") {
+ if (jobMaterial?.methodType !== "Make to Order") {
itemLedgerInserts.push({
entryType: "Consumption",
documentType: "Job Consumption",
@@ -1816,7 +1816,7 @@ serve(async (req: Request) => {
createdBy: userId,
});
- if (jobMaterial?.methodType !== "Make") {
+ if (jobMaterial?.methodType !== "Make to Order") {
itemLedgerInserts.push({
entryType: "Consumption",
documentType: "Job Consumption",
diff --git a/packages/database/supabase/functions/lib/methods.ts b/packages/database/supabase/functions/lib/methods.ts
index 59202a0f8d..124816502d 100644
--- a/packages/database/supabase/functions/lib/methods.ts
+++ b/packages/database/supabase/functions/lib/methods.ts
@@ -499,7 +499,7 @@ export async function calculateQuoteLinePrices(
.from("quoteMaterial")
.select("id, itemId, unitCost")
.eq("quoteLineId", quoteLineId)
- .eq("methodType", "Buy");
+ .eq("methodType", "Purchase to Order");
const buyItemIds = [
...new Set((buyMaterials.data ?? []).map((m) => m.itemId)),
@@ -610,9 +610,9 @@ export async function calculateQuoteLinePrices(
}
function walkTree(node: EnhancedNode) {
- if (node.methodType === "Buy") {
+ if (node.methodType === "Purchase to Order") {
pushBuyCostEffect(node.itemId, node.itemType, node.quantity, node.unitCost);
- } else if (node.methodType === "Pick") {
+ } else if (node.methodType === "Pull from Inventory") {
const costFn = (quantity: number) =>
node.unitCost * node.quantity * quantity;
switch (node.itemType) {
diff --git a/packages/database/supabase/functions/lib/scheduling/scheduling-engine.ts b/packages/database/supabase/functions/lib/scheduling/scheduling-engine.ts
index 90416de31b..d194cfc4d8 100644
--- a/packages/database/supabase/functions/lib/scheduling/scheduling-engine.ts
+++ b/packages/database/supabase/functions/lib/scheduling/scheduling-engine.ts
@@ -484,7 +484,7 @@ export class SchedulingEngine {
.selectFrom("jobMaterial")
.select(["id", "jobMakeMethodId"])
.where("jobMakeMethodId", "in", makeMethodIds)
- .where("methodType", "=", "Make")
+ .where("methodType", "=", "Make to Order")
.where("jobOperationId", "is", null)
.execute();
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index b5e7a18ba2..8caa5568da 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -16274,6 +16274,7 @@ export type Database = {
quantity: number
scrapQuantity: number
shelfIds: Json
+ sourcingType: Database["public"]["Enums"]["sourcingType"]
tags: string[] | null
unitOfMeasureCode: string
updatedAt: string | null
@@ -16297,6 +16298,7 @@ export type Database = {
quantity: number
scrapQuantity?: number
shelfIds?: Json
+ sourcingType?: Database["public"]["Enums"]["sourcingType"]
tags?: string[] | null
unitOfMeasureCode: string
updatedAt?: string | null
@@ -16320,6 +16322,7 @@ export type Database = {
quantity?: number
scrapQuantity?: number
shelfIds?: Json
+ sourcingType?: Database["public"]["Enums"]["sourcingType"]
tags?: string[] | null
unitOfMeasureCode?: string
updatedAt?: string | null
@@ -45257,6 +45260,7 @@ export type Database = {
itemId: string | null
itemReadableId: string | null
itemReadableIdWithoutRevision: string | null
+ itemScrapPercentage: number | null
itemType: string | null
jobId: string | null
jobMakeMethodId: string | null
@@ -49332,14 +49336,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["supplierCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["supplierCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -52475,7 +52479,7 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["shipmentCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -52489,7 +52493,7 @@ export type Database = {
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["shipmentCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -56808,7 +56812,6 @@ export type Database = {
Args: { jid: string }
Returns: {
description: string
- externalId: Json
isRoot: boolean
itemId: string
itemReadableId: string
@@ -58214,7 +58217,7 @@ export type Database = {
maintenanceSource: "Scheduled" | "Reactive" | "Non-Conformance"
makeMethodStatus: "Draft" | "Active" | "Archived"
methodOperationOrder: "After Previous" | "With Previous"
- methodType: "Buy" | "Make" | "Pick"
+ methodType: "Purchase to Order" | "Pull from Inventory" | "Make to Order"
module:
| "Accounting"
| "Documents"
@@ -58424,6 +58427,7 @@ export type Database = {
| "Outbound Transfer"
shipmentStatus: "Draft" | "Pending" | "Posted" | "Voided"
shippingCarrier: "UPS" | "FedEx" | "USPS" | "DHL" | "Other"
+ sourcingType: "Specified" | "Drop Ship" | "Ship from Inventory"
stockTransferStatus: "Draft" | "Released" | "In Progress" | "Completed"
supplierLedgerDocumentType:
| "Payment"
@@ -59357,7 +59361,7 @@ export const Constants = {
maintenanceSource: ["Scheduled", "Reactive", "Non-Conformance"],
makeMethodStatus: ["Draft", "Active", "Archived"],
methodOperationOrder: ["After Previous", "With Previous"],
- methodType: ["Buy", "Make", "Pick"],
+ methodType: ["Purchase to Order", "Pull from Inventory", "Make to Order"],
module: [
"Accounting",
"Documents",
@@ -59587,6 +59591,7 @@ export const Constants = {
],
shipmentStatus: ["Draft", "Pending", "Posted", "Voided"],
shippingCarrier: ["UPS", "FedEx", "USPS", "DHL", "Other"],
+ sourcingType: ["Specified", "Drop Ship", "Ship from Inventory"],
stockTransferStatus: ["Draft", "Released", "In Progress", "Completed"],
supplierLedgerDocumentType: [
"Payment",
diff --git a/packages/database/supabase/functions/mrp/index.ts b/packages/database/supabase/functions/mrp/index.ts
index d470a8172d..dcb81390aa 100644
--- a/packages/database/supabase/functions/mrp/index.ts
+++ b/packages/database/supabase/functions/mrp/index.ts
@@ -108,7 +108,7 @@ serve(async (req: Request) => {
estimatedQuantity: number;
leadTimeOffset: number;
replenishmentSystem: "Buy" | "Make";
- methodType: "Make" | "Pick" | "Buy";
+ methodType: "Make to Order" | "Pull from Inventory" | "Purchase to Order";
}
>();
@@ -422,10 +422,11 @@ serve(async (req: Request) => {
replenishmentSystem === "Buy and Make"
? "Buy"
: (replenishmentSystem as "Buy" | "Make"),
- methodType: (treeNode?.methodType ?? "Buy") as
- | "Make"
- | "Pick"
- | "Buy",
+ methodType: (treeNode?.methodType ?? "Purchase to Order") as
+ | "Make to Order"
+ | "Pull from Inventory"
+ | "Purchase to Order"
+ ,
});
}
@@ -453,7 +454,7 @@ serve(async (req: Request) => {
const totalLeadTime = accumulatedLeadTime + req.leadTimeOffset;
// Skip Make+Make items - they will be produced, not procured
- if (req.methodType === "Make" && req.replenishmentSystem === "Make") {
+ if (req.methodType === "Make to Order" && req.replenishmentSystem === "Make") {
continue;
}
@@ -473,7 +474,7 @@ serve(async (req: Request) => {
}
// If this is a Pick item with Make replenishment, recursively expand its BOM
- if (req.methodType === "Pick" && req.replenishmentSystem === "Make") {
+ if (req.methodType === "Pull from Inventory" && req.replenishmentSystem === "Make") {
await processRequirement(
locationId,
periodId,
@@ -1124,5 +1125,5 @@ type ItemRequirement = {
baseQuantity: number; // Quantity required per unit of parent
leadTimeOffset: number;
replenishmentSystem: "Buy" | "Make";
- methodType: "Make" | "Pick" | "Buy";
+ methodType: "Make to Order" | "Pull from Inventory" | "Purchase to Order";
};
diff --git a/packages/database/supabase/functions/post-sales-invoice/index.ts b/packages/database/supabase/functions/post-sales-invoice/index.ts
index 1e8cf93bfe..a6bb68aa50 100644
--- a/packages/database/supabase/functions/post-sales-invoice/index.ts
+++ b/packages/database/supabase/functions/post-sales-invoice/index.ts
@@ -253,7 +253,7 @@ serve(async (req: Request) => {
// if the sales order line is null, we ship the part, do the normal entries and do not use accrual/reversing
if (
invoiceLine.salesOrderLineId === null &&
- invoiceLine.methodType !== "Make"
+ invoiceLine.methodType !== "Make to Order"
) {
// create the shipment line
shipmentLineInserts.push({
diff --git a/packages/database/supabase/functions/recalculate/index.ts b/packages/database/supabase/functions/recalculate/index.ts
index 3360a23644..55709974dc 100644
--- a/packages/database/supabase/functions/recalculate/index.ts
+++ b/packages/database/supabase/functions/recalculate/index.ts
@@ -66,7 +66,7 @@ serve(async (req: Request) => {
.select("*")
.eq("id", jobMakeMethod.data.parentMaterialId)
.single();
- if (jobMaterial.data?.methodType !== "Make") {
+ if (jobMaterial.data?.methodType !== "Make to Order") {
return new Response(JSON.stringify({ success: true }), {
headers: { ...corsHeaders, "Content-Type": "application/json" },
status: 200,
@@ -85,7 +85,7 @@ serve(async (req: Request) => {
);
}
- if (jobMaterial.data.methodType !== "Make") {
+ if (jobMaterial.data.methodType !== "Make to Order") {
console.log(
`Job material ${jobMakeMethod.data.parentMaterialId} is not a 'Make' type. Skipping recalculation.`
);
@@ -215,7 +215,7 @@ const updateJobQuantities = async (
// Get scrap percentage from jobMaterial (stored at job creation time)
// Fall back to itemReplenishment if not stored
let scrapPercentage = 0;
- if (tree.data.methodType === "Make") {
+ if (tree.data.methodType === "Make to Order") {
const jobMaterial = await trx
.selectFrom("jobMaterial")
.select("itemScrapPercentage")
@@ -243,12 +243,12 @@ const updateJobQuantities = async (
// totalWithScrap = target + scrap allowance (what we need to make/procure)
// estimatedQuantity: For Make = good quantity (without scrap), For Buy/Pick = total
const scrapQuantity =
- tree.data.methodType === "Make" ? targetQuantity * scrapPercentage : 0;
+ tree.data.methodType === "Make to Order" ? targetQuantity * scrapPercentage : 0;
const totalWithScrap = Math.ceil(targetQuantity + scrapQuantity);
// For Make: estimatedQuantity is good quantity (without scrap)
// For Buy/Pick: estimatedQuantity = total (but scrap is 0, so same as target)
const estimatedQuantity =
- tree.data.methodType === "Make" ? targetQuantity : totalWithScrap;
+ tree.data.methodType === "Make to Order" ? targetQuantity : totalWithScrap;
// Update jobMaterial with scrap and estimated quantities
await trx
diff --git a/packages/database/supabase/functions/sync/index.ts b/packages/database/supabase/functions/sync/index.ts
index 5be2a1898e..ca21bac728 100644
--- a/packages/database/supabase/functions/sync/index.ts
+++ b/packages/database/supabase/functions/sync/index.ts
@@ -18,7 +18,7 @@ const onShapeDataValidator = z.object({
name: z.string(),
quantity: z.number(),
replenishmentSystem: z.enum(["Make", "Buy", "Buy and Make"]),
- defaultMethodType: z.enum(["Make", "Buy", "Pick"]),
+ defaultMethodType: z.enum(["Make to Order", "Purchase to Order", "Pull from Inventory"]),
data: z.record(z.string(), z.any()),
});
@@ -560,7 +560,7 @@ serve(async (req: Request) => {
existingMakeMethod: existingMakeMethod ?? null,
});
- if (defaultMethodType === "Make" || isMade) {
+ if (defaultMethodType === "Make to Order" || isMade) {
if (existingMakeMethod) {
if (existingMakeMethod.status === "Draft") {
// Draft - use existing make method directly
diff --git a/packages/database/supabase/migrations/20260321143847_method-type-migration.sql b/packages/database/supabase/migrations/20260321143847_method-type-migration.sql
new file mode 100644
index 0000000000..e22afd31b3
--- /dev/null
+++ b/packages/database/supabase/migrations/20260321143847_method-type-migration.sql
@@ -0,0 +1,2189 @@
+-- Method Type Refactor Migration
+-- Renames: Buy -> Purchase to Order, Pick -> Pull from Inventory, Make -> Make to Order
+--
+-- Strategy: Convert enum columns to text, drop old enum, create new enum, convert back.
+-- This avoids ever having both old and new values in the enum.
+
+-- Step 1: Drop dependent views, functions, and triggers
+
+DROP VIEW IF EXISTS "openSalesOrderLines";
+DROP VIEW IF EXISTS "openJobMaterialLines";
+DROP VIEW IF EXISTS "salesRfqLines";
+DROP VIEW IF EXISTS "parts";
+DROP VIEW IF EXISTS "materials";
+DROP VIEW IF EXISTS "tools";
+DROP VIEW IF EXISTS "consumables";
+DROP VIEW IF EXISTS "services";
+DROP VIEW IF EXISTS "quoteLines";
+DROP VIEW IF EXISTS "quoteLinePrices";
+DROP VIEW IF EXISTS "quoteMaterialWithMakeMethodId";
+DROP VIEW IF EXISTS "jobMaterialWithMakeMethodId";
+DROP VIEW IF EXISTS "salesOrders";
+DROP VIEW IF EXISTS "salesOrderLines";
+DROP VIEW IF EXISTS "salesInvoiceLines";
+
+DROP FUNCTION IF EXISTS get_method_tree(TEXT);
+DROP FUNCTION IF EXISTS get_job_methods_by_method_id(TEXT);
+DROP FUNCTION IF EXISTS get_job_method(TEXT);
+DROP FUNCTION IF EXISTS get_quote_methods_by_method_id(TEXT);
+DROP FUNCTION IF EXISTS get_quote_methods(TEXT);
+DROP FUNCTION IF EXISTS get_job_quantity_on_hand(TEXT, TEXT, TEXT);
+DROP FUNCTION IF EXISTS get_material_details(TEXT);
+DROP FUNCTION IF EXISTS get_consumable_details(TEXT);
+DROP FUNCTION IF EXISTS get_part_details(TEXT);
+DROP FUNCTION IF EXISTS get_tool_details(TEXT);
+
+DROP TRIGGER IF EXISTS insert_quote_material_make_method_trigger ON "quoteMaterial";
+DROP TRIGGER IF EXISTS update_quote_material_make_method_item_id_trigger ON "quoteMaterial";
+DROP TRIGGER IF EXISTS insert_job_material_make_method_trigger ON "jobMaterial";
+DROP TRIGGER IF EXISTS update_job_material_make_method_item_id_trigger ON "jobMaterial";
+DROP TRIGGER IF EXISTS insert_quote_line_make_method_trigger ON "quoteLine";
+DROP TRIGGER IF EXISTS update_quote_line_make_method_item_id_trigger ON "quoteLine";
+
+-- Step 2: Convert all enum columns to text (removes enum dependency)
+
+ALTER TABLE "item" ALTER COLUMN "defaultMethodType" DROP DEFAULT;
+ALTER TABLE "item" ALTER COLUMN "defaultMethodType" TYPE TEXT USING "defaultMethodType"::TEXT;
+
+ALTER TABLE "methodMaterial" ALTER COLUMN "methodType" DROP DEFAULT;
+ALTER TABLE "methodMaterial" ALTER COLUMN "methodType" TYPE TEXT USING "methodType"::TEXT;
+
+ALTER TABLE "quoteLine" ALTER COLUMN "methodType" DROP DEFAULT;
+ALTER TABLE "quoteLine" ALTER COLUMN "methodType" TYPE TEXT USING "methodType"::TEXT;
+
+ALTER TABLE "quoteMaterial" ALTER COLUMN "methodType" DROP DEFAULT;
+ALTER TABLE "quoteMaterial" ALTER COLUMN "methodType" TYPE TEXT USING "methodType"::TEXT;
+
+ALTER TABLE "jobMaterial" ALTER COLUMN "methodType" DROP DEFAULT;
+ALTER TABLE "jobMaterial" ALTER COLUMN "methodType" TYPE TEXT USING "methodType"::TEXT;
+
+ALTER TABLE "salesOrderLine" ALTER COLUMN "methodType" DROP DEFAULT;
+ALTER TABLE "salesOrderLine" ALTER COLUMN "methodType" TYPE TEXT USING "methodType"::TEXT;
+
+ALTER TABLE "salesInvoiceLine" ALTER COLUMN "methodType" DROP DEFAULT;
+ALTER TABLE "salesInvoiceLine" ALTER COLUMN "methodType" TYPE TEXT USING "methodType"::TEXT;
+
+-- Step 3: Rewrite data in-place (text columns, no enum constraint)
+
+UPDATE "item" SET "defaultMethodType" = CASE "defaultMethodType"
+ WHEN 'Buy' THEN 'Purchase to Order'
+ WHEN 'Pick' THEN 'Pull from Inventory'
+ WHEN 'Make' THEN 'Make to Order'
+ ELSE "defaultMethodType"
+END WHERE "defaultMethodType" IN ('Buy', 'Pick', 'Make');
+
+UPDATE "methodMaterial" SET "methodType" = CASE "methodType"
+ WHEN 'Buy' THEN 'Purchase to Order'
+ WHEN 'Pick' THEN 'Pull from Inventory'
+ WHEN 'Make' THEN 'Make to Order'
+ ELSE "methodType"
+END WHERE "methodType" IN ('Buy', 'Pick', 'Make');
+
+UPDATE "quoteLine" SET "methodType" = CASE "methodType"
+ WHEN 'Buy' THEN 'Purchase to Order'
+ WHEN 'Pick' THEN 'Pull from Inventory'
+ WHEN 'Make' THEN 'Make to Order'
+ ELSE "methodType"
+END WHERE "methodType" IN ('Buy', 'Pick', 'Make');
+
+UPDATE "quoteMaterial" SET "methodType" = CASE "methodType"
+ WHEN 'Buy' THEN 'Purchase to Order'
+ WHEN 'Pick' THEN 'Pull from Inventory'
+ WHEN 'Make' THEN 'Make to Order'
+ ELSE "methodType"
+END WHERE "methodType" IN ('Buy', 'Pick', 'Make');
+
+UPDATE "jobMaterial" SET "methodType" = CASE "methodType"
+ WHEN 'Buy' THEN 'Purchase to Order'
+ WHEN 'Pick' THEN 'Pull from Inventory'
+ WHEN 'Make' THEN 'Make to Order'
+ ELSE "methodType"
+END WHERE "methodType" IN ('Buy', 'Pick', 'Make');
+
+UPDATE "salesOrderLine" SET "methodType" = CASE "methodType"
+ WHEN 'Buy' THEN 'Purchase to Order'
+ WHEN 'Pick' THEN 'Pull from Inventory'
+ WHEN 'Make' THEN 'Make to Order'
+ ELSE "methodType"
+END WHERE "methodType" IN ('Buy', 'Pick', 'Make');
+
+UPDATE "salesInvoiceLine" SET "methodType" = CASE "methodType"
+ WHEN 'Buy' THEN 'Purchase to Order'
+ WHEN 'Pick' THEN 'Pull from Inventory'
+ WHEN 'Make' THEN 'Make to Order'
+ ELSE "methodType"
+END WHERE "methodType" IN ('Buy', 'Pick', 'Make');
+
+-- Step 4: Drop old enum, create new enum
+
+DROP TYPE "methodType";
+
+CREATE TYPE "methodType" AS ENUM (
+ 'Purchase to Order',
+ 'Pull from Inventory',
+ 'Make to Order'
+);
+
+-- Step 5: Convert text columns back to enum and restore defaults
+
+ALTER TABLE "item" ALTER COLUMN "defaultMethodType" TYPE "methodType" USING "defaultMethodType"::"methodType";
+ALTER TABLE "item" ALTER COLUMN "defaultMethodType" SET DEFAULT 'Pull from Inventory';
+
+ALTER TABLE "methodMaterial" ALTER COLUMN "methodType" TYPE "methodType" USING "methodType"::"methodType";
+ALTER TABLE "methodMaterial" ALTER COLUMN "methodType" SET DEFAULT 'Pull from Inventory';
+
+ALTER TABLE "quoteLine" ALTER COLUMN "methodType" TYPE "methodType" USING "methodType"::"methodType";
+ALTER TABLE "quoteLine" ALTER COLUMN "methodType" SET DEFAULT 'Make to Order';
+
+ALTER TABLE "quoteMaterial" ALTER COLUMN "methodType" TYPE "methodType" USING "methodType"::"methodType";
+ALTER TABLE "quoteMaterial" ALTER COLUMN "methodType" SET DEFAULT 'Make to Order';
+
+ALTER TABLE "jobMaterial" ALTER COLUMN "methodType" TYPE "methodType" USING "methodType"::"methodType";
+ALTER TABLE "jobMaterial" ALTER COLUMN "methodType" SET DEFAULT 'Make to Order';
+
+ALTER TABLE "salesOrderLine" ALTER COLUMN "methodType" TYPE "methodType" USING "methodType"::"methodType";
+ALTER TABLE "salesOrderLine" ALTER COLUMN "methodType" SET DEFAULT 'Pull from Inventory';
+
+ALTER TABLE "salesInvoiceLine" ALTER COLUMN "methodType" TYPE "methodType" USING "methodType"::"methodType";
+ALTER TABLE "salesInvoiceLine" ALTER COLUMN "methodType" SET DEFAULT 'Pull from Inventory';
+
+-- Step 6: Recreate views with new values
+
+CREATE OR REPLACE VIEW "openSalesOrderLines" AS (
+ SELECT
+ sol."id",
+ sol."salesOrderId",
+ sol."itemId",
+ sol."promisedDate",
+ sol."methodType",
+ sol."unitOfMeasureCode",
+ sol."quantityToSend",
+ sol."salesOrderLineType",
+ sol."companyId",
+ COALESCE(sol."locationId", so."locationId") AS "locationId",
+ i."replenishmentSystem",
+ i."itemTrackingType",
+ ir."leadTime" AS "leadTime"
+ FROM "salesOrderLine" sol
+ INNER JOIN "salesOrder" so ON sol."salesOrderId" = so."id"
+ INNER JOIN "item" i ON sol."itemId" = i."id"
+ INNER JOIN "itemReplenishment" ir ON i."id" = ir."itemId"
+ WHERE
+ sol."salesOrderLineType" != 'Service'
+ AND sol."methodType" != 'Make to Order'
+ AND so."status" IN ('To Ship', 'To Ship and Invoice')
+);
+
+CREATE OR REPLACE VIEW "openJobMaterialLines" AS (
+ SELECT
+ jm."id",
+ jm."jobId",
+ jmm."parentMaterialId",
+ jm."jobMakeMethodId",
+ j."jobId" as "jobReadableId",
+ jm."itemId",
+ jm."quantityToIssue",
+ jm."unitOfMeasureCode",
+ jm."companyId",
+ i1."replenishmentSystem",
+ i1."itemTrackingType",
+ ir."leadTime" AS "leadTime",
+ j."locationId",
+ j."dueDate"
+ FROM "jobMaterial" jm
+ INNER JOIN "job" j ON jm."jobId" = j."id"
+ INNER JOIN "jobMakeMethod" jmm ON jm."jobMakeMethodId" = jmm."id"
+ INNER JOIN "item" i1 ON jm."itemId" = i1."id"
+ INNER JOIN "item" i2 ON j."itemId" = i2."id"
+ INNER JOIN "itemReplenishment" ir ON i2."id" = ir."itemId"
+ WHERE j."status" IN (
+ 'Planned',
+ 'Ready',
+ 'In Progress',
+ 'Paused'
+ )
+ AND jm."methodType" != 'Make to Order'
+);
+
+CREATE OR REPLACE VIEW "salesRfqLines" WITH(SECURITY_INVOKER=true) AS
+ SELECT
+ srl.*,
+ mu.id as "modelId",
+ mu."autodeskUrn",
+ mu."modelPath",
+ mu."name" as "modelName",
+ mu."size" as "modelSize",
+ CASE
+ WHEN i."thumbnailPath" IS NULL AND mu."thumbnailPath" IS NOT NULL THEN mu."thumbnailPath"
+ ELSE i."thumbnailPath"
+ END as "thumbnailPath",
+ i."name" as "itemName",
+ i."defaultMethodType" AS "methodType",
+ i."readableId" AS "itemReadableId",
+ i."type" AS "itemType"
+ FROM "salesRfqLine" srl
+ LEFT JOIN "item" i ON i.id = srl."itemId"
+ LEFT JOIN "modelUpload" mu ON mu.id = srl."modelUploadId";
+
+CREATE OR REPLACE VIEW "parts" WITH (SECURITY_INVOKER=true) AS
+WITH latest_items AS (
+ SELECT DISTINCT ON (i."readableId", i."companyId")
+ i.*,
+ mu.id as "modelUploadId",
+ mu."modelPath",
+ mu."thumbnailPath" as "modelThumbnailPath",
+ mu."name" as "modelName",
+ mu."size" as "modelSize"
+ FROM "item" i
+ LEFT JOIN "modelUpload" mu ON mu.id = i."modelUploadId"
+ ORDER BY i."readableId", i."companyId", i."createdAt" DESC NULLS LAST
+),
+item_revisions AS (
+ SELECT
+ i."readableId",
+ i."companyId",
+ json_agg(
+ json_build_object(
+ 'id', i.id,
+ 'revision', i."revision",
+ 'name', i."name",
+ 'description', i."description",
+ 'active', i."active",
+ 'createdAt', i."createdAt"
+ ) ORDER BY i."createdAt"
+ ) as "revisions"
+ FROM "item" i
+ GROUP BY i."readableId", i."companyId"
+)
+SELECT
+ li."active",
+ li."assignee",
+ li."defaultMethodType",
+ li."description",
+ li."itemTrackingType",
+ li."name",
+ li."replenishmentSystem",
+ li."unitOfMeasureCode",
+ li."notes",
+ li."revision",
+ li."readableId",
+ li."readableIdWithRevision",
+ li."id",
+ li."companyId",
+ CASE
+ WHEN li."thumbnailPath" IS NULL AND li."modelThumbnailPath" IS NOT NULL THEN li."modelThumbnailPath"
+ ELSE li."thumbnailPath"
+ END as "thumbnailPath",
+ li."modelPath",
+ li."modelName",
+ li."modelSize",
+ ps."supplierIds",
+ uom.name as "unitOfMeasure",
+ ir."revisions",
+ p."customFields",
+ p."tags",
+ ic."itemPostingGroupId",
+ (
+ SELECT COALESCE(
+ jsonb_object_agg(
+ eim."integration",
+ CASE
+ WHEN eim."metadata" IS NOT NULL THEN eim."metadata"
+ ELSE to_jsonb(eim."externalId")
+ END
+ ) FILTER (WHERE eim."externalId" IS NOT NULL OR eim."metadata" IS NOT NULL),
+ '{}'::jsonb
+ )
+ FROM "externalIntegrationMapping" eim
+ WHERE eim."entityType" = 'item' AND eim."entityId" = li.id
+ ) AS "externalId",
+ li."createdBy",
+ li."createdAt",
+ li."updatedBy",
+ li."updatedAt"
+FROM "part" p
+INNER JOIN latest_items li ON li."readableId" = p."id" AND li."companyId" = p."companyId"
+LEFT JOIN item_revisions ir ON ir."readableId" = p."id" AND ir."companyId" = p."companyId"
+LEFT JOIN (
+ SELECT
+ "itemId",
+ "companyId",
+ string_agg(ps."supplierPartId", ',') AS "supplierIds"
+ FROM "supplierPart" ps
+ GROUP BY "itemId", "companyId"
+) ps ON ps."itemId" = li."id" AND ps."companyId" = li."companyId"
+LEFT JOIN "unitOfMeasure" uom ON uom.code = li."unitOfMeasureCode" AND uom."companyId" = li."companyId"
+LEFT JOIN "itemCost" ic ON ic."itemId" = li.id;
+
+CREATE OR REPLACE VIEW "materials" WITH (SECURITY_INVOKER=true) AS
+WITH latest_items AS (
+ SELECT DISTINCT ON (i."readableId", i."companyId")
+ i.*,
+ mu."modelPath",
+ mu."thumbnailPath" as "modelThumbnailPath",
+ mu."name" as "modelName",
+ mu."size" as "modelSize"
+ FROM "item" i
+ LEFT JOIN "modelUpload" mu ON mu.id = i."modelUploadId"
+ ORDER BY i."readableId", i."companyId", i."createdAt" DESC NULLS LAST
+),
+item_revisions AS (
+ SELECT
+ i."readableId",
+ i."companyId",
+ json_agg(
+ json_build_object(
+ 'id', i.id,
+ 'revision', i."revision",
+ 'methodType', i."defaultMethodType",
+ 'type', i."type"
+ ) ORDER BY i."createdAt"
+ ) as "revisions"
+ FROM "item" i
+ GROUP BY i."readableId", i."companyId"
+)
+SELECT
+ i."active",
+ i."assignee",
+ i."defaultMethodType",
+ i."description",
+ i."itemTrackingType",
+ i."name",
+ i."replenishmentSystem",
+ i."unitOfMeasureCode",
+ i."notes",
+ i."revision",
+ i."readableId",
+ i."readableIdWithRevision",
+ i."id",
+ i."companyId",
+ CASE
+ WHEN i."thumbnailPath" IS NULL AND i."modelThumbnailPath" IS NOT NULL THEN i."modelThumbnailPath"
+ ELSE i."thumbnailPath"
+ END as "thumbnailPath",
+ i."modelUploadId",
+ i."modelPath",
+ i."modelName",
+ i."modelSize",
+ ps."supplierIds",
+ uom.name as "unitOfMeasure",
+ ir."revisions",
+ mf."name" AS "materialForm",
+ ms."name" AS "materialSubstance",
+ md."name" AS "dimensions",
+ mfin."name" AS "finish",
+ mg."name" AS "grade",
+ mt."name" AS "materialType",
+ m."materialSubstanceId",
+ m."materialFormId",
+ m."customFields",
+ m."tags",
+ ic."itemPostingGroupId",
+ (
+ SELECT COALESCE(
+ jsonb_object_agg(
+ eim."integration",
+ CASE
+ WHEN eim."metadata" IS NOT NULL THEN eim."metadata"
+ ELSE to_jsonb(eim."externalId")
+ END
+ ) FILTER (WHERE eim."externalId" IS NOT NULL OR eim."metadata" IS NOT NULL),
+ '{}'::jsonb
+ )
+ FROM "externalIntegrationMapping" eim
+ WHERE eim."entityType" = 'item' AND eim."entityId" = i.id
+ ) AS "externalId",
+ i."createdBy",
+ i."createdAt",
+ i."updatedBy",
+ i."updatedAt"
+FROM "material" m
+ INNER JOIN latest_items i ON i."readableId" = m."id" AND i."companyId" = m."companyId"
+ LEFT JOIN item_revisions ir ON ir."readableId" = m."id" AND ir."companyId" = i."companyId"
+ LEFT JOIN (
+ SELECT
+ ps."itemId",
+ ps."companyId",
+ string_agg(ps."supplierPartId", ',') AS "supplierIds"
+ FROM "supplierPart" ps
+ GROUP BY ps."itemId", ps."companyId"
+ ) ps ON ps."itemId" = i."id" AND ps."companyId" = i."companyId"
+ LEFT JOIN "modelUpload" mu ON mu.id = i."modelUploadId"
+ LEFT JOIN "unitOfMeasure" uom ON uom.code = i."unitOfMeasureCode" AND uom."companyId" = i."companyId"
+ LEFT JOIN "materialForm" mf ON mf."id" = m."materialFormId"
+ LEFT JOIN "materialSubstance" ms ON ms."id" = m."materialSubstanceId"
+ LEFT JOIN "materialDimension" md ON m."dimensionId" = md."id"
+ LEFT JOIN "materialFinish" mfin ON m."finishId" = mfin."id"
+ LEFT JOIN "materialGrade" mg ON m."gradeId" = mg."id"
+ LEFT JOIN "materialType" mt ON m."materialTypeId" = mt."id"
+ LEFT JOIN "itemCost" ic ON ic."itemId" = i.id;
+
+CREATE OR REPLACE VIEW "tools" WITH (SECURITY_INVOKER=true) AS
+WITH latest_items AS (
+ SELECT DISTINCT ON (i."readableId", i."companyId")
+ i.*,
+ mu.id as "modelUploadId",
+ mu."modelPath",
+ mu."thumbnailPath" as "modelThumbnailPath",
+ mu."name" as "modelName",
+ mu."size" as "modelSize"
+ FROM "item" i
+ LEFT JOIN "modelUpload" mu ON mu.id = i."modelUploadId"
+ ORDER BY i."readableId", i."companyId", i."createdAt" DESC NULLS LAST
+),
+item_revisions AS (
+ SELECT
+ i."readableId",
+ i."companyId",
+ json_agg(
+ json_build_object(
+ 'id', i.id,
+ 'revision', i."revision",
+ 'methodType', i."defaultMethodType",
+ 'type', i."type"
+ ) ORDER BY i."createdAt"
+ ) as "revisions"
+ FROM "item" i
+ GROUP BY i."readableId", i."companyId"
+)
+SELECT
+ li."active",
+ li."assignee",
+ li."defaultMethodType",
+ li."description",
+ li."itemTrackingType",
+ li."name",
+ li."replenishmentSystem",
+ li."unitOfMeasureCode",
+ li."notes",
+ li."revision",
+ li."readableId",
+ li."readableIdWithRevision",
+ li."id",
+ li."companyId",
+ CASE
+ WHEN li."thumbnailPath" IS NULL AND li."modelThumbnailPath" IS NOT NULL THEN li."modelThumbnailPath"
+ ELSE li."thumbnailPath"
+ END as "thumbnailPath",
+ li."modelPath",
+ li."modelName",
+ li."modelSize",
+ ps."supplierIds",
+ uom.name as "unitOfMeasure",
+ ir."revisions",
+ t."customFields",
+ t."tags",
+ ic."itemPostingGroupId",
+ (
+ SELECT COALESCE(
+ jsonb_object_agg(
+ eim."integration",
+ CASE
+ WHEN eim."metadata" IS NOT NULL THEN eim."metadata"
+ ELSE to_jsonb(eim."externalId")
+ END
+ ) FILTER (WHERE eim."externalId" IS NOT NULL OR eim."metadata" IS NOT NULL),
+ '{}'::jsonb
+ )
+ FROM "externalIntegrationMapping" eim
+ WHERE eim."entityType" = 'item' AND eim."entityId" = li.id
+ ) AS "externalId",
+ li."createdBy",
+ li."createdAt",
+ li."updatedBy",
+ li."updatedAt"
+FROM "tool" t
+ INNER JOIN latest_items li ON li."readableId" = t."id" AND li."companyId" = t."companyId"
+LEFT JOIN item_revisions ir ON ir."readableId" = t."id" AND ir."companyId" = li."companyId"
+LEFT JOIN (
+ SELECT
+ "itemId",
+ "companyId",
+ string_agg(ps."supplierPartId", ',') AS "supplierIds"
+ FROM "supplierPart" ps
+ GROUP BY "itemId", "companyId"
+) ps ON ps."itemId" = li."id" AND ps."companyId" = li."companyId"
+LEFT JOIN "unitOfMeasure" uom ON uom.code = li."unitOfMeasureCode" AND uom."companyId" = li."companyId"
+LEFT JOIN "itemCost" ic ON ic."itemId" = li.id;
+
+CREATE OR REPLACE VIEW "consumables" WITH (SECURITY_INVOKER=true) AS
+WITH latest_items AS (
+ SELECT DISTINCT ON (i."readableId", i."companyId")
+ i.*,
+ mu."modelPath",
+ mu."thumbnailPath" as "modelThumbnailPath",
+ mu."name" as "modelName",
+ mu."size" as "modelSize"
+ FROM "item" i
+ LEFT JOIN "modelUpload" mu ON mu.id = i."modelUploadId"
+ ORDER BY i."readableId", i."companyId", i."createdAt" DESC NULLS LAST
+),
+item_revisions AS (
+ SELECT
+ i."readableId",
+ i."companyId",
+ json_agg(
+ json_build_object(
+ 'id', i.id,
+ 'revision', i."revision",
+ 'methodType', i."defaultMethodType",
+ 'type', i."type"
+ ) ORDER BY i."createdAt"
+ ) as "revisions"
+ FROM "item" i
+ GROUP BY i."readableId", i."companyId"
+)
+SELECT
+ li."active",
+ li."assignee",
+ li."defaultMethodType",
+ li."description",
+ li."itemTrackingType",
+ li."name",
+ li."replenishmentSystem",
+ li."unitOfMeasureCode",
+ li."notes",
+ li."revision",
+ li."readableId",
+ li."readableIdWithRevision",
+ li."id",
+ li."companyId",
+ CASE
+ WHEN li."thumbnailPath" IS NULL AND li."modelThumbnailPath" IS NOT NULL THEN li."modelThumbnailPath"
+ ELSE li."thumbnailPath"
+ END as "thumbnailPath",
+ li."modelUploadId",
+ li."modelPath",
+ li."modelName",
+ li."modelSize",
+ ps."supplierIds",
+ uom.name as "unitOfMeasure",
+ ir."revisions",
+ c."customFields",
+ c."tags",
+ ic."itemPostingGroupId",
+ (
+ SELECT COALESCE(
+ jsonb_object_agg(
+ eim."integration",
+ CASE
+ WHEN eim."metadata" IS NOT NULL THEN eim."metadata"
+ ELSE to_jsonb(eim."externalId")
+ END
+ ) FILTER (WHERE eim."externalId" IS NOT NULL OR eim."metadata" IS NOT NULL),
+ '{}'::jsonb
+ )
+ FROM "externalIntegrationMapping" eim
+ WHERE eim."entityType" = 'item' AND eim."entityId" = li.id
+ ) AS "externalId",
+ li."createdBy",
+ li."createdAt",
+ li."updatedBy",
+ li."updatedAt"
+FROM "consumable" c
+ INNER JOIN latest_items li ON li."readableId" = c."id" AND li."companyId" = c."companyId"
+LEFT JOIN item_revisions ir ON ir."readableId" = c."id" AND ir."companyId" = li."companyId"
+LEFT JOIN (
+ SELECT
+ "itemId",
+ "companyId",
+ string_agg(ps."supplierPartId", ',') AS "supplierIds"
+ FROM "supplierPart" ps
+ GROUP BY "itemId", "companyId"
+) ps ON ps."itemId" = li."id" AND ps."companyId" = li."companyId"
+LEFT JOIN "unitOfMeasure" uom ON uom.code = li."unitOfMeasureCode" AND uom."companyId" = li."companyId"
+LEFT JOIN "itemCost" ic ON ic."itemId" = li.id;
+
+CREATE OR REPLACE VIEW "services" WITH(SECURITY_INVOKER=true) AS
+WITH latest_items AS (
+ SELECT DISTINCT ON (i."readableId", i."companyId")
+ i.*
+ FROM "item" i
+ ORDER BY i."readableId", i."companyId", i."createdAt" DESC NULLS LAST
+),
+item_revisions AS (
+ SELECT
+ i."readableId",
+ i."companyId",
+ json_agg(
+ json_build_object(
+ 'id', i.id,
+ 'revision', i."revision",
+ 'methodType', i."defaultMethodType",
+ 'type', i."type"
+ ) ORDER BY i."createdAt"
+ ) as "revisions"
+ FROM "item" i
+ GROUP BY i."readableId", i."companyId"
+)
+SELECT
+ li."active",
+ li."assignee",
+ li."defaultMethodType",
+ li."description",
+ li."itemTrackingType",
+ li."name",
+ li."replenishmentSystem",
+ li."unitOfMeasureCode",
+ li."notes",
+ li."revision",
+ li."readableId",
+ li."readableIdWithRevision",
+ li."id",
+ li."companyId",
+ li."thumbnailPath",
+ ps."supplierIds",
+ uom.name as "unitOfMeasure",
+ ir."revisions",
+ s."customFields",
+ s."tags",
+ ic."itemPostingGroupId",
+ (
+ SELECT COALESCE(
+ jsonb_object_agg(
+ eim."integration",
+ CASE
+ WHEN eim."metadata" IS NOT NULL THEN eim."metadata"
+ ELSE to_jsonb(eim."externalId")
+ END
+ ) FILTER (WHERE eim."externalId" IS NOT NULL OR eim."metadata" IS NOT NULL),
+ '{}'::jsonb
+ )
+ FROM "externalIntegrationMapping" eim
+ WHERE eim."entityType" = 'item' AND eim."entityId" = li.id
+ ) AS "externalId",
+ li."createdBy",
+ li."createdAt",
+ li."updatedBy",
+ li."updatedAt"
+FROM "service" s
+ INNER JOIN latest_items li ON li."readableId" = s."id" AND li."companyId" = s."companyId"
+LEFT JOIN item_revisions ir ON ir."readableId" = s."id" AND ir."companyId" = li."companyId"
+LEFT JOIN (
+ SELECT
+ "itemId",
+ "companyId",
+ string_agg(ps."supplierPartId", ',') AS "supplierIds"
+ FROM "supplierPart" ps
+ GROUP BY "itemId", "companyId"
+) ps ON ps."itemId" = li."id" AND ps."companyId" = li."companyId"
+LEFT JOIN "unitOfMeasure" uom ON uom.code = li."unitOfMeasureCode" AND uom."companyId" = li."companyId"
+LEFT JOIN "itemCost" ic ON ic."itemId" = li.id;
+
+CREATE OR REPLACE VIEW "quoteLines" WITH(SECURITY_INVOKER=true) AS (
+ SELECT
+ ql.*,
+ i."readableIdWithRevision" as "itemReadableId",
+ CASE
+ WHEN i."thumbnailPath" IS NULL AND mu."thumbnailPath" IS NOT NULL THEN mu."thumbnailPath"
+ WHEN i."thumbnailPath" IS NULL AND imu."thumbnailPath" IS NOT NULL THEN imu."thumbnailPath"
+ ELSE i."thumbnailPath"
+ END as "thumbnailPath",
+ COALESCE(mu.id, imu.id) as "modelId",
+ COALESCE(mu."autodeskUrn", imu."autodeskUrn") as "autodeskUrn",
+ COALESCE(mu."modelPath", imu."modelPath") as "modelPath",
+ COALESCE(mu."name", imu."name") as "modelName",
+ COALESCE(mu."size", imu."size") as "modelSize",
+ ic."unitCost" as "unitCost"
+ FROM "quoteLine" ql
+ LEFT JOIN "modelUpload" mu ON ql."modelUploadId" = mu."id"
+ INNER JOIN "item" i ON i.id = ql."itemId"
+ LEFT JOIN "itemCost" ic ON ic."itemId" = i.id
+ LEFT JOIN "modelUpload" imu ON imu.id = i."modelUploadId"
+);
+
+CREATE OR REPLACE VIEW "quoteLinePrices" WITH(SECURITY_INVOKER=true) AS (
+ SELECT
+ ql.*,
+ i."readableIdWithRevision" as "itemReadableId",
+ CASE
+ WHEN i."thumbnailPath" IS NULL AND mu."thumbnailPath" IS NOT NULL THEN mu."thumbnailPath"
+ WHEN i."thumbnailPath" IS NULL AND imu."thumbnailPath" IS NOT NULL THEN imu."thumbnailPath"
+ ELSE i."thumbnailPath"
+ END as "thumbnailPath",
+ COALESCE(mu.id, imu.id) as "modelId",
+ COALESCE(mu."autodeskUrn", imu."autodeskUrn") as "autodeskUrn",
+ COALESCE(mu."modelPath", imu."modelPath") as "modelPath",
+ COALESCE(mu."name", imu."name") as "modelName",
+ COALESCE(mu."size", imu."size") as "modelSize",
+ ic."unitCost" as "unitCost",
+ qlp."quantity" as "qty",
+ qlp."unitPrice",
+ CASE
+ WHEN q."revisionId" > 0 THEN q."quoteId" || '-' || q."revisionId"::text
+ ELSE q."quoteId"
+ END as "quoteReadableId",
+ q."createdAt" as "quoteCreatedAt",
+ q."customerId"
+ FROM "quoteLine" ql
+ INNER JOIN "quote" q ON q.id = ql."quoteId"
+ LEFT JOIN "modelUpload" mu ON ql."modelUploadId" = mu."id"
+ INNER JOIN "item" i ON i.id = ql."itemId"
+ LEFT JOIN "itemCost" ic ON ic."itemId" = i.id
+ LEFT JOIN "modelUpload" imu ON imu.id = i."modelUploadId"
+ LEFT JOIN "quoteLinePrice" qlp ON qlp."quoteLineId" = ql.id
+);
+
+CREATE OR REPLACE VIEW "quoteMaterialWithMakeMethodId" WITH(SECURITY_INVOKER=true) AS
+ SELECT
+ qm.*,
+ qmm."id" AS "quoteMaterialMakeMethodId",
+ qmm.version AS "version"
+ FROM "quoteMaterial" qm
+ LEFT JOIN "quoteMakeMethod" qmm
+ ON qmm."parentMaterialId" = qm."id";
+
+CREATE OR REPLACE VIEW "jobMaterialWithMakeMethodId" WITH(SECURITY_INVOKER=true) AS
+ SELECT
+ jm.*,
+ s."name" AS "shelfName",
+ jmm."id" AS "jobMaterialMakeMethodId",
+ jmm.version AS "version",
+ i."readableIdWithRevision" as "itemReadableId",
+ i."readableId" as "itemReadableIdWithoutRevision"
+ FROM "jobMaterial" jm
+ LEFT JOIN "jobMakeMethod" jmm
+ ON jmm."parentMaterialId" = jm."id"
+ LEFT JOIN "shelf" s ON s.id = jm."shelfId"
+ INNER JOIN "item" i ON i.id = jm."itemId";
+
+CREATE OR REPLACE VIEW "salesOrderLines" WITH(SECURITY_INVOKER=true) AS (
+ SELECT
+ sl.*,
+ i."readableIdWithRevision" as "itemReadableId",
+ CASE
+ WHEN i."thumbnailPath" IS NULL AND mu."thumbnailPath" IS NOT NULL THEN mu."thumbnailPath"
+ WHEN i."thumbnailPath" IS NULL AND imu."thumbnailPath" IS NOT NULL THEN imu."thumbnailPath"
+ ELSE i."thumbnailPath"
+ END as "thumbnailPath",
+ COALESCE(mu.id, imu.id) as "modelId",
+ COALESCE(mu."autodeskUrn", imu."autodeskUrn") as "autodeskUrn",
+ COALESCE(mu."modelPath", imu."modelPath") as "modelPath",
+ COALESCE(mu."name", imu."name") as "modelName",
+ COALESCE(mu."size", imu."size") as "modelSize",
+ ic."unitCost" as "unitCost",
+ cp."customerPartId",
+ cp."customerPartRevision",
+ so."orderDate",
+ so."customerId",
+ so."salesOrderId" as "salesOrderReadableId"
+ FROM "salesOrderLine" sl
+ INNER JOIN "salesOrder" so ON so.id = sl."salesOrderId"
+ LEFT JOIN "modelUpload" mu ON sl."modelUploadId" = mu."id"
+ INNER JOIN "item" i ON i.id = sl."itemId"
+ LEFT JOIN "itemCost" ic ON ic."itemId" = i.id
+ LEFT JOIN "modelUpload" imu ON imu.id = i."modelUploadId"
+ LEFT JOIN "customerPartToItem" cp ON cp."customerId" = so."customerId" AND cp."itemId" = i.id
+);
+
+CREATE OR REPLACE VIEW "salesInvoiceLines" WITH(SECURITY_INVOKER=true) AS (
+ SELECT
+ sl.*,
+ i."readableIdWithRevision" as "itemReadableId",
+ CASE
+ WHEN i."thumbnailPath" IS NULL AND mu."thumbnailPath" IS NOT NULL THEN mu."thumbnailPath"
+ WHEN i."thumbnailPath" IS NULL AND imu."thumbnailPath" IS NOT NULL THEN imu."thumbnailPath"
+ ELSE i."thumbnailPath"
+ END as "thumbnailPath",
+ i.name as "itemName",
+ i.description as "itemDescription",
+ ic."unitCost" as "unitCost",
+ (SELECT cp."customerPartId"
+ FROM "customerPartToItem" cp
+ WHERE cp."customerId" = si."customerId" AND cp."itemId" = i.id
+ LIMIT 1) as "customerPartId"
+ FROM "salesInvoiceLine" sl
+ INNER JOIN "salesInvoice" si ON si.id = sl."invoiceId"
+ LEFT JOIN "modelUpload" mu ON sl."modelUploadId" = mu."id"
+ INNER JOIN "item" i ON i.id = sl."itemId"
+ LEFT JOIN "itemCost" ic ON ic."itemId" = i.id
+ LEFT JOIN "modelUpload" imu ON imu.id = i."modelUploadId"
+);
+
+CREATE OR REPLACE VIEW "salesOrders" WITH(SECURITY_INVOKER=true) AS
+ SELECT
+ s.*,
+ sl."thumbnailPath",
+ sl."itemType",
+ sl."orderTotal" + COALESCE(ss."shippingCost", 0) AS "orderTotal",
+ sl."jobs",
+ sl."lines",
+ st."name" AS "shippingTermName",
+ sp."paymentTermId",
+ ss."shippingMethodId",
+ ss."receiptRequestedDate",
+ ss."receiptPromisedDate",
+ ss."dropShipment",
+ ss."shippingCost",
+ (
+ SELECT COALESCE(
+ jsonb_object_agg(
+ eim."integration",
+ CASE
+ WHEN eim."metadata" IS NOT NULL THEN eim."metadata"
+ ELSE to_jsonb(eim."externalId")
+ END
+ ) FILTER (WHERE eim."externalId" IS NOT NULL OR eim."metadata" IS NOT NULL),
+ '{}'::jsonb
+ )
+ FROM "externalIntegrationMapping" eim
+ WHERE eim."entityType" = 'salesOrder' AND eim."entityId" = s.id
+ ) AS "externalId"
+ FROM "salesOrder" s
+ LEFT JOIN (
+ SELECT
+ sol."salesOrderId",
+ MIN(CASE
+ WHEN i."thumbnailPath" IS NULL AND mu."thumbnailPath" IS NOT NULL THEN mu."thumbnailPath"
+ ELSE i."thumbnailPath"
+ END) AS "thumbnailPath",
+ SUM(
+ DISTINCT (1+COALESCE(sol."taxPercent", 0))*(COALESCE(sol."saleQuantity", 0)*(COALESCE(sol."unitPrice", 0)) + COALESCE(sol."shippingCost", 0) + COALESCE(sol."addOnCost", 0))
+ ) AS "orderTotal",
+ MIN(i."type") AS "itemType",
+ ARRAY_AGG(
+ CASE
+ WHEN j.id IS NOT NULL THEN json_build_object(
+ 'id', j.id,
+ 'jobId', j."jobId",
+ 'status', j."status",
+ 'dueDate', j."dueDate",
+ 'productionQuantity', j."productionQuantity",
+ 'quantityComplete', j."quantityComplete",
+ 'quantityShipped', j."quantityShipped",
+ 'quantity', j."quantity",
+ 'scrapQuantity', j."scrapQuantity",
+ 'salesOrderLineId', sol.id,
+ 'assignee', j."assignee"
+ )
+ ELSE NULL
+ END
+ ) FILTER (WHERE j.id IS NOT NULL) AS "jobs",
+ ARRAY_AGG(
+ json_build_object(
+ 'id', sol.id,
+ 'methodType', sol."methodType",
+ 'saleQuantity', sol."saleQuantity"
+ )
+ ) AS "lines"
+ FROM "salesOrderLine" sol
+ LEFT JOIN "item" i ON i."id" = sol."itemId"
+ LEFT JOIN "modelUpload" mu ON mu.id = i."modelUploadId"
+ LEFT JOIN "job" j ON j."salesOrderId" = sol."salesOrderId" AND j."salesOrderLineId" = sol."id"
+ GROUP BY sol."salesOrderId"
+ ) sl ON sl."salesOrderId" = s."id"
+ LEFT JOIN "salesOrderShipment" ss ON ss."id" = s."id"
+ LEFT JOIN "shippingTerm" st ON st."id" = ss."shippingTermId"
+ LEFT JOIN "salesOrderPayment" sp ON sp."id" = s."id";
+
+-- Step 7: Recreate functions with new values
+
+CREATE OR REPLACE FUNCTION get_method_tree(uid TEXT)
+RETURNS TABLE (
+ "methodMaterialId" TEXT,
+ "makeMethodId" TEXT,
+ "materialMakeMethodId" TEXT,
+ "itemId" TEXT,
+ "itemReadableId" TEXT,
+ "itemType" TEXT,
+ "description" TEXT,
+ "unitOfMeasureCode" TEXT,
+ "unitCost" NUMERIC,
+ "quantity" NUMERIC,
+ "methodType" "methodType",
+ "itemTrackingType" TEXT,
+ "parentMaterialId" TEXT,
+ "order" DOUBLE PRECISION,
+ "operationId" TEXT,
+ "isRoot" BOOLEAN,
+ "kit" BOOLEAN,
+ "revision" TEXT,
+ "externalId" JSONB,
+ "version" NUMERIC(10,2),
+ "shelfIds" JSONB,
+ "isPickDescendant" BOOLEAN
+) AS $$
+WITH RECURSIVE material AS (
+ SELECT
+ "id",
+ "makeMethodId",
+ "methodType",
+ COALESCE(
+ "materialMakeMethodId",
+ CASE WHEN "methodType" = 'Pull from Inventory' THEN (
+ SELECT amm.id FROM "activeMakeMethods" amm WHERE amm."itemId" = "methodMaterial"."itemId" LIMIT 1
+ ) END
+ ) AS "materialMakeMethodId",
+ "itemId",
+ "itemType",
+ "quantity",
+ "makeMethodId" AS "parentMaterialId",
+ NULL AS "operationId",
+ COALESCE("order", 1) AS "order",
+ "kit",
+ "shelfIds",
+ false AS "isPickDescendant"
+ FROM
+ "methodMaterial"
+ WHERE
+ "makeMethodId" = uid
+ UNION
+ SELECT
+ child."id",
+ child."makeMethodId",
+ child."methodType",
+ COALESCE(
+ child."materialMakeMethodId",
+ CASE WHEN child."methodType" = 'Pull from Inventory' THEN (
+ SELECT amm.id FROM "activeMakeMethods" amm WHERE amm."itemId" = child."itemId" LIMIT 1
+ ) END
+ ) AS "materialMakeMethodId",
+ child."itemId",
+ child."itemType",
+ child."quantity",
+ parent."id" AS "parentMaterialId",
+ child."methodOperationId" AS "operationId",
+ child."order",
+ child."kit",
+ child."shelfIds",
+ (parent."methodType" = 'Pull from Inventory' OR parent."isPickDescendant") AS "isPickDescendant"
+ FROM
+ "methodMaterial" child
+ INNER JOIN material parent ON parent."materialMakeMethodId" = child."makeMethodId"
+)
+SELECT
+ material.id as "methodMaterialId",
+ material."makeMethodId",
+ material."materialMakeMethodId",
+ material."itemId",
+ item."readableIdWithRevision" AS "itemReadableId",
+ material."itemType",
+ item."name" AS "description",
+ item."unitOfMeasureCode",
+ cost."unitCost",
+ material."quantity",
+ material."methodType",
+ item."itemTrackingType",
+ material."parentMaterialId",
+ material."order",
+ material."operationId",
+ false AS "isRoot",
+ material."kit",
+ item."revision",
+ (
+ SELECT COALESCE(
+ jsonb_object_agg(
+ eim."integration",
+ CASE
+ WHEN eim."metadata" IS NOT NULL THEN eim."metadata"
+ ELSE to_jsonb(eim."externalId")
+ END
+ ) FILTER (WHERE eim."externalId" IS NOT NULL),
+ '{}'::jsonb
+ )
+ FROM "externalIntegrationMapping" eim
+ WHERE eim."entityType" = 'item' AND eim."entityId" = item.id
+ ) AS "externalId",
+ mm2."version",
+ material."shelfIds",
+ material."isPickDescendant"
+FROM material
+INNER JOIN item
+ ON material."itemId" = item.id
+INNER JOIN "itemCost" cost
+ ON item.id = cost."itemId"
+INNER JOIN "makeMethod" mm
+ ON material."makeMethodId" = mm.id
+LEFT JOIN "makeMethod" mm2
+ ON material."materialMakeMethodId" = mm2.id
+UNION
+SELECT
+ mm."id" AS "methodMaterialId",
+ NULL AS "makeMethodId",
+ mm.id AS "materialMakeMethodId",
+ mm."itemId",
+ item."readableIdWithRevision" AS "itemReadableId",
+ item."type"::text,
+ item."name" AS "description",
+ item."unitOfMeasureCode",
+ cost."unitCost",
+ 1 AS "quantity",
+ 'Make to Order' AS "methodType",
+ item."itemTrackingType",
+ NULL AS "parentMaterialId",
+ CAST(1 AS DOUBLE PRECISION) AS "order",
+ NULL AS "operationId",
+ true AS "isRoot",
+ false AS "kit",
+ item."revision",
+ (
+ SELECT COALESCE(
+ jsonb_object_agg(
+ eim."integration",
+ CASE
+ WHEN eim."metadata" IS NOT NULL THEN eim."metadata"
+ ELSE to_jsonb(eim."externalId")
+ END
+ ) FILTER (WHERE eim."externalId" IS NOT NULL),
+ '{}'::jsonb
+ )
+ FROM "externalIntegrationMapping" eim
+ WHERE eim."entityType" = 'item' AND eim."entityId" = item.id
+ ) AS "externalId",
+ mm."version",
+ '{}'::JSONB AS "shelfIds",
+ false AS "isPickDescendant"
+FROM "makeMethod" mm
+INNER JOIN item
+ ON mm."itemId" = item.id
+INNER JOIN "itemCost" cost
+ ON item.id = cost."itemId"
+WHERE mm.id = uid
+ORDER BY "order"
+$$ LANGUAGE sql STABLE;
+
+
+CREATE OR REPLACE FUNCTION get_job_methods_by_method_id(mid TEXT)
+RETURNS TABLE (
+ "jobId" TEXT,
+ "methodMaterialId" TEXT,
+ "jobMakeMethodId" TEXT,
+ "jobMaterialMakeMethodId" TEXT,
+ "itemId" TEXT,
+ "itemReadableId" TEXT,
+ "description" TEXT,
+ "unitOfMeasureCode" TEXT,
+ "itemType" TEXT,
+ "quantity" NUMERIC,
+ "unitCost" NUMERIC,
+ "methodType" "methodType",
+ "parentMaterialId" TEXT,
+ "order" DOUBLE PRECISION,
+ "kit" BOOLEAN,
+ "isRoot" BOOLEAN,
+ "shelfId" TEXT
+) AS $$
+WITH RECURSIVE material AS (
+ SELECT
+ "jobId",
+ "id",
+ "id" AS "jobMakeMethodId",
+ 'Make to Order'::"methodType" AS "methodType",
+ "id" AS "jobMaterialMakeMethodId",
+ "itemId",
+ 'Part' AS "itemType",
+ 1::NUMERIC AS "quantity",
+ 0::NUMERIC AS "unitCost",
+ "parentMaterialId",
+ CAST(1 AS DOUBLE PRECISION) AS "order",
+ FALSE AS "kit",
+ TRUE AS "isRoot",
+ NULL::TEXT AS "shelfId"
+ FROM
+ "jobMakeMethod"
+ WHERE
+ "id" = mid
+ UNION
+ SELECT
+ child."jobId",
+ child."id",
+ child."jobMakeMethodId",
+ child."methodType",
+ child."jobMaterialMakeMethodId",
+ child."itemId",
+ child."itemType",
+ child."quantity",
+ child."unitCost",
+ parent."id" AS "parentMaterialId",
+ child."order",
+ child."kit",
+ FALSE AS "isRoot",
+ child."shelfId"
+ FROM
+ "jobMaterialWithMakeMethodId" child
+ INNER JOIN material parent ON parent."jobMaterialMakeMethodId" = child."jobMakeMethodId"
+ WHERE parent."methodType" = 'Make to Order'
+)
+SELECT
+ material."jobId",
+ material.id as "methodMaterialId",
+ material."jobMakeMethodId",
+ material."jobMaterialMakeMethodId",
+ material."itemId",
+ item."readableId" AS "itemReadableId",
+ item."name" AS "description",
+ item."unitOfMeasureCode",
+ material."itemType",
+ material."quantity",
+ material."unitCost",
+ material."methodType",
+ material."parentMaterialId",
+ material."order",
+ material."kit",
+ material."isRoot",
+ material."shelfId"
+FROM material
+INNER JOIN item ON material."itemId" = item.id
+ORDER BY "order"
+$$ LANGUAGE sql STABLE;
+
+
+CREATE OR REPLACE FUNCTION get_job_method(jid TEXT)
+RETURNS TABLE (
+ "jobId" TEXT,
+ "methodMaterialId" TEXT,
+ "jobMakeMethodId" TEXT,
+ "jobMaterialMakeMethodId" TEXT,
+ "itemId" TEXT,
+ "itemReadableId" TEXT,
+ "description" TEXT,
+ "itemType" TEXT,
+ "quantity" NUMERIC,
+ "unitCost" NUMERIC,
+ "methodType" "methodType",
+ "parentMaterialId" TEXT,
+ "order" DOUBLE PRECISION,
+ "isRoot" BOOLEAN,
+ "kit" BOOLEAN,
+ "revision" TEXT,
+ "version" NUMERIC(10,2),
+ "shelfId" TEXT
+) AS $$
+WITH RECURSIVE material AS (
+ SELECT
+ "jobId",
+ "id",
+ "id" AS "jobMakeMethodId",
+ 'Make to Order'::"methodType" AS "methodType",
+ "id" AS "jobMaterialMakeMethodId",
+ "itemId",
+ 'Part' AS "itemType",
+ 1::NUMERIC AS "quantity",
+ 0::NUMERIC AS "unitCost",
+ "parentMaterialId",
+ CAST(1 AS DOUBLE PRECISION) AS "order",
+ TRUE AS "isRoot",
+ FALSE AS "kit",
+ "version",
+ NULL::TEXT AS "shelfId"
+ FROM
+ "jobMakeMethod"
+ WHERE
+ "jobId" = jid
+ AND "parentMaterialId" IS NULL
+ UNION
+ SELECT
+ child."jobId",
+ child."id",
+ child."jobMakeMethodId",
+ child."methodType",
+ child."jobMaterialMakeMethodId",
+ child."itemId",
+ child."itemType",
+ child."quantity",
+ child."unitCost",
+ parent."id" AS "parentMaterialId",
+ child."order",
+ FALSE AS "isRoot",
+ child."kit",
+ child."version",
+ child."shelfId"
+ FROM
+ "jobMaterialWithMakeMethodId" child
+ INNER JOIN material parent ON parent."jobMaterialMakeMethodId" = child."jobMakeMethodId"
+ WHERE parent."methodType" = 'Make to Order'
+)
+SELECT
+ material."jobId",
+ material.id as "methodMaterialId",
+ material."jobMakeMethodId",
+ material."jobMaterialMakeMethodId",
+ material."itemId",
+ item."readableIdWithRevision" AS "itemReadableId",
+ item."name" AS "description",
+ material."itemType",
+ material."quantity",
+ material."unitCost",
+ material."methodType",
+ material."parentMaterialId",
+ material."order",
+ material."isRoot",
+ material."kit",
+ item."revision",
+ material."version",
+ material."shelfId"
+FROM material
+INNER JOIN item ON material."itemId" = item.id
+WHERE material."jobId" = jid
+ORDER BY "order"
+$$ LANGUAGE sql STABLE;
+
+
+CREATE OR REPLACE FUNCTION get_quote_methods_by_method_id(mid TEXT)
+RETURNS TABLE (
+ "quoteId" TEXT,
+ "quoteLineId" TEXT,
+ "methodMaterialId" TEXT,
+ "quoteMakeMethodId" TEXT,
+ "quoteMaterialMakeMethodId" TEXT,
+ "itemId" TEXT,
+ "itemReadableId" TEXT,
+ "description" TEXT,
+ "unitOfMeasureCode" TEXT,
+ "itemType" TEXT,
+ "itemTrackingType" TEXT,
+ "quantity" NUMERIC,
+ "unitCost" NUMERIC,
+ "methodType" "methodType",
+ "parentMaterialId" TEXT,
+ "order" DOUBLE PRECISION,
+ "isRoot" BOOLEAN,
+ "kit" BOOLEAN,
+ "revision" TEXT,
+ "externalId" JSONB,
+ "version" NUMERIC(10,2),
+ "shelfId" TEXT
+) AS $$
+WITH RECURSIVE material AS (
+ SELECT
+ "quoteId",
+ "quoteLineId",
+ "id",
+ "id" AS "quoteMakeMethodId",
+ 'Make to Order'::"methodType" AS "methodType",
+ "id" AS "quoteMaterialMakeMethodId",
+ "version",
+ "itemId",
+ 'Part' AS "itemType",
+ 1::NUMERIC AS "quantity",
+ 0::NUMERIC AS "unitCost",
+ "parentMaterialId",
+ CAST(1 AS DOUBLE PRECISION) AS "order",
+ TRUE AS "isRoot",
+ FALSE AS "kit",
+ NULL::TEXT AS "shelfId"
+ FROM
+ "quoteMakeMethod"
+ WHERE
+ "id" = mid
+ UNION
+ SELECT
+ child."quoteId",
+ child."quoteLineId",
+ child."id",
+ child."quoteMakeMethodId",
+ child."methodType",
+ child."quoteMaterialMakeMethodId",
+ child."version",
+ child."itemId",
+ child."itemType",
+ child."quantity",
+ child."unitCost",
+ parent."id" AS "parentMaterialId",
+ child."order",
+ FALSE AS "isRoot",
+ child."kit",
+ child."shelfId"
+ FROM
+ "quoteMaterialWithMakeMethodId" child
+ INNER JOIN material parent ON parent."quoteMaterialMakeMethodId" = child."quoteMakeMethodId"
+ WHERE parent."methodType" = 'Make to Order'
+)
+SELECT
+ material."quoteId",
+ material."quoteLineId",
+ material.id as "methodMaterialId",
+ material."quoteMakeMethodId",
+ material."quoteMaterialMakeMethodId",
+ material."itemId",
+ item."readableIdWithRevision" AS "itemReadableId",
+ item."name" AS "description",
+ item."unitOfMeasureCode",
+ material."itemType",
+ item."itemTrackingType",
+ material."quantity",
+ material."unitCost",
+ material."methodType",
+ material."parentMaterialId",
+ material."order",
+ material."isRoot",
+ material."kit",
+ item."revision",
+ (
+ SELECT COALESCE(
+ jsonb_object_agg(
+ eim."integration",
+ CASE
+ WHEN eim."metadata" IS NOT NULL THEN eim."metadata"
+ ELSE to_jsonb(eim."externalId")
+ END
+ ) FILTER (WHERE eim."externalId" IS NOT NULL),
+ '{}'::jsonb
+ )
+ FROM "externalIntegrationMapping" eim
+ WHERE eim."entityType" = 'item' AND eim."entityId" = item.id
+ ) AS "externalId",
+ material."version",
+ material."shelfId"
+FROM material
+INNER JOIN item ON material."itemId" = item.id
+ORDER BY "order"
+$$ LANGUAGE sql STABLE;
+
+
+CREATE OR REPLACE FUNCTION get_quote_methods(qid TEXT)
+RETURNS TABLE (
+ "quoteId" TEXT,
+ "quoteLineId" TEXT,
+ "methodMaterialId" TEXT,
+ "quoteMakeMethodId" TEXT,
+ "quoteMaterialMakeMethodId" TEXT,
+ "itemId" TEXT,
+ "itemReadableId" TEXT,
+ "description" TEXT,
+ "itemType" TEXT,
+ "quantity" NUMERIC,
+ "unitCost" NUMERIC,
+ "methodType" "methodType",
+ "parentMaterialId" TEXT,
+ "order" DOUBLE PRECISION,
+ "isRoot" BOOLEAN,
+ "kit" BOOLEAN,
+ "revision" TEXT,
+ "externalId" JSONB,
+ "version" NUMERIC(10,2),
+ "shelfId" TEXT
+) AS $$
+WITH RECURSIVE material AS (
+ SELECT
+ "quoteId",
+ "quoteLineId",
+ "id",
+ "id" AS "quoteMakeMethodId",
+ 'Make to Order'::"methodType" AS "methodType",
+ "id" AS "quoteMaterialMakeMethodId",
+ "itemId",
+ 'Part' AS "itemType",
+ 1::NUMERIC AS "quantity",
+ 0::NUMERIC AS "unitCost",
+ "parentMaterialId",
+ CAST(1 AS DOUBLE PRECISION) AS "order",
+ TRUE AS "isRoot",
+ FALSE AS "kit",
+ "version",
+ NULL::TEXT AS "shelfId"
+ FROM
+ "quoteMakeMethod"
+ WHERE
+ "quoteId" = qid
+ AND "parentMaterialId" IS NULL
+ UNION
+ SELECT
+ child."quoteId",
+ child."quoteLineId",
+ child."id",
+ child."quoteMakeMethodId",
+ child."methodType",
+ child."quoteMaterialMakeMethodId",
+ child."itemId",
+ child."itemType",
+ child."quantity",
+ child."unitCost",
+ parent."id" AS "parentMaterialId",
+ child."order",
+ FALSE AS "isRoot",
+ child."kit",
+ child."version",
+ child."shelfId"
+ FROM
+ "quoteMaterialWithMakeMethodId" child
+ INNER JOIN material parent ON parent."quoteMaterialMakeMethodId" = child."quoteMakeMethodId"
+)
+SELECT
+ material."quoteId",
+ material."quoteLineId",
+ material.id as "methodMaterialId",
+ material."quoteMakeMethodId",
+ material."quoteMaterialMakeMethodId",
+ material."itemId",
+ item."readableIdWithRevision" AS "itemReadableId",
+ item."name" AS "description",
+ material."itemType",
+ material."quantity",
+ material."unitCost",
+ material."methodType",
+ material."parentMaterialId",
+ material."order",
+ material."isRoot",
+ material."kit",
+ item."revision",
+ (
+ SELECT COALESCE(
+ jsonb_object_agg(
+ eim."integration",
+ CASE
+ WHEN eim."metadata" IS NOT NULL THEN eim."metadata"
+ ELSE to_jsonb(eim."externalId")
+ END
+ ) FILTER (WHERE eim."externalId" IS NOT NULL),
+ '{}'::jsonb
+ )
+ FROM "externalIntegrationMapping" eim
+ WHERE eim."entityType" = 'item' AND eim."entityId" = item.id
+ ) AS "externalId",
+ material."version",
+ material."shelfId"
+FROM material
+INNER JOIN item ON material."itemId" = item.id
+WHERE material."quoteId" = qid
+ORDER BY "order"
+$$ LANGUAGE sql STABLE;
+
+
+CREATE OR REPLACE FUNCTION get_job_quantity_on_hand(job_id TEXT, company_id TEXT, location_id TEXT)
+ RETURNS TABLE (
+ "id" TEXT,
+ "jobMaterialItemId" TEXT,
+ "jobMakeMethodId" TEXT,
+ "itemReadableId" TEXT,
+ "name" TEXT,
+ "description" TEXT,
+ "itemTrackingType" "itemTrackingType",
+ "methodType" "methodType",
+ "type" "itemType",
+ "thumbnailPath" TEXT,
+ "unitOfMeasureCode" TEXT,
+ "quantityPerParent" NUMERIC,
+ "estimatedQuantity" NUMERIC,
+ "quantityIssued" NUMERIC,
+ "quantityOnHandInShelf" NUMERIC,
+ "quantityOnHandNotInShelf" NUMERIC,
+ "quantityOnSalesOrder" NUMERIC,
+ "quantityOnPurchaseOrder" NUMERIC,
+ "quantityOnProductionOrder" NUMERIC,
+ "quantityFromProductionOrderInShelf" NUMERIC,
+ "quantityFromProductionOrderNotInShelf" NUMERIC,
+ "quantityInTransitToShelf" NUMERIC,
+ "shelfId" TEXT,
+ "shelfName" TEXT
+ ) AS $$
+ BEGIN
+ RETURN QUERY
+
+WITH
+ job_materials AS (
+ SELECT
+ jm."id",
+ jm."itemId",
+ jm."jobMakeMethodId",
+ jm."description",
+ jm."methodType",
+ jm."quantity",
+ jm."estimatedQuantity",
+ jm."quantityIssued",
+ jm."shelfId"
+ FROM
+ "jobMaterial" jm
+ WHERE
+ jm."jobId" = job_id
+ ),
+ open_purchase_orders AS (
+ SELECT
+ pol."itemId" AS "purchaseOrderItemId",
+ SUM(pol."quantityToReceive" * pol."conversionFactor") AS "quantityOnPurchaseOrder"
+ FROM
+ "purchaseOrder" po
+ INNER JOIN "purchaseOrderLine" pol
+ ON pol."purchaseOrderId" = po."id"
+ INNER JOIN job_materials jm
+ ON jm."itemId" = pol."itemId"
+ WHERE
+ po."status" IN (
+ 'To Receive',
+ 'To Receive and Invoice'
+ )
+ AND po."companyId" = company_id
+ AND pol."locationId" = location_id
+ GROUP BY pol."itemId"
+ ),
+ open_stock_transfers_to AS (
+ SELECT
+ stl."itemId",
+ stl."toShelfId" AS "shelfId",
+ SUM(stl."outstandingQuantity") AS "quantityOnStockTransferTo"
+ FROM "stockTransferLine" stl
+ INNER JOIN "stockTransfer" st ON stl."stockTransferId" = st."id"
+ INNER JOIN job_materials jm ON jm."itemId" = stl."itemId"
+ WHERE st."status" IN ('Released', 'In Progress')
+ AND st."companyId" = company_id
+ AND st."locationId" = location_id
+ GROUP BY stl."itemId", stl."toShelfId"
+ ),
+ open_stock_transfers_from AS (
+ SELECT
+ stl."itemId",
+ stl."fromShelfId" AS "shelfId",
+ SUM(stl."outstandingQuantity") AS "quantityOnStockTransferFrom"
+ FROM "stockTransferLine" stl
+ INNER JOIN "stockTransfer" st ON stl."stockTransferId" = st."id"
+ INNER JOIN job_materials jm ON jm."itemId" = stl."itemId"
+ WHERE st."status" IN ('Released', 'In Progress')
+ AND st."companyId" = company_id
+ AND st."locationId" = location_id
+ GROUP BY stl."itemId", stl."fromShelfId"
+ ),
+ stock_transfers_in_transit AS (
+ SELECT
+ COALESCE(stt."itemId", stf."itemId") AS "itemId",
+ COALESCE(stt."shelfId", stf."shelfId") AS "shelfId",
+ COALESCE(stt."quantityOnStockTransferTo", 0) - COALESCE(stf."quantityOnStockTransferFrom", 0) AS "quantityInTransit"
+ FROM open_stock_transfers_to stt
+ FULL OUTER JOIN open_stock_transfers_from stf ON stt."itemId" = stf."itemId" AND stt."shelfId" = stf."shelfId"
+ ),
+ open_sales_orders AS (
+ SELECT
+ sol."itemId" AS "salesOrderItemId",
+ SUM(sol."quantityToSend") AS "quantityOnSalesOrder"
+ FROM
+ "salesOrder" so
+ INNER JOIN "salesOrderLine" sol
+ ON sol."salesOrderId" = so."id"
+ INNER JOIN job_materials jm
+ ON jm."itemId" = sol."itemId"
+ WHERE
+ so."status" IN (
+ 'Confirmed',
+ 'To Ship and Invoice',
+ 'To Ship',
+ 'To Invoice',
+ 'In Progress'
+ )
+ AND so."companyId" = company_id
+ AND sol."locationId" = location_id
+ GROUP BY sol."itemId"
+ ),
+ open_jobs AS (
+ SELECT
+ j."itemId" AS "jobItemId",
+ SUM(j."productionQuantity" + j."scrapQuantity" - j."quantityReceivedToInventory" - j."quantityShipped") AS "quantityOnProductionOrder"
+ FROM job j
+ WHERE j."status" IN (
+ 'Ready',
+ 'In Progress',
+ 'Paused'
+ )
+ GROUP BY j."itemId"
+ ),
+ open_job_requirements AS (
+ SELECT
+ jm."itemId",
+ jm."shelfId",
+ SUM(jm."quantityToIssue") AS "quantityOnProductionDemand"
+ FROM "jobMaterial" jm
+ INNER JOIN "job" j ON jm."jobId" = j."id"
+ INNER JOIN job_materials jmat
+ ON jmat."itemId" = jm."itemId"
+ WHERE j."status" IN (
+ 'Planned',
+ 'Ready',
+ 'In Progress',
+ 'Paused'
+ )
+ AND jm."methodType" != 'Make to Order'
+ AND j."companyId" = company_id
+ AND j."locationId" = location_id
+ GROUP BY jm."itemId", jm."shelfId"
+ ),
+ open_job_requirements_in_shelf AS (
+ SELECT
+ ojr."itemId",
+ SUM(ojr."quantityOnProductionDemand") AS "quantityOnProductionDemandInShelf"
+ FROM open_job_requirements ojr
+ INNER JOIN job_materials jm
+ ON jm."itemId" = ojr."itemId" AND jm."shelfId" = ojr."shelfId"
+ GROUP BY ojr."itemId"
+ ),
+ open_job_requirements_not_in_shelf AS (
+ SELECT
+ ojr."itemId",
+ SUM(ojr."quantityOnProductionDemand") AS "quantityOnProductionDemandNotInShelf"
+ FROM open_job_requirements ojr
+ INNER JOIN job_materials jm
+ ON jm."itemId" = ojr."itemId" AND (jm."shelfId" IS NULL OR jm."shelfId" != ojr."shelfId")
+ GROUP BY ojr."itemId"
+ ),
+ item_ledgers AS (
+ SELECT
+ il."itemId" AS "ledgerItemId",
+ il."shelfId",
+ SUM(il."quantity") AS "quantityOnHand"
+ FROM "itemLedger" il
+ INNER JOIN job_materials jm
+ ON jm."itemId" = il."itemId"
+ WHERE il."companyId" = company_id
+ AND il."locationId" = location_id
+ GROUP BY il."itemId", il."shelfId"
+ ),
+ item_ledgers_in_shelf AS (
+ SELECT
+ il."ledgerItemId",
+ SUM(il."quantityOnHand") AS "quantityOnHandInShelf"
+ FROM item_ledgers il
+ INNER JOIN job_materials jm
+ ON jm."itemId" = il."ledgerItemId" AND jm."shelfId" = il."shelfId"
+ GROUP BY il."ledgerItemId"
+ ),
+ item_ledgers_not_in_shelf AS (
+ SELECT
+ il."ledgerItemId",
+ SUM(il."quantityOnHand") AS "quantityOnHandNotInShelf"
+ FROM item_ledgers il
+ INNER JOIN job_materials jm
+ ON jm."itemId" = il."ledgerItemId" AND (jm."shelfId" IS NULL OR jm."shelfId" != il."shelfId")
+ GROUP BY il."ledgerItemId"
+ )
+
+SELECT
+ jm."id",
+ jm."itemId" AS "jobMaterialItemId",
+ jm."jobMakeMethodId",
+ i."readableId" AS "itemReadableId",
+ i."name",
+ jm."description",
+ i."itemTrackingType",
+ jm."methodType",
+ i."type",
+ CASE
+ WHEN i."thumbnailPath" IS NULL AND mu."thumbnailPath" IS NOT NULL THEN mu."thumbnailPath"
+ ELSE i."thumbnailPath"
+ END AS "thumbnailPath",
+ i."unitOfMeasureCode",
+ jm."quantity" as "quantityPerParent",
+ jm."estimatedQuantity",
+ jm."quantityIssued",
+ COALESCE(ils."quantityOnHandInShelf", 0) AS "quantityOnHandInShelf",
+ COALESCE(ilns."quantityOnHandNotInShelf", 0) AS "quantityOnHandNotInShelf",
+ COALESCE(so."quantityOnSalesOrder", 0) AS "quantityOnSalesOrder",
+ COALESCE(po."quantityOnPurchaseOrder", 0) AS "quantityOnPurchaseOrder",
+ COALESCE(oj."quantityOnProductionOrder", 0) AS "quantityOnProductionOrder",
+ COALESCE(ojis."quantityOnProductionDemandInShelf", 0) AS "quantityFromProductionOrderInShelf",
+ COALESCE(ojns."quantityOnProductionDemandNotInShelf", 0) AS "quantityFromProductionOrderNotInShelf",
+ COALESCE(stit."quantityInTransit", 0) AS "quantityInTransitToShelf",
+ jm."shelfId",
+ s."name" AS "shelfName"
+FROM
+ job_materials jm
+ INNER JOIN "item" i ON i."id" = jm."itemId"
+ LEFT JOIN "shelf" s ON s."id" = jm."shelfId"
+ LEFT JOIN item_ledgers_in_shelf ils ON i."id" = ils."ledgerItemId"
+ LEFT JOIN item_ledgers_not_in_shelf ilns ON i."id" = ilns."ledgerItemId"
+ LEFT JOIN open_sales_orders so ON i."id" = so."salesOrderItemId"
+ LEFT JOIN open_purchase_orders po ON i."id" = po."purchaseOrderItemId"
+ LEFT JOIN open_jobs oj ON i."id" = oj."jobItemId"
+ LEFT JOIN open_job_requirements_in_shelf ojis ON i."id" = ojis."itemId"
+ LEFT JOIN open_job_requirements_not_in_shelf ojns ON i."id" = ojns."itemId"
+ LEFT JOIN "modelUpload" mu ON mu.id = i."modelUploadId"
+ LEFT JOIN stock_transfers_in_transit stit ON jm."itemId" = stit."itemId" AND jm."shelfId" = stit."shelfId";
+ END;
+$$ LANGUAGE plpgsql SECURITY DEFINER;
+
+
+CREATE OR REPLACE FUNCTION get_part_details(item_id TEXT)
+RETURNS TABLE (
+ "active" BOOLEAN,
+ "assignee" TEXT,
+ "defaultMethodType" "methodType",
+ "description" TEXT,
+ "itemTrackingType" "itemTrackingType",
+ "name" TEXT,
+ "replenishmentSystem" "itemReplenishmentSystem",
+ "unitOfMeasureCode" TEXT,
+ "notes" JSONB,
+ "thumbnailPath" TEXT,
+ "modelId" TEXT,
+ "modelPath" TEXT,
+ "modelName" TEXT,
+ "modelSize" BIGINT,
+ "id" TEXT,
+ "companyId" TEXT,
+ "unitOfMeasure" TEXT,
+ "readableId" TEXT,
+ "revision" TEXT,
+ "readableIdWithRevision" TEXT,
+ "revisions" JSON,
+ "customFields" JSONB,
+ "tags" TEXT[],
+ "itemPostingGroupId" TEXT,
+ "createdBy" TEXT,
+ "createdAt" TIMESTAMP WITH TIME ZONE,
+ "updatedBy" TEXT,
+ "updatedAt" TIMESTAMP WITH TIME ZONE
+) AS $$
+DECLARE
+ v_readable_id TEXT;
+ v_company_id TEXT;
+BEGIN
+ SELECT i."readableId", i."companyId" INTO v_readable_id, v_company_id
+ FROM "item" i
+ WHERE i.id = item_id;
+
+ RETURN QUERY
+ WITH item_revisions AS (
+ SELECT
+ json_agg(
+ json_build_object(
+ 'id', i.id,
+ 'revision', i."revision",
+ 'methodType', i."defaultMethodType",
+ 'type', i."type"
+ ) ORDER BY
+ i."createdAt" DESC
+ ) as "revisions"
+ FROM "item" i
+ WHERE i."readableId" = v_readable_id
+ AND i."companyId" = v_company_id
+ )
+ SELECT
+ i."active",
+ i."assignee",
+ i."defaultMethodType",
+ i."description",
+ i."itemTrackingType",
+ i."name",
+ i."replenishmentSystem",
+ i."unitOfMeasureCode",
+ i."notes",
+ CASE
+ WHEN i."thumbnailPath" IS NULL AND mu."thumbnailPath" IS NOT NULL THEN mu."thumbnailPath"
+ ELSE i."thumbnailPath"
+ END as "thumbnailPath",
+ mu.id as "modelId",
+ mu."modelPath",
+ mu."name" as "modelName",
+ mu."size" as "modelSize",
+ i."id",
+ i."companyId",
+ uom.name as "unitOfMeasure",
+ i."readableId",
+ i."revision",
+ i."readableIdWithRevision",
+ ir."revisions",
+ p."customFields",
+ p."tags",
+ ic."itemPostingGroupId",
+ i."createdBy",
+ i."createdAt",
+ i."updatedBy",
+ i."updatedAt"
+ FROM "part" p
+ LEFT JOIN "item" i ON i."readableId" = p."id" AND i."companyId" = p."companyId"
+ LEFT JOIN item_revisions ir ON true
+ LEFT JOIN (
+ SELECT
+ ps."itemId",
+ string_agg(ps."supplierPartId", ',') AS "supplierIds"
+ FROM "supplierPart" ps
+ GROUP BY ps."itemId"
+ ) ps ON ps."itemId" = i.id
+ LEFT JOIN "modelUpload" mu ON mu.id = i."modelUploadId"
+ LEFT JOIN "unitOfMeasure" uom ON uom.code = i."unitOfMeasureCode" AND uom."companyId" = i."companyId"
+ LEFT JOIN "itemCost" ic ON ic."itemId" = i.id
+ WHERE i."id" = item_id;
+END;
+$$ LANGUAGE plpgsql;
+
+
+CREATE OR REPLACE FUNCTION get_tool_details(item_id TEXT)
+RETURNS TABLE (
+ "active" BOOLEAN,
+ "assignee" TEXT,
+ "defaultMethodType" "methodType",
+ "description" TEXT,
+ "itemTrackingType" "itemTrackingType",
+ "name" TEXT,
+ "replenishmentSystem" "itemReplenishmentSystem",
+ "unitOfMeasureCode" TEXT,
+ "notes" JSONB,
+ "thumbnailPath" TEXT,
+ "modelId" TEXT,
+ "modelPath" TEXT,
+ "modelName" TEXT,
+ "modelSize" BIGINT,
+ "id" TEXT,
+ "companyId" TEXT,
+ "unitOfMeasure" TEXT,
+ "readableId" TEXT,
+ "revision" TEXT,
+ "readableIdWithRevision" TEXT,
+ "revisions" JSON,
+ "customFields" JSONB,
+ "tags" TEXT[],
+ "itemPostingGroupId" TEXT,
+ "createdBy" TEXT,
+ "createdAt" TIMESTAMP WITH TIME ZONE,
+ "updatedBy" TEXT,
+ "updatedAt" TIMESTAMP WITH TIME ZONE
+) AS $$
+DECLARE
+ v_readable_id TEXT;
+ v_company_id TEXT;
+BEGIN
+ SELECT i."readableId", i."companyId" INTO v_readable_id, v_company_id
+ FROM "item" i
+ WHERE i.id = item_id;
+
+ RETURN QUERY
+ WITH item_revisions AS (
+ SELECT
+ json_agg(
+ json_build_object(
+ 'id', i.id,
+ 'revision', i."revision",
+ 'methodType', i."defaultMethodType",
+ 'type', i."type"
+ ) ORDER BY
+ i."createdAt" DESC
+ ) as "revisions"
+ FROM "item" i
+ WHERE i."readableId" = v_readable_id
+ AND i."companyId" = v_company_id
+ )
+ SELECT
+ i."active",
+ i."assignee",
+ i."defaultMethodType",
+ i."description",
+ i."itemTrackingType",
+ i."name",
+ i."replenishmentSystem",
+ i."unitOfMeasureCode",
+ i."notes",
+ CASE
+ WHEN i."thumbnailPath" IS NULL AND mu."thumbnailPath" IS NOT NULL THEN mu."thumbnailPath"
+ ELSE i."thumbnailPath"
+ END as "thumbnailPath",
+ mu.id as "modelId",
+ mu."modelPath",
+ mu."name" as "modelName",
+ mu."size" as "modelSize",
+ i."id",
+ i."companyId",
+ uom.name as "unitOfMeasure",
+ i."readableId",
+ i."revision",
+ i."readableIdWithRevision",
+ ir."revisions",
+ t."customFields",
+ t."tags",
+ ic."itemPostingGroupId",
+ i."createdBy",
+ i."createdAt",
+ i."updatedBy",
+ i."updatedAt"
+ FROM "tool" t
+ LEFT JOIN "item" i ON i."readableId" = t."id" AND i."companyId" = t."companyId"
+ LEFT JOIN item_revisions ir ON true
+ LEFT JOIN (
+ SELECT
+ ps."itemId",
+ string_agg(ps."supplierPartId", ',') AS "supplierIds"
+ FROM "supplierPart" ps
+ GROUP BY ps."itemId"
+ ) ps ON ps."itemId" = i.id
+ LEFT JOIN "modelUpload" mu ON mu.id = i."modelUploadId"
+ LEFT JOIN "unitOfMeasure" uom ON uom.code = i."unitOfMeasureCode" AND uom."companyId" = i."companyId"
+ LEFT JOIN "itemCost" ic ON ic."itemId" = i.id
+ WHERE i."id" = item_id;
+END;
+$$ LANGUAGE plpgsql;
+
+
+CREATE OR REPLACE FUNCTION get_material_details(item_id TEXT)
+RETURNS TABLE (
+ "active" BOOLEAN,
+ "assignee" TEXT,
+ "defaultMethodType" "methodType",
+ "description" TEXT,
+ "itemTrackingType" "itemTrackingType",
+ "name" TEXT,
+ "replenishmentSystem" "itemReplenishmentSystem",
+ "unitOfMeasureCode" TEXT,
+ "notes" JSONB,
+ "thumbnailPath" TEXT,
+ "modelUploadId" TEXT,
+ "modelPath" TEXT,
+ "modelName" TEXT,
+ "modelSize" BIGINT,
+ "id" TEXT,
+ "companyId" TEXT,
+ "readableId" TEXT,
+ "revision" TEXT,
+ "readableIdWithRevision" TEXT,
+ "supplierIds" TEXT,
+ "unitOfMeasure" TEXT,
+ "revisions" JSON,
+ "materialForm" TEXT,
+ "materialSubstance" TEXT,
+ "finish" TEXT,
+ "grade" TEXT,
+ "dimensions" TEXT,
+ "materialType" TEXT,
+ "materialSubstanceId" TEXT,
+ "materialFormId" TEXT,
+ "materialTypeId" TEXT,
+ "dimensionId" TEXT,
+ "gradeId" TEXT,
+ "finishId" TEXT,
+ "customFields" JSONB,
+ "tags" TEXT[],
+ "itemPostingGroupId" TEXT,
+ "createdBy" TEXT,
+ "createdAt" TIMESTAMP WITH TIME ZONE,
+ "updatedBy" TEXT,
+ "updatedAt" TIMESTAMP WITH TIME ZONE
+) AS $$
+DECLARE
+ v_readable_id TEXT;
+ v_company_id TEXT;
+BEGIN
+ SELECT i."readableId", i."companyId" INTO v_readable_id, v_company_id
+ FROM "item" i
+ WHERE i.id = item_id;
+
+ RETURN QUERY
+ WITH item_revisions AS (
+ SELECT
+ json_agg(
+ json_build_object(
+ 'id', i.id,
+ 'revision', i."revision",
+ 'methodType', i."defaultMethodType",
+ 'type', i."type"
+ ) ORDER BY
+ i."createdAt"
+ ) as "revisions"
+ FROM "item" i
+ WHERE i."readableId" = v_readable_id
+ AND i."companyId" = v_company_id
+ )
+ SELECT
+ i."active",
+ i."assignee",
+ i."defaultMethodType",
+ i."description",
+ i."itemTrackingType",
+ i."name",
+ i."replenishmentSystem",
+ i."unitOfMeasureCode",
+ i."notes",
+ CASE
+ WHEN i."thumbnailPath" IS NULL AND mu."thumbnailPath" IS NOT NULL THEN mu."thumbnailPath"
+ ELSE i."thumbnailPath"
+ END as "thumbnailPath",
+ mu.id as "modelUploadId",
+ mu."modelPath",
+ mu."name" as "modelName",
+ mu."size" as "modelSize",
+ i."id",
+ i."companyId",
+ i."readableId",
+ i."revision",
+ i."readableIdWithRevision",
+ ps."supplierIds",
+ uom.name as "unitOfMeasure",
+ ir."revisions",
+ mf."name" AS "materialForm",
+ ms."name" AS "materialSubstance",
+ mfin."name" AS "finish",
+ mg."name" AS "grade",
+ md."name" AS "dimensions",
+ mt."name" AS "materialType",
+ m."materialSubstanceId",
+ m."materialFormId",
+ m."materialTypeId",
+ m."dimensionId",
+ m."gradeId",
+ m."finishId",
+ m."customFields",
+ m."tags",
+ ic."itemPostingGroupId",
+ i."createdBy",
+ i."createdAt",
+ i."updatedBy",
+ i."updatedAt"
+ FROM "material" m
+ LEFT JOIN "item" i ON i."readableId" = m."id" AND i."companyId" = m."companyId"
+ LEFT JOIN item_revisions ir ON true
+ LEFT JOIN (
+ SELECT
+ ps."itemId",
+ string_agg(ps."supplierPartId", ',') AS "supplierIds"
+ FROM "supplierPart" ps
+ GROUP BY ps."itemId"
+ ) ps ON ps."itemId" = i.id
+ LEFT JOIN "modelUpload" mu ON mu.id = i."modelUploadId"
+ LEFT JOIN "unitOfMeasure" uom ON uom.code = i."unitOfMeasureCode" AND uom."companyId" = i."companyId"
+ LEFT JOIN "materialForm" mf ON mf."id" = m."materialFormId"
+ LEFT JOIN "materialSubstance" ms ON ms."id" = m."materialSubstanceId"
+ LEFT JOIN "materialDimension" md ON m."dimensionId" = md."id"
+ LEFT JOIN "materialFinish" mfin ON m."finishId" = mfin."id"
+ LEFT JOIN "materialGrade" mg ON m."gradeId" = mg."id"
+ LEFT JOIN "materialType" mt ON m."materialTypeId" = mt."id"
+ LEFT JOIN "itemCost" ic ON ic."itemId" = i.id
+ WHERE i."id" = item_id;
+END;
+$$ LANGUAGE plpgsql STABLE;
+
+
+CREATE OR REPLACE FUNCTION get_consumable_details(item_id TEXT)
+RETURNS TABLE (
+ "active" BOOLEAN,
+ "assignee" TEXT,
+ "defaultMethodType" "methodType",
+ "description" TEXT,
+ "itemTrackingType" "itemTrackingType",
+ "name" TEXT,
+ "replenishmentSystem" "itemReplenishmentSystem",
+ "unitOfMeasureCode" TEXT,
+ "notes" JSONB,
+ "thumbnailPath" TEXT,
+ "modelUploadId" TEXT,
+ "modelPath" TEXT,
+ "modelName" TEXT,
+ "modelSize" BIGINT,
+ "id" TEXT,
+ "companyId" TEXT,
+ "readableId" TEXT,
+ "revision" TEXT,
+ "readableIdWithRevision" TEXT,
+ "supplierIds" TEXT,
+ "unitOfMeasure" TEXT,
+ "revisions" JSON,
+ "customFields" JSONB,
+ "tags" TEXT[],
+ "itemPostingGroupId" TEXT,
+ "createdBy" TEXT,
+ "createdAt" TIMESTAMP WITH TIME ZONE,
+ "updatedBy" TEXT,
+ "updatedAt" TIMESTAMP WITH TIME ZONE
+) AS $$
+DECLARE
+ v_readable_id TEXT;
+ v_company_id TEXT;
+BEGIN
+ SELECT i."readableId", i."companyId" INTO v_readable_id, v_company_id
+ FROM "item" i
+ WHERE i.id = item_id;
+
+ RETURN QUERY
+ WITH item_revisions AS (
+ SELECT
+ json_agg(
+ json_build_object(
+ 'id', i.id,
+ 'revision', i."revision",
+ 'methodType', i."defaultMethodType",
+ 'type', i."type"
+ ) ORDER BY
+ i."createdAt"
+ ) as "revisions"
+ FROM "item" i
+ WHERE i."readableId" = v_readable_id
+ AND i."companyId" = v_company_id
+ )
+ SELECT
+ i."active",
+ i."assignee",
+ i."defaultMethodType",
+ i."description",
+ i."itemTrackingType",
+ i."name",
+ i."replenishmentSystem",
+ i."unitOfMeasureCode",
+ i."notes",
+ CASE
+ WHEN i."thumbnailPath" IS NULL AND mu."thumbnailPath" IS NOT NULL THEN mu."thumbnailPath"
+ ELSE i."thumbnailPath"
+ END as "thumbnailPath",
+ mu.id as "modelUploadId",
+ mu."modelPath",
+ mu."name" as "modelName",
+ mu."size" as "modelSize",
+ i."id",
+ i."companyId",
+ i."readableId",
+ i."revision",
+ i."readableIdWithRevision",
+ ps."supplierIds",
+ uom.name as "unitOfMeasure",
+ ir."revisions",
+ c."customFields",
+ c."tags",
+ ic."itemPostingGroupId",
+ i."createdBy",
+ i."createdAt",
+ i."updatedBy",
+ i."updatedAt"
+ FROM "consumable" c
+ LEFT JOIN "item" i ON i."readableId" = c."id" AND i."companyId" = c."companyId"
+ LEFT JOIN item_revisions ir ON true
+ LEFT JOIN (
+ SELECT
+ ps."itemId",
+ string_agg(ps."supplierPartId", ',') AS "supplierIds"
+ FROM "supplierPart" ps
+ GROUP BY ps."itemId"
+ ) ps ON ps."itemId" = i.id
+ LEFT JOIN "modelUpload" mu ON mu.id = i."modelUploadId"
+ LEFT JOIN "unitOfMeasure" uom ON uom.code = i."unitOfMeasureCode" AND uom."companyId" = i."companyId"
+ LEFT JOIN "itemCost" ic ON ic."itemId" = i.id
+ WHERE i."id" = item_id;
+END;
+$$ LANGUAGE plpgsql STABLE;
+
+-- Step 8: Recreate triggers with new enum values
+
+CREATE TRIGGER insert_quote_line_make_method_trigger
+AFTER INSERT ON "quoteLine"
+FOR EACH ROW
+WHEN (new."methodType" = 'Make to Order')
+EXECUTE FUNCTION insert_quote_line_make_method();
+
+CREATE TRIGGER update_quote_line_make_method_item_id_trigger
+ AFTER UPDATE OF "itemId", "methodType" ON "quoteLine"
+ FOR EACH ROW
+ WHEN (
+ (old."methodType" = 'Make to Order' AND old."itemId" IS DISTINCT FROM new."itemId") OR
+ (new."methodType" = 'Make to Order' AND old."methodType" <> 'Make to Order')
+ )
+ EXECUTE FUNCTION update_quote_line_make_method_item_id();
+
+CREATE TRIGGER insert_quote_material_make_method_trigger
+ AFTER INSERT ON "quoteMaterial"
+ FOR EACH ROW
+ WHEN (new."methodType" = 'Make to Order')
+ EXECUTE FUNCTION insert_quote_material_make_method();
+
+CREATE TRIGGER update_quote_material_make_method_item_id_trigger
+ AFTER UPDATE OF "itemId", "methodType" ON "quoteMaterial"
+ FOR EACH ROW
+ WHEN (
+ (old."methodType" = 'Make to Order' AND old."itemId" IS DISTINCT FROM new."itemId") OR
+ (new."methodType" = 'Make to Order' AND old."methodType" <> 'Make to Order')
+ )
+ EXECUTE FUNCTION update_quote_material_make_method_item_id();
+
+CREATE TRIGGER insert_job_material_make_method_trigger
+ AFTER INSERT ON "jobMaterial"
+ FOR EACH ROW
+ WHEN (NEW."methodType" = 'Make to Order')
+ EXECUTE FUNCTION insert_job_material_make_method();
+
+CREATE TRIGGER update_job_material_make_method_item_id_trigger
+ AFTER UPDATE OF "itemId", "methodType" ON "jobMaterial"
+ FOR EACH ROW
+ WHEN (
+ (OLD."methodType" = 'Make to Order' AND OLD."itemId" IS DISTINCT FROM NEW."itemId") OR
+ (NEW."methodType" = 'Make to Order' AND OLD."methodType" <> 'Make to Order')
+ )
+ EXECUTE FUNCTION update_job_material_make_method_item_id();
diff --git a/packages/database/supabase/migrations/20260321230229_sourcing-types.sql b/packages/database/supabase/migrations/20260321230229_sourcing-types.sql
new file mode 100644
index 0000000000..aac0e83e07
--- /dev/null
+++ b/packages/database/supabase/migrations/20260321230229_sourcing-types.sql
@@ -0,0 +1,8 @@
+CREATE TYPE "sourcingType" AS ENUM (
+ 'Specified',
+ 'Drop Ship',
+ 'Ship from Inventory'
+);
+
+ALTER TABLE "methodMaterial"
+ ADD COLUMN "sourcingType" "sourcingType" NOT NULL DEFAULT 'Specified';
diff --git a/packages/ee/src/onshape/lib/data.ts b/packages/ee/src/onshape/lib/data.ts
index bbbdf17cdb..4224dba4ee 100644
--- a/packages/ee/src/onshape/lib/data.ts
+++ b/packages/ee/src/onshape/lib/data.ts
@@ -1,6 +1,10 @@
import { z } from "zod";
-const methodType = ["Buy", "Make", "Pick"] as const;
+const methodType = [
+ "Purchase to Order",
+ "Make to Order",
+ "Pull from Inventory"
+] as const;
const replenishmentSystems = ["Buy", "Make", "Buy and Make"] as const;
export const onShapeDataValidator = z
diff --git a/packages/ee/src/paperless-parts/config.tsx b/packages/ee/src/paperless-parts/config.tsx
index ff2b62d283..1bb714e75d 100644
--- a/packages/ee/src/paperless-parts/config.tsx
+++ b/packages/ee/src/paperless-parts/config.tsx
@@ -68,7 +68,7 @@ export const PaperlessParts = defineIntegration({
secretKey: z
.string()
.min(1, { message: "Webhook Signing Secret is required" }),
- methodType: z.enum(["Buy", "Pick"]),
+ methodType: z.enum(["Purchase to Order", "Pull from Inventory"]),
trackingType: z.enum(["Inventory", "Non-Inventory", "Batch"]),
billOfProcessBlackList: z.array(z.string()).optional(),
usePaperlessOrderNumber: zfd.checkbox()
diff --git a/packages/ee/src/paperless-parts/lib/lib.ts b/packages/ee/src/paperless-parts/lib/lib.ts
index ebf52a766d..20cf72cd99 100644
--- a/packages/ee/src/paperless-parts/lib/lib.ts
+++ b/packages/ee/src/paperless-parts/lib/lib.ts
@@ -580,7 +580,7 @@ export async function getOrCreateMaterial(
input: PaperlessPartsMaterialInput;
createdBy: string;
companyId: string;
- defaultMethodType: "Buy" | "Pick";
+ defaultMethodType: "Purchase to Order" | "Pull from Inventory";
defaultTrackingType: "Inventory" | "Non-Inventory" | "Batch";
}
): Promise<{
@@ -1970,7 +1970,7 @@ export async function createPartFromComponent(
number,
NonNullable<z.infer<typeof OrderItemSchema>["components"]>[number]
>;
- defaultMethodType: "Buy" | "Pick";
+ defaultMethodType: "Purchase to Order" | "Pull from Inventory";
defaultTrackingType: "Inventory" | "Non-Inventory" | "Batch";
billOfProcessBlackList?: string[];
}
@@ -2107,10 +2107,12 @@ export async function createPartFromComponent(
const childIsPurchased =
(childComponent as any)?.obtain_method === "purchased";
- const methodType = childIsPurchased ? "Buy" : "Make";
+ const methodType = childIsPurchased
+ ? "Purchase to Order"
+ : "Make to Order";
let materialMakeMethodId: string | undefined;
- if (methodType === "Make") {
+ if (methodType === "Make to Order") {
const materialMakeMethod = await carbon
.from("makeMethod")
.select("id")
@@ -2122,7 +2124,7 @@ export async function createPartFromComponent(
materials.push({
itemId: childItemId,
itemType: "Part",
- methodType: methodType ?? "Pick",
+ methodType: methodType ?? "Pull from Inventory",
materialMakeMethodId,
quantity:
childRef.quantity ?? (childComponent as any)?.innate_quantity ?? 1,
@@ -2223,7 +2225,7 @@ export async function createPartFromComponent(
description: component.description,
type: "Part",
replenishmentSystem: isPurchased ? "Buy" : "Make",
- defaultMethodType: isPurchased ? "Buy" : "Make",
+ defaultMethodType: isPurchased ? "Purchase to Order" : "Make to Order",
itemTrackingType: "Non-Inventory",
unitOfMeasureCode: "EA",
active: true,
@@ -2420,7 +2422,7 @@ export async function getOrCreatePart(
number,
NonNullable<z.infer<typeof OrderItemSchema>["components"]>[number]
>;
- defaultMethodType: "Buy" | "Pick";
+ defaultMethodType: "Purchase to Order" | "Pull from Inventory";
defaultTrackingType: "Inventory" | "Non-Inventory" | "Batch";
billOfProcessBlackList?: string[];
}
@@ -2550,7 +2552,7 @@ export async function insertOrderLines(
companyId: string;
createdBy: string;
orderItems: z.infer<typeof OrderSchema>["order_items"];
- defaultMethodType: "Buy" | "Pick";
+ defaultMethodType: "Purchase to Order" | "Pull from Inventory";
defaultTrackingType: "Inventory" | "Non-Inventory" | "Batch";
billOfProcessBlackList?: string[];
}
@@ -2796,7 +2798,7 @@ export async function insertQuoteLines(
companyId: string;
createdBy: string;
quoteItems: QuoteItem[];
- defaultMethodType: "Buy" | "Pick";
+ defaultMethodType: "Purchase to Order" | "Pull from Inventory";
defaultTrackingType: "Inventory" | "Non-Inventory" | "Batch";
billOfProcessBlackList?: string[];
}
@@ -2935,7 +2937,7 @@ export async function insertQuoteLines(
quoteId,
itemId,
description: component.description || component.part_name || "",
- methodType: rootMethodType as "Make" | "Buy",
+ methodType: rootMethodType as "Make to Order" | "Purchase to Order",
quantity: quantities.length > 0 ? quantities : null,
unitOfMeasureCode: "EA",
status: "Not Started",
@@ -3212,7 +3214,7 @@ export async function insertQuoteLines(
quoteMakeMethodId,
itemId: childItemId,
itemType: "Part",
- methodType: "Make",
+ methodType: "Make to Order",
description:
childItemResult.data?.name ??
(childComponent as any).description ??
@@ -3304,7 +3306,7 @@ export async function insertQuoteLines(
quoteMakeMethodId,
itemId: childItemId,
itemType: "Part",
- methodType: "Buy",
+ methodType: "Pull from Inventory",
description:
childItemResult.data?.name ??
(childComponent as any).description ??
diff --git a/packages/form/src/components/Array.tsx b/packages/form/src/components/Array.tsx
index 5d2f433356..110d7f6c5b 100644
--- a/packages/form/src/components/Array.tsx
+++ b/packages/form/src/components/Array.tsx
@@ -22,7 +22,6 @@ type FormArrayProps = InputProps & {
isRequired?: boolean;
};
-// biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
const Array = forwardRef<HTMLInputElement, FormArrayProps>(
(
{
diff --git a/packages/form/src/components/Boolean.tsx b/packages/form/src/components/Boolean.tsx
index bc147cc8e4..1ac7136674 100644
--- a/packages/form/src/components/Boolean.tsx
+++ b/packages/form/src/components/Boolean.tsx
@@ -21,7 +21,6 @@ type FormBooleanProps = {
onChange?: (value: boolean) => void;
};
-// biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
const Boolean = forwardRef<HTMLInputElement, FormBooleanProps>(
(
{
diff --git a/packages/form/src/components/Number.tsx b/packages/form/src/components/Number.tsx
index 9df09c983b..dd7122a9ea 100644
--- a/packages/form/src/components/Number.tsx
+++ b/packages/form/src/components/Number.tsx
@@ -27,7 +27,6 @@ type FormNumberProps = NumberFieldProps & {
onConfigure?: () => void;
};
-// biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
const Number = forwardRef<HTMLInputElement, FormNumberProps>(
(
{
diff --git a/packages/form/src/components/NumberControlled.tsx b/packages/form/src/components/NumberControlled.tsx
index 9adb898bf1..356f247447 100644
--- a/packages/form/src/components/NumberControlled.tsx
+++ b/packages/form/src/components/NumberControlled.tsx
@@ -38,7 +38,6 @@ type FormNumberProps = NumberFieldProps & {
onConfigure?: () => void;
};
-// biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
const Number = forwardRef<HTMLInputElement, FormNumberProps>(
(
{
diff --git a/packages/form/src/components/index.ts b/packages/form/src/components/index.ts
index ed45de9568..5684e68877 100644
--- a/packages/form/src/components/index.ts
+++ b/packages/form/src/components/index.ts
@@ -1,7 +1,5 @@
-// biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
import Array from "./Array";
import ArrayNumeric from "./ArrayNumeric";
-// biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
import Boolean from "./Boolean";
import type { ComboboxProps } from "./Combobox";
import Combobox from "./Combobox";
@@ -17,7 +15,6 @@ import InputControlled from "./InputControlled";
import InputOTP from "./InputOTP";
import type { MultiSelectProps } from "./MultiSelect";
import MultiSelect from "./MultiSelect";
-// biome-ignore lint/suspicious/noShadowRestrictedNames: suppressed due to migration
import Number from "./Number";
import NumberControlled from "./NumberControlled";
import Password from "./Password";
diff --git a/packages/jobs/trigger/paperless-parts.ts b/packages/jobs/trigger/paperless-parts.ts
index eb9e4b287d..88705c47c7 100644
--- a/packages/jobs/trigger/paperless-parts.ts
+++ b/packages/jobs/trigger/paperless-parts.ts
@@ -105,7 +105,7 @@ const paperlessPartsSchema = z.object({
});
const integrationSchema = z.object({
- methodType: z.enum(["Buy", "Pick"]).optional(),
+ methodType: z.enum(["Purchase to Order", "Pull from Inventory"]).optional(),
trackingType: z.enum(["Inventory", "Non-Inventory", "Batch"]).optional(),
usePaperlessOrderNumber: z.boolean().optional(),
billOfProcessBlackList: z.array(z.string()).optional(),
@@ -150,11 +150,11 @@ export const paperlessPartsTask = task({
integration.data.metadata
);
let usePaperlessOrderNumber = false;
- let methodType: "Buy" | "Pick" = "Pick";
+ let methodType: "Purchase to Order" | "Pull from Inventory" = "Pull from Inventory";
let trackingType: "Inventory" | "Non-Inventory" | "Batch" = "Inventory";
let billOfProcessBlackList: string[] = [];
if (integrationData.success) {
- methodType = integrationData.data.methodType ?? "Pick";
+ methodType = integrationData.data.methodType ?? "Pull from Inventory";
trackingType = integrationData.data.trackingType ?? "Inventory";
if (integrationData.data.usePaperlessOrderNumber) {
usePaperlessOrderNumber = true;
diff --git a/packages/utils/src/status.ts b/packages/utils/src/status.ts
index 37a22948dc..0e56fcdadb 100644
--- a/packages/utils/src/status.ts
+++ b/packages/utils/src/status.ts
@@ -90,7 +90,7 @@ export const getSalesOrderJobStatus = (
) => {
const filteredJobs =
jobs?.filter((j) => j.salesOrderLineId === line.id) ?? [];
- const isMade = line.methodType === "Make";
+ const isMade = line.methodType === "Make to Order";
const saleQuantity = line.saleQuantity ?? 0;
const totalProduction = filteredJobs.reduce(
@@ -157,7 +157,7 @@ type SalesOrderForProductionCheck = {
}>;
lines?: Array<{
id: string;
- methodType: "Buy" | "Make" | "Pick";
+ methodType: "Purchase to Order" | "Make to Order" | "Pull from Inventory";
saleQuantity: number;
}>;
};
@@ -173,7 +173,7 @@ export const hasIncompleteJobs = (
const jobs = salesOrder.jobs ?? [];
const lines = salesOrder.lines ?? [];
- const makeLines = lines.filter((line) => line.methodType === "Make");
+ const makeLines = lines.filter((line) => line.methodType === "Make to Order");
if (makeLines.length === 0) {
return false;
}