Skip to content

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

refactor: convert readableId to readableIdWithRevision

Brad Barbincb47f543a3cf
diff --git a/apps/erp/app/components/RealtimeDataProvider.tsx b/apps/erp/app/components/RealtimeDataProvider.tsx
index 94a75406db..eb4ad797ff 100644
--- a/apps/erp/app/components/RealtimeDataProvider.tsx
+++ b/apps/erp/app/components/RealtimeDataProvider.tsx
@@ -55,7 +55,8 @@ const RealtimeDataProvider = ({ children }: { children: React.ReactNode }) => {
"id, readableIdWithRevision, name, type, replenishmentSystem, active, itemTrackingType"
)
.eq("companyId", companyId)
- .order("readableIdWithRevision"),
+ .order("readableId", { ascending: true })
+ .order("revision", { ascending: false }),
carbon
.from("supplier")
.select("id, name")
diff --git a/apps/erp/app/integrations/onshape/lib/OnshapeSync.tsx b/apps/erp/app/integrations/onshape/lib/OnshapeSync.tsx
index 037ac39419..565cab7516 100644
--- a/apps/erp/app/integrations/onshape/lib/OnshapeSync.tsx
+++ b/apps/erp/app/integrations/onshape/lib/OnshapeSync.tsx
@@ -39,6 +39,7 @@ interface TreeData {
id?: string;
index: string;
readableId: string;
+ readableIdWithRevision: string;
name?: string;
quantity: number;
unitOfMeasure: string;
@@ -369,7 +370,7 @@ export const OnshapeSync = ({
<div className="max-h-60 overflow-y-auto flex flex-col">
{bomRows.map((row) => {
const isSynced = row.id;
- const partId = row.readableId || row.name;
+ const partId = row.readableIdWithRevision || row.name;
return (
<div
key={row.index}
@@ -416,7 +417,7 @@ export const OnshapeSync = ({
{partId ? (
<span className="line-clamp-1">
- {row.readableId || row.name}
+ {row.readableIdWithRevision || row.name}
</span>
) : (
<Status color="red">No part ID</Status>
diff --git a/apps/erp/app/integrations/onshape/lib/data.ts b/apps/erp/app/integrations/onshape/lib/data.ts
index edf52fedd1..5f935a7656 100644
--- a/apps/erp/app/integrations/onshape/lib/data.ts
+++ b/apps/erp/app/integrations/onshape/lib/data.ts
@@ -7,6 +7,7 @@ export const onShapeDataValidator = z
id: z.string().optional(),
index: z.string(),
readableId: z.string().optional(),
+ revision: z.string().optional(),
name: z.string(),
quantity: z.number(),
replenishmentSystem: z.enum(itemReplenishmentSystems),
diff --git a/apps/erp/app/modules/inventory/inventory.service.ts b/apps/erp/app/modules/inventory/inventory.service.ts
index 0eabdcd4d0..1e54407089 100644
--- a/apps/erp/app/modules/inventory/inventory.service.ts
+++ b/apps/erp/app/modules/inventory/inventory.service.ts
@@ -111,7 +111,7 @@ export async function getInventoryItems(
if (args?.search) {
query = query.or(
- `name.ilike.%${args.search}%,readableId.ilike.%${args.search}%`
+ `name.ilike.%${args.search}%,readableIdWithRevision.ilike.%${args.search}%`
);
}
@@ -138,7 +138,7 @@ export async function getInventoryItemsCount(
if (args?.search) {
query = query.or(
- `name.ilike.%${args.search}%,readableId.ilike.%${args.search}%`
+ `name.ilike.%${args.search}%,readableIdWithRevision.ilike.%${args.search}%`
);
}
diff --git a/apps/erp/app/modules/items/ui/Item/BillOfMaterial.tsx b/apps/erp/app/modules/items/ui/Item/BillOfMaterial.tsx
index 2380ad0b56..3b1478cee1 100644
--- a/apps/erp/app/modules/items/ui/Item/BillOfMaterial.tsx
+++ b/apps/erp/app/modules/items/ui/Item/BillOfMaterial.tsx
@@ -621,7 +621,9 @@ function MaterialForm({
const item = await carbon
.from("item")
- .select("name, readableId, type, unitOfMeasureCode, defaultMethodType")
+ .select(
+ "name, readableIdWithRevision, type, unitOfMeasureCode, defaultMethodType"
+ )
.eq("id", itemId)
.eq("companyId", company.id)
.single();
@@ -634,7 +636,7 @@ function MaterialForm({
setItemData((d) => ({
...d,
itemId,
- itemReadableId: item.data?.readableId ?? "",
+ itemReadableId: item.data?.readableIdWithRevision ?? "",
description: item.data?.name ?? "",
unitOfMeasureCode: item.data?.unitOfMeasureCode ?? "EA",
methodType: item.data?.defaultMethodType ?? "Buy",
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobBillOfMaterial.tsx b/apps/erp/app/modules/production/ui/Jobs/JobBillOfMaterial.tsx
index 63ed62f3b6..030d21da66 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobBillOfMaterial.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobBillOfMaterial.tsx
@@ -685,7 +685,7 @@ function MaterialForm({
carbon
.from("item")
.select(
- "name, readableId, type, unitOfMeasureCode, defaultMethodType, itemTrackingType"
+ "name, readableIdWithRevision, type, unitOfMeasureCode, defaultMethodType, itemTrackingType"
)
.eq("id", itemId)
.eq("companyId", company.id)
@@ -701,7 +701,7 @@ function MaterialForm({
setItemData((d) => ({
...d,
itemId,
- itemReadableId: item.data?.readableId ?? "",
+ itemReadableId: item.data?.readableIdWithRevision ?? "",
description: item.data?.name ?? "",
unitCost: itemCost.data?.unitCost ?? 0,
unitOfMeasureCode: item.data?.unitOfMeasureCode ?? "EA",
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobForm.tsx b/apps/erp/app/modules/production/ui/Jobs/JobForm.tsx
index 3e7bec2c4c..426c9f58a9 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobForm.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobForm.tsx
@@ -117,7 +117,7 @@ const JobForm = ({ initialValues }: JobFormProps) => {
carbon
.from("item")
.select(
- "name, readableId, defaultMethodType, type, unitOfMeasureCode, modelUploadId"
+ "name, readableIdWithRevision, defaultMethodType, type, unitOfMeasureCode, modelUploadId"
)
.eq("id", itemId)
.eq("companyId", company.id)
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobMaterialForm.tsx b/apps/erp/app/modules/production/ui/Jobs/JobMaterialForm.tsx
index 8ca1f7ab8a..80d9d86eed 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobMaterialForm.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobMaterialForm.tsx
@@ -103,7 +103,9 @@ const JobMaterialForm = ({
const [item, itemCost] = await await Promise.all([
carbon
.from("item")
- .select("name, readableId, type, unitOfMeasureCode, defaultMethodType")
+ .select(
+ "name, readableIdWithRevision, type, unitOfMeasureCode, defaultMethodType"
+ )
.eq("id", itemId)
.single(),
carbon.from("itemCost").select("unitCost").eq("itemId", itemId).single(),
@@ -117,7 +119,7 @@ const JobMaterialForm = ({
setItemData((d) => ({
...d,
itemId,
- itemReadableId: item.data?.readableId ?? "",
+ itemReadableId: item.data?.readableIdWithRevision ?? "",
description: item.data?.name ?? "",
unitCost: itemCost.data?.unitCost ?? 0,
unitOfMeasureCode: item.data?.unitOfMeasureCode ?? "EA",
diff --git a/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLineForm.tsx b/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLineForm.tsx
index c51b7df0f3..a9833d3ca1 100644
--- a/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLineForm.tsx
+++ b/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLineForm.tsx
@@ -20,6 +20,7 @@ import {
import { useCarbon } from "@carbon/auth";
import { Combobox, ValidatedForm } from "@carbon/form";
import { useFetcher, useParams } from "@remix-run/react";
+import type { PostgrestResponse } from "@supabase/supabase-js";
import { useEffect, useMemo, useState } from "react";
import type { z } from "zod";
import {
@@ -40,7 +41,6 @@ import type { MethodItemType } from "~/modules/shared";
import type { action } from "~/routes/x+/purchase-order+/$orderId.$lineId.details";
import { path } from "~/utils/path";
import DeletePurchaseOrderLine from "./DeletePurchaseOrderLine";
-import type { PostgrestResponse } from "@supabase/supabase-js";
type PurchaseOrderLineFormProps = {
initialValues: z.infer<typeof purchaseOrderLineValidator>;
@@ -173,7 +173,7 @@ const PurchaseOrderLineForm = ({
carbon
.from("item")
.select(
- "name, readableId, type, unitOfMeasureCode, itemCost(unitCost), itemReplenishment(purchasingUnitOfMeasureCode, conversionFactor, purchasingLeadTime)"
+ "name, readableIdWithRevision, type, unitOfMeasureCode, itemCost(unitCost), itemReplenishment(purchasingUnitOfMeasureCode, conversionFactor, purchasingLeadTime)"
)
.eq("id", itemId)
.eq("companyId", company.id)
@@ -199,7 +199,7 @@ const PurchaseOrderLineForm = ({
setItemData({
itemId: itemId,
- itemReadableId: item.data?.readableId ?? "",
+ itemReadableId: item.data?.readableIdWithRevision ?? "",
description: item.data?.name ?? "",
purchaseQuantity: supplierPart?.data?.minimumOrderQuantity ?? 1,
supplierUnitPrice:
diff --git a/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteLineForm.tsx b/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteLineForm.tsx
index cd2ab44aed..e39a68f2c1 100644
--- a/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteLineForm.tsx
+++ b/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteLineForm.tsx
@@ -119,7 +119,7 @@ const SupplierQuoteLineForm = ({
const [item, supplierPart] = await Promise.all([
carbon
.from("item")
- .select("name, readableId, type, unitOfMeasureCode")
+ .select("name, readableIdWithRevision, type, unitOfMeasureCode")
.eq("id", itemId)
.eq("companyId", company.id)
.single(),
@@ -139,7 +139,7 @@ const SupplierQuoteLineForm = ({
const newItemData = {
...itemData,
itemId,
- itemReadableId: item.data?.readableId ?? "",
+ itemReadableId: item.data?.readableIdWithRevision ?? "",
description: item.data?.name ?? "",
inventoryUom: item.data?.unitOfMeasureCode ?? "EA",
purchaseUom:
diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfMaterial.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfMaterial.tsx
index 0cafa8f110..941ed826e6 100644
--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfMaterial.tsx
+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfMaterial.tsx
@@ -677,7 +677,9 @@ function MaterialForm({
const [item, itemCost] = await await Promise.all([
carbon
.from("item")
- .select("name, readableId, type, unitOfMeasureCode, defaultMethodType")
+ .select(
+ "name, readableIdWithRevision, type, unitOfMeasureCode, defaultMethodType"
+ )
.eq("id", itemId)
.eq("companyId", company.id)
.single(),
@@ -692,7 +694,7 @@ function MaterialForm({
setItemData((d) => ({
...d,
itemId,
- itemReadableId: item.data?.readableId ?? "",
+ itemReadableId: item.data?.readableIdWithRevision ?? "",
description: item.data?.name ?? "",
unitCost: itemCost.data?.unitCost ?? 0,
unitOfMeasureCode: item.data?.unitOfMeasureCode ?? "EA",
diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteLineForm.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteLineForm.tsx
index 0b212dad5a..498780523f 100644
--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteLineForm.tsx
+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteLineForm.tsx
@@ -167,7 +167,7 @@ const QuoteLineForm = ({
carbon
.from("item")
.select(
- "name, readableId, defaultMethodType, unitOfMeasureCode, modelUploadId"
+ "name, readableIdWithRevision, defaultMethodType, unitOfMeasureCode, modelUploadId"
)
.eq("id", itemId)
.eq("companyId", company.id)
@@ -193,7 +193,7 @@ const QuoteLineForm = ({
const newItemData = {
...itemData,
itemId,
- itemReadableId: item.data?.readableId ?? "",
+ itemReadableId: item.data?.readableIdWithRevision ?? "",
description: item.data?.name ?? "",
methodType: item.data?.defaultMethodType ?? "",
uom: item.data?.unitOfMeasureCode ?? "",
diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteMaterialForm.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteMaterialForm.tsx
index fb36676f36..936a0f9669 100644
--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteMaterialForm.tsx
+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteMaterialForm.tsx
@@ -101,7 +101,9 @@ const QuoteMaterialForm = ({
const [item, itemCost] = await await Promise.all([
carbon
.from("item")
- .select("name, readableId, unitOfMeasureCode, defaultMethodType")
+ .select(
+ "name, readableIdWithRevision, unitOfMeasureCode, defaultMethodType"
+ )
.eq("id", itemId)
.single(),
carbon.from("itemCost").select("unitCost").eq("itemId", itemId).single(),
@@ -115,7 +117,7 @@ const QuoteMaterialForm = ({
setItemData((d) => ({
...d,
itemId,
- itemReadableId: item.data?.readableId ?? "",
+ itemReadableId: item.data?.readableIdWithRevision ?? "",
description: item.data?.name ?? "",
unitCost: itemCost.data?.unitCost ?? 0,
unitOfMeasureCode: item.data?.unitOfMeasureCode ?? "EA",
diff --git a/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderLineForm.tsx b/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderLineForm.tsx
index 262d10484c..aceb6aecbb 100644
--- a/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderLineForm.tsx
+++ b/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderLineForm.tsx
@@ -128,7 +128,7 @@ const SalesOrderLineForm = ({
carbon
.from("item")
.select(
- "name, readableId, defaultMethodType, unitOfMeasureCode, modelUploadId"
+ "name, readableIdWithRevision, defaultMethodType, unitOfMeasureCode, modelUploadId"
)
.eq("id", itemId)
.eq("companyId", company.id)
@@ -150,7 +150,7 @@ const SalesOrderLineForm = ({
setItemData({
itemId,
- itemReadableId: item.data?.readableId,
+ itemReadableId: item.data?.readableIdWithRevision ?? "",
description: item.data?.name ?? "",
methodType: item.data?.defaultMethodType ?? "",
unitPrice: price.data?.unitSalePrice ?? 0,
diff --git a/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderLineJobs.tsx b/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderLineJobs.tsx
index 81e29528ef..0121748024 100644
--- a/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderLineJobs.tsx
+++ b/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderLineJobs.tsx
@@ -354,7 +354,9 @@ function JobDetails({ job }: { job: Job }) {
const [operations] = await Promise.all([
carbon
.from("jobOperation")
- .select("*, jobMakeMethod(parentMaterialId, item(readableId))")
+ .select(
+ "*, jobMakeMethod(parentMaterialId, item(readableIdWithRevision))"
+ )
.eq("jobId", job.id!),
]);
diff --git a/apps/erp/app/modules/shared/imports.models.ts b/apps/erp/app/modules/shared/imports.models.ts
index c9708ac3de..ed90eb9a51 100644
--- a/apps/erp/app/modules/shared/imports.models.ts
+++ b/apps/erp/app/modules/shared/imports.models.ts
@@ -242,6 +242,12 @@ export const fieldMappings = {
required: true,
type: "string",
},
+ revision: {
+ label: "Revision",
+ required: true,
+ type: "string",
+ default: "0",
+ },
name: {
label: "Short Description",
required: true,
@@ -330,6 +336,12 @@ export const fieldMappings = {
required: true,
type: "string",
},
+ revision: {
+ label: "Revision",
+ required: true,
+ type: "string",
+ default: "0",
+ },
name: {
label: "Short Description",
required: true,
@@ -418,6 +430,12 @@ export const fieldMappings = {
required: true,
type: "string",
},
+ revision: {
+ label: "Revision",
+ required: true,
+ type: "string",
+ default: "0",
+ },
name: {
label: "Short Description",
required: true,
@@ -506,6 +524,12 @@ export const fieldMappings = {
required: true,
type: "string",
},
+ revision: {
+ label: "Revision",
+ required: true,
+ type: "string",
+ default: "0",
+ },
name: {
label: "Short Description",
required: true,
@@ -594,6 +618,12 @@ export const fieldMappings = {
required: true,
type: "string",
},
+ revision: {
+ label: "Revision",
+ required: true,
+ type: "string",
+ default: "0",
+ },
name: {
label: "Short Description",
required: true,
diff --git a/apps/erp/app/routes/api+/integrations.onshape.d.$did.v.$vid.e.$eid.bom.ts b/apps/erp/app/routes/api+/integrations.onshape.d.$did.v.$vid.e.$eid.bom.ts
index 13645f360d..6aee7290e0 100644
--- a/apps/erp/app/routes/api+/integrations.onshape.d.$did.v.$vid.e.$eid.bom.ts
+++ b/apps/erp/app/routes/api+/integrations.onshape.d.$did.v.$vid.e.$eid.bom.ts
@@ -5,6 +5,7 @@ import { json } from "@vercel/remix";
import { Onshape as OnshapeConfig } from "~/integrations/onshape/config";
import { OnshapeClient } from "~/integrations/onshape/lib/client";
import { getIntegration } from "~/modules/settings/settings.service";
+import { getReadableIdWithRevision } from "~/utils/string";
export const shouldRevalidate: ShouldRevalidateFunction = () => {
return false;
@@ -95,7 +96,12 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
});
const uniquePartNumbers = new Set(
- flattenedData.map((row) => row["Part number"] || row["Name"])
+ flattenedData.map((row) =>
+ getReadableIdWithRevision(
+ row["Part number"] || row["Name"],
+ row["Revision"]
+ )
+ )
);
let itemsMap: Map<
@@ -110,12 +116,16 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
if (uniquePartNumbers.size) {
const items = await client
.from("item")
- .select("id, readableId, defaultMethodType, replenishmentSystem")
- .in("readableId", Array.from(uniquePartNumbers));
+ .select(
+ "id, readableId, readableIdWithRevision, defaultMethodType, replenishmentSystem"
+ )
+ .in("readableIdWithRevision", Array.from(uniquePartNumbers));
+
+ console.log({ items: items.data });
itemsMap = new Map(
items.data?.map((item) => [
- item.readableId,
+ item.readableIdWithRevision,
{
itemId: item.id,
defaultMethodType: item.defaultMethodType,
@@ -123,10 +133,17 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
},
])
);
+
+ console.log({ itemsMap });
}
const flattenedDataWithMetadata = flattenedData.map((row) => {
- const item = itemsMap?.get(row["Part number"] || row["Name"]);
+ const item = itemsMap?.get(
+ getReadableIdWithRevision(
+ row["Part number"] || row["Name"],
+ row["Revision"]
+ )
+ );
let replenishmentSystem = item?.replenishmentSystem;
let defaultMethodType = item?.defaultMethodType;
@@ -147,6 +164,11 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
mass: row["Mass"],
index: row["Item"],
readableId: row["Part number"],
+ revision: row["Revision"],
+ readableIdWithRevision: getReadableIdWithRevision(
+ row["Part number"],
+ row["Revision"]
+ ),
name: row["Name"],
id: item?.itemId ?? undefined,
replenishmentSystem,
@@ -156,6 +178,8 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
};
});
+ console.log({ flattenedDataWithMetadata });
+
// Return the transformed data instead of the raw response
return json({
data: {
diff --git a/apps/erp/app/routes/x+/inventory+/quantities+/$itemId.tsx b/apps/erp/app/routes/x+/inventory+/quantities+/$itemId.tsx
index 4892ab1b9b..640157c7a1 100644
--- a/apps/erp/app/routes/x+/inventory+/quantities+/$itemId.tsx
+++ b/apps/erp/app/routes/x+/inventory+/quantities+/$itemId.tsx
@@ -120,7 +120,7 @@ export default function ItemInventoryRoute() {
>
<ScrollArea className="h-[calc(100dvh-49px)]">
<InventoryItemHeader
- itemReadableId={item.readableId}
+ itemReadableId={item.readableIdWithRevision ?? item.readableId}
// @ts-ignore
itemType={item.type}
/>
diff --git a/apps/erp/app/routes/x+/job+/$jobId.details.tsx b/apps/erp/app/routes/x+/job+/$jobId.details.tsx
index 3e6c59688c..9c74478949 100644
--- a/apps/erp/app/routes/x+/job+/$jobId.details.tsx
+++ b/apps/erp/app/routes/x+/job+/$jobId.details.tsx
@@ -142,7 +142,7 @@ export default function JobDetailsRoute() {
<JobNotes
id={jobId}
title={jobData?.job.jobId ?? ""}
- subTitle={jobData?.job.itemReadableId ?? ""}
+ subTitle={jobData?.job.itemReadableIdWithRevision ?? ""}
notes={notes}
/>
@@ -272,7 +272,7 @@ function JobPurchaseOrderLineItem({ line }: { line: JobPurchaseOrderLine }) {
</VStack>
<VStack className="items-center" spacing={0}>
<span className="text-sm font-medium text-center">
- {item?.readableId}
+ {item?.readableIdWithRevision}
</span>
<span className="text-xs text-muted-foreground text-center">
{item?.name}
diff --git a/apps/erp/app/routes/x+/job+/update.tsx b/apps/erp/app/routes/x+/job+/update.tsx
index b4c91b3990..e7a70783fb 100644
--- a/apps/erp/app/routes/x+/job+/update.tsx
+++ b/apps/erp/app/routes/x+/job+/update.tsx
@@ -41,7 +41,7 @@ export async function action({ request }: ActionFunctionArgs) {
client
.from("item")
.select(
- "name, readableId, defaultMethodType, unitOfMeasureCode, modelUploadId"
+ "name, readableIdWithRevision, defaultMethodType, unitOfMeasureCode, modelUploadId"
)
.eq("id", value)
.eq("companyId", companyId)
@@ -58,6 +58,7 @@ export async function action({ request }: ActionFunctionArgs) {
.from("job")
.update({
itemId: value,
+ itemReadableId: item.data?.readableIdWithRevision ?? "",
unitOfMeasureCode: item.data?.unitOfMeasureCode ?? "EA",
quantity:
(manufacturing?.data?.lotSize ?? 0) === 0
diff --git a/apps/erp/app/routes/x+/part+/$itemId.sales.customer-parts.$customerPartToItemId.tsx b/apps/erp/app/routes/x+/part+/$itemId.sales.customer-parts.$customerPartToItemId.tsx
index 4a184f1059..ad4610b42a 100644
--- a/apps/erp/app/routes/x+/part+/$itemId.sales.customer-parts.$customerPartToItemId.tsx
+++ b/apps/erp/app/routes/x+/part+/$itemId.sales.customer-parts.$customerPartToItemId.tsx
@@ -33,7 +33,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
if (!customerPart?.data) throw new Error("Could not find customer part");
const itemData = await getItem(client, customerPart.data.itemId);
- const readableId = itemData?.data?.readableId;
+ const readableId = itemData?.data?.readableIdWithRevision;
return json({
customerPart: customerPart?.data ?? null,
diff --git a/apps/erp/app/routes/x+/part+/$itemId.sales.customer-parts.new.tsx b/apps/erp/app/routes/x+/part+/$itemId.sales.customer-parts.new.tsx
index fe60c020af..849d8d99f0 100644
--- a/apps/erp/app/routes/x+/part+/$itemId.sales.customer-parts.new.tsx
+++ b/apps/erp/app/routes/x+/part+/$itemId.sales.customer-parts.new.tsx
@@ -23,7 +23,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
if (!itemId) throw new Error("Could not find itemId");
const itemData = await getItem(client, itemId);
- const readableId = itemData?.data?.readableId;
+ const readableId = itemData?.data?.readableIdWithRevision;
return json({
readableId,
diff --git a/apps/erp/app/utils/string.ts b/apps/erp/app/utils/string.ts
index 29ea76e077..ddf6515beb 100644
--- a/apps/erp/app/utils/string.ts
+++ b/apps/erp/app/utils/string.ts
@@ -74,3 +74,14 @@ export const interpolateSequenceDate = (value: string | null) => {
return result;
};
+
+export const getReadableIdWithRevision = (
+ readableId: string,
+ revision?: string | null
+) => {
+ if (revision && revision !== "0") {
+ return `${readableId}.${revision}`;
+ }
+
+ return readableId;
+};
diff --git a/apps/mes/app/components/AdjustInventory.tsx b/apps/mes/app/components/AdjustInventory.tsx
index 9c82cfc7bf..e84a6a2c90 100644
--- a/apps/mes/app/components/AdjustInventory.tsx
+++ b/apps/mes/app/components/AdjustInventory.tsx
@@ -100,7 +100,7 @@ export function AdjustInventory({ add }: { add: boolean }) {
return items
.filter((i) => !["Batch", "Serial"].includes(i.itemTrackingType))
.map((item) => ({
- label: item.readableId,
+ label: item.readableIdWithRevision,
helper: item.name,
value: item.id,
}));
diff --git a/apps/mes/app/components/JobOperation.tsx b/apps/mes/app/components/JobOperation.tsx
index bcaa1b846a..3c3bbb0b29 100644
--- a/apps/mes/app/components/JobOperation.tsx
+++ b/apps/mes/app/components/JobOperation.tsx
@@ -4159,7 +4159,7 @@ function IssueModal({
return items
.filter((i) => !["Batch", "Serial"].includes(i.itemTrackingType))
.map((item) => ({
- label: item.readableId,
+ label: item.readableIdWithRevision,
helper: item.name,
value: item.id,
}));
diff --git a/apps/mes/app/components/RealtimeDataProvider.tsx b/apps/mes/app/components/RealtimeDataProvider.tsx
index 6d0a7a7318..599e5dc22b 100644
--- a/apps/mes/app/components/RealtimeDataProvider.tsx
+++ b/apps/mes/app/components/RealtimeDataProvider.tsx
@@ -45,7 +45,8 @@ const RealtimeDataProvider = ({ children }: { children: React.ReactNode }) => {
"id, readableIdWithRevision, name, type, replenishmentSystem, itemTrackingType, active"
)
.eq("companyId", companyId)
- .order("readableIdWithRevision"),
+ .order("readableId", { ascending: true })
+ .order("revision", { ascending: false }),
carbon
.from("employees")
diff --git a/packages/database/src/swagger-docs-schema.ts b/packages/database/src/swagger-docs-schema.ts
index 593fb4f6da..dcb16a9004 100644
--- a/packages/database/src/swagger-docs-schema.ts
+++ b/packages/database/src/swagger-docs-schema.ts
@@ -1296,9 +1296,6 @@ export default {
{
$ref: "#/parameters/rowFilter.consumables.replenishmentSystem",
},
- {
- $ref: "#/parameters/rowFilter.consumables.thumbnailPath",
- },
{
$ref: "#/parameters/rowFilter.consumables.unitOfMeasureCode",
},
@@ -1318,46 +1315,49 @@ export default {
$ref: "#/parameters/rowFilter.consumables.id",
},
{
- $ref: "#/parameters/rowFilter.consumables.itemId",
+ $ref: "#/parameters/rowFilter.consumables.companyId",
},
{
- $ref: "#/parameters/rowFilter.consumables.approved",
+ $ref: "#/parameters/rowFilter.consumables.thumbnailPath",
},
{
- $ref: "#/parameters/rowFilter.consumables.approvedBy",
+ $ref: "#/parameters/rowFilter.consumables.modelUploadId",
},
{
- $ref: "#/parameters/rowFilter.consumables.customFields",
+ $ref: "#/parameters/rowFilter.consumables.modelPath",
},
{
- $ref: "#/parameters/rowFilter.consumables.companyId",
+ $ref: "#/parameters/rowFilter.consumables.modelName",
},
{
- $ref: "#/parameters/rowFilter.consumables.createdBy",
+ $ref: "#/parameters/rowFilter.consumables.modelSize",
},
{
- $ref: "#/parameters/rowFilter.consumables.createdAt",
+ $ref: "#/parameters/rowFilter.consumables.supplierIds",
},
{
- $ref: "#/parameters/rowFilter.consumables.updatedBy",
+ $ref: "#/parameters/rowFilter.consumables.unitOfMeasure",
},
{
- $ref: "#/parameters/rowFilter.consumables.updatedAt",
+ $ref: "#/parameters/rowFilter.consumables.revisions",
},
{
- $ref: "#/parameters/rowFilter.consumables.externalId",
+ $ref: "#/parameters/rowFilter.consumables.customFields",
},
{
$ref: "#/parameters/rowFilter.consumables.tags",
},
{
- $ref: "#/parameters/rowFilter.consumables.supplierIds",
+ $ref: "#/parameters/rowFilter.consumables.createdBy",
},
{
- $ref: "#/parameters/rowFilter.consumables.unitOfMeasure",
+ $ref: "#/parameters/rowFilter.consumables.createdAt",
},
{
- $ref: "#/parameters/rowFilter.consumables.revisions",
+ $ref: "#/parameters/rowFilter.consumables.updatedBy",
+ },
+ {
+ $ref: "#/parameters/rowFilter.consumables.updatedAt",
},
{
$ref: "#/parameters/select",
@@ -9219,9 +9219,6 @@ export default {
{
$ref: "#/parameters/rowFilter.material.id",
},
- {
- $ref: "#/parameters/rowFilter.material.itemId",
- },
{
$ref: "#/parameters/rowFilter.material.materialFormId",
},
@@ -9329,9 +9326,6 @@ export default {
{
$ref: "#/parameters/rowFilter.material.id",
},
- {
- $ref: "#/parameters/rowFilter.material.itemId",
- },
{
$ref: "#/parameters/rowFilter.material.materialFormId",
},
@@ -9393,9 +9387,6 @@ export default {
{
$ref: "#/parameters/rowFilter.material.id",
},
- {
- $ref: "#/parameters/rowFilter.material.itemId",
- },
{
$ref: "#/parameters/rowFilter.material.materialFormId",
},
@@ -9865,7 +9856,7 @@ export default {
$ref: "#/parameters/rowFilter.jobs.name",
},
{
- $ref: "#/parameters/rowFilter.jobs.itemReadableId",
+ $ref: "#/parameters/rowFilter.jobs.itemReadableIdWithRevision",
},
{
$ref: "#/parameters/rowFilter.jobs.itemType",
@@ -16191,9 +16182,6 @@ export default {
{
$ref: "#/parameters/rowFilter.consumable.id",
},
- {
- $ref: "#/parameters/rowFilter.consumable.itemId",
- },
{
$ref: "#/parameters/rowFilter.consumable.approved",
},
@@ -16286,9 +16274,6 @@ export default {
{
$ref: "#/parameters/rowFilter.consumable.id",
},
- {
- $ref: "#/parameters/rowFilter.consumable.itemId",
- },
{
$ref: "#/parameters/rowFilter.consumable.approved",
},
@@ -16335,9 +16320,6 @@ export default {
{
$ref: "#/parameters/rowFilter.consumable.id",
},
- {
- $ref: "#/parameters/rowFilter.consumable.itemId",
- },
{
$ref: "#/parameters/rowFilter.consumable.approved",
},
@@ -32152,13 +32134,13 @@ export default {
$ref: "#/parameters/rowFilter.parts.readableIdWithRevision",
},
{
- $ref: "#/parameters/rowFilter.parts.thumbnailPath",
+ $ref: "#/parameters/rowFilter.parts.id",
},
{
- $ref: "#/parameters/rowFilter.parts.modelId",
+ $ref: "#/parameters/rowFilter.parts.companyId",
},
{
- $ref: "#/parameters/rowFilter.parts.autodeskUrn",
+ $ref: "#/parameters/rowFilter.parts.thumbnailPath",
},
{
$ref: "#/parameters/rowFilter.parts.modelPath",
@@ -32170,25 +32152,19 @@ export default {
$ref: "#/parameters/rowFilter.parts.modelSize",
},
{
- $ref: "#/parameters/rowFilter.parts.id",
- },
- {
- $ref: "#/parameters/rowFilter.parts.itemId",
- },
- {
- $ref: "#/parameters/rowFilter.parts.approved",
+ $ref: "#/parameters/rowFilter.parts.supplierIds",
},
{
- $ref: "#/parameters/rowFilter.parts.approvedBy",
+ $ref: "#/parameters/rowFilter.parts.unitOfMeasure",
},
{
- $ref: "#/parameters/rowFilter.parts.fromDate",
+ $ref: "#/parameters/rowFilter.parts.revisions",
},
{
- $ref: "#/parameters/rowFilter.parts.toDate",
+ $ref: "#/parameters/rowFilter.parts.customFields",
},
{
- $ref: "#/parameters/rowFilter.parts.companyId",
+ $ref: "#/parameters/rowFilter.parts.tags",
},
{
$ref: "#/parameters/rowFilter.parts.createdBy",
@@ -32202,24 +32178,6 @@ export default {
{
$ref: "#/parameters/rowFilter.parts.updatedAt",
},
- {
- $ref: "#/parameters/rowFilter.parts.customFields",
- },
- {
- $ref: "#/parameters/rowFilter.parts.externalId",
- },
- {
- $ref: "#/parameters/rowFilter.parts.tags",
- },
- {
- $ref: "#/parameters/rowFilter.parts.supplierIds",
- },
- {
- $ref: "#/parameters/rowFilter.parts.unitOfMeasure",
- },
- {
- $ref: "#/parameters/rowFilter.parts.revisions",
- },
{
$ref: "#/parameters/select",
},
@@ -32661,9 +32619,6 @@ export default {
{
$ref: "#/parameters/rowFilter.materials.replenishmentSystem",
},
- {
- $ref: "#/parameters/rowFilter.materials.thumbnailPath",
- },
{
$ref: "#/parameters/rowFilter.materials.unitOfMeasureCode",
},
@@ -32683,67 +32638,70 @@ export default {
$ref: "#/parameters/rowFilter.materials.id",
},
{
- $ref: "#/parameters/rowFilter.materials.itemId",
+ $ref: "#/parameters/rowFilter.materials.companyId",
},
{
- $ref: "#/parameters/rowFilter.materials.materialFormId",
+ $ref: "#/parameters/rowFilter.materials.thumbnailPath",
},
{
- $ref: "#/parameters/rowFilter.materials.materialSubstanceId",
+ $ref: "#/parameters/rowFilter.materials.modelUploadId",
},
{
- $ref: "#/parameters/rowFilter.materials.grade",
+ $ref: "#/parameters/rowFilter.materials.modelPath",
},
{
- $ref: "#/parameters/rowFilter.materials.dimensions",
+ $ref: "#/parameters/rowFilter.materials.modelName",
},
{
- $ref: "#/parameters/rowFilter.materials.finish",
+ $ref: "#/parameters/rowFilter.materials.modelSize",
},
{
- $ref: "#/parameters/rowFilter.materials.approved",
+ $ref: "#/parameters/rowFilter.materials.supplierIds",
},
{
- $ref: "#/parameters/rowFilter.materials.approvedBy",
+ $ref: "#/parameters/rowFilter.materials.unitOfMeasure",
},
{
- $ref: "#/parameters/rowFilter.materials.customFields",
+ $ref: "#/parameters/rowFilter.materials.revisions",
},
{
- $ref: "#/parameters/rowFilter.materials.companyId",
+ $ref: "#/parameters/rowFilter.materials.materialForm",
},
{
- $ref: "#/parameters/rowFilter.materials.createdBy",
+ $ref: "#/parameters/rowFilter.materials.materialSubstance",
},
{
- $ref: "#/parameters/rowFilter.materials.createdAt",
+ $ref: "#/parameters/rowFilter.materials.finish",
},
{
- $ref: "#/parameters/rowFilter.materials.updatedBy",
+ $ref: "#/parameters/rowFilter.materials.grade",
},
{
- $ref: "#/parameters/rowFilter.materials.updatedAt",
+ $ref: "#/parameters/rowFilter.materials.dimensions",
},
{
- $ref: "#/parameters/rowFilter.materials.externalId",
+ $ref: "#/parameters/rowFilter.materials.materialSubstanceId",
},
{
- $ref: "#/parameters/rowFilter.materials.tags",
+ $ref: "#/parameters/rowFilter.materials.materialFormId",
},
{
- $ref: "#/parameters/rowFilter.materials.materialForm",
+ $ref: "#/parameters/rowFilter.materials.customFields",
},
{
- $ref: "#/parameters/rowFilter.materials.materialSubstance",
+ $ref: "#/parameters/rowFilter.materials.tags",
},
{
- $ref: "#/parameters/rowFilter.materials.supplierIds",
+ $ref: "#/parameters/rowFilter.materials.createdBy",
},
{
- $ref: "#/parameters/rowFilter.materials.unitOfMeasure",
+ $ref: "#/parameters/rowFilter.materials.createdAt",
},
{
- $ref: "#/parameters/rowFilter.materials.revisions",
+ $ref: "#/parameters/rowFilter.materials.updatedBy",
+ },
+ {
+ $ref: "#/parameters/rowFilter.materials.updatedAt",
},
{
$ref: "#/parameters/select",
@@ -33447,9 +33405,6 @@ export default {
{
$ref: "#/parameters/rowFilter.tool.id",
},
- {
- $ref: "#/parameters/rowFilter.tool.itemId",
- },
{
$ref: "#/parameters/rowFilter.tool.approved",
},
@@ -33542,9 +33497,6 @@ export default {
{
$ref: "#/parameters/rowFilter.tool.id",
},
- {
- $ref: "#/parameters/rowFilter.tool.itemId",
- },
{
$ref: "#/parameters/rowFilter.tool.approved",
},
@@ -33591,9 +33543,6 @@ export default {
{
$ref: "#/parameters/rowFilter.tool.id",
},
- {
- $ref: "#/parameters/rowFilter.tool.itemId",
- },
{
$ref: "#/parameters/rowFilter.tool.approved",
},
@@ -34320,9 +34269,6 @@ export default {
{
$ref: "#/parameters/rowFilter.tools.replenishmentSystem",
},
- {
- $ref: "#/parameters/rowFilter.tools.thumbnailPath",
- },
{
$ref: "#/parameters/rowFilter.tools.unitOfMeasureCode",
},
@@ -34342,46 +34288,46 @@ export default {
$ref: "#/parameters/rowFilter.tools.id",
},
{
- $ref: "#/parameters/rowFilter.tools.itemId",
+ $ref: "#/parameters/rowFilter.tools.companyId",
},
{
- $ref: "#/parameters/rowFilter.tools.approved",
+ $ref: "#/parameters/rowFilter.tools.thumbnailPath",
},
{
- $ref: "#/parameters/rowFilter.tools.approvedBy",
+ $ref: "#/parameters/rowFilter.tools.modelPath",
},
{
- $ref: "#/parameters/rowFilter.tools.customFields",
+ $ref: "#/parameters/rowFilter.tools.modelName",
},
{
- $ref: "#/parameters/rowFilter.tools.companyId",
+ $ref: "#/parameters/rowFilter.tools.modelSize",
},
{
- $ref: "#/parameters/rowFilter.tools.createdBy",
+ $ref: "#/parameters/rowFilter.tools.supplierIds",
},
{
- $ref: "#/parameters/rowFilter.tools.createdAt",
+ $ref: "#/parameters/rowFilter.tools.unitOfMeasure",
},
{
- $ref: "#/parameters/rowFilter.tools.updatedBy",
+ $ref: "#/parameters/rowFilter.tools.revisions",
},
{
- $ref: "#/parameters/rowFilter.tools.updatedAt",
+ $ref: "#/parameters/rowFilter.tools.customFields",
},
{
- $ref: "#/parameters/rowFilter.tools.externalId",
+ $ref: "#/parameters/rowFilter.tools.tags",
},
{
- $ref: "#/parameters/rowFilter.tools.tags",
+ $ref: "#/parameters/rowFilter.tools.createdBy",
},
{
- $ref: "#/parameters/rowFilter.tools.supplierIds",
+ $ref: "#/parameters/rowFilter.tools.createdAt",
},
{
- $ref: "#/parameters/rowFilter.tools.unitOfMeasure",
+ $ref: "#/parameters/rowFilter.tools.updatedBy",
},
{
- $ref: "#/parameters/rowFilter.tools.revisions",
+ $ref: "#/parameters/rowFilter.tools.updatedAt",
},
{
$ref: "#/parameters/select",
@@ -50001,9 +49947,6 @@ export default {
{
$ref: "#/parameters/rowFilter.part.id",
},
- {
- $ref: "#/parameters/rowFilter.part.itemId",
- },
{
$ref: "#/parameters/rowFilter.part.approved",
},
@@ -50102,9 +50045,6 @@ export default {
{
$ref: "#/parameters/rowFilter.part.id",
},
- {
- $ref: "#/parameters/rowFilter.part.itemId",
- },
{
$ref: "#/parameters/rowFilter.part.approved",
},
@@ -50157,9 +50097,6 @@ export default {
{
$ref: "#/parameters/rowFilter.part.id",
},
- {
- $ref: "#/parameters/rowFilter.part.itemId",
- },
{
$ref: "#/parameters/rowFilter.part.approved",
},
@@ -51144,6 +51081,63 @@ export default {
tags: ["(rpc) get_permission_companies"],
},
},
+ "/rpc/get_tool_details": {
+ get: {
+ parameters: [
+ {
+ format: "text",
+ in: "query",
+ name: "item_id",
+ required: true,
+ type: "string",
+ },
+ ],
+ produces: [
+ "application/json",
+ "application/vnd.pgrst.object+json;nulls=stripped",
+ "application/vnd.pgrst.object+json",
+ ],
+ responses: {
+ "200": {
+ description: "OK",
+ },
+ },
+ tags: ["(rpc) get_tool_details"],
+ },
+ post: {
+ parameters: [
+ {
+ in: "body",
+ name: "args",
+ required: true,
+ schema: {
+ properties: {
+ item_id: {
+ format: "text",
+ type: "string",
+ },
+ },
+ required: ["item_id"],
+ type: "object",
+ },
+ },
+ {
+ $ref: "#/parameters/preferParams",
+ },
+ ],
+ produces: [
+ "application/json",
+ "application/vnd.pgrst.object+json;nulls=stripped",
+ "application/vnd.pgrst.object+json",
+ ],
+ responses: {
+ "200": {
+ description: "OK",
+ },
+ },
+ tags: ["(rpc) get_tool_details"],
+ },
+ },
"/rpc/get_inventory_quantities": {
get: {
parameters: [
@@ -52538,6 +52532,63 @@ export default {
tags: ["(rpc) get_next_numeric_sequence"],
},
},
+ "/rpc/get_part_details": {
+ get: {
+ parameters: [
+ {
+ format: "text",
+ in: "query",
+ name: "item_id",
+ required: true,
+ type: "string",
+ },
+ ],
+ produces: [
+ "application/json",
+ "application/vnd.pgrst.object+json;nulls=stripped",
+ "application/vnd.pgrst.object+json",
+ ],
+ responses: {
+ "200": {
+ description: "OK",
+ },
+ },
+ tags: ["(rpc) get_part_details"],
+ },
+ post: {
+ parameters: [
+ {
+ in: "body",
+ name: "args",
+ required: true,
+ schema: {
+ properties: {
+ item_id: {
+ format: "text",
+ type: "string",
+ },
+ },
+ required: ["item_id"],
+ type: "object",
+ },
+ },
+ {
+ $ref: "#/parameters/preferParams",
+ },
+ ],
+ produces: [
+ "application/json",
+ "application/vnd.pgrst.object+json;nulls=stripped",
+ "application/vnd.pgrst.object+json",
+ ],
+ responses: {
+ "200": {
+ description: "OK",
+ },
+ },
+ tags: ["(rpc) get_part_details"],
+ },
+ },
"/rpc/xid_pid": {
get: {
parameters: [
@@ -53941,6 +53992,63 @@ export default {
tags: ["(rpc) get_next_sequence"],
},
},
+ "/rpc/get_consumable_details": {
+ get: {
+ parameters: [
+ {
+ format: "text",
+ in: "query",
+ name: "item_id",
+ required: true,
+ type: "string",
+ },
+ ],
+ produces: [
+ "application/json",
+ "application/vnd.pgrst.object+json;nulls=stripped",
+ "application/vnd.pgrst.object+json",
+ ],
+ responses: {
+ "200": {
+ description: "OK",
+ },
+ },
+ tags: ["(rpc) get_consumable_details"],
+ },
+ post: {
+ parameters: [
+ {
+ in: "body",
+ name: "args",
+ required: true,
+ schema: {
+ properties: {
+ item_id: {
+ format: "text",
+ type: "string",
+ },
+ },
+ required: ["item_id"],
+ type: "object",
+ },
+ },
+ {
+ $ref: "#/parameters/preferParams",
+ },
+ ],
+ produces: [
+ "application/json",
+ "application/vnd.pgrst.object+json;nulls=stripped",
+ "application/vnd.pgrst.object+json",
+ ],
+ responses: {
+ "200": {
+ description: "OK",
+ },
+ },
+ tags: ["(rpc) get_consumable_details"],
+ },
+ },
"/rpc/nanoid": {
get: {
parameters: [
@@ -54426,6 +54534,63 @@ export default {
tags: ["(rpc) get_active_job_operations_by_employee"],
},
},
+ "/rpc/get_material_details": {
+ get: {
+ parameters: [
+ {
+ format: "text",
+ in: "query",
+ name: "item_id",
+ required: true,
+ type: "string",
+ },
+ ],
+ produces: [
+ "application/json",
+ "application/vnd.pgrst.object+json;nulls=stripped",
+ "application/vnd.pgrst.object+json",
+ ],
+ responses: {
+ "200": {
+ description: "OK",
+ },
+ },
+ tags: ["(rpc) get_material_details"],
+ },
+ post: {
+ parameters: [
+ {
+ in: "body",
+ name: "args",
+ required: true,
+ schema: {
+ properties: {
+ item_id: {
+ format: "text",
+ type: "string",
+ },
+ },
+ required: ["item_id"],
+ type: "object",
+ },
+ },
+ {
+ $ref: "#/parameters/preferParams",
+ },
+ ],
+ produces: [
+ "application/json",
+ "application/vnd.pgrst.object+json;nulls=stripped",
+ "application/vnd.pgrst.object+json",
+ ],
+ responses: {
+ "200": {
+ description: "OK",
+ },
+ },
+ tags: ["(rpc) get_material_details"],
+ },
+ },
"/rpc/xid_counter": {
get: {
parameters: [
@@ -55434,10 +55599,6 @@ export default {
format: 'public."itemReplenishmentSystem"',
type: "string",
},
- thumbnailPath: {
- format: "text",
- type: "string",
- },
unitOfMeasureCode: {
format: "text",
type: "string",
@@ -55462,52 +55623,46 @@ export default {
format: "text",
type: "string",
},
- itemId: {
+ companyId: {
description:
- "Note:\nThis is a Foreign Key to `item.id`.<fk table='item' column='id'/>",
+ "Note:\nThis is a Foreign Key to `company.id`.<fk table='company' column='id'/>",
format: "text",
type: "string",
},
- approved: {
- format: "boolean",
- type: "boolean",
- },
- approvedBy: {
- description:
- "Note:\nThis is a Foreign Key to `user.id`.<fk table='user' column='id'/>",
+ thumbnailPath: {
format: "text",
type: "string",
},
- customFields: {
- format: "jsonb",
- },
- companyId: {
+ modelUploadId: {
description:
- "Note:\nThis is a Primary Key.<pk/>\nThis is a Foreign Key to `company.id`.<fk table='company' column='id'/>",
+ "Note:\nThis is a Foreign Key to `modelUpload.id`.<fk table='modelUpload' column='id'/>",
format: "text",
type: "string",
},
- createdBy: {
- description:
- "Note:\nThis is a Foreign Key to `user.id`.<fk table='user' column='id'/>",
+ modelPath: {
format: "text",
type: "string",
},
- createdAt: {
- format: "timestamp with time zone",
+ modelName: {
+ format: "text",
type: "string",
},
- updatedBy: {
- description:
- "Note:\nThis is a Foreign Key to `user.id`.<fk table='user' column='id'/>",
+ modelSize: {
+ format: "bigint",
+ type: "integer",
+ },
+ supplierIds: {
format: "text",
type: "string",
},
- updatedAt: {
- format: "timestamp with time zone",
+ unitOfMeasure: {
+ format: "text",
type: "string",
},
- externalId: {
+ revisions: {
+ format: "json",
+ },
+ customFields: {
format: "jsonb",
},
tags: {
@@ -55517,16 +55672,25 @@ export default {
},
type: "array",
},
- supplierIds: {
+ createdBy: {
+ description:
+ "Note:\nThis is a Foreign Key to `user.id`.<fk table='user' column='id'/>",
format: "text",
type: "string",
},
- unitOfMeasure: {
+ createdAt: {
+ format: "timestamp with time zone",
+ type: "string",
+ },
+ updatedBy: {
+ description:
+ "Note:\nThis is a Foreign Key to `user.id`.<fk table='user' column='id'/>",
format: "text",
type: "string",
},
- revisions: {
- format: "json",
+ updatedAt: {
+ format: "timestamp with time zone",
+ type: "string",
},
},
type: "object",
@@ -55834,7 +55998,7 @@ export default {
},
toolId: {
description:
- "Note:\nThis is a Foreign Key to `tool.itemId`.<fk table='tool' column='itemId'/>",
+ "Note:\nThis is a Foreign Key to `item.id`.<fk table='item' column='id'/>",
format: "text",
type: "string",
},
@@ -59054,12 +59218,6 @@ export default {
format: "text",
type: "string",
},
- itemId: {
- description:
- "Note:\nThis is a Foreign Key to `item.id`.<fk table='item' column='id'/>",
- format: "text",
- type: "string",
- },
materialFormId: {
description:
"Note:\nThis is a Foreign Key to `materialForm.id`.<fk table='materialForm' column='id'/>",
@@ -59461,7 +59619,7 @@ export default {
format: "text",
type: "string",
},
- itemReadableId: {
+ itemReadableIdWithRevision: {
format: "text",
type: "string",
},
@@ -61461,7 +61619,7 @@ export default {
},
toolId: {
description:
- "Note:\nThis is a Foreign Key to `tool.itemId`.<fk table='tool' column='itemId'/>",
+ "Note:\nThis is a Foreign Key to `item.id`.<fk table='item' column='id'/>",
format: "text",
type: "string",
},
@@ -62444,12 +62602,6 @@ export default {
format: "text",
type: "string",
},
- itemId: {
- description:
- "Note:\nThis is a Foreign Key to `item.id`.<fk table='item' column='id'/>",
- format: "text",
- type: "string",
- },
approved: {
default: false,
format: "boolean",
@@ -69658,16 +69810,18 @@ export default {
format: "text",
type: "string",
},
- thumbnailPath: {
+ id: {
+ description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
},
- modelId: {
- description: "Note:\nThis is a Primary Key.<pk/>",
+ companyId: {
+ description:
+ "Note:\nThis is a Foreign Key to `company.id`.<fk table='company' column='id'/>",
format: "text",
type: "string",
},
- autodeskUrn: {
+ thumbnailPath: {
format: "text",
type: "string",
},
@@ -69683,40 +69837,26 @@ export default {
format: "bigint",
type: "integer",
},
- 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'/>",
+ supplierIds: {
format: "text",
type: "string",
},
- approved: {
- format: "boolean",
- type: "boolean",
- },
- approvedBy: {
- description:
- "Note:\nThis is a Foreign Key to `user.id`.<fk table='user' column='id'/>",
+ unitOfMeasure: {
format: "text",
type: "string",
},
- fromDate: {
- format: "date",
- type: "string",
+ revisions: {
+ format: "json",
},
- toDate: {
- format: "date",
- type: "string",
+ customFields: {
+ format: "jsonb",
},
- companyId: {
- description:
- "Note:\nThis is a Primary Key.<pk/>\nThis is a Foreign Key to `company.id`.<fk table='company' column='id'/>",
- format: "text",
- type: "string",
+ tags: {
+ format: "text[]",
+ items: {
+ type: "string",
+ },
+ type: "array",
},
createdBy: {
description:
@@ -69738,30 +69878,6 @@ export default {
format: "timestamp with time zone",
type: "string",
},
- customFields: {
- format: "jsonb",
- },
- externalId: {
- format: "jsonb",
- },
- tags: {
- format: "text[]",
- items: {
- type: "string",
- },
- type: "array",
- },
- supplierIds: {
- format: "text",
- type: "string",
- },
- unitOfMeasure: {
- format: "text",
- type: "string",
- },
- revisions: {
- format: "json",
- },
},
type: "object",
},
@@ -69929,10 +70045,6 @@ export default {
format: 'public."itemReplenishmentSystem"',
type: "string",
},
- thumbnailPath: {
- format: "text",
- type: "string",
- },
unitOfMeasureCode: {
format: "text",
type: "string",
@@ -69957,76 +70069,78 @@ export default {
format: "text",
type: "string",
},
- itemId: {
+ companyId: {
description:
- "Note:\nThis is a Foreign Key to `item.id`.<fk table='item' column='id'/>",
+ "Note:\nThis is a Foreign Key to `company.id`.<fk table='company' column='id'/>",
format: "text",
type: "string",
},
- materialFormId: {
- description:
- "Note:\nThis is a Foreign Key to `materialForm.id`.<fk table='materialForm' column='id'/>",
+ thumbnailPath: {
format: "text",
type: "string",
},
- materialSubstanceId: {
+ modelUploadId: {
description:
- "Note:\nThis is a Foreign Key to `materialSubstance.id`.<fk table='materialSubstance' column='id'/>",
+ "Note:\nThis is a Foreign Key to `modelUpload.id`.<fk table='modelUpload' column='id'/>",
format: "text",
type: "string",
},
- grade: {
+ modelPath: {
format: "text",
type: "string",
},
- dimensions: {
+ modelName: {
format: "text",
type: "string",
},
- finish: {
+ modelSize: {
+ format: "bigint",
+ type: "integer",
+ },
+ supplierIds: {
format: "text",
type: "string",
},
- approved: {
- format: "boolean",
- type: "boolean",
+ unitOfMeasure: {
+ format: "text",
+ type: "string",
},
- approvedBy: {
- description:
- "Note:\nThis is a Foreign Key to `user.id`.<fk table='user' column='id'/>",
+ revisions: {
+ format: "json",
+ },
+ materialForm: {
format: "text",
type: "string",
},
- customFields: {
- format: "jsonb",
+ materialSubstance: {
+ format: "text",
+ type: "string",
},
- companyId: {
- description:
- "Note:\nThis is a Primary Key.<pk/>\nThis is a Foreign Key to `company.id`.<fk table='company' column='id'/>",
+ finish: {
format: "text",
type: "string",
},
- createdBy: {
- description:
- "Note:\nThis is a Foreign Key to `user.id`.<fk table='user' column='id'/>",
+ grade: {
format: "text",
type: "string",
},
- createdAt: {
- format: "timestamp with time zone",
+ dimensions: {
+ format: "text",
type: "string",
},
- updatedBy: {
+ materialSubstanceId: {
description:
- "Note:\nThis is a Foreign Key to `user.id`.<fk table='user' column='id'/>",
+ "Note:\nThis is a Foreign Key to `materialSubstance.id`.<fk table='materialSubstance' column='id'/>",
format: "text",
type: "string",
},
- updatedAt: {
- format: "timestamp with time zone",
+ materialFormId: {
+ description:
+ "Note:\nThis is a Foreign Key to `materialForm.id`.<fk table='materialForm' column='id'/>",
+ format: "text",
type: "string",
},
- externalId: {
+ customFields: {
format: "jsonb",
},
tags: {
@@ -70036,25 +70150,26 @@ export default {
},
type: "array",
},
- materialForm: {
+ createdBy: {
+ description:
+ "Note:\nThis is a Foreign Key to `user.id`.<fk table='user' column='id'/>",
format: "text",
type: "string",
},
- materialSubstance: {
- format: "text",
+ createdAt: {
+ format: "timestamp with time zone",
type: "string",
},
- supplierIds: {
+ updatedBy: {
+ description:
+ "Note:\nThis is a Foreign Key to `user.id`.<fk table='user' column='id'/>",
format: "text",
type: "string",
},
- unitOfMeasure: {
- format: "text",
+ updatedAt: {
+ format: "timestamp with time zone",
type: "string",
},
- revisions: {
- format: "json",
- },
},
type: "object",
},
@@ -70357,12 +70472,6 @@ export default {
format: "text",
type: "string",
},
- itemId: {
- description:
- "Note:\nThis is a Foreign Key to `item.id`.<fk table='item' column='id'/>",
- format: "text",
- type: "string",
- },
approved: {
default: false,
format: "boolean",
@@ -70719,10 +70828,6 @@ export default {
format: 'public."itemReplenishmentSystem"',
type: "string",
},
- thumbnailPath: {
- format: "text",
- type: "string",
- },
unitOfMeasureCode: {
format: "text",
type: "string",
@@ -70747,52 +70852,40 @@ export default {
format: "text",
type: "string",
},
- itemId: {
+ companyId: {
description:
- "Note:\nThis is a Foreign Key to `item.id`.<fk table='item' column='id'/>",
+ "Note:\nThis is a Foreign Key to `company.id`.<fk table='company' column='id'/>",
format: "text",
type: "string",
},
- approved: {
- format: "boolean",
- type: "boolean",
- },
- approvedBy: {
- description:
- "Note:\nThis is a Foreign Key to `user.id`.<fk table='user' column='id'/>",
+ thumbnailPath: {
format: "text",
type: "string",
},
- customFields: {
- format: "jsonb",
- },
- companyId: {
- description:
- "Note:\nThis is a Primary Key.<pk/>\nThis is a Foreign Key to `company.id`.<fk table='company' column='id'/>",
+ modelPath: {
format: "text",
type: "string",
},
- createdBy: {
- description:
- "Note:\nThis is a Foreign Key to `user.id`.<fk table='user' column='id'/>",
+ modelName: {
format: "text",
type: "string",
},
- createdAt: {
- format: "timestamp with time zone",
- type: "string",
+ modelSize: {
+ format: "bigint",
+ type: "integer",
},
- updatedBy: {
- description:
- "Note:\nThis is a Foreign Key to `user.id`.<fk table='user' column='id'/>",
+ supplierIds: {
format: "text",
type: "string",
},
- updatedAt: {
- format: "timestamp with time zone",
+ unitOfMeasure: {
+ format: "text",
type: "string",
},
- externalId: {
+ revisions: {
+ format: "json",
+ },
+ customFields: {
format: "jsonb",
},
tags: {
@@ -70802,16 +70895,25 @@ export default {
},
type: "array",
},
- supplierIds: {
+ createdBy: {
+ description:
+ "Note:\nThis is a Foreign Key to `user.id`.<fk table='user' column='id'/>",
format: "text",
type: "string",
},
- unitOfMeasure: {
+ createdAt: {
+ format: "timestamp with time zone",
+ type: "string",
+ },
+ updatedBy: {
+ description:
+ "Note:\nThis is a Foreign Key to `user.id`.<fk table='user' column='id'/>",
format: "text",
type: "string",
},
- revisions: {
- format: "json",
+ updatedAt: {
+ format: "timestamp with time zone",
+ type: "string",
},
},
type: "object",
@@ -71063,7 +71165,7 @@ export default {
},
toolId: {
description:
- "Note:\nThis is a Foreign Key to `tool.itemId`.<fk table='tool' column='itemId'/>",
+ "Note:\nThis is a Foreign Key to `item.id`.<fk table='item' column='id'/>",
format: "text",
type: "string",
},
@@ -78416,26 +78518,13 @@ export default {
type: "object",
},
part: {
- required: [
- "id",
- "itemId",
- "approved",
- "companyId",
- "createdBy",
- "createdAt",
- ],
+ required: ["id", "approved", "companyId", "createdBy", "createdAt"],
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",
- },
approved: {
default: false,
format: "boolean",
@@ -79295,12 +79384,6 @@ export default {
in: "query",
type: "string",
},
- "rowFilter.consumables.thumbnailPath": {
- name: "thumbnailPath",
- required: false,
- in: "query",
- type: "string",
- },
"rowFilter.consumables.unitOfMeasureCode": {
name: "unitOfMeasureCode",
required: false,
@@ -79337,20 +79420,56 @@ export default {
in: "query",
type: "string",
},
- "rowFilter.consumables.itemId": {
- name: "itemId",
+ "rowFilter.consumables.companyId": {
+ name: "companyId",
required: false,
in: "query",
type: "string",
},
- "rowFilter.consumables.approved": {
- name: "approved",
+ "rowFilter.consumables.thumbnailPath": {
+ name: "thumbnailPath",
required: false,
in: "query",
type: "string",
},
- "rowFilter.consumables.approvedBy": {
- name: "approvedBy",
+ "rowFilter.consumables.modelUploadId": {
+ name: "modelUploadId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.consumables.modelPath": {
+ name: "modelPath",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.consumables.modelName": {
+ name: "modelName",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.consumables.modelSize": {
+ name: "modelSize",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.consumables.supplierIds": {
+ name: "supplierIds",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.consumables.unitOfMeasure": {
+ name: "unitOfMeasure",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.consumables.revisions": {
+ name: "revisions",
required: false,
in: "query",
type: "string",
@@ -79361,8 +79480,8 @@ export default {
in: "query",
type: "string",
},
- "rowFilter.consumables.companyId": {
- name: "companyId",
+ "rowFilter.consumables.tags": {
+ name: "tags",
required: false,
in: "query",
type: "string",
@@ -79391,36 +79510,6 @@ export default {
in: "query",
type: "string",
},
- "rowFilter.consumables.externalId": {
- name: "externalId",
- required: false,
- in: "query",
- type: "string",
- },
- "rowFilter.consumables.tags": {
- name: "tags",
- required: false,
- in: "query",
- type: "string",
- },
- "rowFilter.consumables.supplierIds": {
- name: "supplierIds",
- required: false,
- in: "query",
- type: "string",
- },
- "rowFilter.consumables.unitOfMeasure": {
- name: "unitOfMeasure",
- required: false,
- in: "query",
- type: "string",
- },
- "rowFilter.consumables.revisions": {
- name: "revisions",
- required: false,
- in: "query",
- type: "string",
- },
"body.quoteLine": {
name: "quoteLine",
description: "quoteLine",
@@ -83402,12 +83491,6 @@ export default {
in: "query",
type: "string",
},
- "rowFilter.material.itemId": {
- name: "itemId",
- required: false,
- in: "query",
- type: "string",
- },
"rowFilter.material.materialFormId": {
name: "materialFormId",
required: false,
@@ -83867,8 +83950,8 @@ export default {
in: "query",
type: "string",
},
- "rowFilter.jobs.itemReadableId": {
- name: "itemReadableId",
+ "rowFilter.jobs.itemReadableIdWithRevision": {
+ name: "itemReadableIdWithRevision",
required: false,
in: "query",
type: "string",
@@ -87188,12 +87271,6 @@ export default {
in: "query",
type: "string",
},
- "rowFilter.consumable.itemId": {
- name: "itemId",
- required: false,
- in: "query",
- type: "string",
- },
"rowFilter.consumable.approved": {
name: "approved",
required: false,
@@ -95414,20 +95491,20 @@ export default {
in: "query",
type: "string",
},
- "rowFilter.parts.thumbnailPath": {
- name: "thumbnailPath",
+ "rowFilter.parts.id": {
+ name: "id",
required: false,
in: "query",
type: "string",
},
- "rowFilter.parts.modelId": {
- name: "modelId",
+ "rowFilter.parts.companyId": {
+ name: "companyId",
required: false,
in: "query",
type: "string",
},
- "rowFilter.parts.autodeskUrn": {
- name: "autodeskUrn",
+ "rowFilter.parts.thumbnailPath": {
+ name: "thumbnailPath",
required: false,
in: "query",
type: "string",
@@ -95450,44 +95527,32 @@ export default {
in: "query",
type: "string",
},
- "rowFilter.parts.id": {
- name: "id",
- required: false,
- in: "query",
- type: "string",
- },
- "rowFilter.parts.itemId": {
- name: "itemId",
- required: false,
- in: "query",
- type: "string",
- },
- "rowFilter.parts.approved": {
- name: "approved",
+ "rowFilter.parts.supplierIds": {
+ name: "supplierIds",
required: false,
in: "query",
type: "string",
},
- "rowFilter.parts.approvedBy": {
- name: "approvedBy",
+ "rowFilter.parts.unitOfMeasure": {
+ name: "unitOfMeasure",
required: false,
in: "query",
type: "string",
},
- "rowFilter.parts.fromDate": {
- name: "fromDate",
+ "rowFilter.parts.revisions": {
+ name: "revisions",
required: false,
in: "query",
type: "string",
},
- "rowFilter.parts.toDate": {
- name: "toDate",
+ "rowFilter.parts.customFields": {
+ name: "customFields",
required: false,
in: "query",
type: "string",
},
- "rowFilter.parts.companyId": {
- name: "companyId",
+ "rowFilter.parts.tags": {
+ name: "tags",
required: false,
in: "query",
type: "string",
@@ -95516,42 +95581,6 @@ export default {
in: "query",
type: "string",
},
- "rowFilter.parts.customFields": {
- name: "customFields",
- required: false,
- in: "query",
- type: "string",
- },
- "rowFilter.parts.externalId": {
- name: "externalId",
- required: false,
- in: "query",
- type: "string",
- },
- "rowFilter.parts.tags": {
- name: "tags",
- required: false,
- in: "query",
- type: "string",
- },
- "rowFilter.parts.supplierIds": {
- name: "supplierIds",
- required: false,
- in: "query",
- type: "string",
- },
- "rowFilter.parts.unitOfMeasure": {
- name: "unitOfMeasure",
- required: false,
- in: "query",
- type: "string",
- },
- "rowFilter.parts.revisions": {
- name: "revisions",
- required: false,
- in: "query",
- type: "string",
- },
"body.currency": {
name: "currency",
description: "currency",
@@ -95753,12 +95782,6 @@ export default {
in: "query",
type: "string",
},
- "rowFilter.materials.thumbnailPath": {
- name: "thumbnailPath",
- required: false,
- in: "query",
- type: "string",
- },
"rowFilter.materials.unitOfMeasureCode": {
name: "unitOfMeasureCode",
required: false,
@@ -95795,128 +95818,134 @@ export default {
in: "query",
type: "string",
},
- "rowFilter.materials.itemId": {
- name: "itemId",
+ "rowFilter.materials.companyId": {
+ name: "companyId",
required: false,
in: "query",
type: "string",
},
- "rowFilter.materials.materialFormId": {
- name: "materialFormId",
+ "rowFilter.materials.thumbnailPath": {
+ name: "thumbnailPath",
required: false,
in: "query",
type: "string",
},
- "rowFilter.materials.materialSubstanceId": {
- name: "materialSubstanceId",
+ "rowFilter.materials.modelUploadId": {
+ name: "modelUploadId",
required: false,
in: "query",
type: "string",
},
- "rowFilter.materials.grade": {
- name: "grade",
+ "rowFilter.materials.modelPath": {
+ name: "modelPath",
required: false,
in: "query",
type: "string",
},
- "rowFilter.materials.dimensions": {
- name: "dimensions",
+ "rowFilter.materials.modelName": {
+ name: "modelName",
required: false,
in: "query",
type: "string",
},
- "rowFilter.materials.finish": {
- name: "finish",
+ "rowFilter.materials.modelSize": {
+ name: "modelSize",
required: false,
in: "query",
type: "string",
},
- "rowFilter.materials.approved": {
- name: "approved",
+ "rowFilter.materials.supplierIds": {
+ name: "supplierIds",
required: false,
in: "query",
type: "string",
},
- "rowFilter.materials.approvedBy": {
- name: "approvedBy",
+ "rowFilter.materials.unitOfMeasure": {
+ name: "unitOfMeasure",
required: false,
in: "query",
type: "string",
},
- "rowFilter.materials.customFields": {
- name: "customFields",
+ "rowFilter.materials.revisions": {
+ name: "revisions",
required: false,
in: "query",
type: "string",
},
- "rowFilter.materials.companyId": {
- name: "companyId",
+ "rowFilter.materials.materialForm": {
+ name: "materialForm",
required: false,
in: "query",
type: "string",
},
- "rowFilter.materials.createdBy": {
- name: "createdBy",
+ "rowFilter.materials.materialSubstance": {
+ name: "materialSubstance",
required: false,
in: "query",
type: "string",
},
- "rowFilter.materials.createdAt": {
- name: "createdAt",
+ "rowFilter.materials.finish": {
+ name: "finish",
required: false,
in: "query",
type: "string",
},
- "rowFilter.materials.updatedBy": {
- name: "updatedBy",
+ "rowFilter.materials.grade": {
+ name: "grade",
required: false,
in: "query",
type: "string",
},
- "rowFilter.materials.updatedAt": {
- name: "updatedAt",
+ "rowFilter.materials.dimensions": {
+ name: "dimensions",
required: false,
in: "query",
type: "string",
},
- "rowFilter.materials.externalId": {
- name: "externalId",
+ "rowFilter.materials.materialSubstanceId": {
+ name: "materialSubstanceId",
required: false,
in: "query",
type: "string",
},
- "rowFilter.materials.tags": {
- name: "tags",
+ "rowFilter.materials.materialFormId": {
+ name: "materialFormId",
required: false,
in: "query",
type: "string",
},
- "rowFilter.materials.materialForm": {
- name: "materialForm",
+ "rowFilter.materials.customFields": {
+ name: "customFields",
required: false,
in: "query",
type: "string",
},
- "rowFilter.materials.materialSubstance": {
- name: "materialSubstance",
+ "rowFilter.materials.tags": {
+ name: "tags",
required: false,
in: "query",
type: "string",
},
- "rowFilter.materials.supplierIds": {
- name: "supplierIds",
+ "rowFilter.materials.createdBy": {
+ name: "createdBy",
required: false,
in: "query",
type: "string",
},
- "rowFilter.materials.unitOfMeasure": {
- name: "unitOfMeasure",
+ "rowFilter.materials.createdAt": {
+ name: "createdAt",
required: false,
in: "query",
type: "string",
},
- "rowFilter.materials.revisions": {
- name: "revisions",
+ "rowFilter.materials.updatedBy": {
+ name: "updatedBy",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.materials.updatedAt": {
+ name: "updatedAt",
required: false,
in: "query",
type: "string",
@@ -96221,12 +96250,6 @@ export default {
in: "query",
type: "string",
},
- "rowFilter.tool.itemId": {
- name: "itemId",
- required: false,
- in: "query",
- type: "string",
- },
"rowFilter.tool.approved": {
name: "approved",
required: false,
@@ -96623,12 +96646,6 @@ export default {
in: "query",
type: "string",
},
- "rowFilter.tools.thumbnailPath": {
- name: "thumbnailPath",
- required: false,
- in: "query",
- type: "string",
- },
"rowFilter.tools.unitOfMeasureCode": {
name: "unitOfMeasureCode",
required: false,
@@ -96665,86 +96682,86 @@ export default {
in: "query",
type: "string",
},
- "rowFilter.tools.itemId": {
- name: "itemId",
+ "rowFilter.tools.companyId": {
+ name: "companyId",
required: false,
in: "query",
type: "string",
},
- "rowFilter.tools.approved": {
- name: "approved",
+ "rowFilter.tools.thumbnailPath": {
+ name: "thumbnailPath",
required: false,
in: "query",
type: "string",
},
- "rowFilter.tools.approvedBy": {
- name: "approvedBy",
+ "rowFilter.tools.modelPath": {
+ name: "modelPath",
required: false,
in: "query",
type: "string",
},
- "rowFilter.tools.customFields": {
- name: "customFields",
+ "rowFilter.tools.modelName": {
+ name: "modelName",
required: false,
in: "query",
type: "string",
},
- "rowFilter.tools.companyId": {
- name: "companyId",
+ "rowFilter.tools.modelSize": {
+ name: "modelSize",
required: false,
in: "query",
type: "string",
},
- "rowFilter.tools.createdBy": {
- name: "createdBy",
+ "rowFilter.tools.supplierIds": {
+ name: "supplierIds",
required: false,
in: "query",
type: "string",
},
- "rowFilter.tools.createdAt": {
- name: "createdAt",
+ "rowFilter.tools.unitOfMeasure": {
+ name: "unitOfMeasure",
required: false,
in: "query",
type: "string",
},
- "rowFilter.tools.updatedBy": {
- name: "updatedBy",
+ "rowFilter.tools.revisions": {
+ name: "revisions",
required: false,
in: "query",
type: "string",
},
- "rowFilter.tools.updatedAt": {
- name: "updatedAt",
+ "rowFilter.tools.customFields": {
+ name: "customFields",
required: false,
in: "query",
type: "string",
},
- "rowFilter.tools.externalId": {
- name: "externalId",
+ "rowFilter.tools.tags": {
+ name: "tags",
required: false,
in: "query",
type: "string",
},
- "rowFilter.tools.tags": {
- name: "tags",
+ "rowFilter.tools.createdBy": {
+ name: "createdBy",
required: false,
in: "query",
type: "string",
},
- "rowFilter.tools.supplierIds": {
- name: "supplierIds",
+ "rowFilter.tools.createdAt": {
+ name: "createdAt",
required: false,
in: "query",
type: "string",
},
- "rowFilter.tools.unitOfMeasure": {
- name: "unitOfMeasure",
+ "rowFilter.tools.updatedBy": {
+ name: "updatedBy",
required: false,
in: "query",
type: "string",
},
- "rowFilter.tools.revisions": {
- name: "revisions",
+ "rowFilter.tools.updatedAt": {
+ name: "updatedAt",
required: false,
in: "query",
type: "string",
@@ -105224,12 +105241,6 @@ export default {
in: "query",
type: "string",
},
- "rowFilter.part.itemId": {
- name: "itemId",
- required: false,
- in: "query",
- type: "string",
- },
"rowFilter.part.approved": {
name: "approved",
required: false,
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index 60c9e64e51..64684e5cac 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -40680,14 +40680,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["paymentCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["paymentCountryCode"]
+ columns: ["customerCountryCode"]
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 dbae623b22..185e650c84 100644
--- a/packages/database/supabase/functions/convert/index.ts
+++ b/packages/database/supabase/functions/convert/index.ts
@@ -685,10 +685,8 @@ serve(async (req: Request) => {
if (linesToCreateItems.length > 0) {
itemInserts = await Promise.all(
linesToCreateItems.map(async (line) => {
- const baseReadableId = line.customerPartRevision
- ? `${line.customerPartId}-${line.customerPartRevision}`
- : `${line.customerPartId}`;
- let readableId = baseReadableId;
+ let revisionId = line.customerPartRevision ?? "0";
+ let readableId = line.customerPartId ?? "";
let suffix = 1;
// Check for uniqueness and append a suffix if necessary
@@ -697,6 +695,7 @@ serve(async (req: Request) => {
.from("item")
.select("id")
.eq("readableId", readableId)
+ .eq("revision", revisionId)
.eq("companyId", companyId)
.single();
@@ -711,13 +710,14 @@ serve(async (req: Request) => {
}
// If not unique, append or increment suffix
- readableId = `${baseReadableId} (${suffix})`;
+ revisionId = `${revisionId} (${suffix})`;
suffix++;
}
readableIdToLineIdMapping.set(readableId, line.id!);
return {
readableId,
+ revision: revisionId,
type: "Part" as const,
active: false,
name: line.description ?? line.itemName ?? "",
@@ -797,17 +797,25 @@ serve(async (req: Request) => {
const itemIds = await trx
.insertInto("item")
.values(itemInserts)
- .returning(["id", "readableId"])
+ .returning(["id", "readableId", "revision"])
.execute();
const partInserts: Database["public"]["Tables"]["part"]["Insert"][] =
itemIds.map((item) => ({
id: item.readableId!,
- itemId: item.id!,
companyId,
createdBy: userId,
}));
- await trx.insertInto("part").values(partInserts).execute();
+ await trx
+ .insertInto("part")
+ .values(partInserts)
+ .onConflict((oc) =>
+ oc.columns(["id", "companyId"]).doUpdateSet({
+ updatedAt: new Date().toISOString(),
+ updatedBy: userId,
+ })
+ )
+ .execute();
const salesRfqLineUpdates: Database["public"]["Tables"]["salesRfqLine"]["Update"][] =
itemIds.map((item) => ({
diff --git a/packages/database/supabase/functions/create/index.ts b/packages/database/supabase/functions/create/index.ts
index 77a8943483..dec9c7b8a6 100644
--- a/packages/database/supabase/functions/create/index.ts
+++ b/packages/database/supabase/functions/create/index.ts
@@ -648,7 +648,7 @@ serve(async (req: Request) => {
purchaseOrderId,
purchaseOrderLineType: item.type,
itemId: item.id,
- itemReadableId: item.readableId,
+ itemReadableId: item.readableIdWithRevision,
description: item.name || item.description,
purchaseQuantity: operation.operationQuantity || 1,
purchaseUnitOfMeasureCode: item.unitOfMeasureCode,
diff --git a/packages/database/supabase/functions/get-method/index.ts b/packages/database/supabase/functions/get-method/index.ts
index cf7fe7ff49..da9213945c 100644
--- a/packages/database/supabase/functions/get-method/index.ts
+++ b/packages/database/supabase/functions/get-method/index.ts
@@ -690,13 +690,14 @@ serve(async (req: Request) => {
const item = await client
.from("item")
.select(
- "readableId, type, name, itemTrackingType, itemCost(unitCost)"
+ "readableId, readableIdWithRevision, type, name, itemTrackingType, itemCost(unitCost)"
)
.eq("id", itemId)
.eq("companyId", companyId)
.single();
if (item.data) {
- itemReadableId = item.data.readableId;
+ itemReadableId =
+ item.data.readableIdWithRevision ?? item.data.readableId;
itemType = item.data.type;
unitCost =
item.data.itemCost[0]?.unitCost ?? child.data.unitCost;
@@ -752,9 +753,10 @@ serve(async (req: Request) => {
if (bomConfiguration) {
// @ts-expect-error - we can't assign undefined to materialsWithConfiguredFields but we filter them in the next step
materialsWithConfiguredFields = bomConfiguration
- .map((readableId, index) => {
+ .map((readableIdWithRevision, index) => {
const material = materialsWithConfiguredFields.find(
- (material) => material.itemReadableId === readableId
+ (material) =>
+ material.itemReadableId === readableIdWithRevision
);
if (material) {
return {
@@ -1549,12 +1551,15 @@ serve(async (req: Request) => {
if (itemId !== child.data.itemId) {
const item = await client
.from("item")
- .select("readableId, type, name, itemCost(unitCost)")
+ .select(
+ "readableIdWithRevision, readableId, type, name, itemCost(unitCost)"
+ )
.eq("id", itemId)
.eq("companyId", companyId)
.single();
if (item.data) {
- itemReadableId = item.data.readableId;
+ itemReadableId =
+ item.data.readableIdWithRevision ?? item.data.readableId;
itemType = item.data.type;
unitCost =
item.data.itemCost[0]?.unitCost ?? child.data.unitCost;
@@ -1605,9 +1610,10 @@ serve(async (req: Request) => {
if (bomConfiguration) {
// @ts-expect-error - we can't assign undefined to materialsWithConfiguredFields but we filter them in the next step
materialsWithConfiguredFields = bomConfiguration
- .map((readableId, index) => {
+ .map((readableIdWithRevision, index) => {
const material = materialsWithConfiguredFields.find(
- (material) => material.itemReadableId === readableId
+ (material) =>
+ material.itemReadableId === readableIdWithRevision
);
if (material) {
return {
diff --git a/packages/database/supabase/functions/import-csv/index.ts b/packages/database/supabase/functions/import-csv/index.ts
index 25a630a2da..976ac35bb1 100644
--- a/packages/database/supabase/functions/import-csv/index.ts
+++ b/packages/database/supabase/functions/import-csv/index.ts
@@ -1,12 +1,13 @@
import { parse } from "https://deno.land/[email protected]/encoding/csv.ts";
import { serve } from "https://deno.land/[email protected]/http/server.ts";
import { nanoid } from "https://deno.land/x/[email protected]/mod.ts";
-import z from "npm:zod@^3.24.1";
import { sql } from "npm:[email protected]";
+import z from "npm:zod@^3.24.1";
import { DB, getConnectionPool, getDatabaseClient } from "../lib/database.ts";
import { corsHeaders } from "../lib/headers.ts";
import { getSupabaseServiceRole } from "../lib/supabase.ts";
import { Database } from "../lib/types.ts";
+import { getReadableIdWithRevision } from "../lib/utils.ts";
const pool = getConnectionPool(1);
const db = getDatabaseClient<DB>(pool);
@@ -342,7 +343,7 @@ serve(async (req: Request) => {
}[] = [];
const materialPartialInserts: Record<
string,
- Omit<Database["public"]["Tables"]["material"]["Insert"], "itemId">
+ Database["public"]["Tables"]["material"]["Insert"]
> = {};
const materialUpdates: {
@@ -353,6 +354,7 @@ serve(async (req: Request) => {
const itemValidator = z.object({
id: z.string(),
readableId: z.string(),
+ revision: z.string().optional(),
name: z.string(),
description: z.string().optional(),
active: z.string().optional(),
@@ -378,7 +380,7 @@ serve(async (req: Request) => {
});
for (const record of mappedRecords) {
- const item = itemValidator.safeParse(record);
+ let item = itemValidator.safeParse(record);
if (!item.success) {
console.error(item.error.message);
@@ -386,18 +388,23 @@ serve(async (req: Request) => {
}
const { id, ...rest } = item.data;
+ const readableIdWithRevision = getReadableIdWithRevision(
+ item.data.readableId,
+ item.data.revision
+ );
if (
externalIdMap.has(getExternalId(id)) &&
- !readableIds.has(item.data.readableId)
+ !readableIds.has(readableIdWithRevision)
) {
const existingItem = externalIdMap.get(getExternalId(id))!;
- readableIds.add(item.data.readableId);
+ readableIds.add(readableIdWithRevision);
itemUpdates.push({
id: existingItem.id,
data: {
...rest,
+ revision: rest.revision ?? "0",
active: rest.active?.toLowerCase() !== "false" ?? true,
updatedAt: new Date().toISOString(),
updatedBy: userId,
@@ -411,7 +418,7 @@ serve(async (req: Request) => {
const material = materialValidator.safeParse(record);
if (material.success) {
materialUpdates.push({
- id: existingItem.id,
+ id: material.data.readableId,
data: {
materialSubstanceId: material.data.materialSubstanceId,
materialFormId: material.data.materialFormId,
@@ -425,8 +432,8 @@ serve(async (req: Request) => {
});
}
}
- } else if (!readableIds.has(rest.readableId)) {
- readableIds.add(rest.readableId);
+ } else if (!readableIds.has(readableIdWithRevision)) {
+ readableIds.add(readableIdWithRevision);
const newItem = {
...rest,
replenishmentSystem: rest.replenishmentSystem ?? "Buy",
@@ -439,6 +446,7 @@ serve(async (req: Request) => {
| "Fixture"
| "Consumable",
companyId,
+ revision: rest.revision ?? "0",
createdAt: new Date().toISOString(),
createdBy: userId,
externalId: {
@@ -454,9 +462,9 @@ serve(async (req: Request) => {
continue;
}
if (material.success) {
- materialPartialInserts[rest.readableId!] = {
+ materialPartialInserts[material.data.readableId!] = {
...material.data,
- id: rest.readableId,
+ id: material.data.readableId,
companyId,
createdAt: new Date().toISOString(),
createdBy: userId,
@@ -494,7 +502,6 @@ serve(async (req: Request) => {
const specificInserts: Database["public"]["Tables"]["part"]["Insert"][] =
insertedItems.map((item) => ({
id: item.readableId,
- itemId: item.id!,
approved: true,
externalId: item.externalId,
companyId,
@@ -516,7 +523,6 @@ serve(async (req: Request) => {
if (materialData) {
acc.push({
id: item.readableId,
- itemId: item.id!,
materialSubstanceId: materialData.materialSubstanceId,
materialFormId: materialData.materialFormId,
dimensions: materialData.dimensions,
@@ -560,7 +566,7 @@ serve(async (req: Request) => {
await trx
.updateTable("material")
.set(update.data)
- .where("itemId", "=", update.id)
+ .where("id", "=", update.id)
.execute();
}
}
diff --git a/packages/database/supabase/functions/issue/index.ts b/packages/database/supabase/functions/issue/index.ts
index 6927e4c5fc..b5f01fd607 100644
--- a/packages/database/supabase/functions/issue/index.ts
+++ b/packages/database/supabase/functions/issue/index.ts
@@ -153,7 +153,7 @@ serve(async (req: Request) => {
const item = await trx
.selectFrom("item")
.where("id", "=", job?.itemId!)
- .select(["readableId"])
+ .select(["readableIdWithRevision"])
.executeTakeFirstOrThrow();
const quantityReceivedToInventory =
@@ -189,7 +189,7 @@ serve(async (req: Request) => {
documentId: jobId,
companyId,
itemId: job?.itemId!,
- itemReadableId: item?.readableId,
+ itemReadableId: item?.readableIdWithRevision,
quantity: quantityReceivedToInventory,
locationId,
shelfId,
@@ -215,7 +215,7 @@ serve(async (req: Request) => {
documentId: jobId,
companyId,
itemId: job?.itemId!,
- itemReadableId: item?.readableId,
+ itemReadableId: item?.readableIdWithRevision,
quantity: 1,
locationId,
shelfId,
@@ -242,7 +242,7 @@ serve(async (req: Request) => {
documentId: jobId,
companyId,
itemId: job?.itemId!,
- itemReadableId: item?.readableId,
+ itemReadableId: item?.readableIdWithRevision,
quantity: quantityReceivedToInventory,
locationId,
shelfId,
@@ -663,7 +663,13 @@ serve(async (req: Request) => {
trx
.selectFrom("item")
.where("id", "=", itemId)
- .select(["id", "itemTrackingType", "name", "readableId", "type"])
+ .select([
+ "id",
+ "itemTrackingType",
+ "name",
+ "readableIdWithRevision",
+ "type",
+ ])
.executeTakeFirst(),
]);
@@ -777,7 +783,7 @@ serve(async (req: Request) => {
description: item?.name,
estimatedQuantity: 0,
itemId: itemId!,
- itemReadableId: item?.readableId,
+ itemReadableId: item?.readableIdWithRevision,
itemType: item?.type,
jobId: jobOperation?.jobId!,
jobMakeMethodId: jobOperation?.jobMakeMethodId,
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index 60c9e64e51..64684e5cac 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -40680,14 +40680,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["paymentCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["paymentCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
diff --git a/packages/database/supabase/functions/lib/utils.ts b/packages/database/supabase/functions/lib/utils.ts
index 0bf27e6a7a..bd69e6c5a2 100644
--- a/packages/database/supabase/functions/lib/utils.ts
+++ b/packages/database/supabase/functions/lib/utils.ts
@@ -41,6 +41,17 @@ export const interpolateSequenceDate = (value?: string | null) => {
return result;
};
+export const getReadableIdWithRevision = (
+ readableId: string,
+ revision?: string | null
+) => {
+ if (revision && revision !== "0") {
+ return `${readableId}.${revision}`;
+ }
+
+ return readableId;
+};
+
type AccountType = "asset" | "liability" | "equity" | "revenue" | "expense";
export const credit = (accountType: AccountType, amount: number) => {
diff --git a/packages/database/supabase/functions/mcp/tools.ts b/packages/database/supabase/functions/mcp/tools.ts
index 44dea3393b..e582a98331 100644
--- a/packages/database/supabase/functions/mcp/tools.ts
+++ b/packages/database/supabase/functions/mcp/tools.ts
@@ -1,19 +1,19 @@
-import "jsr:@supabase/functions-js/edge-runtime.d.ts";
import SupabaseClient from "https://esm.sh/v135/@supabase/[email protected]/dist/module/SupabaseClient.d.ts";
-import { tool } from "../lib/tool.ts";
+import { Transaction } from "https://esm.sh/v135/[email protected]/dist/cjs/kysely.d.ts";
+import "jsr:@supabase/functions-js/edge-runtime.d.ts";
import z from "npm:zod@^3.24.1";
-import { Database } from "../lib/types.ts";
+import { getCurrencyByCode } from "../lib/api/accounting.ts";
import {
- getSupplierPayment,
+ deletePurchaseOrder,
getSupplier as getSupplierById,
+ getSupplierPayment,
getSupplierShipping,
insertSupplierInteraction,
- deletePurchaseOrder,
} from "../lib/api/purchasing.ts";
-import { getCurrencyByCode } from "../lib/api/accounting.ts";
-import { getNextSequence } from "../shared/get-next-sequence.ts";
-import { Transaction } from "https://esm.sh/v135/[email protected]/dist/cjs/kysely.d.ts";
import { DB } from "../lib/database.ts";
+import { tool } from "../lib/tool.ts";
+import { Database } from "../lib/types.ts";
+import { getNextSequence } from "../shared/get-next-sequence.ts";
const model = new Supabase.ai.Session("gte-small");
@@ -93,6 +93,7 @@ const createPurchaseOrder = tool({
if (supplier.currencyCode) {
const currency = await getCurrencyByCode(
+ // @ts-ignore
context.db,
context.companyId,
supplier.currencyCode
@@ -151,12 +152,18 @@ const createPurchaseOrder = tool({
// Create purchase order lines for each part
await Promise.all(
- args.parts.map(async (part) => {
+ args.parts.map(async (part: { partId: string; quantity: number }) => {
// Get item details
const [item, supplierPart] = await Promise.all([
context.db
.selectFrom("item")
- .select(["id", "name", "readableId", "type", "unitOfMeasureCode"])
+ .select([
+ "id",
+ "name",
+ "readableIdWithRevision",
+ "type",
+ "unitOfMeasureCode",
+ ])
.where("id", "=", part.partId)
.where("companyId", "=", context.companyId)
.executeTakeFirst(),
@@ -197,7 +204,7 @@ const createPurchaseOrder = tool({
.values({
purchaseOrderId: purchaseOrderId,
itemId: part.partId,
- itemReadableId: item.readableId,
+ itemReadableId: item.readableIdWithRevision,
description: item.name,
purchaseOrderLineType: item.type,
purchaseQuantity: part.quantity,
@@ -256,9 +263,12 @@ const getPart = tool({
context.client
.from("item")
.select("*")
- .eq("readableId", readableId)
+ .or(
+ `readableId.eq.${readableId},readableIdWithRevision.eq.${readableId}`
+ )
.eq("companyId", context.companyId)
- .single(),
+ .order("revision", { ascending: false })
+ .limit(1),
context.client
.from("supplierPart")
.select("*, item(*)")
@@ -275,11 +285,11 @@ const getPart = tool({
supplierId: supplierPart.data.supplierId,
};
}
- if (part.data) {
+ if (part.data?.[0]) {
return {
- id: part.data.id,
- name: part.data.name,
- description: part.data.description,
+ id: part.data[0].id,
+ name: part.data[0].name,
+ description: part.data[0].description,
};
}
diff --git a/packages/database/supabase/functions/post-purchase-invoice/index.ts b/packages/database/supabase/functions/post-purchase-invoice/index.ts
index 08f1514df9..ada19b449a 100644
--- a/packages/database/supabase/functions/post-purchase-invoice/index.ts
+++ b/packages/database/supabase/functions/post-purchase-invoice/index.ts
@@ -94,7 +94,7 @@ serve(async (req: Request) => {
const [items, itemCosts, purchaseOrderLines, supplier] = await Promise.all([
client
.from("item")
- .select("id, itemTrackingType, readableId")
+ .select("id, itemTrackingType")
.in("id", itemIds)
.eq("companyId", companyId),
client
diff --git a/packages/database/supabase/functions/post-sales-invoice/index.ts b/packages/database/supabase/functions/post-sales-invoice/index.ts
index aa5f81fc3f..996a00459b 100644
--- a/packages/database/supabase/functions/post-sales-invoice/index.ts
+++ b/packages/database/supabase/functions/post-sales-invoice/index.ts
@@ -86,7 +86,7 @@ serve(async (req: Request) => {
const [items, itemCosts, salesOrderLines, customer] = await Promise.all([
client
.from("item")
- .select("id, itemTrackingType, readableId")
+ .select("id, itemTrackingType")
.in("id", itemIds)
.eq("companyId", companyId),
client
diff --git a/packages/database/supabase/functions/sync/index.ts b/packages/database/supabase/functions/sync/index.ts
index aa30733cfc..6e78c91538 100644
--- a/packages/database/supabase/functions/sync/index.ts
+++ b/packages/database/supabase/functions/sync/index.ts
@@ -4,6 +4,7 @@ import { DB, getConnectionPool, getDatabaseClient } from "../lib/database.ts";
import z from "npm:zod@^3.24.1";
import { corsHeaders } from "../lib/headers.ts";
import { getSupabaseServiceRole } from "../lib/supabase.ts";
+import { getReadableIdWithRevision } from "../lib/utils.ts";
const pool = getConnectionPool(1);
const db = getDatabaseClient<DB>(pool);
@@ -12,6 +13,7 @@ const onShapeDataValidator = z.object({
index: z.string(),
id: z.string().optional(),
readableId: z.string().optional(),
+ revision: z.string().optional(),
name: z.string(),
quantity: z.number(),
replenishmentSystem: z.enum(["Make", "Buy", "Buy and Make"]),
@@ -66,7 +68,9 @@ serve(async (req: Request) => {
.in("itemId", Array.from(existingItemIds)),
client
.from("item")
- .select("id, readableId, unitOfMeasureCode, type")
+ .select(
+ "id, readableId, readableIdWithRevision, unitOfMeasureCode, type, revision"
+ )
.eq("companyId", companyId)
.in("id", Array.from(existingItemIds)),
]);
@@ -163,6 +167,7 @@ serve(async (req: Request) => {
const {
id,
readableId,
+ revision,
name,
quantity,
replenishmentSystem,
@@ -185,6 +190,7 @@ serve(async (req: Request) => {
.insertInto("item")
.values({
readableId: partId,
+ revision: revision ?? "0",
name,
type: "Part",
unitOfMeasureCode: "EA",
@@ -203,7 +209,6 @@ serve(async (req: Request) => {
.insertInto("part")
.values({
id: partId,
- itemId: itemId!,
companyId,
createdBy: userId,
})
@@ -216,6 +221,11 @@ serve(async (req: Request) => {
existingItemsByItemId.set(itemId, {
id: itemId,
readableId: partId,
+ readableIdWithRevision: getReadableIdWithRevision(
+ partId,
+ revision
+ ),
+ revision: revision ?? "0",
unitOfMeasureCode: "EA",
type: "Part",
});
@@ -281,7 +291,8 @@ serve(async (req: Request) => {
methodType: defaultMethodType,
order: index,
itemReadableId:
- existingItemsByItemId.get(itemId)?.readableId ?? partId,
+ existingItemsByItemId.get(itemId)?.readableIdWithRevision ??
+ partId,
itemType: existingItemsByItemId.get(itemId)?.type ?? "Part",
unitOfMeasureCode:
existingItemsByItemId.get(itemId)?.unitOfMeasureCode ?? "EA",
diff --git a/packages/database/supabase/migrations/20250519122022_revisions.sql b/packages/database/supabase/migrations/20250519122022_revisions.sql
index 6fab8c8538..c2fe6ef361 100644
--- a/packages/database/supabase/migrations/20250519122022_revisions.sql
+++ b/packages/database/supabase/migrations/20250519122022_revisions.sql
@@ -1,6 +1,6 @@
ALTER TABLE "item" ADD COLUMN "revision" TEXT DEFAULT '0';
ALTER TABLE "item" ADD COLUMN "readableIdWithRevision" TEXT GENERATED ALWAYS AS (
- COALESCE("readableId" || CASE WHEN "revision" != '0' THEN '.' || "revision" ELSE '' END, "readableId")
+ COALESCE("readableId" || CASE WHEN "revision" = '0' THEN '' WHEN "revision" = '' THEN '' ELSE '.' || "revision" END, "readableId")
) STORED;
ALTER TABLE "item" DROP CONSTRAINT "item_unique";
diff --git a/packages/documents/src/pdf/JobTravelerPDF.tsx b/packages/documents/src/pdf/JobTravelerPDF.tsx
index 515ca98a86..d8fe82690e 100644
--- a/packages/documents/src/pdf/JobTravelerPDF.tsx
+++ b/packages/documents/src/pdf/JobTravelerPDF.tsx
@@ -64,7 +64,7 @@ const JobTravelerPDF = ({
<View style={tw("mb-6")}>
<Header
title={job.jobId}
- subtitle={item.readableId}
+ subtitle={item.readableIdWithRevision}
tertiaryTitle={item.name}
company={company}
/>
diff --git a/packages/react/src/Combobox.tsx b/packages/react/src/Combobox.tsx
index 1cd21f056f..f0a2f24aa2 100644
--- a/packages/react/src/Combobox.tsx
+++ b/packages/react/src/Combobox.tsx
@@ -205,7 +205,7 @@ function VirtualizedCommand({
>
{items.map((virtualRow) => {
const item = filteredOptions[virtualRow.index];
- const value =
+ const itemValue =
typeof item.label === "string"
? CSS.escape(item.label) + CSS.escape(item.helper ?? "")
: reactNodeToString(item.label);
@@ -245,7 +245,7 @@ function VirtualizedCommand({
<LuCheck
className={cn(
"ml-auto h-4 w-4",
- item.value === value ? "opacity-100" : "opacity-0"
+ itemValue === value ? "opacity-100" : "opacity-0"
)}
/>
</CommandItem>