Skip to content

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

feat: fix get methods to support multiple make methods per part

Brad Barbin1c0a66df523f
diff --git a/README.md b/README.md
index 1a42dd189f..a9ed5e2d7f 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-![CarbonOS](https://github.com/user-attachments/assets/664eb49a-f873-49f8-bb6f-95a94ba89f97)
+![Carbon](https://github.com/user-attachments/assets/664eb49a-f873-49f8-bb6f-95a94ba89f97)
Carbon is the open-source operating system for manufacturing.
diff --git a/apps/erp/app/components/Activity.tsx b/apps/erp/app/components/Activity.tsx
index d357e312e2..c3b6952eed 100644
--- a/apps/erp/app/components/Activity.tsx
+++ b/apps/erp/app/components/Activity.tsx
@@ -33,7 +33,7 @@ const Activity = ({
<div className="flex-grow">
<p>
<span className="font-semibold mr-1">
- {person?.name ?? "CarbonOS Admin"}
+ {person?.name ?? "Carbon Admin"}
</span>
<span className="text-gray-400">{activityMessage}</span>
</p>
diff --git a/apps/erp/app/components/Icons.tsx b/apps/erp/app/components/Icons.tsx
index da9b84d6a2..ba1598d691 100644
--- a/apps/erp/app/components/Icons.tsx
+++ b/apps/erp/app/components/Icons.tsx
@@ -1,5 +1,5 @@
import type { Database } from "@carbon/database";
-import { Badge, cn, HStack, Status } from "@carbon/react";
+import { Badge, cn, Status } from "@carbon/react";
import { AiOutlinePartition } from "react-icons/ai";
import { FaCodePullRequest } from "react-icons/fa6";
import {
@@ -116,7 +116,7 @@ export function MethodBadge({ type, text, to, className }: MethodBadgeProps) {
const mode = useMode();
const style = getReplenishmentBadgeColor(type, mode);
return (
- <HStack className="group" spacing={1}>
+ <Link to={to} prefetch="intent" className="group flex items-center gap-1">
<Badge style={style} className={className}>
<MethodIcon
type={type === "Make Inactive" ? "Make" : type}
@@ -124,14 +124,10 @@ export function MethodBadge({ type, text, to, className }: MethodBadgeProps) {
/>
{text}
</Badge>
- <Link
- className="group-hover:opacity-100 opacity-0 transition-opacity duration-200 w-4 h-4 text-foreground"
- to={to}
- prefetch="intent"
- >
+ <span className="group-hover:opacity-100 opacity-0 transition-opacity duration-200 w-4 h-4 text-foreground">
<LuExternalLink />
- </Link>
- </HStack>
+ </span>
+ </Link>
);
}
diff --git a/apps/erp/app/components/ImportCSVModal/FieldMappings.tsx b/apps/erp/app/components/ImportCSVModal/FieldMappings.tsx
index b47a7349ec..36de8146af 100644
--- a/apps/erp/app/components/ImportCSVModal/FieldMappings.tsx
+++ b/apps/erp/app/components/ImportCSVModal/FieldMappings.tsx
@@ -172,7 +172,7 @@ export function FieldMapping({
{currentStep === 0 ? (
<div className="grid grid-cols-2 gap-x-4 gap-y-2">
<div className="text-sm">CSV column</div>
- <div className="text-sm">CarbonOS column</div>
+ <div className="text-sm">Carbon column</div>
{Object.entries(mappableFields).map(
([name, { label, required, type }]) => (
<FieldRow
diff --git a/apps/erp/app/components/Layout/Topbar/Feedback.tsx b/apps/erp/app/components/Layout/Topbar/Feedback.tsx
index b54a78d0bd..9775bdac76 100644
--- a/apps/erp/app/components/Layout/Topbar/Feedback.tsx
+++ b/apps/erp/app/components/Layout/Topbar/Feedback.tsx
@@ -154,7 +154,7 @@ const Feedback = () => {
<p className="text-sm">
Have a technical issue? Contact{" "}
<a className="text-primary" href={`mailto:${SUPPORT_EMAIL}`}>
- CarbonOS Support.
+ Carbon Support.
</a>
</p>
</VStack>
diff --git a/apps/erp/app/integrations/quickbooks/config.tsx b/apps/erp/app/integrations/quickbooks/config.tsx
index 4b2e056cae..40de35ea6c 100644
--- a/apps/erp/app/integrations/quickbooks/config.tsx
+++ b/apps/erp/app/integrations/quickbooks/config.tsx
@@ -9,7 +9,7 @@ export const QuickBooks: IntegrationConfig = {
category: "Accounting",
logo: Logo,
description:
- "Integrating CarbonOS with QuickBooks enables you to post transactions from sales invoices and purchase invoices into your existing accounting software, neatly organizing everything in your bookkeeping software.",
+ "Integrating Carbon with QuickBooks enables you to post transactions from sales invoices and purchase invoices into your existing accounting software, neatly organizing everything in your bookkeeping software.",
shortDescription:
"Automatically post transactions from sales and purchase invoices.",
images: [],
diff --git a/apps/erp/app/integrations/xero/config.tsx b/apps/erp/app/integrations/xero/config.tsx
index bb66636b9e..f3d326808e 100644
--- a/apps/erp/app/integrations/xero/config.tsx
+++ b/apps/erp/app/integrations/xero/config.tsx
@@ -9,7 +9,7 @@ export const Xero: IntegrationConfig = {
category: "Accounting",
logo: Logo,
description:
- "Integrating CarbonOS with Xero enables you to post transactions from sales invoices and purchase invoices into your existing accounting software, neatly organizing everything in your bookkeeping software.",
+ "Integrating Carbon with Xero enables you to post transactions from sales invoices and purchase invoices into your existing accounting software, neatly organizing everything in your bookkeeping software.",
shortDescription:
"Automatically post transactions from sales and purchase invoices.",
images: [],
diff --git a/apps/erp/app/integrations/zapier/config.tsx b/apps/erp/app/integrations/zapier/config.tsx
index 5b1a4d9a40..f66de1c2f3 100644
--- a/apps/erp/app/integrations/zapier/config.tsx
+++ b/apps/erp/app/integrations/zapier/config.tsx
@@ -9,7 +9,7 @@ export const Zapier: IntegrationConfig = {
category: "Automation",
logo: Logo,
description:
- "Integrating with Zapier enables you to automate tasks and workflows in your business by connecting CarbonOS to other apps.",
+ "Integrating with Zapier enables you to automate tasks and workflows in your business by connecting Carbon to other apps.",
shortDescription: "Automate tasks and workflows in your business.",
images: [],
onInitialize: () => {},
diff --git a/apps/erp/app/modules/documents/ui/Documents/DocumentsTable.tsx b/apps/erp/app/modules/documents/ui/Documents/DocumentsTable.tsx
index 84d1d1faad..4e95b52fee 100644
--- a/apps/erp/app/modules/documents/ui/Documents/DocumentsTable.tsx
+++ b/apps/erp/app/modules/documents/ui/Documents/DocumentsTable.tsx
@@ -202,20 +202,20 @@ const DocumentsTable = memo(
cell: ({ row }) =>
row.original.sourceDocument &&
row.original.sourceDocumentId && (
- <HStack className="group" spacing={1}>
+ <Link
+ to={getDocumentLocation(
+ row.original
+ .sourceDocument as (typeof documentSourceTypes)[number],
+ row.original.sourceDocumentId
+ )}
+ prefetch="intent"
+ className="group flex items-center gap-1"
+ >
<Enumerable value={row.original.sourceDocument} />{" "}
- <Link
- className="group-hover:opacity-100 opacity-0 transition-opacity duration-200 w-4 h-4 text-foreground"
- to={getDocumentLocation(
- row.original
- .sourceDocument as (typeof documentSourceTypes)[number],
- row.original.sourceDocumentId
- )}
- prefetch="intent"
- >
+ <span className="group-hover:opacity-100 opacity-0 transition-opacity duration-200 w-4 h-4 text-foreground">
<LuExternalLink />
- </Link>
- </HStack>
+ </span>
+ </Link>
),
meta: {
icon: <LuFileText />,
diff --git a/apps/erp/app/modules/items/items.models.ts b/apps/erp/app/modules/items/items.models.ts
index 39294c1b8a..fc85fdeb71 100644
--- a/apps/erp/app/modules/items/items.models.ts
+++ b/apps/erp/app/modules/items/items.models.ts
@@ -167,6 +167,7 @@ export const getMethodValidator = z.object({
export const makeMethodVersionValidator = z.object({
copyFromId: z.string().min(1, { message: "Please select a source method" }),
+ activeVersionId: zfd.text(z.string().optional()),
version: zfd.numeric(
z.number().min(0, { message: "Please enter a version" })
),
diff --git a/apps/erp/app/modules/items/items.service.ts b/apps/erp/app/modules/items/items.service.ts
index f80356b899..3eb6901b34 100644
--- a/apps/erp/app/modules/items/items.service.ts
+++ b/apps/erp/app/modules/items/items.service.ts
@@ -41,7 +41,23 @@ import type {
unitOfMeasureValidator,
} from "./items.models";
-export async function copyMakeMethod(
+export async function activateMethodVersion(
+ client: SupabaseClient<Database>,
+ payload: {
+ id: string;
+ companyId: string;
+ userId: string;
+ }
+) {
+ return client.functions.invoke<{ convertedId: string }>("convert", {
+ body: {
+ type: "methodVersionToActive",
+ ...payload,
+ },
+ });
+}
+
+export async function copyItem(
client: SupabaseClient<Database>,
args: z.infer<typeof getMethodValidator> & {
companyId: string;
@@ -59,6 +75,24 @@ export async function copyMakeMethod(
});
}
+export async function copyMakeMethod(
+ client: SupabaseClient<Database>,
+ args: z.infer<typeof getMethodValidator> & {
+ companyId: string;
+ userId: string;
+ }
+) {
+ return client.functions.invoke("get-method", {
+ body: {
+ type: "makeMethodToMakeMethod",
+ sourceId: args.sourceId,
+ targetId: args.targetId,
+ companyId: args.companyId,
+ userId: args.userId,
+ },
+ });
+}
+
export async function createRevision(
client: SupabaseClient<Database>,
args: {
@@ -558,7 +592,7 @@ export async function getMaterialUsedIn(
client
.from("methodMaterial")
.select(
- "id, methodType, ...makeMethod!makeMethodId(...item(documentReadableId:readableIdWithRevision, documentId:id, itemType:type))"
+ "id, methodType, ...makeMethod!makeMethodId(documentId:id, version, ...item(documentReadableId:readableIdWithRevision, documentParentId:id, itemType:type))"
)
.eq("itemId", itemId)
.eq("companyId", companyId),
@@ -644,7 +678,7 @@ export async function getPartUsedIn(
client
.from("methodMaterial")
.select(
- "id, methodType, ...makeMethod!makeMethodId(...item(documentReadableId:readableIdWithRevision, documentId:id, itemType:type))"
+ "id, methodType, ...makeMethod!makeMethodId(documentId:id, version, ...item(documentReadableId:readableIdWithRevision, documentParentId:id, itemType:type))"
)
.eq("itemId", itemId)
.eq("companyId", companyId),
@@ -1966,13 +2000,38 @@ export async function upsertMakeMethodVersion(
createdBy: string;
}
) {
- console.log(makeMethodVersion);
- return {
- data: {
- id: makeMethodVersion.copyFromId,
- },
- error: null,
- };
+ const currentMakeMethod = await client
+ .from("makeMethod")
+ .select("*")
+ .eq("id", makeMethodVersion.copyFromId)
+ .eq("companyId", makeMethodVersion.companyId)
+ .single();
+
+ if (currentMakeMethod.error) return currentMakeMethod;
+
+ const { id, version, ...data } = currentMakeMethod.data;
+
+ const insert = await client
+ .from("makeMethod")
+ .insert({
+ ...data,
+ status: "Draft",
+ version: makeMethodVersion.version,
+ createdBy: makeMethodVersion.createdBy,
+ })
+ .select("id, ...item(itemId:id, type)")
+ .single();
+
+ if (insert.error) return insert;
+
+ if (makeMethodVersion.activeVersionId) {
+ await client
+ .from("makeMethod")
+ .update({ status: "Active" })
+ .eq("id", makeMethodVersion.activeVersionId);
+ }
+
+ return insert;
}
export async function upsertMethodMaterial(
diff --git a/apps/erp/app/modules/items/ui/Item/BillOfMaterial.tsx b/apps/erp/app/modules/items/ui/Item/BillOfMaterial.tsx
index 4215e7f8ca..1e806e3f35 100644
--- a/apps/erp/app/modules/items/ui/Item/BillOfMaterial.tsx
+++ b/apps/erp/app/modules/items/ui/Item/BillOfMaterial.tsx
@@ -139,7 +139,7 @@ const BillOfMaterial = ({
const permissions = usePermissions();
const isReadOnly =
permissions.can("update", "parts") === false ||
- makeMethod.status === "Active";
+ makeMethod.status !== "Draft";
const fetcher = useFetcher<{}>();
const [searchParams] = useSearchParams();
diff --git a/apps/erp/app/modules/items/ui/Item/BillOfProcess.tsx b/apps/erp/app/modules/items/ui/Item/BillOfProcess.tsx
index 7523f11fe3..3f8e97c818 100644
--- a/apps/erp/app/modules/items/ui/Item/BillOfProcess.tsx
+++ b/apps/erp/app/modules/items/ui/Item/BillOfProcess.tsx
@@ -193,7 +193,7 @@ const BillOfProcess = ({
const permissions = usePermissions();
const isReadOnly =
permissions.can("update", "parts") === false ||
- makeMethod.status === "Active";
+ makeMethod.status !== "Draft";
const makeMethodId = makeMethod.id;
@@ -550,7 +550,9 @@ const BillOfProcess = ({
parameters={parameters}
operationId={item.id!}
isDisabled={
- selectedItemId === null || isTemporaryId(selectedItemId!)
+ isReadOnly ||
+ selectedItemId === null ||
+ isTemporaryId(selectedItemId!)
}
configurable={configurable}
rulesByField={rulesByField}
@@ -588,7 +590,9 @@ const BillOfProcess = ({
attributes={attributes}
operationId={item.id!}
isDisabled={
- selectedItemId === null || isTemporaryId(selectedItemId!)
+ isReadOnly ||
+ selectedItemId === null ||
+ isTemporaryId(selectedItemId!)
}
configurable={configurable}
rulesByField={rulesByField}
@@ -612,7 +616,9 @@ const BillOfProcess = ({
tools={tools}
operationId={item.id!}
isDisabled={
- selectedItemId === null || isTemporaryId(selectedItemId!)
+ isReadOnly ||
+ selectedItemId === null ||
+ isTemporaryId(selectedItemId!)
}
/>
</div>
diff --git a/apps/erp/app/modules/items/ui/Item/MakeMethodTools.tsx b/apps/erp/app/modules/items/ui/Item/MakeMethodTools.tsx
index 23e420fe3c..ca3ceb4e71 100644
--- a/apps/erp/app/modules/items/ui/Item/MakeMethodTools.tsx
+++ b/apps/erp/app/modules/items/ui/Item/MakeMethodTools.tsx
@@ -2,13 +2,18 @@ import { Number, Submit, ValidatedForm } from "@carbon/form";
import {
Alert,
AlertTitle,
+ Badge,
Button,
Checkbox,
DropdownMenu,
DropdownMenuContent,
DropdownMenuIcon,
DropdownMenuItem,
+ DropdownMenuPortal,
DropdownMenuSeparator,
+ DropdownMenuSub,
+ DropdownMenuSubContent,
+ DropdownMenuSubTrigger,
DropdownMenuTrigger,
HStack,
Menubar,
@@ -27,17 +32,23 @@ import {
} from "@carbon/react";
import { Link, useFetcher, useParams } from "@remix-run/react";
import { useEffect, useState } from "react";
+import { flushSync } from "react-dom";
import {
LuCheck,
LuChevronDown,
LuCirclePlus,
+ LuCopy,
+ LuEye,
LuGitBranch,
LuGitFork,
LuGitMerge,
+ LuPencil,
+ LuStar,
+ LuTrash,
LuTriangleAlert,
} from "react-icons/lu";
-import { RxCodesandboxLogo } from "react-icons/rx";
import { Hidden, Item } from "~/components/Form";
+import { Confirm } from "~/components/Modals";
import { usePermissions } from "~/hooks";
import type { MethodItemType } from "~/modules/shared";
import { path } from "~/utils/path";
@@ -81,12 +92,17 @@ const MakeMethodTools = ({
const getMethodModal = useDisclosure();
const saveMethodModal = useDisclosure();
- const newVersionDisclosure = useDisclosure();
+ const newVersionModal = useDisclosure();
+ const activeMethodModal = useDisclosure();
const itemLink = type && itemId ? getLinkToItemDetails(type, itemId) : null;
- const activeVersion =
- makeMethods.find((m) => m.id === methodId) ?? makeMethods[0];
+ const activeMethodId = makeMethodId ?? methodId;
+ const activeMethod =
+ makeMethods.find((m) => m.id === activeMethodId) ?? makeMethods[0];
+
const maxVersion = Math.max(...makeMethods.map((m) => m.version));
+ const [selectedVersion, setSelectedVersion] =
+ useState<MakeMethod>(activeMethod);
return (
<>
@@ -124,46 +140,102 @@ const MakeMethodTools = ({
<DropdownMenu>
<DropdownMenuTrigger asChild>
- <Button
- variant="ghost"
- leftIcon={<RxCodesandboxLogo />}
- rightIcon={<LuChevronDown />}
- >
- Version {activeVersion.version}
+ <Button variant="ghost" rightIcon={<LuChevronDown />}>
+ <div className="flex items-center gap-2">
+ <Badge variant="outline">V{activeMethod.version}</Badge>
+ <MakeMethodVersionStatus status={activeMethod.status} />
+ </div>
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
{makeMethods && makeMethods.length > 0 && (
<>
- <DropdownMenuSeparator />
- {makeMethods.map((makeMethod) => {
- const isCurrent =
- (makeMethod.id === methodId &&
- makeMethodId === undefined) ||
- makeMethod.id === makeMethodId;
- return (
- <Link
- key={makeMethod.id}
- to={getPathToMakeMethod(type, itemId, makeMethod.id)}
- className="relative flex gap-4 justify-between cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors hover:bg-accent hover:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50"
- >
- <div className="flex items-center gap-2">
- <LuCheck className={cn(!isCurrent && "opacity-0")} />
- <span>Version {makeMethod.version}</span>
- </div>
- <MakeMethodVersionStatus
- status={makeMethod.status}
- isActive={
- makeMethod.status === "Active" ||
- makeMethods.length === 1
- }
- />
- </Link>
- );
- })}
+ {makeMethods
+ .sort((a, b) => b.version - a.version)
+ .map((makeMethod) => {
+ const isCurrent =
+ (makeMethod.id === methodId &&
+ makeMethodId === undefined) ||
+ makeMethod.id === makeMethodId;
+
+ const isReadOnly = makeMethod.status !== "Draft";
+
+ return (
+ <DropdownMenuSub key={makeMethod.id}>
+ <DropdownMenuSubTrigger className="flex items-center justify-between gap-4">
+ <div className="flex items-center gap-2">
+ <LuCheck
+ className={cn(!isCurrent && "opacity-0")}
+ />
+ <span>Version {makeMethod.version}</span>
+ </div>
+ <MakeMethodVersionStatus
+ status={makeMethod.status}
+ isActive={
+ makeMethod.status === "Active" ||
+ makeMethods.length === 1
+ }
+ />
+ </DropdownMenuSubTrigger>
+ <DropdownMenuPortal>
+ <DropdownMenuSubContent>
+ <DropdownMenuItem asChild>
+ <Link
+ to={getPathToMakeMethod(
+ type,
+ itemId,
+ makeMethod.id
+ )}
+ >
+ <DropdownMenuIcon
+ icon={isReadOnly ? <LuEye /> : <LuPencil />}
+ />
+ {isReadOnly ? "View Version" : "Edit Version"}
+ </Link>
+ </DropdownMenuItem>
+ <DropdownMenuItem
+ onClick={() => {
+ flushSync(() => {
+ setSelectedVersion(makeMethod);
+ });
+ newVersionModal.onOpen();
+ }}
+ >
+ <DropdownMenuIcon icon={<LuCopy />} />
+ Copy Version
+ </DropdownMenuItem>
+ <DropdownMenuSeparator />
+ <DropdownMenuItem
+ destructive
+ disabled={
+ makeMethod.status === "Active" ||
+ !permissions.can("delete", "parts")
+ }
+ >
+ <DropdownMenuIcon icon={<LuTrash />} />
+ Delete Version
+ </DropdownMenuItem>
+ <DropdownMenuSeparator />
+ <DropdownMenuItem
+ disabled={makeMethod.status === "Active"}
+ onClick={() => {
+ flushSync(() => {
+ setSelectedVersion(makeMethod);
+ });
+ activeMethodModal.onOpen();
+ }}
+ >
+ <DropdownMenuIcon icon={<LuStar />} />
+ Set as Active Version
+ </DropdownMenuItem>
+ </DropdownMenuSubContent>
+ </DropdownMenuPortal>
+ </DropdownMenuSub>
+ );
+ })}
<DropdownMenuSeparator />
{permissions.can("create", "production") && (
- <DropdownMenuItem onClick={newVersionDisclosure.onOpen}>
+ <DropdownMenuItem onClick={newVersionModal.onOpen}>
<DropdownMenuIcon icon={<LuCirclePlus />} />
New Version
</DropdownMenuItem>
@@ -206,7 +278,6 @@ const MakeMethodTools = ({
label="Source Method"
type={type}
includeInactive={includeInactive}
- disabledItems={[itemId]}
replenishmentSystem="Make"
/>
<div className="flex items-center space-x-2">
@@ -306,12 +377,12 @@ const MakeMethodTools = ({
</Modal>
)}
- {newVersionDisclosure.isOpen && (
+ {newVersionModal.isOpen && (
<Modal
open
onOpenChange={(open) => {
if (!open) {
- newVersionDisclosure.onClose();
+ newVersionModal.onClose();
}
}}
>
@@ -319,13 +390,15 @@ const MakeMethodTools = ({
<ValidatedForm
method="post"
fetcher={fetcher}
- action={path.to.newMakeMethodVersion}
+ action={`${path.to.newMakeMethodVersion}?methodToReplace=${activeMethodId}`}
validator={makeMethodVersionValidator}
defaultValues={{
- copyFromId: activeVersion.id,
+ copyFromId: selectedVersion.id,
+ activeVersionId:
+ makeMethods.length === 1 ? selectedVersion.id : undefined,
version: maxVersion + 1,
}}
- onSubmit={newVersionDisclosure.onClose}
+ onSubmit={newVersionModal.onClose}
>
<ModalHeader>
<ModalTitle>New Version</ModalTitle>
@@ -335,6 +408,7 @@ const MakeMethodTools = ({
</ModalHeader>
<ModalBody>
<Hidden name="copyFromId" />
+ <Hidden name="activeVersionId" />
<VStack spacing={4}>
{makeMethods.length == 1 && (
<Alert variant="warning">
@@ -357,10 +431,7 @@ const MakeMethodTools = ({
</VStack>
</ModalBody>
<ModalFooter>
- <Button
- onClick={newVersionDisclosure.onClose}
- variant="secondary"
- >
+ <Button onClick={newVersionModal.onClose} variant="secondary">
Cancel
</Button>
<Submit>Create Version</Submit>
@@ -369,6 +440,23 @@ const MakeMethodTools = ({
</ModalContent>
</Modal>
)}
+
+ {activeMethodModal.isOpen && (
+ <Confirm
+ action={`${path.to.activeMethodVersion(
+ selectedVersion.id
+ )}?methodToReplace=${activeMethodId}`}
+ confirmText="Make Active"
+ title={`Set Version ${selectedVersion.version} as Active Version?`}
+ text="This will make this version read-only and replace any material make methods with this version."
+ isOpen
+ onSubmit={() => {
+ activeMethodModal.onClose();
+ setSelectedVersion(activeMethod);
+ }}
+ onCancel={activeMethodModal.onClose}
+ />
+ )}
</>
);
};
diff --git a/apps/erp/app/modules/items/ui/Item/UsedIn.tsx b/apps/erp/app/modules/items/ui/Item/UsedIn.tsx
index b6409ab411..94fdd53dc9 100644
--- a/apps/erp/app/modules/items/ui/Item/UsedIn.tsx
+++ b/apps/erp/app/modules/items/ui/Item/UsedIn.tsx
@@ -1,5 +1,6 @@
import type { Database, Json } from "@carbon/database";
import {
+ Badge,
cn,
Count,
DropdownMenu,
@@ -35,7 +36,7 @@ import { usePermissions } from "~/hooks";
import type { MethodItemType } from "~/modules/shared";
import { path } from "~/utils/path";
import { getReadableIdWithRevision } from "~/utils/string";
-import { getLinkToItemManufacturing } from "./ItemForm";
+import { getPathToMakeMethod } from "../Methods/utils";
import RevisionForm from "./RevisionForm";
export function UsedInSkeleton() {
@@ -74,6 +75,7 @@ export type UsedInNode = {
itemType?: MethodItemType;
methodType?: string;
revision?: string;
+ version?: number;
}[];
};
@@ -281,7 +283,6 @@ export function RevisionsItem({
Edit
</DropdownMenuItem> */}
<DropdownMenuItem
- destructive
onSelect={() => {
flushSync(() => {
setSelectedRevision({
@@ -294,7 +295,7 @@ export function RevisionsItem({
}}
>
<DropdownMenuIcon icon={<LuStar />} />
- Make Default
+ Set as Default Revision
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
@@ -418,6 +419,11 @@ export function UsedInItem({
/>
)}
<span className="truncate">{child.documentReadableId}</span>
+ {child.version && (
+ <Badge variant="outline" className="ml-2">
+ V{child.version}
+ </Badge>
+ )}
</Hyperlink>
))
)}
@@ -452,7 +458,11 @@ function getUseInLink(
)}?filter=itemReadableId:eq:${itemReadableIdWithRevision}`;
case "methodMaterials":
if (!child.documentId || !child.itemType) return "#";
- return getLinkToItemManufacturing(child.itemType, child.documentId);
+ return getPathToMakeMethod(
+ child.itemType,
+ child.documentParentId!,
+ child.documentId
+ );
case "purchaseOrderLines":
if (!child.documentId) return "#";
return path.to.purchaseOrder(child.documentId);
diff --git a/apps/erp/app/modules/items/ui/Parts/PartProperties.tsx b/apps/erp/app/modules/items/ui/Parts/PartProperties.tsx
index e28dc2ecd5..520d7b7844 100644
--- a/apps/erp/app/modules/items/ui/Parts/PartProperties.tsx
+++ b/apps/erp/app/modules/items/ui/Parts/PartProperties.tsx
@@ -380,19 +380,21 @@ const PartProperties = () => {
<Suspense fallback={null}>
<Await resolve={routeData?.makeMethods}>
{(makeMethods) =>
- makeMethods.data?.map((method) => {
- const isActive =
- method.status === "Active" ||
- makeMethods.data?.length === 1;
- return (
- <MethodBadge
- key={method.id}
- type={isActive ? "Make" : "Make Inactive"}
- text={`Version ${method.version}`}
- to={path.to.partMakeMethod(itemId, method.id)}
- />
- );
- })
+ 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"}
+ text={`Version ${method.version}`}
+ to={path.to.partMakeMethod(itemId, method.id)}
+ />
+ );
+ })
}
</Await>
</Suspense>
@@ -466,19 +468,19 @@ const PartProperties = () => {
<h3 className="text-xs text-muted-foreground">Files</h3>
</HStack>
{routeData?.partSummary?.modelId && (
- <HStack className="group" spacing={1}>
+ <Link
+ className="group flex items-center gap-1"
+ to={path.to.file.cadModel(routeData?.partSummary.modelId)}
+ target="_blank"
+ >
<Badge variant="secondary">
<LuMove3D className="w-3 h-3 mr-1 text-emerald-500" />
3D Model
</Badge>
- <Link
- className="group-hover:opacity-100 opacity-0 transition-opacity duration-200 w-4 h-4 text-foreground"
- to={path.to.file.cadModel(routeData?.partSummary.modelId)}
- target="_blank"
- >
+ <span className="group-hover:opacity-100 opacity-0 transition-opacity duration-200 w-4 h-4 text-foreground">
<LuExternalLink />
- </Link>
- </HStack>
+ </span>
+ </Link>
)}
<Suspense fallback={null}>
diff --git a/apps/erp/app/modules/items/ui/Tools/ToolProperties.tsx b/apps/erp/app/modules/items/ui/Tools/ToolProperties.tsx
index 2c06d2506e..bf54e156df 100644
--- a/apps/erp/app/modules/items/ui/Tools/ToolProperties.tsx
+++ b/apps/erp/app/modules/items/ui/Tools/ToolProperties.tsx
@@ -347,19 +347,21 @@ const ToolProperties = () => {
<Suspense fallback={null}>
<Await resolve={routeData?.makeMethods}>
{(makeMethods) =>
- makeMethods.data?.map((method) => {
- const isActive =
- method.status === "Active" ||
- makeMethods.data?.length === 1;
- return (
- <MethodBadge
- key={method.id}
- type={isActive ? "Make" : "Make Inactive"}
- text={`Version ${method.version}`}
- to={path.to.partMakeMethod(itemId, method.id)}
- />
- );
- })
+ 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"}
+ text={`Version ${method.version}`}
+ to={path.to.partMakeMethod(itemId, method.id)}
+ />
+ );
+ })
}
</Await>
</Suspense>
diff --git a/apps/erp/app/modules/production/production.service.ts b/apps/erp/app/modules/production/production.service.ts
index 2412922e01..cbbceea7a7 100644
--- a/apps/erp/app/modules/production/production.service.ts
+++ b/apps/erp/app/modules/production/production.service.ts
@@ -1301,6 +1301,7 @@ export async function upsertMakeMethodFromJobMethod(
userId: string;
}
) {
+ console.log("upsertMakeMethodFromJobMethod", jobMethod);
const { error } = await client.functions.invoke("get-method", {
body: {
type: "jobMakeMethodToItem",
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobBoMExplorer.tsx b/apps/erp/app/modules/production/ui/Jobs/JobBoMExplorer.tsx
index e632e951ef..01c7af45cc 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobBoMExplorer.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobBoMExplorer.tsx
@@ -231,6 +231,11 @@ function NodeText({ node }: { node: FlatTreeItem<JobMethod> }) {
<span className="font-medium text-sm truncate">
{node.data.description || node.data.itemReadableId}
</span>
+ {node.data.revision && node.data.revision !== "0" && (
+ <Badge variant="outline" className="text-xs">
+ {node.data.revision}
+ </Badge>
+ )}
</div>
);
}
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobMakeMethodTools.tsx b/apps/erp/app/modules/production/ui/Jobs/JobMakeMethodTools.tsx
index 0725c96a9e..8dd2047ae7 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobMakeMethodTools.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobMakeMethodTools.tsx
@@ -1,8 +1,9 @@
import { useCarbon } from "@carbon/auth";
-import { ValidatedForm } from "@carbon/form";
+import { SelectControlled, ValidatedForm } from "@carbon/form";
import {
Alert,
AlertTitle,
+ Badge,
Button,
Checkbox,
HStack,
@@ -47,12 +48,13 @@ import { RiProgress4Line } from "react-icons/ri";
import { ConfiguratorModal } from "~/components/Configurator/ConfiguratorForm";
import { Hidden, Item, Submit } from "~/components/Form";
import type { Tree } from "~/components/TreeView";
-import { usePermissions, useRouteData } from "~/hooks";
+import { usePermissions, useRouteData, useUser } from "~/hooks";
import type {
ConfigurationParameter,
ConfigurationParameterGroup,
} from "~/modules/items";
import { getLinkToItemDetails } from "~/modules/items/ui/Item/ItemForm";
+import MakeMethodVersionStatus from "~/modules/items/ui/Item/MakeMethodVersionStatus";
import { QuoteLineMethodForm } from "~/modules/sales/ui/Quotes/QuoteLineMethodForm";
import type { MethodItemType } from "~/modules/shared/types";
import { path } from "~/utils/path";
@@ -76,7 +78,9 @@ const JobMakeMethodTools = ({ makeMethod }: { makeMethod?: JobMakeMethod }) => {
const materialRouteData = useRouteData<{
makeMethod: JobMakeMethod;
- }>(path.to.jobMakeMethod(jobId, methodId!, methodId!));
+ }>(path.to.jobMakeMethod(jobId, methodId!));
+
+ console.log(materialRouteData);
const itemId =
materialRouteData?.makeMethod?.itemId ?? routeData?.job?.itemId;
@@ -182,6 +186,48 @@ const JobMakeMethodTools = ({ makeMethod }: { makeMethod?: JobMakeMethod }) => {
}
};
+ const {
+ company: { id: companyId },
+ } = useUser();
+ const [makeMethods, setMakeMethods] = useState<
+ { label: JSX.Element; value: string }[]
+ >([]);
+ const [selectedMakeMethod, setSelectedMakeMethod] = useState<string | null>(
+ null
+ );
+
+ const getMakeMethods = async (itemId: string) => {
+ setMakeMethods([]);
+ setSelectedMakeMethod(null);
+ if (!carbon) return;
+ const { data, error } = await carbon
+ .from("makeMethod")
+ .select("id, version, status")
+ .eq("itemId", itemId)
+ .eq("companyId", companyId)
+ .order("version", { ascending: false });
+
+ if (error) {
+ toast.error(error.message);
+ }
+
+ setMakeMethods(
+ data?.map(({ id, version, status }) => ({
+ label: (
+ <div className="flex items-center gap-2">
+ <Badge variant="outline">V{version}</Badge>{" "}
+ <MakeMethodVersionStatus status={status} />
+ </div>
+ ),
+ value: id,
+ })) ?? []
+ );
+
+ if (data?.length === 1) {
+ setSelectedMakeMethod(data[0].id);
+ }
+ };
+
return (
<>
{permissions.can("update", "production") &&
@@ -189,6 +235,14 @@ const JobMakeMethodTools = ({ makeMethod }: { makeMethod?: JobMakeMethod }) => {
<Menubar>
<HStack className="w-full justify-start">
<HStack spacing={0}>
+ <MenubarItem
+ isLoading={isGetMethodLoading}
+ isDisabled={isDisabled || isGetMethodLoading}
+ leftIcon={<LuGitBranch />}
+ onClick={getMethodModal.onOpen}
+ >
+ Get Method
+ </MenubarItem>
<MenubarItem
isDisabled={
!permissions.can("update", "parts") || isSaveMethodLoading
@@ -199,14 +253,7 @@ const JobMakeMethodTools = ({ makeMethod }: { makeMethod?: JobMakeMethod }) => {
>
Save Method
</MenubarItem>
- <MenubarItem
- isLoading={isGetMethodLoading}
- isDisabled={isDisabled || isGetMethodLoading}
- leftIcon={<LuGitBranch />}
- onClick={getMethodModal.onOpen}
- >
- Get Method
- </MenubarItem>
+
{isConfigured && isJobMethod && (
<MenubarItem
leftIcon={<LuGitMerge />}
@@ -408,13 +455,41 @@ const JobMakeMethodTools = ({ makeMethod }: { makeMethod?: JobMakeMethod }) => {
)}
<VStack spacing={4}>
+ <Alert variant="destructive">
+ <LuTriangleAlert className="h-4 w-4" />
+ <AlertTitle>
+ This will overwrite the existing manufacturing method and
+ the latest versions of all subassemblies.
+ </AlertTitle>
+ </Alert>
<Item
- name="targetId"
+ name="itemId"
label="Target Method"
type={(routeData?.job?.itemType ?? "Part") as "Part"}
+ onChange={(value) => {
+ if (value) {
+ getMakeMethods(value?.value);
+ } else {
+ setMakeMethods([]);
+ setSelectedMakeMethod(null);
+ }
+ }}
includeInactive={includeInactive === true}
replenishmentSystem="Make"
/>
+ <SelectControlled
+ name="targetId"
+ options={makeMethods}
+ label="Version"
+ value={selectedMakeMethod ?? undefined}
+ onChange={(value) => {
+ if (value) {
+ setSelectedMakeMethod(value?.value);
+ } else {
+ setSelectedMakeMethod(null);
+ }
+ }}
+ />
<div className="flex items-center space-x-2">
<Checkbox
id="include-inactive"
@@ -442,7 +517,12 @@ const JobMakeMethodTools = ({ makeMethod }: { makeMethod?: JobMakeMethod }) => {
<Button onClick={saveMethodModal.onClose} variant="secondary">
Cancel
</Button>
- <Submit variant={hasMethods ? "destructive" : "primary"}>
+ <Submit
+ variant={hasMethods ? "destructive" : "primary"}
+ isDisabled={
+ !selectedMakeMethod || !permissions.can("update", "parts")
+ }
+ >
Confirm
</Submit>
</ModalFooter>
diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteMakeMethodTools.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteMakeMethodTools.tsx
index 0bbc14c2ce..1c7d33d798 100644
--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteMakeMethodTools.tsx
+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteMakeMethodTools.tsx
@@ -1,8 +1,9 @@
import { useCarbon } from "@carbon/auth";
-import { ValidatedForm } from "@carbon/form";
+import { SelectControlled, ValidatedForm } from "@carbon/form";
import {
Alert,
AlertTitle,
+ Badge,
Button,
Checkbox,
HStack,
@@ -44,12 +45,13 @@ import { RiProgress4Line } from "react-icons/ri";
import { ConfiguratorModal } from "~/components/Configurator/ConfiguratorForm";
import { Hidden, Item, Submit } from "~/components/Form";
import type { Tree } from "~/components/TreeView";
-import { usePermissions, useRouteData } from "~/hooks";
+import { usePermissions, useRouteData, useUser } from "~/hooks";
import type {
ConfigurationParameter,
ConfigurationParameterGroup,
} from "~/modules/items";
import { getLinkToItemDetails } from "~/modules/items/ui/Item/ItemForm";
+import MakeMethodVersionStatus from "~/modules/items/ui/Item/MakeMethodVersionStatus";
import type { MethodItemType } from "~/modules/shared/types";
import { path } from "~/utils/path";
import { getMethodValidator } from "../../sales.models";
@@ -156,6 +158,48 @@ const QuoteMakeMethodTools = () => {
});
};
+ const {
+ company: { id: companyId },
+ } = useUser();
+ const [makeMethods, setMakeMethods] = useState<
+ { label: JSX.Element; value: string }[]
+ >([]);
+ const [selectedMakeMethod, setSelectedMakeMethod] = useState<string | null>(
+ null
+ );
+
+ const getMakeMethods = async (itemId: string) => {
+ setMakeMethods([]);
+ setSelectedMakeMethod(null);
+ if (!carbon) return;
+ const { data, error } = await carbon
+ .from("makeMethod")
+ .select("id, version, status")
+ .eq("itemId", itemId)
+ .eq("companyId", companyId)
+ .order("version", { ascending: false });
+
+ if (error) {
+ toast.error(error.message);
+ }
+
+ setMakeMethods(
+ data?.map(({ id, version, status }) => ({
+ label: (
+ <div className="flex items-center gap-2">
+ <Badge variant="outline">V{version}</Badge>{" "}
+ <MakeMethodVersionStatus status={status} />
+ </div>
+ ),
+ value: id,
+ })) ?? []
+ );
+
+ if (data?.length === 1) {
+ setSelectedMakeMethod(data[0].id);
+ }
+ };
+
return (
<>
{line &&
@@ -380,13 +424,41 @@ const QuoteMakeMethodTools = () => {
)}
<VStack spacing={4}>
+ <Alert variant="destructive">
+ <LuTriangleAlert className="h-4 w-4" />
+ <AlertTitle>
+ This will overwrite the existing manufacturing method and
+ the latest versions of all subassemblies.
+ </AlertTitle>
+ </Alert>
<Item
- name="targetId"
+ name="itemId"
label="Target Method"
type={(line?.itemType ?? "Part") as "Part"}
+ onChange={(value) => {
+ if (value) {
+ getMakeMethods(value?.value);
+ } else {
+ setMakeMethods([]);
+ setSelectedMakeMethod(null);
+ }
+ }}
includeInactive={includeInactive === true}
replenishmentSystem="Make"
/>
+ <SelectControlled
+ name="targetId"
+ options={makeMethods}
+ label="Version"
+ value={selectedMakeMethod ?? undefined}
+ onChange={(value) => {
+ if (value) {
+ setSelectedMakeMethod(value?.value);
+ } else {
+ setSelectedMakeMethod(null);
+ }
+ }}
+ />
<div className="flex items-center space-x-2">
<Checkbox
id="include-inactive"
diff --git a/apps/erp/app/modules/settings/ui/Integrations/IntegrationForm.tsx b/apps/erp/app/modules/settings/ui/Integrations/IntegrationForm.tsx
index 4d9dd4ac62..ef2ebc65a6 100644
--- a/apps/erp/app/modules/settings/ui/Integrations/IntegrationForm.tsx
+++ b/apps/erp/app/modules/settings/ui/Integrations/IntegrationForm.tsx
@@ -82,7 +82,7 @@ export function IntegrationForm({
<span className="text-xs text-[#878787] text-right">
<Badge variant="secondary">{integration.category}</Badge> •
- Published by CarbonOS
+ Published by Carbon
</span>
</div>
</VStack>
diff --git a/apps/erp/app/routes/file+/sales-invoice+/$id[.]pdf.tsx b/apps/erp/app/routes/file+/sales-invoice+/$id[.]pdf.tsx
index a2c0a47650..4514ac923d 100644
--- a/apps/erp/app/routes/file+/sales-invoice+/$id[.]pdf.tsx
+++ b/apps/erp/app/routes/file+/sales-invoice+/$id[.]pdf.tsx
@@ -118,7 +118,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
company={company.data}
locale={locale}
meta={{
- author: "CarbonOS",
+ author: "Carbon",
keywords: "sales order",
subject: "Sales Invoice",
}}
diff --git a/apps/erp/app/routes/file+/sales-order+/$id[.]pdf.tsx b/apps/erp/app/routes/file+/sales-order+/$id[.]pdf.tsx
index 0f1080709e..4d591d42aa 100644
--- a/apps/erp/app/routes/file+/sales-order+/$id[.]pdf.tsx
+++ b/apps/erp/app/routes/file+/sales-order+/$id[.]pdf.tsx
@@ -110,7 +110,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
company={company.data}
locale={locale}
meta={{
- author: "CarbonOS",
+ author: "Carbon",
keywords: "sales order",
subject: "Sales Order",
}}
diff --git a/apps/erp/app/routes/x+/api+/$lang.intro.tsx b/apps/erp/app/routes/x+/api+/$lang.intro.tsx
index a122de43e5..b6222109ec 100644
--- a/apps/erp/app/routes/x+/api+/$lang.intro.tsx
+++ b/apps/erp/app/routes/x+/api+/$lang.intro.tsx
@@ -16,7 +16,7 @@ export default function Route() {
<h2 className="doc-heading">Authentication</h2>
<div className="doc-section">
<article className="code-column text-foreground">
- <p>CarbonOS uses API token authentication for the public API.</p>
+ <p>Carbon uses API token authentication for the public API.</p>
<p>
First you'll need an <Link to={path.to.apiKeys}>API Key</Link>.
</p>
diff --git a/apps/erp/app/routes/x+/items+/methods+/get.tsx b/apps/erp/app/routes/x+/items+/methods+/get.tsx
index 02826a3841..e7288f7f18 100644
--- a/apps/erp/app/routes/x+/items+/methods+/get.tsx
+++ b/apps/erp/app/routes/x+/items+/methods+/get.tsx
@@ -2,7 +2,7 @@ import { getCarbonServiceRole } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { validationError, validator } from "@carbon/form";
import { json, redirect, type ActionFunctionArgs } from "@vercel/remix";
-import { copyMakeMethod, getMethodValidator } from "~/modules/items";
+import { copyItem, getMethodValidator } from "~/modules/items";
import { path, requestReferrer } from "~/utils/path";
export async function action({ request }: ActionFunctionArgs) {
@@ -19,7 +19,7 @@ export async function action({ request }: ActionFunctionArgs) {
return validationError(validation.error);
}
- const upsert = await copyMakeMethod(serviceRole, {
+ const upsert = await copyItem(serviceRole, {
...validation.data,
companyId,
userId,
diff --git a/apps/erp/app/routes/x+/items+/methods+/save.tsx b/apps/erp/app/routes/x+/items+/methods+/save.tsx
index f0755c0892..52342a0e1c 100644
--- a/apps/erp/app/routes/x+/items+/methods+/save.tsx
+++ b/apps/erp/app/routes/x+/items+/methods+/save.tsx
@@ -2,7 +2,7 @@ import { getCarbonServiceRole } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { validationError, validator } from "@carbon/form";
import { json, redirect, type ActionFunctionArgs } from "@vercel/remix";
-import { copyMakeMethod, getMethodValidator } from "~/modules/items";
+import { copyItem, getMethodValidator } from "~/modules/items";
import { path, requestReferrer } from "~/utils/path";
export async function action({ request }: ActionFunctionArgs) {
@@ -19,7 +19,7 @@ export async function action({ request }: ActionFunctionArgs) {
return validationError(validation.error);
}
- const upsert = await copyMakeMethod(serviceRole, {
+ const upsert = await copyItem(serviceRole, {
...validation.data,
companyId,
userId,
diff --git a/apps/erp/app/routes/x+/items+/methods+/version.new.tsx b/apps/erp/app/routes/x+/items+/methods+/version.new.tsx
index 91ddff9cdb..fedc745813 100644
--- a/apps/erp/app/routes/x+/items+/methods+/version.new.tsx
+++ b/apps/erp/app/routes/x+/items+/methods+/version.new.tsx
@@ -1,13 +1,14 @@
-import { assertIsPost, error } from "@carbon/auth";
+import { assertIsPost, error, getCarbonServiceRole } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { validationError, validator } from "@carbon/form";
import { json, redirect, type ActionFunctionArgs } from "@vercel/remix";
import {
+ copyMakeMethod,
makeMethodVersionValidator,
upsertMakeMethodVersion,
} from "~/modules/items";
-import { path, requestReferrer } from "~/utils/path";
+import { getPathToMakeMethod } from "~/modules/items/ui/Methods/utils";
export async function action({ request, params }: ActionFunctionArgs) {
assertIsPost(request);
@@ -42,7 +43,9 @@ export async function action({ request, params }: ActionFunctionArgs) {
}
const methodOperationId = insertMethodOperation.data?.id;
- if (!methodOperationId) {
+ const itemId = insertMethodOperation.data?.itemId;
+ const itemType = insertMethodOperation.data?.type;
+ if (!methodOperationId || !itemType) {
return json(
{
id: null,
@@ -54,11 +57,20 @@ export async function action({ request, params }: ActionFunctionArgs) {
);
}
- const redirectFrom = requestReferrer(request);
- const redirectTo = redirectFrom?.replace(
- validation.data.copyFromId,
- methodOperationId
- );
+ const copy = await copyMakeMethod(getCarbonServiceRole(), {
+ sourceId: validation.data.copyFromId,
+ targetId: methodOperationId,
+ companyId,
+ userId,
+ });
+
+ if (copy.error) {
+ return json({
+ success: false,
+ message: "Failed to copy make method",
+ });
+ }
- return redirect(redirectTo ?? path.to.items);
+ // @ts-expect-error
+ throw redirect(getPathToMakeMethod(itemType, itemId, methodOperationId));
}
diff --git a/apps/erp/app/routes/x+/items+/methods+/versions.activate.$id.tsx b/apps/erp/app/routes/x+/items+/methods+/versions.activate.$id.tsx
new file mode 100644
index 0000000000..8c45675c49
--- /dev/null
+++ b/apps/erp/app/routes/x+/items+/methods+/versions.activate.$id.tsx
@@ -0,0 +1,54 @@
+import { assertIsPost, getCarbonServiceRole } from "@carbon/auth";
+import { requirePermissions } from "@carbon/auth/auth.server";
+import { json, redirect, type ActionFunctionArgs } from "@vercel/remix";
+import { activateMethodVersion } from "~/modules/items/items.service";
+import { requestReferrer } from "~/utils/path";
+
+export async function action({ request, params }: ActionFunctionArgs) {
+ assertIsPost(request);
+ const { companyId, userId } = await requirePermissions(request, {
+ update: "parts",
+ });
+
+ const url = new URL(request.url);
+ const methodToReplace = url.searchParams.get("methodToReplace");
+
+ const { id } = params;
+ if (!id) {
+ return json({ success: false, message: "Invalid operation tool id" });
+ }
+
+ const update = await activateMethodVersion(getCarbonServiceRole(), {
+ id,
+ companyId,
+ userId,
+ });
+
+ if (update.error) {
+ return json({
+ success: false,
+ message: "Failed to activate method version",
+ });
+ }
+
+ if (!methodToReplace) {
+ return json({
+ success: false,
+ message: "Method to replace is required",
+ });
+ }
+
+ const redirectPath = requestReferrer(request)?.replace(
+ methodToReplace ?? "",
+ id ?? ""
+ );
+
+ if (!redirectPath) {
+ return json({
+ success: false,
+ message: "Failed to redirect to the correct page",
+ });
+ }
+
+ return redirect(redirectPath);
+}
diff --git a/apps/erp/app/routes/x+/job+/methods+/save.tsx b/apps/erp/app/routes/x+/job+/methods+/save.tsx
index 840c4f9c0c..dca57ce26d 100644
--- a/apps/erp/app/routes/x+/job+/methods+/save.tsx
+++ b/apps/erp/app/routes/x+/job+/methods+/save.tsx
@@ -19,6 +19,7 @@ export async function action({ request }: ActionFunctionArgs) {
const serviceRole = getCarbonServiceRole();
const validation = await validator(getJobMethodValidator).validate(formData);
+
if (validation.error) {
return validationError(validation.error);
}
diff --git a/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.make.$methodId.tsx b/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.make.$methodId.tsx
index 13bf35ae87..75180576c4 100644
--- a/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.make.$methodId.tsx
+++ b/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.make.$methodId.tsx
@@ -75,6 +75,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
}
return defer({
+ makeMethod: makeMethod.data,
materials:
materials?.data.map((m) => ({
...m,
diff --git a/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.method.$methodId.tsx b/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.method.$methodId.tsx
index 18e2ed3aa2..e94397b5e5 100644
--- a/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.method.$methodId.tsx
+++ b/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.method.$methodId.tsx
@@ -113,6 +113,7 @@ export default function QuoteMakeMethodRoute() {
<QuoteBillOfProcess
key={`bop:${methodId}`}
quoteMakeMethodId={methodId}
+ // @ts-expect-error
operations={operations}
tags={tags ?? []}
/>
@@ -120,6 +121,7 @@ export default function QuoteMakeMethodRoute() {
key={`bom:${methodId}`}
quoteMakeMethodId={methodId}
materials={materials}
+ // @ts-expect-error
operations={operations}
/>
diff --git a/apps/erp/app/routes/x+/sales+/_index.tsx b/apps/erp/app/routes/x+/sales+/_index.tsx
index dac7ee5b75..c8eeb0c9c4 100644
--- a/apps/erp/app/routes/x+/sales+/_index.tsx
+++ b/apps/erp/app/routes/x+/sales+/_index.tsx
@@ -29,13 +29,13 @@ import {
Thead,
Tr,
} from "@carbon/react";
-import { FunnelChart } from "@carbon/react/FunnelChart";
import {
ChartContainer,
ChartTooltip,
ChartTooltipContent,
type ChartConfig,
} from "@carbon/react/Chart";
+import { FunnelChart } from "@carbon/react/FunnelChart";
import { getLocalTimeZone, parseDate, today } from "@internationalized/date";
import { useDateFormatter, useNumberFormatter } from "@react-aria/i18n";
import type { DateRange } from "@react-types/datepicker";
diff --git a/apps/erp/app/utils/path.ts b/apps/erp/app/utils/path.ts
index ede69d6a26..7d6b9e89b7 100644
--- a/apps/erp/app/utils/path.ts
+++ b/apps/erp/app/utils/path.ts
@@ -257,6 +257,8 @@ export const path = {
accountingRoot: `${x}/accounting`,
accountingSubcategory: (id: string) =>
generatePath(`${x}/accounting/subcategory/${id}`),
+ activeMethodVersion: (id: string) =>
+ generatePath(`${x}/items/methods/versions/activate/${id}`),
activateGauge: (id: string) =>
generatePath(`${x}/quality/gauges/activate/${id}`),
attribute: (id: string) => generatePath(`${x}/people/attribute/${id}`),
@@ -627,13 +629,8 @@ export const path = {
jobMaterials: (id: string) => generatePath(`${x}/job/${id}/materials`),
jobMethod: (jobId: string, methodId: string) =>
generatePath(`${x}/job/${jobId}/method/${methodId}`),
- jobMakeMethod: (jobId: string, makeMethodId: string, materialId?: string) =>
- generatePath(
- `${x}/job/${jobId}/make/${makeMethodId}${
- materialId ? `?materialId=${materialId}` : ""
- }`
- ),
-
+ jobMakeMethod: (jobId: string, makeMethodId: string) =>
+ generatePath(`${x}/job/${jobId}/make/${makeMethodId}`),
jobMaterialsOrder: `${x}/job/methods/material/order`,
jobMethodGet: `${x}/job/methods/get`,
jobMethodSave: `${x}/job/methods/save`,
diff --git a/apps/mes/app/components/Feedback.tsx b/apps/mes/app/components/Feedback.tsx
index 7e51e355d6..e758a33ecb 100644
--- a/apps/mes/app/components/Feedback.tsx
+++ b/apps/mes/app/components/Feedback.tsx
@@ -158,7 +158,7 @@ const Feedback = () => {
<p className="text-sm">
Have a technical issue? Contact{" "}
<a className="text-primary" href={`mailto:${SUPPORT_EMAIL}`}>
- CarbonOS Support.
+ Carbon Support.
</a>
</p>
</VStack>
diff --git a/apps/mes/app/routes/_public+/_layout.tsx b/apps/mes/app/routes/_public+/_layout.tsx
index 07042a5ee7..69e3446830 100644
--- a/apps/mes/app/routes/_public+/_layout.tsx
+++ b/apps/mes/app/routes/_public+/_layout.tsx
@@ -13,7 +13,7 @@ export default function PublicRoute() {
className="relative z-20 flex items-center text-white"
>
<BsHexagonFill className="w-6 h-6 mr-2" />
- CarbonOS
+ Carbon
</Heading>
<div className="relative z-20 mt-auto">
diff --git a/apps/starter/app/routes/_public+/login.tsx b/apps/starter/app/routes/_public+/login.tsx
index 82fe7fa6bd..ea20ee6afa 100644
--- a/apps/starter/app/routes/_public+/login.tsx
+++ b/apps/starter/app/routes/_public+/login.tsx
@@ -97,12 +97,12 @@ export default function LoginRoute() {
<>
<div className="flex flex-col items-center justify-center">
<img
- src="/carbon-logo-dark.png"
+ src="/carbon-logo-mark.svg"
alt="Carbon Logo"
className="block dark:hidden max-w-[100px] mb-3"
/>
<img
- src="/carbon-logo-light.png"
+ src="/carbon-logo-mark.svg"
alt="Carbon Logo"
className="hidden dark:block max-w-[100px] mb-3"
/>
diff --git a/packages/database/src/swagger-docs-schema.ts b/packages/database/src/swagger-docs-schema.ts
index 3365f4b442..73ffb4f5d5 100644
--- a/packages/database/src/swagger-docs-schema.ts
+++ b/packages/database/src/swagger-docs-schema.ts
@@ -25266,6 +25266,84 @@ export default {
tags: ["customerContact"],
},
},
+ "/activeMakeMethods": {
+ get: {
+ parameters: [
+ {
+ $ref: "#/parameters/rowFilter.activeMakeMethods.id",
+ },
+ {
+ $ref: "#/parameters/rowFilter.activeMakeMethods.itemId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.activeMakeMethods.companyId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.activeMakeMethods.createdAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.activeMakeMethods.createdBy",
+ },
+ {
+ $ref: "#/parameters/rowFilter.activeMakeMethods.updatedAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.activeMakeMethods.updatedBy",
+ },
+ {
+ $ref: "#/parameters/rowFilter.activeMakeMethods.customFields",
+ },
+ {
+ $ref: "#/parameters/rowFilter.activeMakeMethods.tags",
+ },
+ {
+ $ref: "#/parameters/rowFilter.activeMakeMethods.version",
+ },
+ {
+ $ref: "#/parameters/rowFilter.activeMakeMethods.status",
+ },
+ {
+ $ref: "#/parameters/rowFilter.activeMakeMethods.rn",
+ },
+ {
+ $ref: "#/parameters/select",
+ },
+ {
+ $ref: "#/parameters/order",
+ },
+ {
+ $ref: "#/parameters/range",
+ },
+ {
+ $ref: "#/parameters/rangeUnit",
+ },
+ {
+ $ref: "#/parameters/offset",
+ },
+ {
+ $ref: "#/parameters/limit",
+ },
+ {
+ $ref: "#/parameters/preferCount",
+ },
+ ],
+ responses: {
+ "200": {
+ description: "OK",
+ schema: {
+ items: {
+ $ref: "#/definitions/activeMakeMethods",
+ },
+ type: "array",
+ },
+ },
+ "206": {
+ description: "Partial Content",
+ },
+ },
+ tags: ["activeMakeMethods"],
+ },
+ },
"/oauthCode": {
get: {
parameters: [
@@ -58235,7 +58313,7 @@ export default {
properties: {
id: {
description:
- "Note:\nThis is a Foreign Key to `supplierLocation.id`.<fk table='supplierLocation' column='id'/>",
+ "Note:\nThis is a Primary Key.<pk/>\nThis is a Foreign Key to `supplierLocation.id`.<fk table='supplierLocation' column='id'/>",
format: "text",
type: "string",
},
@@ -58284,7 +58362,7 @@ export default {
},
supplierLocationId: {
description:
- "Note:\nThis is a Primary Key.<pk/>\nThis is a Foreign Key to `supplierLocation.id`.<fk table='supplierLocation' column='id'/>",
+ "Note:\nThis is a Foreign Key to `supplierLocation.id`.<fk table='supplierLocation' column='id'/>",
format: "text",
type: "string",
},
@@ -66548,6 +66626,69 @@ export default {
},
type: "object",
},
+ activeMakeMethods: {
+ properties: {
+ id: {
+ description: "Note:\nThis is a Primary Key.<pk/>",
+ format: "text",
+ type: "string",
+ },
+ itemId: {
+ description:
+ "Note:\nThis is a Foreign Key to `item.id`.<fk table='item' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ companyId: {
+ description:
+ "Note:\nThis is a Foreign Key to `company.id`.<fk table='company' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ createdAt: {
+ format: "timestamp with time zone",
+ type: "string",
+ },
+ createdBy: {
+ description:
+ "Note:\nThis is a Foreign Key to `user.id`.<fk table='user' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ updatedAt: {
+ format: "timestamp with time zone",
+ type: "string",
+ },
+ updatedBy: {
+ format: "text",
+ type: "string",
+ },
+ customFields: {
+ format: "jsonb",
+ },
+ tags: {
+ format: "text[]",
+ items: {
+ type: "string",
+ },
+ type: "array",
+ },
+ version: {
+ format: "numeric",
+ type: "number",
+ },
+ status: {
+ enum: ["Draft", "Active", "Archived"],
+ format: 'public."makeMethodStatus"',
+ type: "string",
+ },
+ rn: {
+ format: "bigint",
+ type: "integer",
+ },
+ },
+ type: "object",
+ },
oauthCode: {
required: [
"id",
@@ -91685,6 +91826,87 @@ export default {
in: "query",
type: "string",
},
+ "body.activeMakeMethods": {
+ name: "activeMakeMethods",
+ description: "activeMakeMethods",
+ required: false,
+ in: "body",
+ schema: {
+ $ref: "#/definitions/activeMakeMethods",
+ },
+ },
+ "rowFilter.activeMakeMethods.id": {
+ name: "id",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.activeMakeMethods.itemId": {
+ name: "itemId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.activeMakeMethods.companyId": {
+ name: "companyId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.activeMakeMethods.createdAt": {
+ name: "createdAt",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.activeMakeMethods.createdBy": {
+ name: "createdBy",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.activeMakeMethods.updatedAt": {
+ name: "updatedAt",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.activeMakeMethods.updatedBy": {
+ name: "updatedBy",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.activeMakeMethods.customFields": {
+ name: "customFields",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.activeMakeMethods.tags": {
+ name: "tags",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.activeMakeMethods.version": {
+ name: "version",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.activeMakeMethods.status": {
+ name: "status",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.activeMakeMethods.rn": {
+ name: "rn",
+ required: false,
+ in: "query",
+ type: "string",
+ },
"body.oauthCode": {
name: "oauthCode",
description: "oauthCode",
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index 77569b5b7e..7b54683d95 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -8619,6 +8619,7 @@ export type Database = {
itemId: string
jobId: string
locationId: string
+ makeMethodId: string | null
modelUploadId: string | null
notes: Json | null
productionQuantity: number | null
@@ -8656,6 +8657,7 @@ export type Database = {
itemId: string
jobId: string
locationId: string
+ makeMethodId?: string | null
modelUploadId?: string | null
notes?: Json | null
productionQuantity?: number | null
@@ -8693,6 +8695,7 @@ export type Database = {
itemId?: string
jobId?: string
locationId?: string
+ makeMethodId?: string | null
modelUploadId?: string | null
notes?: Json | null
productionQuantity?: number | null
@@ -8875,6 +8878,34 @@ export type Database = {
referencedRelation: "location"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "job_makeMethodId_fkey"
+ columns: ["makeMethodId"]
+ isOneToOne: false
+ referencedRelation: "activeMakeMethods"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "job_makeMethodId_fkey"
+ columns: ["makeMethodId"]
+ isOneToOne: false
+ referencedRelation: "jobOperationsWithMakeMethods"
+ referencedColumns: ["makeMethodId"]
+ },
+ {
+ foreignKeyName: "job_makeMethodId_fkey"
+ columns: ["makeMethodId"]
+ isOneToOne: false
+ referencedRelation: "makeMethod"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "job_makeMethodId_fkey"
+ columns: ["makeMethodId"]
+ isOneToOne: false
+ referencedRelation: "quoteOperationsWithMakeMethods"
+ referencedColumns: ["makeMethodId"]
+ },
{
foreignKeyName: "job_quoteId_fkey"
columns: ["quoteId"]
@@ -9056,6 +9087,7 @@ export type Database = {
trackedEntityId: string | null
updatedAt: string | null
updatedBy: string | null
+ version: number
}
Insert: {
companyId: string
@@ -9072,6 +9104,7 @@ export type Database = {
trackedEntityId?: string | null
updatedAt?: string | null
updatedBy?: string | null
+ version?: number
}
Update: {
companyId?: string
@@ -9088,6 +9121,7 @@ export type Database = {
trackedEntityId?: string | null
updatedAt?: string | null
updatedBy?: string | null
+ version?: number
}
Relationships: [
{
@@ -11902,6 +11936,13 @@ export type Database = {
referencedRelation: "tools"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "methodMaterial_materialMakeMethodId_fkey"
+ columns: ["materialMakeMethodId"]
+ isOneToOne: false
+ referencedRelation: "activeMakeMethods"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "methodMaterial_materialMakeMethodId_fkey"
columns: ["materialMakeMethodId"]
@@ -11923,6 +11964,13 @@ export type Database = {
referencedRelation: "quoteOperationsWithMakeMethods"
referencedColumns: ["makeMethodId"]
},
+ {
+ foreignKeyName: "methodMaterial_methodId_fkey"
+ columns: ["makeMethodId"]
+ isOneToOne: false
+ referencedRelation: "activeMakeMethods"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "methodMaterial_methodId_fkey"
columns: ["makeMethodId"]
@@ -12147,6 +12195,13 @@ export type Database = {
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
+ {
+ foreignKeyName: "methodOperation_methodId_fkey"
+ columns: ["makeMethodId"]
+ isOneToOne: false
+ referencedRelation: "activeMakeMethods"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "methodOperation_methodId_fkey"
columns: ["makeMethodId"]
@@ -20979,6 +21034,7 @@ export type Database = {
id: string
internalNotes: Json | null
locationId: string | null
+ makeMethodId: string | null
opportunityId: string | null
quoteId: string
revisionId: number
@@ -21014,6 +21070,7 @@ export type Database = {
id?: string
internalNotes?: Json | null
locationId?: string | null
+ makeMethodId?: string | null
opportunityId?: string | null
quoteId: string
revisionId?: number
@@ -21049,6 +21106,7 @@ export type Database = {
id?: string
internalNotes?: Json | null
locationId?: string | null
+ makeMethodId?: string | null
opportunityId?: string | null
quoteId?: string
revisionId?: number
@@ -21248,6 +21306,34 @@ export type Database = {
referencedRelation: "location"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "quote_makeMethodId_fkey"
+ columns: ["makeMethodId"]
+ isOneToOne: false
+ referencedRelation: "activeMakeMethods"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quote_makeMethodId_fkey"
+ columns: ["makeMethodId"]
+ isOneToOne: false
+ referencedRelation: "jobOperationsWithMakeMethods"
+ referencedColumns: ["makeMethodId"]
+ },
+ {
+ foreignKeyName: "quote_makeMethodId_fkey"
+ columns: ["makeMethodId"]
+ isOneToOne: false
+ referencedRelation: "makeMethod"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quote_makeMethodId_fkey"
+ columns: ["makeMethodId"]
+ isOneToOne: false
+ referencedRelation: "quoteOperationsWithMakeMethods"
+ referencedColumns: ["makeMethodId"]
+ },
{
foreignKeyName: "quote_opportunityId_fkey"
columns: ["opportunityId"]
@@ -21911,6 +21997,7 @@ export type Database = {
tags: string[] | null
updatedAt: string | null
updatedBy: string | null
+ version: number
}
Insert: {
companyId: string
@@ -21926,6 +22013,7 @@ export type Database = {
tags?: string[] | null
updatedAt?: string | null
updatedBy?: string | null
+ version?: number
}
Update: {
companyId?: string
@@ -21941,6 +22029,7 @@ export type Database = {
tags?: string[] | null
updatedAt?: string | null
updatedBy?: string | null
+ version?: number
}
Relationships: [
{
@@ -33616,6 +33705,122 @@ export type Database = {
},
]
}
+ activeMakeMethods: {
+ Row: {
+ companyId: string | null
+ createdAt: string | null
+ createdBy: string | null
+ customFields: Json | null
+ id: string | null
+ itemId: string | null
+ rn: number | null
+ status: Database["public"]["Enums"]["makeMethodStatus"] | null
+ tags: string[] | null
+ updatedAt: string | null
+ updatedBy: string | null
+ version: number | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "method_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "method_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "method_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "method_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "method_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "method_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "method_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "method_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "method_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "method_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "consumables"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "method_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "item"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "method_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "materials"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "method_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "parts"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "method_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "tools"
+ referencedColumns: ["id"]
+ },
+ ]
+ }
companies: {
Row: {
addressLine1: string | null
@@ -37916,14 +38121,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["supplierCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["supplierCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -40143,14 +40348,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["invoiceCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["invoiceCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -40686,14 +40891,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["paymentCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["paymentCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
diff --git a/packages/database/supabase/functions/convert/index.ts b/packages/database/supabase/functions/convert/index.ts
index 185e650c84..617b30f149 100644
--- a/packages/database/supabase/functions/convert/index.ts
+++ b/packages/database/supabase/functions/convert/index.ts
@@ -19,7 +19,7 @@ const db = getDatabaseClient<DB>(pool);
const payloadValidator = z.discriminatedUnion("type", [
z.object({
- type: z.literal("salesRfqToQuote"),
+ type: z.literal("methodVersionToActive"),
id: z.string(),
companyId: z.string(),
userId: z.string(),
@@ -52,12 +52,19 @@ const payloadValidator = z.discriminatedUnion("type", [
digitalQuoteAcceptedBy: z.string().optional(),
digitalQuoteAcceptedByEmail: z.string().optional(),
}),
+
z.object({
type: z.literal("salesOrderToSalesInvoice"),
id: z.string(),
companyId: z.string(),
userId: z.string(),
}),
+ z.object({
+ type: z.literal("salesRfqToQuote"),
+ id: z.string(),
+ companyId: z.string(),
+ userId: z.string(),
+ }),
z.object({
type: z.literal("shipmentToSalesInvoice"),
id: z.string(),
@@ -108,6 +115,95 @@ serve(async (req: Request) => {
);
switch (type) {
+ case "methodVersionToActive": {
+ const makeMethodId = id;
+ const makeMethod = await client
+ .from("makeMethod")
+ .select("*")
+ .eq("id", makeMethodId)
+ .single();
+ if (makeMethod.error) throw new Error(makeMethod.error.message);
+
+ const [relatedMakeMethods, draftQuotes, draftJobs] = await Promise.all([
+ client
+ .from("makeMethod")
+ .select("*")
+ .eq("itemId", makeMethod.data?.itemId)
+ .eq("companyId", companyId),
+ client
+ .from("quote")
+ .select("*")
+ .eq("companyId", companyId)
+ .eq("status", "Draft"),
+ client
+ .from("job")
+ .select("*")
+ .eq("companyId", companyId)
+ .eq("status", "Draft"),
+ ]);
+
+ if (relatedMakeMethods.error)
+ throw new Error(relatedMakeMethods.error.message);
+
+ if (draftQuotes.error) throw new Error(draftQuotes.error.message);
+ if (draftJobs.error) throw new Error(draftJobs.error.message);
+
+ const draftMakeMethodIds = relatedMakeMethods.data
+ ?.filter(
+ (makeMethod) =>
+ makeMethod.id !== makeMethodId && makeMethod.status === "Draft"
+ )
+ ?.map((makeMethod) => makeMethod.id);
+
+ const activeMakeMethodIds = relatedMakeMethods.data
+ ?.filter(
+ (makeMethod) =>
+ makeMethod.id !== makeMethodId && makeMethod.status === "Active"
+ )
+ ?.map((makeMethod) => makeMethod.id);
+
+ const relatedMakeMethodIds = [
+ ...(draftMakeMethodIds ?? []),
+ ...(activeMakeMethodIds ?? []),
+ ];
+
+ const [methodMaterials] = await Promise.all([
+ client
+ .from("methodMaterial")
+ .select("*")
+ .in("materialMakeMethodId", relatedMakeMethodIds)
+ .eq("companyId", companyId),
+ ]);
+
+ if (methodMaterials.error)
+ throw new Error(methodMaterials.error.message);
+
+ await db.transaction().execute(async (trx) => {
+ if (activeMakeMethodIds.length > 0) {
+ await trx
+ .updateTable("makeMethod")
+ .set({ status: "Archived" })
+ .where("id", "in", activeMakeMethodIds)
+ .execute();
+ }
+
+ await trx
+ .updateTable("makeMethod")
+ .set({ status: "Active" })
+ .where("id", "=", makeMethodId)
+ .execute();
+
+ if (relatedMakeMethodIds.length > 0) {
+ await trx
+ .updateTable("methodMaterial")
+ .set({ materialMakeMethodId: makeMethodId })
+ .where("materialMakeMethodId", "in", relatedMakeMethodIds)
+ .execute();
+ }
+ });
+
+ break;
+ }
case "purchaseOrderToPurchaseInvoice": {
const purchaseOrderId = id;
const [
diff --git a/packages/database/supabase/functions/get-method/index.ts b/packages/database/supabase/functions/get-method/index.ts
index da9213945c..fb81f56a3c 100644
--- a/packages/database/supabase/functions/get-method/index.ts
+++ b/packages/database/supabase/functions/get-method/index.ts
@@ -46,6 +46,7 @@ const payloadValidator = z.object({
"itemToQuoteMakeMethod",
"jobMakeMethodToItem",
"jobToItem",
+ "makeMethodToMakeMethod",
"procedureToOperation",
"quoteLineToItem",
"quoteLineToJob",
@@ -90,13 +91,13 @@ serve(async (req: Request) => {
case "itemToItem": {
const [sourceMakeMethod, targetMakeMethod] = await Promise.all([
client
- .from("makeMethod")
+ .from("activeMakeMethods")
.select("*")
.eq("itemId", sourceId)
.eq("companyId", companyId)
.single(),
client
- .from("makeMethod")
+ .from("activeMakeMethods")
.select("*")
.eq("itemId", targetId)
.eq("companyId", companyId)
@@ -106,6 +107,13 @@ serve(async (req: Request) => {
throw new Error("Failed to get make methods");
}
+ if (
+ sourceMakeMethod.data.id === null ||
+ targetMakeMethod.data.id === null
+ ) {
+ throw new Error("Failed to get make methods");
+ }
+
const [sourceMaterials, sourceOperations] = await Promise.all([
client
.from("methodMaterial")
@@ -147,7 +155,7 @@ serve(async (req: Request) => {
...material,
productionQuantity: undefined,
id: undefined, // Let the database generate a new ID
- makeMethodId: targetMakeMethod.data.id,
+ makeMethodId: targetMakeMethod.data.id!,
createdBy: userId,
}))
)
@@ -168,7 +176,7 @@ serve(async (req: Request) => {
}) => ({
...operation,
id: undefined, // Let the database generate a new ID
- makeMethodId: targetMakeMethod.data.id,
+ makeMethodId: targetMakeMethod.data.id!,
createdBy: userId,
})
)
@@ -262,7 +270,7 @@ serve(async (req: Request) => {
const [makeMethod, jobMakeMethod, workCenters, supplierProcesses] =
await Promise.all([
client
- .from("makeMethod")
+ .from("activeMakeMethods")
.select("*")
.eq("itemId", itemId)
.eq("companyId", companyId)
@@ -294,7 +302,7 @@ serve(async (req: Request) => {
}
const [methodTrees, configurationRules] = await Promise.all([
- getMethodTree(client, makeMethod.data.id),
+ getMethodTree(client, makeMethod.data.id!),
isConfigured
? client
.from("configurationRule")
@@ -340,6 +348,11 @@ serve(async (req: Request) => {
.execute(),
trx.deleteFrom("jobMaterial").where("jobId", "=", jobId).execute(),
trx.deleteFrom("jobOperation").where("jobId", "=", jobId).execute(),
+ trx
+ .updateTable("jobMakeMethod")
+ .set({ version: makeMethod.data.version ?? 1 })
+ .where("id", "=", jobMakeMethod.data.id!)
+ .execute(),
]);
async function getConfiguredValue<T>({
@@ -834,7 +847,7 @@ serve(async (req: Request) => {
const [makeMethod, jobMakeMethod, workCenters, supplierProcesses] =
await Promise.all([
client
- .from("makeMethod")
+ .from("activeMakeMethods")
.select("*")
.eq("itemId", itemId)
.eq("companyId", companyId)
@@ -861,7 +874,7 @@ serve(async (req: Request) => {
}
const [methodTrees] = await Promise.all([
- getMethodTree(client, makeMethod.data.id),
+ getMethodTree(client, makeMethod.data.id!),
]);
if (methodTrees.error) {
@@ -889,6 +902,11 @@ serve(async (req: Request) => {
.deleteFrom("jobOperation")
.where("jobMakeMethodId", "=", jobMakeMethodId)
.execute(),
+ trx
+ .updateTable("jobMakeMethod")
+ .set({ version: makeMethod.data.version ?? 1 })
+ .where("id", "=", jobMakeMethodId)
+ .execute(),
]);
// traverse method tree and create:
@@ -1125,7 +1143,7 @@ serve(async (req: Request) => {
configurationRules,
] = await Promise.all([
client
- .from("makeMethod")
+ .from("activeMakeMethods")
.select("*")
.eq("itemId", itemId)
.eq("companyId", companyId)
@@ -1168,7 +1186,7 @@ serve(async (req: Request) => {
}
const [methodTrees] = await Promise.all([
- getMethodTree(client, makeMethod.data.id),
+ getMethodTree(client, makeMethod.data.id!),
]);
if (methodTrees.error) {
@@ -1205,6 +1223,11 @@ serve(async (req: Request) => {
.deleteFrom("quoteOperation")
.where("quoteLineId", "=", quoteLineId)
.execute(),
+ trx
+ .updateTable("quoteMakeMethod")
+ .set({ version: makeMethod.data.version ?? 1 })
+ .where("id", "=", quoteMakeMethod.data.id!)
+ .execute(),
]);
async function getConfiguredValue<
@@ -1691,7 +1714,7 @@ serve(async (req: Request) => {
const [makeMethod, quoteMakeMethod, workCenters, supplierProcesses] =
await Promise.all([
client
- .from("makeMethod")
+ .from("activeMakeMethods")
.select("*")
.eq("itemId", itemId)
.eq("companyId", companyId)
@@ -1718,7 +1741,7 @@ serve(async (req: Request) => {
}
const [methodTrees] = await Promise.all([
- getMethodTree(client, makeMethod.data.id),
+ getMethodTree(client, makeMethod.data.id!),
]);
if (methodTrees.error) {
@@ -1746,6 +1769,11 @@ serve(async (req: Request) => {
.deleteFrom("quoteOperation")
.where("quoteMakeMethodId", "=", quoteMakeMethodId)
.execute(),
+ trx
+ .updateTable("quoteMakeMethod")
+ .set({ version: makeMethod.data.version ?? 1 })
+ .where("id", "=", quoteMakeMethodId)
+ .execute(),
]);
// traverse method tree and create:
@@ -1963,13 +1991,13 @@ serve(async (req: Request) => {
}
case "jobMakeMethodToItem": {
const jobMakeMethodId = sourceId;
- const itemId = targetId;
+ const makeMethodId = targetId;
const [makeMethod, jobMakeMethod] = await Promise.all([
client
.from("makeMethod")
.select("*")
- .eq("itemId", itemId)
+ .eq("id", makeMethodId)
.eq("companyId", companyId)
.single(),
client
@@ -1988,6 +2016,8 @@ serve(async (req: Request) => {
throw new Error("Failed to get job make method");
}
+ const itemId = makeMethod.data?.itemId;
+
const [jobOperations] = await Promise.all([
client
.from("jobOperationsWithMakeMethods")
@@ -2235,13 +2265,13 @@ serve(async (req: Request) => {
if (!jobId) {
throw new Error("Invalid sourceId");
}
- const itemId = targetId;
+ const makeMethodId = targetId;
const [makeMethod, jobMakeMethod, jobOperations] = await Promise.all([
client
.from("makeMethod")
.select("*")
- .eq("itemId", itemId)
+ .eq("id", makeMethodId)
.eq("companyId", companyId)
.single(),
client
@@ -2272,6 +2302,8 @@ serve(async (req: Request) => {
throw new Error("Failed to get job operations");
}
+ const itemId = makeMethod.data?.itemId;
+
const [jobMethodTrees] = await Promise.all([
getJobMethodTree(client, jobMakeMethod.data.id),
]);
@@ -2292,7 +2324,7 @@ serve(async (req: Request) => {
});
const makeMethods = await client
- .from("makeMethod")
+ .from("activeMakeMethods")
.select("*")
.in("itemId", madeItemIds)
.eq("companyId", companyId);
@@ -2302,7 +2334,7 @@ serve(async (req: Request) => {
const makeMethodByItemId: Record<string, string> = {};
makeMethods.data?.forEach((m) => {
- makeMethodByItemId[m.itemId] = m.id;
+ makeMethodByItemId[m.itemId ?? ""] = m.id;
});
await db.transaction().execute(async (trx) => {
@@ -2494,6 +2526,169 @@ serve(async (req: Request) => {
break;
}
+ case "makeMethodToMakeMethod": {
+ const [sourceMakeMethod, targetMakeMethod] = await Promise.all([
+ client
+ .from("makeMethod")
+ .select("*")
+ .eq("id", sourceId)
+ .eq("companyId", companyId)
+ .single(),
+ client
+ .from("makeMethod")
+ .select("*")
+ .eq("id", targetId)
+ .eq("companyId", companyId)
+ .single(),
+ ]);
+ if (sourceMakeMethod.error || targetMakeMethod.error) {
+ throw new Error("Failed to get make methods");
+ }
+
+ const [sourceMaterials, sourceOperations] = await Promise.all([
+ client
+ .from("methodMaterial")
+ .select("*")
+ .eq("makeMethodId", sourceMakeMethod.data.id)
+ .eq("companyId", companyId),
+ client
+ .from("methodOperation")
+ .select(
+ "*, methodOperationTool(*), methodOperationParameter(*), methodOperationAttribute(*)"
+ )
+ .eq("makeMethodId", sourceMakeMethod.data.id)
+ .eq("companyId", companyId),
+ ]);
+
+ if (sourceMaterials.error || sourceOperations.error) {
+ throw new Error("Failed to get source materials or operations");
+ }
+
+ await db.transaction().execute(async (trx) => {
+ // Delete existing materials and operations from target method
+ await Promise.all([
+ trx
+ .deleteFrom("methodMaterial")
+ .where("makeMethodId", "=", targetMakeMethod.data.id)
+ .execute(),
+ trx
+ .deleteFrom("methodOperation")
+ .where("makeMethodId", "=", targetMakeMethod.data.id)
+ .execute(),
+ ]);
+
+ // Copy materials from source to target
+ if (sourceMaterials.data && sourceMaterials.data.length > 0) {
+ await trx
+ .insertInto("methodMaterial")
+ .values(
+ sourceMaterials.data.map((material) => ({
+ ...material,
+ productionQuantity: undefined,
+ id: undefined, // Let the database generate a new ID
+ makeMethodId: targetMakeMethod.data.id,
+ createdBy: userId,
+ }))
+ )
+ .execute();
+ }
+
+ // Copy operations from source to target
+ if (sourceOperations.data && sourceOperations.data.length > 0) {
+ const operationIds = await trx
+ .insertInto("methodOperation")
+ .values(
+ sourceOperations.data.map(
+ ({
+ methodOperationTool: _tools,
+ methodOperationParameter: _parameters,
+ methodOperationAttribute: _attributes,
+ ...operation
+ }) => ({
+ ...operation,
+ id: undefined, // Let the database generate a new ID
+ makeMethodId: targetMakeMethod.data.id,
+ createdBy: userId,
+ })
+ )
+ )
+ .returning(["id"])
+ .execute();
+
+ for await (const [
+ index,
+ operation,
+ ] of sourceOperations.data.entries()) {
+ const {
+ methodOperationTool,
+ methodOperationParameter,
+ methodOperationAttribute,
+ procedureId,
+ } = operation;
+ const operationId = operationIds[index].id;
+
+ if (
+ operationId &&
+ Array.isArray(methodOperationTool) &&
+ methodOperationTool.length > 0
+ ) {
+ await trx
+ .insertInto("methodOperationTool")
+ .values(
+ methodOperationTool.map((tool) => ({
+ toolId: tool.toolId,
+ quantity: tool.quantity,
+ operationId,
+ companyId,
+ createdBy: userId,
+ }))
+ )
+ .execute();
+ }
+
+ if (!procedureId) {
+ if (
+ Array.isArray(methodOperationParameter) &&
+ methodOperationParameter.length > 0
+ ) {
+ await trx
+ .insertInto("methodOperationParameter")
+ .values(
+ methodOperationParameter.map((param) => ({
+ operationId: operationId!,
+ key: param.key,
+ value: param.value,
+ companyId,
+ createdBy: userId,
+ }))
+ )
+ .execute();
+ }
+
+ if (
+ Array.isArray(methodOperationAttribute) &&
+ methodOperationAttribute.length > 0
+ ) {
+ await trx
+ .insertInto("methodOperationAttribute")
+ .values(
+ methodOperationAttribute.map(
+ ({ id: _id, ...attribute }) => ({
+ ...attribute,
+ operationId: operationId!,
+ companyId,
+ createdBy: userId,
+ })
+ )
+ )
+ .execute();
+ }
+ }
+ }
+ }
+ });
+ break;
+ }
case "procedureToOperation": {
const procedureId = sourceId;
const operationId = targetId;
@@ -2629,14 +2824,14 @@ serve(async (req: Request) => {
if (!quoteId || !quoteLineId) {
throw new Error("Invalid sourceId");
}
- const itemId = targetId;
+ const makeMethodId = targetId;
const [makeMethod, quoteMakeMethod, quoteOperations] =
await Promise.all([
client
.from("makeMethod")
.select("*")
- .eq("itemId", itemId)
+ .eq("id", makeMethodId)
.eq("companyId", companyId)
.single(),
client
@@ -2667,6 +2862,8 @@ serve(async (req: Request) => {
throw new Error("Failed to get quote operations");
}
+ const itemId = makeMethod.data?.itemId;
+
const [quoteMethodTrees] = await Promise.all([
getQuoteMethodTree(client, quoteMakeMethod.data.id),
]);
@@ -2691,7 +2888,7 @@ serve(async (req: Request) => {
);
const makeMethods = await client
- .from("makeMethod")
+ .from("activeMakeMethods")
.select("*")
.in("itemId", madeItemIds)
.eq("companyId", companyId);
@@ -2701,7 +2898,7 @@ serve(async (req: Request) => {
const makeMethodByItemId: Record<string, string> = {};
makeMethods.data?.forEach((m) => {
- makeMethodByItemId[m.itemId] = m.id;
+ makeMethodByItemId[m.itemId ?? ""] = m.id;
});
await db.transaction().execute(async (trx) => {
@@ -3465,13 +3662,13 @@ serve(async (req: Request) => {
}
case "quoteMakeMethodToItem": {
const quoteMakeMethodId = sourceId;
- const itemId = targetId;
+ const makeMethodId = targetId;
const [makeMethod, quoteMakeMethod] = await Promise.all([
client
.from("makeMethod")
.select("*")
- .eq("itemId", itemId)
+ .eq("id", makeMethodId)
.eq("companyId", companyId)
.single(),
client
@@ -3490,6 +3687,8 @@ serve(async (req: Request) => {
throw new Error("Failed to get quote make method");
}
+ const itemId = makeMethod.data?.itemId;
+
const [quoteOperations] = await Promise.all([
client
.from("quoteOperationsWithMakeMethods")
@@ -3533,16 +3732,20 @@ serve(async (req: Request) => {
});
const makeMethods = await client
- .from("makeMethod")
+ .from("activeMakeMethods")
.select("*")
- .in("itemId", madeItemIds);
+ .in("itemId", madeItemIds)
+ .eq("companyId", companyId);
+
if (makeMethods.error) {
throw new Error("Failed to get make methods");
}
const makeMethodByItemId: Record<string, string> = {};
makeMethods.data?.forEach((m) => {
- makeMethodByItemId[m.itemId] = m.id;
+ if (m.itemId) {
+ makeMethodByItemId[m.itemId] = m.id;
+ }
});
await db.transaction().execute(async (trx) => {
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index 77569b5b7e..7b54683d95 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -8619,6 +8619,7 @@ export type Database = {
itemId: string
jobId: string
locationId: string
+ makeMethodId: string | null
modelUploadId: string | null
notes: Json | null
productionQuantity: number | null
@@ -8656,6 +8657,7 @@ export type Database = {
itemId: string
jobId: string
locationId: string
+ makeMethodId?: string | null
modelUploadId?: string | null
notes?: Json | null
productionQuantity?: number | null
@@ -8693,6 +8695,7 @@ export type Database = {
itemId?: string
jobId?: string
locationId?: string
+ makeMethodId?: string | null
modelUploadId?: string | null
notes?: Json | null
productionQuantity?: number | null
@@ -8875,6 +8878,34 @@ export type Database = {
referencedRelation: "location"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "job_makeMethodId_fkey"
+ columns: ["makeMethodId"]
+ isOneToOne: false
+ referencedRelation: "activeMakeMethods"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "job_makeMethodId_fkey"
+ columns: ["makeMethodId"]
+ isOneToOne: false
+ referencedRelation: "jobOperationsWithMakeMethods"
+ referencedColumns: ["makeMethodId"]
+ },
+ {
+ foreignKeyName: "job_makeMethodId_fkey"
+ columns: ["makeMethodId"]
+ isOneToOne: false
+ referencedRelation: "makeMethod"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "job_makeMethodId_fkey"
+ columns: ["makeMethodId"]
+ isOneToOne: false
+ referencedRelation: "quoteOperationsWithMakeMethods"
+ referencedColumns: ["makeMethodId"]
+ },
{
foreignKeyName: "job_quoteId_fkey"
columns: ["quoteId"]
@@ -9056,6 +9087,7 @@ export type Database = {
trackedEntityId: string | null
updatedAt: string | null
updatedBy: string | null
+ version: number
}
Insert: {
companyId: string
@@ -9072,6 +9104,7 @@ export type Database = {
trackedEntityId?: string | null
updatedAt?: string | null
updatedBy?: string | null
+ version?: number
}
Update: {
companyId?: string
@@ -9088,6 +9121,7 @@ export type Database = {
trackedEntityId?: string | null
updatedAt?: string | null
updatedBy?: string | null
+ version?: number
}
Relationships: [
{
@@ -11902,6 +11936,13 @@ export type Database = {
referencedRelation: "tools"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "methodMaterial_materialMakeMethodId_fkey"
+ columns: ["materialMakeMethodId"]
+ isOneToOne: false
+ referencedRelation: "activeMakeMethods"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "methodMaterial_materialMakeMethodId_fkey"
columns: ["materialMakeMethodId"]
@@ -11923,6 +11964,13 @@ export type Database = {
referencedRelation: "quoteOperationsWithMakeMethods"
referencedColumns: ["makeMethodId"]
},
+ {
+ foreignKeyName: "methodMaterial_methodId_fkey"
+ columns: ["makeMethodId"]
+ isOneToOne: false
+ referencedRelation: "activeMakeMethods"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "methodMaterial_methodId_fkey"
columns: ["makeMethodId"]
@@ -12147,6 +12195,13 @@ export type Database = {
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
+ {
+ foreignKeyName: "methodOperation_methodId_fkey"
+ columns: ["makeMethodId"]
+ isOneToOne: false
+ referencedRelation: "activeMakeMethods"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "methodOperation_methodId_fkey"
columns: ["makeMethodId"]
@@ -20979,6 +21034,7 @@ export type Database = {
id: string
internalNotes: Json | null
locationId: string | null
+ makeMethodId: string | null
opportunityId: string | null
quoteId: string
revisionId: number
@@ -21014,6 +21070,7 @@ export type Database = {
id?: string
internalNotes?: Json | null
locationId?: string | null
+ makeMethodId?: string | null
opportunityId?: string | null
quoteId: string
revisionId?: number
@@ -21049,6 +21106,7 @@ export type Database = {
id?: string
internalNotes?: Json | null
locationId?: string | null
+ makeMethodId?: string | null
opportunityId?: string | null
quoteId?: string
revisionId?: number
@@ -21248,6 +21306,34 @@ export type Database = {
referencedRelation: "location"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "quote_makeMethodId_fkey"
+ columns: ["makeMethodId"]
+ isOneToOne: false
+ referencedRelation: "activeMakeMethods"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quote_makeMethodId_fkey"
+ columns: ["makeMethodId"]
+ isOneToOne: false
+ referencedRelation: "jobOperationsWithMakeMethods"
+ referencedColumns: ["makeMethodId"]
+ },
+ {
+ foreignKeyName: "quote_makeMethodId_fkey"
+ columns: ["makeMethodId"]
+ isOneToOne: false
+ referencedRelation: "makeMethod"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quote_makeMethodId_fkey"
+ columns: ["makeMethodId"]
+ isOneToOne: false
+ referencedRelation: "quoteOperationsWithMakeMethods"
+ referencedColumns: ["makeMethodId"]
+ },
{
foreignKeyName: "quote_opportunityId_fkey"
columns: ["opportunityId"]
@@ -21911,6 +21997,7 @@ export type Database = {
tags: string[] | null
updatedAt: string | null
updatedBy: string | null
+ version: number
}
Insert: {
companyId: string
@@ -21926,6 +22013,7 @@ export type Database = {
tags?: string[] | null
updatedAt?: string | null
updatedBy?: string | null
+ version?: number
}
Update: {
companyId?: string
@@ -21941,6 +22029,7 @@ export type Database = {
tags?: string[] | null
updatedAt?: string | null
updatedBy?: string | null
+ version?: number
}
Relationships: [
{
@@ -33616,6 +33705,122 @@ export type Database = {
},
]
}
+ activeMakeMethods: {
+ Row: {
+ companyId: string | null
+ createdAt: string | null
+ createdBy: string | null
+ customFields: Json | null
+ id: string | null
+ itemId: string | null
+ rn: number | null
+ status: Database["public"]["Enums"]["makeMethodStatus"] | null
+ tags: string[] | null
+ updatedAt: string | null
+ updatedBy: string | null
+ version: number | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "method_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "method_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "method_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "method_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "method_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "method_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "method_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "method_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "method_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "method_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "consumables"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "method_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "item"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "method_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "materials"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "method_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "parts"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "method_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "tools"
+ referencedColumns: ["id"]
+ },
+ ]
+ }
companies: {
Row: {
addressLine1: string | null
@@ -37916,14 +38121,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["supplierCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["supplierCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -40143,14 +40348,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["invoiceCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["invoiceCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -40686,14 +40891,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["paymentCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["paymentCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
diff --git a/packages/database/supabase/migrations/20250603011801_make-method-version.sql b/packages/database/supabase/migrations/20250603011801_make-method-version.sql
index 43fffeb8f3..8bc8d260f8 100644
--- a/packages/database/supabase/migrations/20250603011801_make-method-version.sql
+++ b/packages/database/supabase/migrations/20250603011801_make-method-version.sql
@@ -4,3 +4,274 @@ ALTER TABLE "makeMethod" DROP CONSTRAINT "makeMethod_unique_itemId";
ALTER TABLE "makeMethod" ADD COLUMN "version" NUMERIC(10, 2) NOT NULL DEFAULT 1;
ALTER TABLE "makeMethod" ADD COLUMN "status" "makeMethodStatus" NOT NULL DEFAULT 'Draft';
ALTER TABLE "makeMethod" ADD CONSTRAINT "makeMethod_unique_itemId_version" UNIQUE ("itemId", "version");
+
+CREATE OR REPLACE VIEW "activeMakeMethods" AS
+WITH ranked_make_methods AS (
+ SELECT
+ *,
+ ROW_NUMBER() OVER (PARTITION BY "itemId" ORDER BY
+ CASE
+ WHEN "status" = 'Active' THEN 1
+ ELSE 2
+ END,
+ "version" DESC
+ ) as rn
+ FROM "makeMethod"
+ WHERE "status" != 'Archived'
+)
+SELECT * FROM ranked_make_methods WHERE rn = 1;
+
+
+ALTER TABLE "quoteMakeMethod" ADD COLUMN "version" NUMERIC(10, 2) NOT NULL DEFAULT 1;
+ALTER TABLE "jobMakeMethod" ADD COLUMN "version" NUMERIC(10, 2) NOT NULL DEFAULT 1;
+
+
+CREATE OR REPLACE FUNCTION insert_job_make_method()
+RETURNS TRIGGER AS $$
+DECLARE
+ v_item_readable_id TEXT;
+ v_item_tracking_type TEXT;
+ v_job_make_method_id TEXT;
+ v_version NUMERIC(10, 2);
+BEGIN
+ -- Get item details
+ SELECT "readableId", "itemTrackingType" INTO v_item_readable_id, v_item_tracking_type
+ FROM "item"
+ WHERE "id" = NEW."itemId";
+
+ SELECT "version" INTO v_version FROM "activeMakeMethods" WHERE "itemId" = NEW."itemId";
+
+ -- Insert job make method first
+ INSERT INTO "jobMakeMethod" ("jobId", "itemId", "companyId", "createdBy",
+ "requiresSerialTracking", "requiresBatchTracking", "version")
+ VALUES (NEW."id", NEW."itemId", NEW."companyId", NEW."createdBy",
+ v_item_tracking_type = 'Serial', v_item_tracking_type = 'Batch', v_version)
+ RETURNING "id" INTO v_job_make_method_id;
+
+ -- Insert tracked entity with job make method ID in attributes
+ INSERT INTO "trackedEntity" ("sourceDocument", "sourceDocumentId", "sourceDocumentReadableId",
+ "quantity", "status", "companyId", "createdBy",
+ "attributes")
+ VALUES ('Item', NEW."itemId", v_item_readable_id, NEW."quantity", 'Reserved',
+ NEW."companyId", NEW."createdBy",
+ jsonb_build_object('Job', NEW."id", 'Job Make Method', v_job_make_method_id));
+
+ RETURN NEW;
+END;
+$$ LANGUAGE plpgsql;
+
+
+CREATE OR REPLACE FUNCTION insert_job_material_make_method()
+RETURNS TRIGGER AS $$
+DECLARE
+ v_item_readable_id TEXT;
+ v_item_tracking_type TEXT;
+ v_job_make_method_id TEXT;
+ v_version NUMERIC(10, 2);
+BEGIN
+ -- Get item details
+ SELECT "readableIdWithRevision", "itemTrackingType" INTO v_item_readable_id, v_item_tracking_type
+ FROM "item"
+ WHERE "id" = NEW."itemId";
+
+ SELECT "version" INTO v_version FROM "activeMakeMethods" WHERE "itemId" = NEW."itemId";
+
+ -- Insert job make method first
+ INSERT INTO "jobMakeMethod" ("jobId", "parentMaterialId", "itemId", "companyId", "createdBy",
+ "requiresSerialTracking", "requiresBatchTracking", "version")
+ VALUES (NEW."jobId", NEW."id", NEW."itemId", NEW."companyId", NEW."createdBy",
+ v_item_tracking_type = 'Serial', v_item_tracking_type = 'Batch', v_version)
+ RETURNING "id" INTO v_job_make_method_id;
+
+ -- Insert tracked entity with job make method ID in attributes
+ INSERT INTO "trackedEntity" ("sourceDocument", "sourceDocumentId", "sourceDocumentReadableId",
+ "quantity", "status", "companyId", "createdBy",
+ "attributes")
+ VALUES ('Item', NEW."itemId", v_item_readable_id, NEW."quantity", 'Reserved',
+ NEW."companyId", NEW."createdBy",
+ jsonb_build_object('Job', NEW."jobId", 'Job Make Method', v_job_make_method_id, 'Job Material', NEW."id"));
+
+ RETURN NEW;
+END;
+$$ LANGUAGE plpgsql;
+
+CREATE OR REPLACE FUNCTION update_job_material_make_method_item_id()
+ RETURNS TRIGGER AS $$
+DECLARE
+ v_item_readable_id TEXT;
+ v_item_tracking_type TEXT;
+ v_job_make_method_id TEXT;
+ v_version NUMERIC(10, 2);
+BEGIN
+ -- Get item details
+ SELECT "readableIdWithRevision", "itemTrackingType" INTO v_item_readable_id, v_item_tracking_type
+ FROM "item"
+ WHERE "id" = NEW."itemId";
+
+ SELECT "version" INTO v_version FROM "activeMakeMethods" WHERE "itemId" = NEW."itemId";
+ IF NOT EXISTS (
+ SELECT 1 FROM "jobMakeMethod"
+ WHERE "jobId" = NEW."jobId" AND "parentMaterialId" = NEW."id"
+ ) THEN
+ -- Insert job make method first
+ INSERT INTO "jobMakeMethod" ("jobId", "parentMaterialId", "itemId", "companyId", "createdBy",
+ "requiresSerialTracking", "requiresBatchTracking", "version")
+ VALUES (NEW."jobId", NEW."id", NEW."itemId", NEW."companyId", NEW."createdBy",
+ v_item_tracking_type = 'Serial', v_item_tracking_type = 'Batch', v_version)
+ RETURNING "id" INTO v_job_make_method_id;
+
+ -- Insert tracked entity with job make method ID in attributes
+ INSERT INTO "trackedEntity" ("sourceDocument", "sourceDocumentId", "sourceDocumentReadableId",
+ "quantity", "status", "companyId", "createdBy",
+ "attributes")
+ VALUES ('Item', NEW."itemId", v_item_readable_id, NEW."quantity", 'Reserved',
+ NEW."companyId", NEW."createdBy",
+ jsonb_build_object('Job', NEW."jobId", 'Job Make Method', v_job_make_method_id, 'Job Material', NEW."id"));
+ ELSE
+ -- Update job make method first
+ UPDATE "jobMakeMethod"
+ SET "itemId" = NEW."itemId",
+ "requiresSerialTracking" = (v_item_tracking_type = 'Serial'),
+ "requiresBatchTracking" = (v_item_tracking_type = 'Batch'),
+ "version" = v_version
+ WHERE "jobId" = NEW."jobId" AND "parentMaterialId" = NEW."id"
+ RETURNING "id" INTO v_job_make_method_id;
+
+ -- Insert tracked entity with job make method ID in attributes
+ INSERT INTO "trackedEntity" ("sourceDocument", "sourceDocumentId", "sourceDocumentReadableId",
+ "quantity", "status", "companyId", "createdBy",
+ "attributes")
+ VALUES ('Item', NEW."itemId", v_item_readable_id, NEW."quantity", 'Reserved',
+ NEW."companyId", NEW."createdBy",
+ jsonb_build_object('Job', NEW."jobId", 'Job Make Method', v_job_make_method_id, 'Job Material', NEW."id"));
+ END IF;
+ RETURN NEW;
+END;
+$$ LANGUAGE plpgsql;
+
+
+
+CREATE OR REPLACE VIEW "quoteMaterialWithMakeMethodId" WITH(SECURITY_INVOKER=true) AS
+ SELECT
+ qm.*,
+ qmm."id" AS "quoteMaterialMakeMethodId"
+ FROM "quoteMaterial" qm
+ LEFT JOIN "quoteMakeMethod" qmm
+ ON qmm."parentMaterialId" = qm."id";
+
+CREATE OR REPLACE VIEW "jobMaterialWithMakeMethodId" WITH(SECURITY_INVOKER=true) AS
+ SELECT
+ jm.*,
+ jmm."id" AS "jobMaterialMakeMethodId"
+ FROM "jobMaterial" jm
+ LEFT JOIN "jobMakeMethod" jmm
+ ON jmm."parentMaterialId" = jm."id";
+
+CREATE OR REPLACE VIEW "jobOperationsWithMakeMethods" WITH(SECURITY_INVOKER=true) AS
+ SELECT
+ mm.id AS "makeMethodId",
+ jo.*
+ FROM "jobOperation" jo
+ INNER JOIN "jobMakeMethod" jmm
+ ON jo."jobMakeMethodId" = jmm.id
+ LEFT JOIN "makeMethod" mm
+ ON jmm."itemId" = mm."itemId" AND jmm."version" = mm."version";
+
+
+DROP VIEW IF EXISTS "quoteOperationsWithMakeMethods";
+COMMIT;
+CREATE OR REPLACE VIEW "quoteOperationsWithMakeMethods" WITH(SECURITY_INVOKER=true) AS
+ SELECT
+ mm.id AS "makeMethodId",
+ qo.*
+ FROM "quoteOperation" qo
+ INNER JOIN "quoteMakeMethod" qmm
+ ON qo."quoteMakeMethodId" = qmm.id
+ LEFT JOIN "makeMethod" mm
+ ON qmm."itemId" = mm."itemId" AND qmm."version" = mm."version";
+
+
+
+CREATE OR REPLACE FUNCTION insert_quote_line_make_method()
+RETURNS TRIGGER AS $$
+DECLARE
+ v_version NUMERIC(10, 2);
+BEGIN
+ SELECT "version" INTO v_version FROM "activeMakeMethods" WHERE "itemId" = NEW."itemId";
+ INSERT INTO "quoteMakeMethod" (
+ "quoteId", "quoteLineId", "itemId", "companyId", "createdAt", "createdBy", "version"
+ )
+ VALUES (
+ NEW."quoteId", NEW."id", NEW."itemId", NEW."companyId", NOW(), NEW."createdBy", v_version
+ );
+ RETURN NEW;
+END;
+$$ LANGUAGE plpgsql;
+
+CREATE OR REPLACE FUNCTION insert_quote_material_make_method()
+RETURNS TRIGGER AS $$
+DECLARE
+ v_version NUMERIC(10, 2);
+BEGIN
+ SELECT "version" INTO v_version FROM "activeMakeMethods" WHERE "itemId" = NEW."itemId";
+ INSERT INTO "quoteMakeMethod" (
+ "quoteId", "quoteLineId", "parentMaterialId", "itemId", "companyId", "createdAt", "createdBy", "version"
+ )
+ VALUES (
+ NEW."quoteId", NEW."quoteLineId", NEW."id", NEW."itemId", NEW."companyId", NOW(), NEW."createdBy", v_version
+ );
+ RETURN NEW;
+END;
+$$ LANGUAGE plpgsql;
+
+CREATE OR REPLACE FUNCTION update_quote_line_make_method_item_id()
+RETURNS TRIGGER AS $$
+DECLARE
+ v_version NUMERIC(10, 2);
+BEGIN
+ SELECT "version" INTO v_version FROM "activeMakeMethods" WHERE "itemId" = NEW."itemId";
+ IF NOT EXISTS (
+ SELECT 1 FROM "quoteMakeMethod"
+ WHERE "quoteLineId" = NEW."id" AND "parentMaterialId" IS NULL
+ ) THEN
+ INSERT INTO "quoteMakeMethod" (
+ "quoteId", "quoteLineId", "itemId", "companyId", "createdAt", "createdBy", "version"
+ )
+ VALUES (
+ NEW."quoteId", NEW."id", NEW."itemId", NEW."companyId", NOW(), NEW."createdBy", v_version
+ );
+ ELSE
+ UPDATE "quoteMakeMethod"
+ SET "itemId" = NEW."itemId",
+ "version" = v_version
+ WHERE "quoteLineId" = NEW."id" AND "parentMaterialId" IS NULL;
+ END IF;
+ RETURN NEW;
+END;
+$$ LANGUAGE plpgsql;
+
+CREATE OR REPLACE FUNCTION update_quote_material_make_method_item_id()
+RETURNS TRIGGER AS $$
+DECLARE
+ v_version NUMERIC(10, 2);
+BEGIN
+ SELECT "version" INTO v_version FROM "activeMakeMethods" WHERE "itemId" = NEW."itemId";
+ IF NOT EXISTS (
+ SELECT 1 FROM "quoteMakeMethod"
+ WHERE "quoteLineId" = NEW."quoteLineId" AND "parentMaterialId" = NEW."id"
+ ) THEN
+ INSERT INTO "quoteMakeMethod" (
+ "quoteId", "quoteLineId", "parentMaterialId", "itemId", "companyId", "createdAt", "createdBy", "version"
+ )
+ VALUES (
+ NEW."quoteId", NEW."quoteLineId", NEW."id", NEW."itemId", NEW."companyId", NOW(), NEW."createdBy", v_version
+ );
+ ELSE
+ UPDATE "quoteMakeMethod"
+ SET "itemId" = NEW."itemId",
+ "version" = v_version
+ WHERE "quoteLineId" = NEW."quoteLineId" AND "parentMaterialId" = NEW."id";
+ END IF;
+ RETURN NEW;
+END;
+$$ LANGUAGE plpgsql;
\ No newline at end of file
diff --git a/packages/database/supabase/templates/magic-link.html b/packages/database/supabase/templates/magic-link.html
index c0adbd69c7..43c107dd4e 100644
--- a/packages/database/supabase/templates/magic-link.html
+++ b/packages/database/supabase/templates/magic-link.html
@@ -1,4 +1,4 @@
-<h2>Magic Link for CarbonOS</h2>
+<h2>Magic Link for Carbon</h2>
<p>Follow this link to login:</p>
diff --git a/packages/documents/src/pdf/NonConformancePDF.tsx b/packages/documents/src/pdf/NonConformancePDF.tsx
index 89f2ab1899..2e2ebc121f 100644
--- a/packages/documents/src/pdf/NonConformancePDF.tsx
+++ b/packages/documents/src/pdf/NonConformancePDF.tsx
@@ -45,7 +45,7 @@ const NonConformancePDF = ({
<Template
title={title}
meta={{
- author: meta?.author ?? "CarbonOS",
+ author: meta?.author ?? "Carbon",
keywords: meta?.keywords ?? "non-conformance report",
subject: meta?.subject ?? "Non-Conformance Report",
}}
diff --git a/packages/documents/src/pdf/PackingSlipPDF.tsx b/packages/documents/src/pdf/PackingSlipPDF.tsx
index 63ed969c66..c1fceac572 100644
--- a/packages/documents/src/pdf/PackingSlipPDF.tsx
+++ b/packages/documents/src/pdf/PackingSlipPDF.tsx
@@ -1,12 +1,10 @@
-import type { Database } from "@carbon/database";
-import { Text, View, Image } from "@react-pdf/renderer";
-import { createTw } from "react-pdf-tailwind";
import bwipjs from "@bwip-js/node";
-import {
- formatCityStatePostalCode,
- TrackedEntityAttributes,
-} from "@carbon/utils";
+import type { Database } from "@carbon/database";
import type { JSONContent } from "@carbon/react";
+import type { TrackedEntityAttributes } from "@carbon/utils";
+import { formatCityStatePostalCode } from "@carbon/utils";
+import { Image, Text, View } from "@react-pdf/renderer";
+import { createTw } from "react-pdf-tailwind";
import type { PDF } from "../types";
import { Header, Note, Summary, Template } from "./components";
@@ -100,7 +98,7 @@ const PackingSlipPDF = ({
<Template
title={title}
meta={{
- author: meta?.author ?? "CarbonOS",
+ author: meta?.author ?? "Carbon",
keywords: meta?.keywords ?? "packing slip",
subject: meta?.subject ?? "Packing Slip",
}}
diff --git a/packages/documents/src/pdf/PurchaseOrderPDF.tsx b/packages/documents/src/pdf/PurchaseOrderPDF.tsx
index 3fd159105f..203e6488f4 100644
--- a/packages/documents/src/pdf/PurchaseOrderPDF.tsx
+++ b/packages/documents/src/pdf/PurchaseOrderPDF.tsx
@@ -89,7 +89,7 @@ const PurchaseOrderPDF = ({
<Template
title={title}
meta={{
- author: meta?.author ?? "CarbonOS",
+ author: meta?.author ?? "Carbon",
keywords: meta?.keywords ?? "purchase order",
subject: meta?.subject ?? "Purchase Order",
}}
diff --git a/packages/documents/src/pdf/QuotePDF.tsx b/packages/documents/src/pdf/QuotePDF.tsx
index d7e86da393..a93a3814dc 100644
--- a/packages/documents/src/pdf/QuotePDF.tsx
+++ b/packages/documents/src/pdf/QuotePDF.tsx
@@ -128,7 +128,7 @@ const QuotePDF = ({
<Template
title={title}
meta={{
- author: meta?.author ?? "CarbonOS",
+ author: meta?.author ?? "Carbon",
keywords: meta?.keywords ?? "quote",
subject: meta?.subject ?? "Quote",
}}
diff --git a/packages/documents/src/pdf/SalesInvoicePDF.tsx b/packages/documents/src/pdf/SalesInvoicePDF.tsx
index 8ea572d822..e534e79e69 100644
--- a/packages/documents/src/pdf/SalesInvoicePDF.tsx
+++ b/packages/documents/src/pdf/SalesInvoicePDF.tsx
@@ -107,7 +107,7 @@ const SalesInvoicePDF = ({
<Template
title={title}
meta={{
- author: meta?.author ?? "CarbonOS",
+ author: meta?.author ?? "Carbon",
keywords: meta?.keywords ?? "sales invoice",
subject: meta?.subject ?? "Invoice",
}}
diff --git a/packages/documents/src/pdf/SalesOrderPDF.tsx b/packages/documents/src/pdf/SalesOrderPDF.tsx
index 02785ab806..0c467909d2 100644
--- a/packages/documents/src/pdf/SalesOrderPDF.tsx
+++ b/packages/documents/src/pdf/SalesOrderPDF.tsx
@@ -1,5 +1,5 @@
import type { Database } from "@carbon/database";
-import { Text, View, Image } from "@react-pdf/renderer";
+import { Image, Text, View } from "@react-pdf/renderer";
import { createTw } from "react-pdf-tailwind";
import type { JSONContent } from "@carbon/react";
@@ -78,7 +78,7 @@ const SalesOrderPDF = ({
<Template
title={title}
meta={{
- author: meta?.author ?? "CarbonOS",
+ author: meta?.author ?? "Carbon",
keywords: meta?.keywords ?? "sales order",
subject: meta?.subject ?? "Sales Order",
}}
diff --git a/packages/documents/src/pdf/components/Template.tsx b/packages/documents/src/pdf/components/Template.tsx
index 8f024afc18..c7c76d9cfe 100644
--- a/packages/documents/src/pdf/components/Template.tsx
+++ b/packages/documents/src/pdf/components/Template.tsx
@@ -41,7 +41,7 @@ const Template = ({ title, meta, children }: TemplateProps) => {
return (
<Document
- author={meta?.author ?? "CarbonOS"}
+ author={meta?.author ?? "Carbon"}
keywords={meta?.keywords}
subject={meta?.subject}
title={title}