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: move inventory/non-inventory to item level

Brad Barbin7be4d75a16ab
diff --git a/apps/carbon/app/components/Form/Item.tsx b/apps/carbon/app/components/Form/Item.tsx
index cfcd252934..9d1f05e17c 100644
--- a/apps/carbon/app/components/Form/Item.tsx
+++ b/apps/carbon/app/components/Form/Item.tsx
@@ -52,7 +52,7 @@ const Item = ({ type, ...props }: ItemSelectProps) => {
id: "",
name: created,
description: "",
- partType: "Inventory" as "Inventory",
+ itemInventoryType: "Inventory",
replenishmentSystem: "Buy and Make",
unitOfMeasureCode: "EA",
blocked: false,
diff --git a/apps/carbon/app/components/Form/Part.tsx b/apps/carbon/app/components/Form/Part.tsx
index 6aee81079c..a011eada7f 100644
--- a/apps/carbon/app/components/Form/Part.tsx
+++ b/apps/carbon/app/components/Form/Part.tsx
@@ -49,7 +49,7 @@ const Part = ({ partReplenishmentSystem, ...props }: PartSelectProps) => {
id: "",
name: created,
description: "",
- partType: "Inventory" as "Inventory",
+ itemInventoryType: "Inventory" as "Inventory",
replenishmentSystem: partReplenishmentSystem ?? "Buy and Make",
unitOfMeasureCode: "EA",
blocked: false,
diff --git a/apps/carbon/app/components/Layout/Navigation/useModules.tsx b/apps/carbon/app/components/Layout/Navigation/useModules.tsx
index d2703c3c0e..f517fb85b9 100644
--- a/apps/carbon/app/components/Layout/Navigation/useModules.tsx
+++ b/apps/carbon/app/components/Layout/Navigation/useModules.tsx
@@ -21,7 +21,7 @@ export function useModules() {
{
permission: "parts",
name: "Items",
- to: path.to.partsSearch,
+ to: path.to.parts,
icon: LuComponent,
},
// {
diff --git a/apps/carbon/app/modules/accounting/accounting.models.ts b/apps/carbon/app/modules/accounting/accounting.models.ts
index a50b24b9ab..f1a337db48 100644
--- a/apps/carbon/app/modules/accounting/accounting.models.ts
+++ b/apps/carbon/app/modules/accounting/accounting.models.ts
@@ -342,7 +342,8 @@ export const itemLedgerValidator = z.object({
entryType: z.enum(itemLedgerTypes),
documentType: z.union([z.enum(itemLedgerDocumentTypes), z.undefined()]),
documentId: z.string().optional(),
- itemId: z.string().min(1, { message: "Part is required" }),
+ itemId: z.string().min(1, { message: "Item is required" }),
+ itemReadableId: z.string().optional(),
locationId: z.string().optional(),
shelfId: z.string().optional(),
quantity: z.number(),
@@ -392,6 +393,7 @@ export const costLedgerValidator = z.object({
documentType: z.union([z.enum(itemLedgerDocumentTypes), z.undefined()]),
documentId: z.string().optional(),
itemId: zfd.text(z.string()),
+ itemReadableId: zfd.text(z.string()),
quantity: z.number(),
cost: z.number(),
costPostedToGL: z.number(),
diff --git a/apps/carbon/app/modules/accounting/accounting.service.ts b/apps/carbon/app/modules/accounting/accounting.service.ts
index 9c97c8e168..2b39baa13d 100644
--- a/apps/carbon/app/modules/accounting/accounting.service.ts
+++ b/apps/carbon/app/modules/accounting/accounting.service.ts
@@ -652,7 +652,7 @@ export async function insertPartEntries(
return client.from("itemLedger").insert(itemEntries);
}
-export async function insertPartLedger(
+export async function insertItemLedger(
client: SupabaseClient<Database>,
itemEntry: z.infer<typeof itemLedgerValidator> & {
companyId: string;
diff --git a/apps/carbon/app/modules/parts/parts.models.ts b/apps/carbon/app/modules/parts/parts.models.ts
index d064fee63e..a8c9350d29 100644
--- a/apps/carbon/app/modules/parts/parts.models.ts
+++ b/apps/carbon/app/modules/parts/parts.models.ts
@@ -1,7 +1,7 @@
import { z } from "zod";
import { zfd } from "zod-form-data";
-export const partTypes = ["Inventory", "Non-Inventory"] as const;
+export const itemInventoryTypes = ["Inventory", "Non-Inventory"] as const;
export const partReplenishmentSystems = [
"Buy",
"Make",
@@ -32,6 +32,11 @@ export const itemValidator = z.object({
name: z.string().min(1, { message: "Name is required" }).max(255),
description: zfd.text(z.string().optional()),
itemGroupId: zfd.text(z.string().optional()),
+ itemInventoryType: z.enum(itemInventoryTypes, {
+ errorMap: (issue, ctx) => ({
+ message: "Part type is required",
+ }),
+ }),
blocked: zfd.checkbox(),
active: zfd.checkbox(),
});
@@ -136,11 +141,6 @@ export const partValidator = itemValidator.merge(
message: "Replenishment system is required",
}),
}),
- partType: z.enum(partTypes, {
- errorMap: (issue, ctx) => ({
- message: "Part type is required",
- }),
- }),
unitOfMeasureCode: z
.string()
.min(1, { message: "Unit of Measure is required" }),
diff --git a/apps/carbon/app/modules/parts/parts.service.ts b/apps/carbon/app/modules/parts/parts.service.ts
index d603e6fd49..abddd5ca34 100644
--- a/apps/carbon/app/modules/parts/parts.service.ts
+++ b/apps/carbon/app/modules/parts/parts.service.ts
@@ -1,7 +1,7 @@
import type { Database, Json } from "@carbon/database";
import { getLocalTimeZone, today } from "@internationalized/date";
import type { SupabaseClient } from "@supabase/supabase-js";
-import type { z } from "zod";
+import { type z } from "zod";
import type { GenericQueryFilters } from "~/utils/query";
import { setGenericQueryFilters } from "~/utils/query";
import { sanitize } from "~/utils/supabase";
@@ -448,6 +448,8 @@ export async function upsertPart(
readableId: part.id,
name: part.name,
type: "Part",
+ itemGroupId: part.itemGroupId,
+ itemInventoryType: part.itemInventoryType,
companyId: part.companyId,
createdBy: part.createdBy,
})
@@ -462,7 +464,6 @@ export async function upsertPart(
id: part.id,
itemId: itemId,
replenishmentSystem: part.replenishmentSystem,
- partType: part.partType,
unitOfMeasureCode: part.unitOfMeasureCode,
companyId: part.companyId,
createdBy: part.createdBy,
@@ -477,14 +478,15 @@ export async function upsertPart(
name: part.name,
description: part.description,
itemGroupId: part.itemGroupId,
+ itemInventoryType: part.itemInventoryType,
active: part.active,
blocked: part.blocked,
};
const partUpdate = {
replenishmentSystem: part.replenishmentSystem,
- partType: part.partType,
unitOfMeasureCode: part.unitOfMeasureCode,
+ customFields: part.customFields,
};
const [updateItem, updatePart] = await Promise.all([
@@ -699,6 +701,8 @@ export async function upsertService(
readableId: service.id,
name: service.name,
type: "Service",
+ itemGroupId: service.itemGroupId,
+ itemInventoryType: service.itemInventoryType,
companyId: service.companyId,
createdBy: service.createdBy,
})
@@ -724,6 +728,7 @@ export async function upsertService(
name: service.name,
description: service.description,
itemGroupId: service.itemGroupId,
+ itemInventoryType: service.itemInventoryType,
active: service.active,
blocked: service.blocked,
};
diff --git a/apps/carbon/app/modules/parts/types.ts b/apps/carbon/app/modules/parts/types.ts
index 83e6173a34..a5a987ccf1 100644
--- a/apps/carbon/app/modules/parts/types.ts
+++ b/apps/carbon/app/modules/parts/types.ts
@@ -52,7 +52,7 @@ export type Part = NonNullable<
Awaited<ReturnType<typeof getParts>>["data"]
>[number];
-export type PartType = Database["public"]["Enums"]["partType"];
+export type PartType = Database["public"]["Enums"]["itemInventoryType"];
export type Service = NonNullable<
Awaited<ReturnType<typeof getServices>>["data"]
diff --git a/apps/carbon/app/modules/parts/ui/Part/PartForm.tsx b/apps/carbon/app/modules/parts/ui/Part/PartForm.tsx
index d4159758c7..cb179dca3a 100644
--- a/apps/carbon/app/modules/parts/ui/Part/PartForm.tsx
+++ b/apps/carbon/app/modules/parts/ui/Part/PartForm.tsx
@@ -30,8 +30,8 @@ import {
import { usePermissions, useUser } from "~/hooks";
import { useSupabase } from "~/lib/supabase";
import {
+ itemInventoryTypes,
partReplenishmentSystems,
- partTypes,
partValidator,
} from "~/modules/parts";
import { path } from "~/utils/path";
@@ -111,10 +111,10 @@ const PartForm = ({ initialValues, type = "card", onClose }: PartFormProps) => {
const permissions = usePermissions();
const isEditing = !!initialValues.id;
- const partTypeOptions =
- partTypes.map((partType) => ({
- label: partType,
- value: partType,
+ const itemInventoryTypeOptions =
+ itemInventoryTypes.map((itemInventoryType) => ({
+ label: itemInventoryType,
+ value: itemInventoryType,
})) ?? [];
const partReplenishmentSystemOptions =
@@ -181,9 +181,9 @@ const PartForm = ({ initialValues, type = "card", onClose }: PartFormProps) => {
options={partReplenishmentSystemOptions}
/>
<Select
- name="partType"
+ name="itemInventoryType"
label="Part Type"
- options={partTypeOptions}
+ options={itemInventoryTypeOptions}
/>
<UnitOfMeasure
name="unitOfMeasureCode"
diff --git a/apps/carbon/app/modules/parts/ui/Part/PartHeader.tsx b/apps/carbon/app/modules/parts/ui/Part/PartHeader.tsx
index 1e914fbd6d..fd0656a86f 100644
--- a/apps/carbon/app/modules/parts/ui/Part/PartHeader.tsx
+++ b/apps/carbon/app/modules/parts/ui/Part/PartHeader.tsx
@@ -87,9 +87,11 @@ const PartHeader = () => {
</CardAttributeValue>
</CardAttribute>
<CardAttribute>
- <CardAttributeLabel>Part Type</CardAttributeLabel>
+ <CardAttributeLabel>Inventory Type</CardAttributeLabel>
<CardAttributeValue>
- <Enumerable value={routeData?.partSummary?.partType ?? null} />
+ <Enumerable
+ value={routeData?.partSummary?.itemInventoryType ?? null}
+ />
</CardAttributeValue>
</CardAttribute>
<CardAttribute>
diff --git a/apps/carbon/app/modules/parts/ui/Parts/PartsTable.tsx b/apps/carbon/app/modules/parts/ui/Parts/PartsTable.tsx
index ceccadaff0..fd8f1793f1 100644
--- a/apps/carbon/app/modules/parts/ui/Parts/PartsTable.tsx
+++ b/apps/carbon/app/modules/parts/ui/Parts/PartsTable.tsx
@@ -8,7 +8,7 @@ import { EmployeeAvatar, Hyperlink, New, Table } from "~/components";
import { usePermissions, useUrlParams } from "~/hooks";
import { useCustomColumns } from "~/hooks/useCustomColumns";
import type { Part } from "~/modules/parts";
-import { partReplenishmentSystems, partTypes } from "~/modules/parts";
+import { itemInventoryTypes, partReplenishmentSystems } from "~/modules/parts";
import { usePeople } from "~/stores";
import type { ListItem } from "~/types";
import { path } from "~/utils/path";
@@ -48,13 +48,13 @@ const PartsTable = memo(({ data, count, itemGroups }: PartsTableProps) => {
cell: (item) => item.getValue(),
},
{
- accessorKey: "partType",
- header: "Part Type",
+ accessorKey: "itemInventoryType",
+ header: "Inventory",
cell: (item) => <Enumerable value={item.getValue<string>()} />,
meta: {
filter: {
type: "static",
- options: partTypes.map((type) => ({
+ options: itemInventoryTypes.map((type) => ({
value: type,
label: <Enumerable value={type} />,
})),
diff --git a/apps/carbon/app/modules/parts/ui/Service/ServiceForm.tsx b/apps/carbon/app/modules/parts/ui/Service/ServiceForm.tsx
index 52635bfa5c..829306af04 100644
--- a/apps/carbon/app/modules/parts/ui/Service/ServiceForm.tsx
+++ b/apps/carbon/app/modules/parts/ui/Service/ServiceForm.tsx
@@ -13,6 +13,7 @@ import type { z } from "zod";
import {
Boolean,
CustomFormFields,
+ Hidden,
Input,
InputControlled,
ItemGroup,
@@ -105,6 +106,7 @@ const ServiceForm = ({ initialValues }: ServiceFormProps) => {
)}
</CardHeader>
<CardContent>
+ <Hidden name="itemInventoryType" value="Non-Inventory" />
<div
className={cn(
"grid w-full gap-x-8 gap-y-2",
diff --git a/apps/carbon/app/modules/parts/ui/usePartsSubmodules.tsx b/apps/carbon/app/modules/parts/ui/usePartsSubmodules.tsx
index a981f9ff2d..a50febae5c 100644
--- a/apps/carbon/app/modules/parts/ui/usePartsSubmodules.tsx
+++ b/apps/carbon/app/modules/parts/ui/usePartsSubmodules.tsx
@@ -8,7 +8,7 @@ const partsRoutes: AuthenticatedRouteGroup[] = [
routes: [
{
name: "Parts",
- to: path.to.partsSearch,
+ to: path.to.parts,
},
{
name: "Services",
diff --git a/apps/carbon/app/modules/purchasing/ui/Suppliers/SuppliersTable.tsx b/apps/carbon/app/modules/purchasing/ui/Suppliers/SuppliersTable.tsx
index 5473540e79..3f4b1fd3d1 100644
--- a/apps/carbon/app/modules/purchasing/ui/Suppliers/SuppliersTable.tsx
+++ b/apps/carbon/app/modules/purchasing/ui/Suppliers/SuppliersTable.tsx
@@ -119,7 +119,7 @@ const SuppliersTable = memo(
header: "Parts",
cell: ({ row }) => (
<Button variant="secondary" asChild>
- <Link to={`${path.to.partsSearch}?supplierId=${row.original.id}`}>
+ <Link to={`${path.to.parts}?supplierId=${row.original.id}`}>
{row.original.partCount ?? 0} Parts
</Link>
</Button>
diff --git a/apps/carbon/app/modules/sales/sales.models.ts b/apps/carbon/app/modules/sales/sales.models.ts
index 968494b970..302ef18be5 100644
--- a/apps/carbon/app/modules/sales/sales.models.ts
+++ b/apps/carbon/app/modules/sales/sales.models.ts
@@ -173,7 +173,6 @@ export const salesOrderLineType = [
"Hardware",
"Consumable",
"Comment",
- "GL Account",
"Fixed Asset",
] as const;
diff --git a/apps/carbon/app/routes/x+/parts+/_index.tsx b/apps/carbon/app/routes/x+/items/_index.tsx
similarity index 75%
rename from apps/carbon/app/routes/x+/parts+/_index.tsx
rename to apps/carbon/app/routes/x+/items/_index.tsx
index 8555df1c73..8584f738f9 100644
--- a/apps/carbon/app/routes/x+/parts+/_index.tsx
+++ b/apps/carbon/app/routes/x+/items/_index.tsx
@@ -2,5 +2,5 @@ import { redirect } from "@remix-run/node";
import { path } from "~/utils/path";
export async function loader() {
- throw redirect(path.to.partsSearch);
+ throw redirect(path.to.parts);
}
diff --git a/apps/carbon/app/routes/x+/parts+/_layout.tsx b/apps/carbon/app/routes/x+/items/_layout.tsx
similarity index 89%
rename from apps/carbon/app/routes/x+/parts+/_layout.tsx
rename to apps/carbon/app/routes/x+/items/_layout.tsx
index e4ff8685f6..29d4c75562 100644
--- a/apps/carbon/app/routes/x+/parts+/_layout.tsx
+++ b/apps/carbon/app/routes/x+/items/_layout.tsx
@@ -7,12 +7,12 @@ import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
export const meta: MetaFunction = () => {
- return [{ title: "Carbon | Parts" }];
+ return [{ title: "Carbon | Items" }];
};
export const handle: Handle = {
- breadcrumb: "Parts",
- to: path.to.partsSearch,
+ breadcrumb: "Items",
+ to: path.to.parts,
module: "parts",
};
diff --git a/apps/carbon/app/routes/x+/parts+/groups.$groupId.tsx b/apps/carbon/app/routes/x+/items/groups.$groupId.tsx
similarity index 100%
rename from apps/carbon/app/routes/x+/parts+/groups.$groupId.tsx
rename to apps/carbon/app/routes/x+/items/groups.$groupId.tsx
diff --git a/apps/carbon/app/routes/x+/parts+/groups.delete.$groupId.tsx b/apps/carbon/app/routes/x+/items/groups.delete.$groupId.tsx
similarity index 100%
rename from apps/carbon/app/routes/x+/parts+/groups.delete.$groupId.tsx
rename to apps/carbon/app/routes/x+/items/groups.delete.$groupId.tsx
diff --git a/apps/carbon/app/routes/x+/parts+/groups.new.tsx b/apps/carbon/app/routes/x+/items/groups.new.tsx
similarity index 100%
rename from apps/carbon/app/routes/x+/parts+/groups.new.tsx
rename to apps/carbon/app/routes/x+/items/groups.new.tsx
diff --git a/apps/carbon/app/routes/x+/parts+/groups.tsx b/apps/carbon/app/routes/x+/items/groups.tsx
similarity index 98%
rename from apps/carbon/app/routes/x+/parts+/groups.tsx
rename to apps/carbon/app/routes/x+/items/groups.tsx
index 116d4f0d5b..28b19df1b5 100644
--- a/apps/carbon/app/routes/x+/parts+/groups.tsx
+++ b/apps/carbon/app/routes/x+/items/groups.tsx
@@ -41,7 +41,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
if (itemGroups.error) {
throw redirect(
- path.to.parts,
+ path.to.items,
await flash(request, error(null, "Error loading item groups"))
);
}
diff --git a/apps/carbon/app/routes/x+/parts+/search.tsx b/apps/carbon/app/routes/x+/items/parts.tsx
similarity index 93%
rename from apps/carbon/app/routes/x+/parts+/search.tsx
rename to apps/carbon/app/routes/x+/items/parts.tsx
index 5068abec0b..103d0f5668 100644
--- a/apps/carbon/app/routes/x+/parts+/search.tsx
+++ b/apps/carbon/app/routes/x+/items/parts.tsx
@@ -5,10 +5,16 @@ import { Outlet, useLoaderData } from "@remix-run/react";
import { PartsTable, getItemGroupsList, getParts } from "~/modules/parts";
import { requirePermissions } from "~/services/auth/auth.server";
import { flash } from "~/services/session.server";
+import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
import { getGenericQueryFilters } from "~/utils/query";
import { error } from "~/utils/result";
+export const handle: Handle = {
+ breadcrumb: "Parts",
+ to: path.to.parts,
+};
+
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "parts",
diff --git a/apps/carbon/app/routes/x+/parts+/routing.tsx b/apps/carbon/app/routes/x+/items/routing.tsx
similarity index 100%
rename from apps/carbon/app/routes/x+/parts+/routing.tsx
rename to apps/carbon/app/routes/x+/items/routing.tsx
diff --git a/apps/carbon/app/routes/x+/parts+/services.tsx b/apps/carbon/app/routes/x+/items/services.tsx
similarity index 98%
rename from apps/carbon/app/routes/x+/parts+/services.tsx
rename to apps/carbon/app/routes/x+/items/services.tsx
index 879f678947..0b58b0ba8b 100644
--- a/apps/carbon/app/routes/x+/parts+/services.tsx
+++ b/apps/carbon/app/routes/x+/items/services.tsx
@@ -46,7 +46,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
if (services.error) {
redirect(
- path.to.parts,
+ path.to.items,
await flash(request, error(services.error, "Failed to fetch services"))
);
}
diff --git a/apps/carbon/app/routes/x+/parts+/uom.$uomId.tsx b/apps/carbon/app/routes/x+/items/uom.$uomId.tsx
similarity index 100%
rename from apps/carbon/app/routes/x+/parts+/uom.$uomId.tsx
rename to apps/carbon/app/routes/x+/items/uom.$uomId.tsx
diff --git a/apps/carbon/app/routes/x+/parts+/uom.delete.$uomId.tsx b/apps/carbon/app/routes/x+/items/uom.delete.$uomId.tsx
similarity index 100%
rename from apps/carbon/app/routes/x+/parts+/uom.delete.$uomId.tsx
rename to apps/carbon/app/routes/x+/items/uom.delete.$uomId.tsx
diff --git a/apps/carbon/app/routes/x+/parts+/uom.new.tsx b/apps/carbon/app/routes/x+/items/uom.new.tsx
similarity index 100%
rename from apps/carbon/app/routes/x+/parts+/uom.new.tsx
rename to apps/carbon/app/routes/x+/items/uom.new.tsx
diff --git a/apps/carbon/app/routes/x+/parts+/uom.tsx b/apps/carbon/app/routes/x+/items/uom.tsx
similarity index 100%
rename from apps/carbon/app/routes/x+/parts+/uom.tsx
rename to apps/carbon/app/routes/x+/items/uom.tsx
diff --git a/apps/carbon/app/routes/x+/part+/$itemId.costing.tsx b/apps/carbon/app/routes/x+/part+/$itemId.costing.tsx
index 160ca35eb8..6517ceb836 100644
--- a/apps/carbon/app/routes/x+/part+/$itemId.costing.tsx
+++ b/apps/carbon/app/routes/x+/part+/$itemId.costing.tsx
@@ -31,13 +31,13 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
if (itemCost.error) {
throw redirect(
- path.to.parts,
+ path.to.items,
await flash(request, error(itemCost.error, "Failed to load part costing"))
);
}
if (accounts.error) {
throw redirect(
- path.to.parts,
+ path.to.items,
await flash(request, error(accounts.error, "Failed to load accounts"))
);
}
diff --git a/apps/carbon/app/routes/x+/part+/$itemId.details.tsx b/apps/carbon/app/routes/x+/part+/$itemId.details.tsx
index eda4f1d70f..7568e7dde2 100644
--- a/apps/carbon/app/routes/x+/part+/$itemId.details.tsx
+++ b/apps/carbon/app/routes/x+/part+/$itemId.details.tsx
@@ -62,9 +62,9 @@ export default function PartDetailsRoute() {
name: partData.partSummary?.name ?? "",
description: partData.partSummary?.description ?? "",
itemGroupId: partData.partSummary?.itemGroupId ?? "",
+ itemInventoryType: partData.partSummary?.itemInventoryType ?? "Inventory",
active: partData.partSummary?.active ?? true,
blocked: partData.partSummary?.blocked ?? false,
- partType: partData.partSummary?.partType ?? "Inventory",
replenishmentSystem: partData.partSummary?.replenishmentSystem ?? "Buy",
unitOfMeasureCode: partData.partSummary?.unitOfMeasureCode ?? "EA",
...getCustomFields(partData.partSummary?.customFields ?? {}),
diff --git a/apps/carbon/app/routes/x+/part+/$itemId.inventory.tsx b/apps/carbon/app/routes/x+/part+/$itemId.inventory.tsx
index 5a5b281470..a8b45d9838 100644
--- a/apps/carbon/app/routes/x+/part+/$itemId.inventory.tsx
+++ b/apps/carbon/app/routes/x+/part+/$itemId.inventory.tsx
@@ -105,7 +105,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
if (shelves.error) {
throw redirect(
- path.to.parts,
+ path.to.items,
await flash(request, error(shelves.error, "Failed to load shelves"))
);
}
@@ -118,7 +118,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
);
if (quantities.error || !quantities.data) {
throw redirect(
- path.to.parts,
+ path.to.items,
await flash(request, error(quantities, "Failed to load part quantities"))
);
}
diff --git a/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.tsx b/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.tsx
index 95aad852f1..e027bef472 100644
--- a/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.tsx
+++ b/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.tsx
@@ -31,7 +31,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
if (partManufacturing.error) {
throw redirect(
- path.to.parts,
+ path.to.items,
await flash(
request,
error(
diff --git a/apps/carbon/app/routes/x+/part+/$itemId.purchasing.tsx b/apps/carbon/app/routes/x+/part+/$itemId.purchasing.tsx
index 94dfba8375..ded30d61ec 100644
--- a/apps/carbon/app/routes/x+/part+/$itemId.purchasing.tsx
+++ b/apps/carbon/app/routes/x+/part+/$itemId.purchasing.tsx
@@ -26,7 +26,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
if (partPurchasing.error) {
throw redirect(
- path.to.parts,
+ path.to.items,
await flash(
request,
error(partPurchasing.error, "Failed to load part purchasing")
diff --git a/apps/carbon/app/routes/x+/part+/$itemId.sale-price.tsx b/apps/carbon/app/routes/x+/part+/$itemId.sale-price.tsx
index ffa7909ab4..4067b4e4dd 100644
--- a/apps/carbon/app/routes/x+/part+/$itemId.sale-price.tsx
+++ b/apps/carbon/app/routes/x+/part+/$itemId.sale-price.tsx
@@ -29,7 +29,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
if (partUnitSalePrice.error) {
throw redirect(
- path.to.parts,
+ path.to.items,
await flash(
request,
error(partUnitSalePrice.error, "Failed to load part unit sale price")
diff --git a/apps/carbon/app/routes/x+/part+/$itemId.tsx b/apps/carbon/app/routes/x+/part+/$itemId.tsx
index 23fce3e36d..8c3826e337 100644
--- a/apps/carbon/app/routes/x+/part+/$itemId.tsx
+++ b/apps/carbon/app/routes/x+/part+/$itemId.tsx
@@ -19,7 +19,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
if (partSummary.error) {
throw redirect(
- path.to.parts,
+ path.to.items,
await flash(
request,
error(partSummary.error, "Failed to load part summary")
diff --git a/apps/carbon/app/routes/x+/part+/_layout.tsx b/apps/carbon/app/routes/x+/part+/_layout.tsx
index 0170e0b22b..5469b22111 100644
--- a/apps/carbon/app/routes/x+/part+/_layout.tsx
+++ b/apps/carbon/app/routes/x+/part+/_layout.tsx
@@ -12,8 +12,8 @@ export const meta: MetaFunction = () => {
};
export const handle: Handle = {
- breadcrumb: "Parts",
- to: path.to.partsSearch,
+ breadcrumb: "Items",
+ to: path.to.items,
module: "parts",
};
diff --git a/apps/carbon/app/routes/x+/part+/new.tsx b/apps/carbon/app/routes/x+/part+/new.tsx
index 1c4b4a62a3..bfc07be195 100644
--- a/apps/carbon/app/routes/x+/part+/new.tsx
+++ b/apps/carbon/app/routes/x+/part+/new.tsx
@@ -38,7 +38,7 @@ export async function action({ request }: ActionFunctionArgs) {
await flash(request, error(createPart.error, "Failed to insert part"))
)
: redirect(
- path.to.partsSearch,
+ path.to.parts,
await flash(request, error(createPart.error, "Failed to insert part"))
);
}
@@ -56,7 +56,7 @@ export default function PartsNewRoute() {
id: "",
name: "",
description: "",
- partType: "Inventory" as "Inventory",
+ itemInventoryType: "Inventory" as "Inventory",
replenishmentSystem: "Buy" as "Buy",
unitOfMeasureCode: "EA",
blocked: false,
diff --git a/apps/carbon/app/routes/x+/sales-order+/$orderId.lines.$lineId.tsx b/apps/carbon/app/routes/x+/sales-order+/$orderId.lines.$lineId.tsx
index 9a643e0e23..f440afa77c 100644
--- a/apps/carbon/app/routes/x+/sales-order+/$orderId.lines.$lineId.tsx
+++ b/apps/carbon/app/routes/x+/sales-order+/$orderId.lines.$lineId.tsx
@@ -60,9 +60,6 @@ export async function action({ request, params }: ActionFunctionArgs) {
} else if (data.salesOrderLineType === "Fixed Asset") {
data.accountNumber = undefined;
data.itemId = undefined;
- } else if (data.salesOrderLineType === "GL Account") {
- data.assetId = undefined;
- data.itemId = undefined;
} else {
data.accountNumber = undefined;
data.assetId = undefined;
diff --git a/apps/carbon/app/routes/x+/service+/$itemId.details.tsx b/apps/carbon/app/routes/x+/service+/$itemId.details.tsx
index 760340e2c2..bb1d82afc4 100644
--- a/apps/carbon/app/routes/x+/service+/$itemId.details.tsx
+++ b/apps/carbon/app/routes/x+/service+/$itemId.details.tsx
@@ -61,6 +61,7 @@ export default function ServiceDetailsRoute() {
description: routeData.service?.description ?? undefined,
serviceType: routeData.service?.serviceType ?? "Internal",
itemGroupId: routeData.service?.itemGroupId ?? undefined,
+ itemInventoryType: "Non-Inventory" as const,
active: routeData.service?.active ?? true,
blocked: routeData.service?.blocked ?? false,
...getCustomFields(routeData.service?.customFields),
diff --git a/apps/carbon/app/routes/x+/service+/$itemId.tsx b/apps/carbon/app/routes/x+/service+/$itemId.tsx
index e4a414c21e..ab917f7733 100644
--- a/apps/carbon/app/routes/x+/service+/$itemId.tsx
+++ b/apps/carbon/app/routes/x+/service+/$itemId.tsx
@@ -25,7 +25,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
if (service.error) {
throw redirect(
- path.to.parts,
+ path.to.items,
await flash(request, error(service.error, "Failed to load service"))
);
}
diff --git a/apps/carbon/app/routes/x+/service+/_layout.tsx b/apps/carbon/app/routes/x+/service+/_layout.tsx
index 576283f1c0..d8eeccca5c 100644
--- a/apps/carbon/app/routes/x+/service+/_layout.tsx
+++ b/apps/carbon/app/routes/x+/service+/_layout.tsx
@@ -12,8 +12,8 @@ export const meta: MetaFunction = () => {
};
export const handle: Handle = {
- breadcrumb: "Parts",
- to: path.to.partsSearch,
+ breadcrumb: "Items",
+ to: path.to.items,
module: "parts",
};
diff --git a/apps/carbon/app/utils/path.ts b/apps/carbon/app/utils/path.ts
index 222ac33b3d..49ee0df07d 100644
--- a/apps/carbon/app/utils/path.ts
+++ b/apps/carbon/app/utils/path.ts
@@ -30,24 +30,24 @@ export const path = {
generatePath(`${api}/users/groups?type=${type}`),
item: (type: string) => generatePath(`${api}/item/${type}`),
locations: `${api}/resources/locations`,
- itemGroups: `${api}/parts/groups`,
+ itemGroups: `${api}/items/groups`,
rollback: (table: string, id: string) =>
generatePath(
`${api}/settings/sequence/rollback?table=${table}&currentSequence=${id}`
),
sequences: (table: string) => `${api}/settings/sequences?table=${table}`,
- services: `${api}/parts/services`,
+ services: `${api}/items/services`,
shifts: (id: string) =>
generatePath(`${api}/resources/shifts?location=${id}`),
shelves: (id: string) =>
- generatePath(`${api}/parts/shelf?locationId=${id}`),
+ generatePath(`${api}/items/shelf?locationId=${id}`),
supplierContacts: (id: string) =>
generatePath(`${api}/purchasing/supplier-contacts?supplierId=${id}`),
supplierLocations: (id: string) =>
generatePath(`${api}/purchasing/supplier-locations?supplierId=${id}`),
supplierStatuses: `${api}/purchasing/supplier-statuses`,
supplierTypes: `${api}/purchasing/supplier-types`,
- unitOfMeasures: `${api}/parts/uoms`,
+ unitOfMeasures: `${api}/items/uoms`,
workCells: (id: string) =>
generatePath(`${api}/resources/work-cells?location=${id}`),
workCellTypes: `${api}/resources/work-cell-types`,
@@ -184,7 +184,7 @@ export const path = {
generatePath(`${x}/resources/locations/delete/${id}`),
deleteNote: (id: string) => generatePath(`${x}/shared/notes/${id}/delete`),
deleteItemGroup: (id: string) =>
- generatePath(`${x}/parts/groups/delete/${id}`),
+ generatePath(`${x}/items/groups/delete/${id}`),
deletePartner: (id: string) =>
generatePath(`${x}/resources/partners/delete/${id}`),
deletePaymentTerm: (id: string) =>
@@ -227,7 +227,7 @@ export const path = {
generatePath(`${x}/purchasing/supplier-statuses/delete/${id}`),
deleteSupplierType: (id: string) =>
generatePath(`${x}/purchasing/supplier-types/delete/${id}`),
- deleteUom: (id: string) => generatePath(`${x}/parts/uom/delete/${id}`),
+ deleteUom: (id: string) => generatePath(`${x}/items/uom/delete/${id}`),
deleteUserAttribute: (id: string) =>
generatePath(`${x}/account/${id}/delete/attribute`),
deleteWorkCell: (id: string) =>
@@ -313,7 +313,7 @@ export const path = {
newLocation: `${x}/resources/locations/new`,
newNote: `${x}/shared/notes/new`,
newPart: `${x}/part/new`,
- newItemGroup: `${x}/parts/groups/new`,
+ newItemGroup: `${x}/items/groups/new`,
newPartSupplier: (id: string) =>
generatePath(`${x}/part/${id}/suppliers/new`),
newPartner: `${x}/resources/partners/new`,
@@ -362,7 +362,7 @@ export const path = {
generatePath(`${x}/supplier/${id}/locations/new`),
newSupplierStatus: `${x}/purchasing/supplier-statuses/new`,
newSupplierType: `${x}/purchasing/supplier-types/new`,
- newUom: `${x}/parts/uom/new`,
+ newUom: `${x}/items/uom/new`,
newWorkCell: `${x}/resources/work-cells/cell/new`,
newWorkCellUnit: (id: string) =>
generatePath(`${x}/resources/work-cells/list/${id}/new`),
@@ -370,8 +370,8 @@ export const path = {
part: (id: string) => generatePath(`${x}/part/${id}`),
partCosting: (id: string) => generatePath(`${x}/part/${id}/costing`),
partDetails: (id: string) => generatePath(`${x}/part/${id}/details`),
- itemGroup: (id: string) => generatePath(`${x}/parts/groups/${id}`),
- itemGroups: `${x}/parts/groups`,
+ itemGroup: (id: string) => generatePath(`${x}/items/groups/${id}`),
+ itemGroups: `${x}/items/groups`,
partInventory: (id: string) => generatePath(`${x}/part/${id}/inventory`),
partInventoryLocation: (id: string, locationId: string) =>
generatePath(`${x}/part/${id}/inventory?location=${locationId}`),
@@ -387,8 +387,8 @@ export const path = {
partSupplier: (itemId: string, id: string) =>
generatePath(`${x}/part/${itemId}/suppliers/${id}`),
partSuppliers: (id: string) => generatePath(`${x}/part/${id}/suppliers`),
- parts: `${x}/parts`,
- partsSearch: `${x}/parts/search`,
+ items: `${x}/items`,
+ parts: `${x}/items/parts`,
partner: (id: string, abilityId: string) =>
generatePath(`${x}/resources/partners/${id}/${abilityId}`),
partners: `${x}/resources/partners`,
@@ -475,7 +475,7 @@ export const path = {
resetPassword: "/reset-password",
resources: `${x}/resources`,
root: "/",
- routings: `${x}/parts/routing`,
+ routings: `${x}/items/routing`,
sales: `${x}/sales`,
salesInvoices: `${x}/invoicing/sales`,
salesOrder: (id: string) => generatePath(`${x}/sales-order/${id}`),
@@ -499,7 +499,7 @@ export const path = {
salesOrders: `${x}/sales/orders`,
scheduling: `${x}/scheduling`,
service: (id: string) => generatePath(`${x}/service/${id}`),
- services: `${x}/parts/services`,
+ services: `${x}/items/services`,
serviceDetails: (id: string) => `${x}/service/${id}/details`,
serviceRoot: `${x}/service`,
serviceSupplier: (serviceId: string, id: string) =>
@@ -542,8 +542,8 @@ export const path = {
generatePath(`${x}/settings/sequences/${id}`),
theme: `${x}/account/theme`,
timecards: `${x}/timecards`,
- uom: (id: string) => generatePath(`${x}/parts/uom/${id}`),
- uoms: `${x}/parts/uom`,
+ uom: (id: string) => generatePath(`${x}/items/uom/${id}`),
+ uoms: `${x}/items/uom`,
userAttribute: (id: string) => generatePath(`${x}/account/${id}/attribute`),
users: `${x}/users`,
workCell: (id: string) =>
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index 1ad7107c66..dd4c943a85 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -2121,6 +2121,7 @@ export type Database = {
id: string
itemId: string | null
itemLedgerType: Database["public"]["Enums"]["itemLedgerType"]
+ itemReadableId: string | null
postingDate: string
quantity: number
}
@@ -2140,6 +2141,7 @@ export type Database = {
id?: string
itemId?: string | null
itemLedgerType: Database["public"]["Enums"]["itemLedgerType"]
+ itemReadableId?: string | null
postingDate?: string
quantity?: number
}
@@ -2159,6 +2161,7 @@ export type Database = {
id?: string
itemId?: string | null
itemLedgerType?: Database["public"]["Enums"]["itemLedgerType"]
+ itemReadableId?: string | null
postingDate?: string
quantity?: number
}
@@ -5422,6 +5425,7 @@ export type Database = {
description: string | null
id: string
itemGroupId: string | null
+ itemInventoryType: Database["public"]["Enums"]["itemInventoryType"]
name: string
readableId: string
type: Database["public"]["Enums"]["itemType"]
@@ -5437,6 +5441,7 @@ export type Database = {
description?: string | null
id?: string
itemGroupId?: string | null
+ itemInventoryType: Database["public"]["Enums"]["itemInventoryType"]
name: string
readableId: string
type: Database["public"]["Enums"]["itemType"]
@@ -5452,6 +5457,7 @@ export type Database = {
description?: string | null
id?: string
itemGroupId?: string | null
+ itemInventoryType?: Database["public"]["Enums"]["itemInventoryType"]
name?: string
readableId?: string
type?: Database["public"]["Enums"]["itemType"]
@@ -6056,6 +6062,7 @@ export type Database = {
externalDocumentId: string | null
id: string
itemId: string
+ itemReadableId: string | null
locationId: string | null
postingDate: string
quantity: number
@@ -6073,6 +6080,7 @@ export type Database = {
externalDocumentId?: string | null
id?: string
itemId: string
+ itemReadableId?: string | null
locationId?: string | null
postingDate?: string
quantity: number
@@ -6090,6 +6098,7 @@ export type Database = {
externalDocumentId?: string | null
id?: string
itemId?: string
+ itemReadableId?: string | null
locationId?: string | null
postingDate?: string
quantity?: number
@@ -7424,7 +7433,6 @@ export type Database = {
fromDate: string | null
id: string
itemId: string
- partType: Database["public"]["Enums"]["partType"]
replenishmentSystem: Database["public"]["Enums"]["itemReplenishmentSystem"]
toDate: string | null
unitOfMeasureCode: string
@@ -7442,7 +7450,6 @@ export type Database = {
fromDate?: string | null
id: string
itemId: string
- partType: Database["public"]["Enums"]["partType"]
replenishmentSystem: Database["public"]["Enums"]["itemReplenishmentSystem"]
toDate?: string | null
unitOfMeasureCode: string
@@ -7460,7 +7467,6 @@ export type Database = {
fromDate?: string | null
id?: string
itemId?: string
- partType?: Database["public"]["Enums"]["partType"]
replenishmentSystem?: Database["public"]["Enums"]["itemReplenishmentSystem"]
toDate?: string | null
unitOfMeasureCode?: string
@@ -12381,6 +12387,7 @@ export type Database = {
createdBy: string
id: string
itemId: string
+ itemReadableId: string | null
lineId: string | null
locationId: string | null
orderQuantity: number
@@ -12400,6 +12407,7 @@ export type Database = {
createdBy: string
id?: string
itemId: string
+ itemReadableId?: string | null
lineId?: string | null
locationId?: string | null
orderQuantity: number
@@ -12419,6 +12427,7 @@ export type Database = {
createdBy?: string
id?: string
itemId?: string
+ itemReadableId?: string | null
lineId?: string | null
locationId?: string | null
orderQuantity?: number
@@ -19719,8 +19728,10 @@ export type Database = {
itemGroup: string | null
itemGroupId: string | null
itemId: string | null
+ itemInventoryType:
+ | Database["public"]["Enums"]["itemInventoryType"]
+ | null
name: string | null
- partType: Database["public"]["Enums"]["partType"] | null
replenishmentSystem:
| Database["public"]["Enums"]["itemReplenishmentSystem"]
| null
@@ -20423,14 +20434,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["supplierCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["id"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["supplierCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["id"]
@@ -22914,6 +22925,7 @@ export type Database = {
glConsolidatedRate: "Average" | "Current" | "Historical"
glIncomeBalance: "Balance Sheet" | "Income Statement"
itemCostingMethod: "Standard" | "Average" | "LIFO" | "FIFO"
+ itemInventoryType: "Inventory" | "Non-Inventory"
itemLedgerDocumentType:
| "Sales Shipment"
| "Sales Invoice"
@@ -22991,7 +23003,6 @@ export type Database = {
| "November"
| "December"
partManufacturingPolicy: "Make to Order" | "Make to Stock"
- partType: "Inventory" | "Non-Inventory"
payableLineType:
| "Comment"
| "G/L Account"
diff --git a/packages/database/supabase/functions/create-purchase-invoice-from-purchase-order/index.ts b/packages/database/supabase/functions/create-purchase-invoice-from-purchase-order/index.ts
index 856d98caec..ffd51b5fa1 100644
--- a/packages/database/supabase/functions/create-purchase-invoice-from-purchase-order/index.ts
+++ b/packages/database/supabase/functions/create-purchase-invoice-from-purchase-order/index.ts
@@ -119,8 +119,8 @@ serve(async (req: Request) => {
invoiceLineType: line.purchaseOrderLineType,
purchaseOrderId: line.purchaseOrderId,
purchaseOrderLineId: line.id,
- partId: line.partId,
- serviceId: line.serviceId,
+ itemId: line.itemId,
+ itemReadableId: line.itemReadableId,
locationId: line.locationId,
shelfId: line.shelfId,
accountNumber: line.accountNumber,
diff --git a/packages/database/supabase/functions/create-receipt-from-purchase-order/index.ts b/packages/database/supabase/functions/create-receipt-from-purchase-order/index.ts
index c8c406a02f..07ba996b54 100644
--- a/packages/database/supabase/functions/create-receipt-from-purchase-order/index.ts
+++ b/packages/database/supabase/functions/create-receipt-from-purchase-order/index.ts
@@ -68,9 +68,10 @@ serve(async (req: Request) => {
const receiptLineItems = purchaseOrderLines.data.reduce<ReceiptLineItem[]>(
(acc, d) => {
if (
- !d.partId ||
+ !d.itemId ||
!d.purchaseQuantity ||
d.unitPrice === null ||
+ d.purchaseOrderLineType === "Service" ||
isNaN(d.unitPrice)
) {
return acc;
@@ -82,7 +83,8 @@ serve(async (req: Request) => {
acc.push({
lineId: d.id,
companyId: companyId,
- partId: d.partId,
+ itemId: d.itemId,
+ itemReadableId: d.itemReadableId,
orderQuantity: d.purchaseQuantity * (d.conversionFactor ?? 1),
outstandingQuantity: outstandingQuantity * (d.conversionFactor ?? 1),
receivedQuantity: outstandingQuantity * (d.conversionFactor ?? 1),
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index 1ad7107c66..dd4c943a85 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -2121,6 +2121,7 @@ export type Database = {
id: string
itemId: string | null
itemLedgerType: Database["public"]["Enums"]["itemLedgerType"]
+ itemReadableId: string | null
postingDate: string
quantity: number
}
@@ -2140,6 +2141,7 @@ export type Database = {
id?: string
itemId?: string | null
itemLedgerType: Database["public"]["Enums"]["itemLedgerType"]
+ itemReadableId?: string | null
postingDate?: string
quantity?: number
}
@@ -2159,6 +2161,7 @@ export type Database = {
id?: string
itemId?: string | null
itemLedgerType?: Database["public"]["Enums"]["itemLedgerType"]
+ itemReadableId?: string | null
postingDate?: string
quantity?: number
}
@@ -5422,6 +5425,7 @@ export type Database = {
description: string | null
id: string
itemGroupId: string | null
+ itemInventoryType: Database["public"]["Enums"]["itemInventoryType"]
name: string
readableId: string
type: Database["public"]["Enums"]["itemType"]
@@ -5437,6 +5441,7 @@ export type Database = {
description?: string | null
id?: string
itemGroupId?: string | null
+ itemInventoryType: Database["public"]["Enums"]["itemInventoryType"]
name: string
readableId: string
type: Database["public"]["Enums"]["itemType"]
@@ -5452,6 +5457,7 @@ export type Database = {
description?: string | null
id?: string
itemGroupId?: string | null
+ itemInventoryType?: Database["public"]["Enums"]["itemInventoryType"]
name?: string
readableId?: string
type?: Database["public"]["Enums"]["itemType"]
@@ -6056,6 +6062,7 @@ export type Database = {
externalDocumentId: string | null
id: string
itemId: string
+ itemReadableId: string | null
locationId: string | null
postingDate: string
quantity: number
@@ -6073,6 +6080,7 @@ export type Database = {
externalDocumentId?: string | null
id?: string
itemId: string
+ itemReadableId?: string | null
locationId?: string | null
postingDate?: string
quantity: number
@@ -6090,6 +6098,7 @@ export type Database = {
externalDocumentId?: string | null
id?: string
itemId?: string
+ itemReadableId?: string | null
locationId?: string | null
postingDate?: string
quantity?: number
@@ -7424,7 +7433,6 @@ export type Database = {
fromDate: string | null
id: string
itemId: string
- partType: Database["public"]["Enums"]["partType"]
replenishmentSystem: Database["public"]["Enums"]["itemReplenishmentSystem"]
toDate: string | null
unitOfMeasureCode: string
@@ -7442,7 +7450,6 @@ export type Database = {
fromDate?: string | null
id: string
itemId: string
- partType: Database["public"]["Enums"]["partType"]
replenishmentSystem: Database["public"]["Enums"]["itemReplenishmentSystem"]
toDate?: string | null
unitOfMeasureCode: string
@@ -7460,7 +7467,6 @@ export type Database = {
fromDate?: string | null
id?: string
itemId?: string
- partType?: Database["public"]["Enums"]["partType"]
replenishmentSystem?: Database["public"]["Enums"]["itemReplenishmentSystem"]
toDate?: string | null
unitOfMeasureCode?: string
@@ -12381,6 +12387,7 @@ export type Database = {
createdBy: string
id: string
itemId: string
+ itemReadableId: string | null
lineId: string | null
locationId: string | null
orderQuantity: number
@@ -12400,6 +12407,7 @@ export type Database = {
createdBy: string
id?: string
itemId: string
+ itemReadableId?: string | null
lineId?: string | null
locationId?: string | null
orderQuantity: number
@@ -12419,6 +12427,7 @@ export type Database = {
createdBy?: string
id?: string
itemId?: string
+ itemReadableId?: string | null
lineId?: string | null
locationId?: string | null
orderQuantity?: number
@@ -19719,8 +19728,10 @@ export type Database = {
itemGroup: string | null
itemGroupId: string | null
itemId: string | null
+ itemInventoryType:
+ | Database["public"]["Enums"]["itemInventoryType"]
+ | null
name: string | null
- partType: Database["public"]["Enums"]["partType"] | null
replenishmentSystem:
| Database["public"]["Enums"]["itemReplenishmentSystem"]
| null
@@ -20423,14 +20434,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["supplierCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["id"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["supplierCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["id"]
@@ -22914,6 +22925,7 @@ export type Database = {
glConsolidatedRate: "Average" | "Current" | "Historical"
glIncomeBalance: "Balance Sheet" | "Income Statement"
itemCostingMethod: "Standard" | "Average" | "LIFO" | "FIFO"
+ itemInventoryType: "Inventory" | "Non-Inventory"
itemLedgerDocumentType:
| "Sales Shipment"
| "Sales Invoice"
@@ -22991,7 +23003,6 @@ export type Database = {
| "November"
| "December"
partManufacturingPolicy: "Make to Order" | "Make to Stock"
- partType: "Inventory" | "Non-Inventory"
payableLineType:
| "Comment"
| "G/L Account"
diff --git a/packages/database/supabase/functions/post-purchase-invoice/index.ts b/packages/database/supabase/functions/post-purchase-invoice/index.ts
index 5afd62a602..942fdaabff 100644
--- a/packages/database/supabase/functions/post-purchase-invoice/index.ts
+++ b/packages/database/supabase/functions/post-purchase-invoice/index.ts
@@ -42,33 +42,21 @@ serve(async (req: Request) => {
const companyId = purchaseInvoice.data.companyId;
- const [parts, services, purchaseOrderLines, supplier] = await Promise.all([
+ const [items, purchaseOrderLines, supplier] = await Promise.all([
client
- .from("part")
- .select("id, itemGroupId, partType")
+ .from("item")
+ .select("id, itemGroupId, itemInventoryType, readableId")
.in(
"id",
purchaseInvoiceLines.data.reduce<string[]>((acc, invoiceLine) => {
- if (invoiceLine.partId && !acc.includes(invoiceLine.partId)) {
- acc.push(invoiceLine.partId);
- }
- return acc;
- }, [])
- )
- .eq("companyId", companyId),
- client
- .from("service")
- .select("id, itemGroupId")
- .in(
- "id",
- purchaseInvoiceLines.data.reduce<string[]>((acc, invoiceLine) => {
- if (invoiceLine.serviceId && !acc.includes(invoiceLine.serviceId)) {
- acc.push(invoiceLine.serviceId);
+ if (invoiceLine.itemId && !acc.includes(invoiceLine.itemId)) {
+ acc.push(invoiceLine.itemId);
}
return acc;
}, [])
)
.eq("companyId", companyId),
+
client
.from("purchaseOrderLine")
.select("*")
@@ -91,8 +79,7 @@ serve(async (req: Request) => {
.eq("companyId", companyId)
.single(),
]);
- if (parts.error) throw new Error("Failed to fetch item groups");
- if (services.error) throw new Error("Failed to fetch service item groups");
+ if (items.error) throw new Error("Failed to fetch item groups");
if (purchaseOrderLines.error)
throw new Error("Failed to fetch purchase order lines");
if (supplier.error) throw new Error("Failed to fetch supplier");
@@ -259,266 +246,19 @@ serve(async (req: Request) => {
let journalLineReference: string;
switch (invoiceLine.invoiceLineType) {
- case "G/L Account":
- const [account, accountDefaults] = await Promise.all([
- client
- .from("accounts")
- .select("name, number, directPosting")
- .eq("number", invoiceLine.accountNumber ?? "")
- .eq("companyId", companyId)
- .single(),
- client
- .from("accountDefault")
- .select(
- "overheadCostAppliedAccount, payablesAccount, purchaseAccount"
- )
- .eq("companyId", companyId)
- .single(),
- ]);
- if (account.error || !account.data)
- throw new Error("Failed to fetch account");
- if (!account.data.directPosting)
- throw new Error("Account is not a direct posting account");
-
- if (accountDefaults.error || !accountDefaults.data)
- throw new Error("Failed to fetch account defaults");
-
- journalLineReference = nanoid();
-
- // debit the G/L account
- journalLineInserts.push({
- accountNumber: account.data.number!,
- description: account.data.name!,
- // we limit the account to assets and expenses in the UI, so we don't need to check here
- amount: debit(
- "asset",
- invoiceLine.quantity * invoiceLine.unitPrice
- ),
- quantity: invoiceLineQuantityInInventoryUnit,
- documentType: "Invoice",
- documentId: purchaseInvoice.data?.id,
- externalDocumentId: purchaseInvoice.data?.supplierReference,
- documentLineReference: journalReference.to.purchaseInvoice(
- invoiceLine.purchaseOrderLineId!
- ),
- journalLineReference,
- companyId,
- });
-
- // credit the direct cost applied account
- journalLineInserts.push({
- accountNumber: accountDefaults.data.overheadCostAppliedAccount!,
- description: "Overhead Cost Applied",
- amount: credit(
- "expense",
- invoiceLine.quantity * invoiceLine.unitPrice
- ),
- quantity: invoiceLineQuantityInInventoryUnit,
- documentType: "Invoice",
- documentId: purchaseInvoice.data?.id,
- externalDocumentId: purchaseInvoice.data?.supplierReference,
- documentLineReference: journalReference.to.purchaseInvoice(
- invoiceLine.purchaseOrderLineId!
- ),
- journalLineReference,
- companyId,
- });
-
- journalLineReference = nanoid();
-
- // debit the purchase account
- journalLineInserts.push({
- accountNumber: accountDefaults.data.purchaseAccount!,
- description: "Purchase Account",
- amount: debit(
- "expense",
- invoiceLine.quantity * invoiceLine.unitPrice
- ),
- quantity: invoiceLineQuantityInInventoryUnit,
- documentType: "Invoice",
- documentId: purchaseInvoice.data?.id,
- externalDocumentId: purchaseInvoice.data?.supplierReference,
- documentLineReference: journalReference.to.purchaseInvoice(
- invoiceLine.purchaseOrderLineId!
- ),
- journalLineReference,
- companyId,
- });
-
- // credit the accounts payable account
- journalLineInserts.push({
- accountNumber: accountDefaults.data.payablesAccount!,
- description: "Accounts Payable",
- amount: credit(
- "liability",
- invoiceLine.quantity * invoiceLine.unitPrice
- ),
- quantity: invoiceLineQuantityInInventoryUnit,
- documentType: "Invoice",
- documentId: purchaseInvoice.data?.id,
- externalDocumentId: purchaseInvoice.data?.supplierReference,
- documentLineReference: journalReference.to.purchaseInvoice(
- invoiceLine.purchaseOrderLineId!
- ),
- journalLineReference,
- companyId,
- });
- break;
- case "Service":
- itemGroupId =
- services.data.find(
- (service) => service.id === invoiceLine.serviceId
- )?.itemGroupId ?? null;
-
- // inventory posting group
- if (`${itemGroupId}-${locationId}` in inventoryPostingGroups) {
- postingGroupInventory =
- inventoryPostingGroups[`${itemGroupId}-${locationId}`];
- } else {
- const inventoryPostingGroup = await getInventoryPostingGroup(
- client,
- {
- itemGroupId,
- locationId,
- }
- );
-
- if (inventoryPostingGroup.error || !inventoryPostingGroup.data) {
- throw new Error("Error getting inventory posting group");
- }
-
- postingGroupInventory = inventoryPostingGroup.data ?? null;
- inventoryPostingGroups[`${itemGroupId}-${locationId}`] =
- postingGroupInventory;
- }
-
- if (!postingGroupInventory) {
- throw new Error("No inventory posting group found");
- }
-
- if (`${itemGroupId}-${supplierTypeId}` in purchasingPostingGroups) {
- postingGroupPurchasing =
- purchasingPostingGroups[`${itemGroupId}-${supplierTypeId}`];
- } else {
- const purchasingPostingGroup = await getPurchasingPostingGroup(
- client,
- {
- itemGroupId,
- supplierTypeId,
- }
- );
-
- if (purchasingPostingGroup.error || !purchasingPostingGroup.data) {
- throw new Error("Error getting purchasing posting group");
- }
-
- postingGroupPurchasing = purchasingPostingGroup.data ?? null;
- purchasingPostingGroups[`${itemGroupId}-${supplierTypeId}`] =
- postingGroupPurchasing;
- }
-
- if (!postingGroupPurchasing) {
- throw new Error("No purchasing posting group found");
- }
-
- if (
- invoiceLine.purchaseOrderLineId !== null &&
- invoiceLine.purchaseOrderLineId in purchaseOrderLineUpdates
- ) {
- // we don't receive services, so match the received to the invoiced
- const update =
- purchaseOrderLineUpdates[invoiceLine.purchaseOrderLineId];
- purchaseOrderLineUpdates[invoiceLine.purchaseOrderLineId] = {
- ...update,
- receivedComplete: update.invoicedComplete,
- quantityReceived: update.quantityInvoiced,
- };
- }
-
- // create the normal GL entries for a service
-
- journalLineReference = nanoid();
-
- // debit the inventory account
- journalLineInserts.push({
- accountNumber: postingGroupInventory.overheadAccount,
- description: "Overhead Account",
- amount: debit(
- "expense",
- invoiceLine.quantity * invoiceLine.unitPrice
- ),
- quantity: invoiceLineQuantityInInventoryUnit,
- documentType: "Invoice",
- documentId: purchaseInvoice.data?.id,
- externalDocumentId: purchaseInvoice.data?.supplierReference,
- journalLineReference,
- companyId,
- });
-
- // creidt the direct cost applied account
- journalLineInserts.push({
- accountNumber: postingGroupInventory.overheadCostAppliedAccount,
- description: "Over Cost Applied",
- amount: credit(
- "expense",
- invoiceLine.quantity * invoiceLine.unitPrice
- ),
- quantity: invoiceLineQuantityInInventoryUnit,
- documentType: "Invoice",
- documentId: purchaseInvoice.data?.id,
- externalDocumentId: purchaseInvoice.data?.supplierReference,
- journalLineReference,
- companyId,
- });
-
- journalLineReference = nanoid();
-
- // debit the purchase account
- journalLineInserts.push({
- accountNumber: postingGroupPurchasing.purchaseAccount,
- description: "Purchase Account",
- amount: debit(
- "expense",
- invoiceLine.quantity * invoiceLine.unitPrice
- ),
- quantity: invoiceLineQuantityInInventoryUnit,
- documentType: "Invoice",
- documentId: purchaseInvoice.data?.id,
- externalDocumentId: purchaseInvoice.data?.supplierReference,
- documentLineReference: journalReference.to.purchaseInvoice(
- invoiceLine.purchaseOrderLineId!
- ),
- journalLineReference,
- companyId,
- });
-
- // credit the accounts payable account
- journalLineInserts.push({
- accountNumber: postingGroupPurchasing.payablesAccount,
- description: "Accounts Payable",
- amount: credit(
- "liability",
- invoiceLine.quantity * invoiceLine.unitPrice
- ),
- quantity: invoiceLineQuantityInInventoryUnit,
- documentType: "Invoice",
- documentId: purchaseInvoice.data?.id,
- externalDocumentId: purchaseInvoice.data?.supplierReference,
- documentLineReference: journalReference.to.purchaseInvoice(
- invoiceLine.purchaseOrderLineId!
- ),
- journalLineReference,
- companyId,
- });
-
- break;
case "Part":
- const partType =
- parts.data.find((part) => part.id === invoiceLine.partId)
- ?.partType ?? "Inventory";
+ case "Service":
+ case "Consumable":
+ case "Fixture":
+ case "Hardware":
+ case "Material":
+ case "Tool":
+ const itemInventoryType =
+ items.data.find((item) => item.id === invoiceLine.itemId)
+ ?.itemInventoryType ?? "Inventory";
itemGroupId =
- parts.data.find((part) => part.id === invoiceLine.partId)
+ items.data.find((item) => item.id === invoiceLine.itemId)
?.itemGroupId ?? null;
// inventory posting group
@@ -576,7 +316,7 @@ serve(async (req: Request) => {
if (invoiceLine.purchaseOrderLineId === null) {
// create the receipt line
receiptLineInserts.push({
- partId: invoiceLine.partId!,
+ itemId: invoiceLine.itemId!,
lineId: invoiceLine.id,
orderQuantity: invoiceLineQuantityInInventoryUnit,
outstandingQuantity: invoiceLineQuantityInInventoryUnit,
@@ -589,11 +329,12 @@ serve(async (req: Request) => {
companyId,
});
- if (partType === "Inventory") {
+ if (itemInventoryType === "Inventory") {
// create the part ledger line
itemLedgerInserts.push({
postingDate: today,
- partId: invoiceLine.partId!,
+ itemId: invoiceLine.itemId!,
+ itemReadableId: invoiceLine.itemReadableId!,
quantity: invoiceLineQuantityInInventoryUnit,
locationId: invoiceLine.locationId,
shelfId: invoiceLine.shelfId,
@@ -615,7 +356,8 @@ serve(async (req: Request) => {
documentId: purchaseInvoice.data?.id ?? undefined,
externalDocumentId:
purchaseInvoice.data?.supplierReference ?? undefined,
- partId: invoiceLine.partId,
+ itemId: invoiceLine.itemId,
+ itemReadableId: invoiceLine.itemReadableId,
quantity: invoiceLineQuantityInInventoryUnit,
cost: invoiceLine.quantity * invoiceLine.unitPrice,
costPostedToGL: invoiceLine.quantity * invoiceLine.unitPrice,
@@ -626,7 +368,7 @@ serve(async (req: Request) => {
journalLineReference = nanoid();
- if (partType === "Inventory") {
+ if (itemInventoryType === "Inventory") {
// debit the inventory account
journalLineInserts.push({
accountNumber: postingGroupInventory.inventoryAccount,
@@ -891,7 +633,8 @@ serve(async (req: Request) => {
documentId: purchaseInvoice.data?.id ?? undefined,
externalDocumentId:
purchaseInvoice.data?.supplierReference ?? undefined,
- partId: invoiceLine.partId,
+ itemId: invoiceLine.itemId,
+ itemReadableId: invoiceLine.itemReadableId,
quantity: quantityToReverse,
cost: quantityToReverse * invoiceLineUnitPriceInInventoryUnit,
costPostedToGL:
@@ -903,7 +646,7 @@ serve(async (req: Request) => {
journalLineReference = nanoid();
- if (partType === "Inventory") {
+ if (itemInventoryType === "Inventory") {
// debit the inventory account
journalLineInserts.push({
accountNumber: postingGroupInventory.inventoryAccount,
@@ -1084,6 +827,112 @@ serve(async (req: Request) => {
break;
case "Comment":
break;
+ case "G/L Account":
+ const [account, accountDefaults] = await Promise.all([
+ client
+ .from("accounts")
+ .select("name, number, directPosting")
+ .eq("number", invoiceLine.accountNumber ?? "")
+ .eq("companyId", companyId)
+ .single(),
+ client
+ .from("accountDefault")
+ .select(
+ "overheadCostAppliedAccount, payablesAccount, purchaseAccount"
+ )
+ .eq("companyId", companyId)
+ .single(),
+ ]);
+ if (account.error || !account.data)
+ throw new Error("Failed to fetch account");
+ if (!account.data.directPosting)
+ throw new Error("Account is not a direct posting account");
+
+ if (accountDefaults.error || !accountDefaults.data)
+ throw new Error("Failed to fetch account defaults");
+
+ journalLineReference = nanoid();
+
+ // debit the G/L account
+ journalLineInserts.push({
+ accountNumber: account.data.number!,
+ description: account.data.name!,
+ // we limit the account to assets and expenses in the UI, so we don't need to check here
+ amount: debit(
+ "asset",
+ invoiceLine.quantity * invoiceLine.unitPrice
+ ),
+ quantity: invoiceLineQuantityInInventoryUnit,
+ documentType: "Invoice",
+ documentId: purchaseInvoice.data?.id,
+ externalDocumentId: purchaseInvoice.data?.supplierReference,
+ documentLineReference: journalReference.to.purchaseInvoice(
+ invoiceLine.purchaseOrderLineId!
+ ),
+ journalLineReference,
+ companyId,
+ });
+
+ // credit the direct cost applied account
+ journalLineInserts.push({
+ accountNumber: accountDefaults.data.overheadCostAppliedAccount!,
+ description: "Overhead Cost Applied",
+ amount: credit(
+ "expense",
+ invoiceLine.quantity * invoiceLine.unitPrice
+ ),
+ quantity: invoiceLineQuantityInInventoryUnit,
+ documentType: "Invoice",
+ documentId: purchaseInvoice.data?.id,
+ externalDocumentId: purchaseInvoice.data?.supplierReference,
+ documentLineReference: journalReference.to.purchaseInvoice(
+ invoiceLine.purchaseOrderLineId!
+ ),
+ journalLineReference,
+ companyId,
+ });
+
+ journalLineReference = nanoid();
+
+ // debit the purchase account
+ journalLineInserts.push({
+ accountNumber: accountDefaults.data.purchaseAccount!,
+ description: "Purchase Account",
+ amount: debit(
+ "expense",
+ invoiceLine.quantity * invoiceLine.unitPrice
+ ),
+ quantity: invoiceLineQuantityInInventoryUnit,
+ documentType: "Invoice",
+ documentId: purchaseInvoice.data?.id,
+ externalDocumentId: purchaseInvoice.data?.supplierReference,
+ documentLineReference: journalReference.to.purchaseInvoice(
+ invoiceLine.purchaseOrderLineId!
+ ),
+ journalLineReference,
+ companyId,
+ });
+
+ // credit the accounts payable account
+ journalLineInserts.push({
+ accountNumber: accountDefaults.data.payablesAccount!,
+ description: "Accounts Payable",
+ amount: credit(
+ "liability",
+ invoiceLine.quantity * invoiceLine.unitPrice
+ ),
+ quantity: invoiceLineQuantityInInventoryUnit,
+ documentType: "Invoice",
+ documentId: purchaseInvoice.data?.id,
+ externalDocumentId: purchaseInvoice.data?.supplierReference,
+ documentLineReference: journalReference.to.purchaseInvoice(
+ invoiceLine.purchaseOrderLineId!
+ ),
+ journalLineReference,
+ companyId,
+ });
+ break;
+
default:
throw new Error("Unsupported invoice line type");
}
diff --git a/packages/database/supabase/functions/post-receipt/index.ts b/packages/database/supabase/functions/post-receipt/index.ts
index f8d3f4b685..e208a11888 100644
--- a/packages/database/supabase/functions/post-receipt/index.ts
+++ b/packages/database/supabase/functions/post-receipt/index.ts
@@ -38,20 +38,20 @@ serve(async (req: Request) => {
const companyId = receipt.data?.companyId;
- const parts = await client
- .from("part")
- .select("id, itemGroupId, partType")
+ const items = await client
+ .from("item")
+ .select("id, itemGroupId, itemInventoryType")
.in(
"id",
receiptLines.data.reduce<string[]>((acc, receiptLine) => {
- if (receiptLine.partId && !acc.includes(receiptLine.partId)) {
- acc.push(receiptLine.partId);
+ if (receiptLine.itemId && !acc.includes(receiptLine.itemId)) {
+ acc.push(receiptLine.itemId);
}
return acc;
}, [])
)
.eq("companyId", companyId);
- if (parts.error) throw new Error("Failed to fetch item groups");
+ if (items.error) throw new Error("Failed to fetch item groups");
switch (receipt.data?.sourceDocument) {
case "Purchase Order": {
@@ -194,12 +194,12 @@ serve(async (req: Request) => {
| Database["public"]["Tables"]["postingGroupInventory"]["Row"]
| null = null;
- const partType =
- parts.data.find((part) => part.id === receiptLine.partId)
- ?.partType ?? "Inventory";
+ const itemInventoryType =
+ items.data.find((item) => item.id === receiptLine.itemId)
+ ?.itemInventoryType ?? "Inventory";
const itemGroupId: string | null =
- parts.data.find((part) => part.id === receiptLine.partId)
+ items.data.find((item) => item.id === receiptLine.itemId)
?.itemGroupId ?? null;
const locationId = receiptLine.locationId ?? null;
const supplierTypeId: string | null =
@@ -424,7 +424,8 @@ serve(async (req: Request) => {
documentType: "Purchase Receipt",
documentId: receipt.data?.id ?? undefined,
externalDocumentId: receipt.data?.externalDocumentId ?? undefined,
- partId: receiptLine.partId,
+ itemId: receiptLine.itemId,
+ itemReadableId: receiptLine.itemReadableId ?? "",
quantity: quantityToReverse,
cost: reversedValue,
costPostedToGL: reversedValue,
@@ -435,7 +436,7 @@ serve(async (req: Request) => {
let journalLineReference = nanoid();
- if (partType === "Inventory") {
+ if (itemInventoryType === "Inventory") {
// debit the inventory account
journalLineInserts.push({
accountNumber: postingGroupInventory.inventoryAccount,
@@ -580,10 +581,11 @@ serve(async (req: Request) => {
});
}
- if (partType === "Inventory") {
+ if (itemInventoryType === "Inventory") {
itemLedgerInserts.push({
postingDate: today,
- partId: receiptLine.partId,
+ itemId: receiptLine.itemId,
+ itemReadableId: receiptLine.itemReadableId ?? "",
quantity: receiptLine.receivedQuantity,
locationId: receiptLine.locationId,
shelfId: receiptLine.shelfId,
diff --git a/packages/database/supabase/migrations/20230330024716_parts.sql b/packages/database/supabase/migrations/20230330024716_parts.sql
index 52f6ed2524..09f6859a47 100644
--- a/packages/database/supabase/migrations/20230330024716_parts.sql
+++ b/packages/database/supabase/migrations/20230330024716_parts.sql
@@ -61,6 +61,11 @@ CREATE TYPE "itemType" AS ENUM (
'Fixture'
);
+CREATE TYPE "itemInventoryType" AS ENUM (
+ 'Inventory',
+ 'Non-Inventory'
+);
+
CREATE TABLE "item" (
"id" TEXT NOT NULL DEFAULT xid(),
"readableId" TEXT NOT NULL,
@@ -68,6 +73,7 @@ CREATE TABLE "item" (
"name" TEXT NOT NULL,
"description" TEXT,
"itemGroupId" TEXT,
+ "itemInventoryType" "itemInventoryType" NOT NULL,
"active" BOOLEAN NOT NULL DEFAULT true,
"blocked" BOOLEAN NOT NULL DEFAULT false,
"companyId" TEXT NOT NULL,
@@ -90,10 +96,6 @@ CREATE INDEX "item_companyId_idx" ON "item" ("companyId");
CREATE INDEX "item_name_companyId_idx" ON "item" ("name", "companyId");
CREATE INDEX "item_type_companyId_idx" ON "item" ("type", "companyId");
-CREATE TYPE "partType" AS ENUM (
- 'Inventory',
- 'Non-Inventory'
-);
CREATE TYPE "itemReplenishmentSystem" AS ENUM (
'Buy',
@@ -181,7 +183,6 @@ CREATE TABLE "part" (
"id" TEXT NOT NULL,
"itemId" TEXT NOT NULL,
"replenishmentSystem" "itemReplenishmentSystem" NOT NULL,
- "partType" "partType" NOT NULL,
"unitOfMeasureCode" TEXT NOT NULL,
"approved" BOOLEAN NOT NULL DEFAULT false,
"approvedBy" TEXT,
@@ -207,7 +208,6 @@ CREATE TABLE "part" (
CREATE INDEX "part_itemId_idx" ON "part" ("itemId");
CREATE INDEX "part_companyId_idx" ON "part" ("companyId");
-CREATE INDEX "part_partType_idx" ON "part"("partType", "companyId");
CREATE INDEX "part_replenishmentSystem_idx" ON "part"("replenishmentSystem", "companyId");
ALTER publication supabase_realtime ADD TABLE "part";
diff --git a/packages/database/supabase/migrations/20230704161623_parts-view.sql b/packages/database/supabase/migrations/20230704161623_parts-view.sql
index eaddeab8b1..a9ba849e32 100644
--- a/packages/database/supabase/migrations/20230704161623_parts-view.sql
+++ b/packages/database/supabase/migrations/20230704161623_parts-view.sql
@@ -4,8 +4,8 @@ CREATE OR REPLACE VIEW "parts" AS
p."itemId",
i.name,
i.description,
- p."partType",
i."itemGroupId",
+ i."itemInventoryType",
pg.name AS "itemGroup",
p."replenishmentSystem",
i.active,
@@ -20,8 +20,8 @@ CREATE OR REPLACE VIEW "parts" AS
GROUP BY p.id,
i.name,
i.description,
- p."partType",
i."itemGroupId",
+ i."itemInventoryType",
pg.name,
p."replenishmentSystem",
i.active,
diff --git a/packages/database/supabase/migrations/20230705033432_ledgers.sql b/packages/database/supabase/migrations/20230705033432_ledgers.sql
index c4cf33c885..c2e40192ee 100644
--- a/packages/database/supabase/migrations/20230705033432_ledgers.sql
+++ b/packages/database/supabase/migrations/20230705033432_ledgers.sql
@@ -194,6 +194,7 @@ CREATE TABLE "costLedger" (
"documentId" TEXT,
"externalDocumentId" TEXT,
"itemId" TEXT,
+ "itemReadableId" TEXT,
"quantity" NUMERIC(12, 4) NOT NULL DEFAULT 0,
"cost" NUMERIC(19, 4) NOT NULL DEFAULT 0,
"costPostedToGL" NUMERIC(19, 4) NOT NULL DEFAULT 0,
@@ -226,6 +227,7 @@ CREATE TABLE "itemLedger" (
"documentId" TEXT,
"externalDocumentId" TEXT,
"itemId" TEXT NOT NULL,
+ "itemReadableId" TEXT,
"locationId" TEXT,
"shelfId" TEXT,
"quantity" NUMERIC(12, 4) NOT NULL,
diff --git a/packages/database/supabase/migrations/20230728025201_receipts.sql b/packages/database/supabase/migrations/20230728025201_receipts.sql
index 31396090b1..ad8cdc5337 100644
--- a/packages/database/supabase/migrations/20230728025201_receipts.sql
+++ b/packages/database/supabase/migrations/20230728025201_receipts.sql
@@ -92,6 +92,7 @@ CREATE TABLE "receiptLine" (
"receiptId" TEXT NOT NULL,
"lineId" TEXT,
"itemId" TEXT NOT NULL,
+ "itemReadableId" TEXT,
"orderQuantity" NUMERIC(18, 4) NOT NULL,
"outstandingQuantity" NUMERIC(18, 4) NOT NULL DEFAULT 0,
"receivedQuantity" NUMERIC(18, 4) NOT NULL DEFAULT 0,
diff --git a/packages/database/supabase/migrations/20240324175747_assignee.sql b/packages/database/supabase/migrations/20240324175747_assignee.sql
index 5882fcaf8b..c57b2de370 100644
--- a/packages/database/supabase/migrations/20240324175747_assignee.sql
+++ b/packages/database/supabase/migrations/20240324175747_assignee.sql
@@ -14,6 +14,7 @@ CREATE OR REPLACE VIEW "parts" WITH(SECURITY_INVOKER=true) AS
i.name,
i.description,
i."itemGroupId",
+ i."itemInventoryType",
i.active,
i.blocked,
p.*,
diff --git a/packages/documents/src/utils/purchase-order.ts b/packages/documents/src/utils/purchase-order.ts
index 08b8fe65df..25609914fc 100644
--- a/packages/documents/src/utils/purchase-order.ts
+++ b/packages/documents/src/utils/purchase-order.ts
@@ -24,7 +24,7 @@ export function getLineDescriptionDetails(
case "Fixed Asset":
return line?.description;
case "G/L Account":
- return `GL Account: ${line?.accountNumber}`;
+ return `G/L Account: ${line?.accountNumber}`;
case "Comment":
default:
const itemDescription = line?.itemDescription