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: purchase order and invoice lines

Brad Barbin2e2c2dbd0afc
diff --git a/apps/carbon/app/components/Editable/EditablePurchaseInvoiceLineNumber.tsx b/apps/carbon/app/components/Editable/EditablePurchaseInvoiceLineNumber.tsx
index e0a3c8ca0c..296f12b68e 100644
--- a/apps/carbon/app/components/Editable/EditablePurchaseInvoiceLineNumber.tsx
+++ b/apps/carbon/app/components/Editable/EditablePurchaseInvoiceLineNumber.tsx
@@ -7,6 +7,7 @@ import type {
import { Combobox } from "~/components";
import type { EditableTableCellComponentProps } from "~/components/Editable";
import type { PurchaseInvoiceLine } from "~/modules/invoicing";
+import type { Item } from "~/stores";
const EditablePurchaseInvoiceLineNumber =
(
@@ -17,9 +18,8 @@ const EditablePurchaseInvoiceLineNumber =
) => Promise<PostgrestSingleResponse<unknown>>,
options: {
client?: SupabaseClient<Database>;
- parts: { label: string; value: string }[];
+ items: Item[];
accounts: { label: string; value: string }[];
- services: { label: string; value: string }[];
defaultLocationId: string | null;
supplierId: string;
userId: string;
@@ -32,15 +32,16 @@ const EditablePurchaseInvoiceLineNumber =
onError,
onUpdate,
}: EditableTableCellComponentProps<PurchaseInvoiceLine>) => {
- const { client, parts, services, accounts, supplierId, userId } = options;
+ const { client, items, accounts, supplierId, userId } = options;
const selectOptions =
- row.invoiceLineType === "Part"
- ? parts
- : row.invoiceLineType === "Service"
- ? services
- : row.invoiceLineType === "G/L Account"
+ row.invoiceLineType === "G/L Account"
? accounts
- : [];
+ : items
+ .filter((item) => item.type === row.invoiceLineType)
+ .map((item) => ({
+ label: item.name,
+ value: item.id,
+ }));
const onAccountChange = async (accountNumber: string) => {
if (!client) throw new Error("Supabase client not found");
@@ -53,6 +54,8 @@ const EditablePurchaseInvoiceLineNumber =
.single();
onUpdate({
+ itemId: null,
+ itemReadableId: null,
description: account.data?.name ?? "",
accountNumber: accountNumber,
});
@@ -61,6 +64,8 @@ const EditablePurchaseInvoiceLineNumber =
const { error } = await client
.from("purchaseInvoiceLine")
.update({
+ itemId: null,
+ itemReadableId: null,
accountNumber: accountNumber,
description: account.data?.name ?? "",
updatedBy: userId,
@@ -74,131 +79,158 @@ const EditablePurchaseInvoiceLineNumber =
}
};
- const onPartChange = async (partId: string) => {
+ const onItemChange = async (itemId: string) => {
if (!client) throw new Error("Supabase client not found");
- const [part, partSupplier, inventory] = await Promise.all([
- client
- .from("part")
- .select(
- `
- name, unitOfMeasureCode,
- partCost(unitCost),
- partReplenishment(purchasingUnitOfMeasureCode, conversionFactor, purchasingLeadTime)
- `
- )
- .eq("id", partId)
- .eq("companyId", row.companyId!)
- .single(),
- client
- .from("partSupplier")
- .select("*")
- .eq("partId", partId)
- .eq("companyId", row.companyId!)
- .eq("supplierId", supplierId)
- .maybeSingle(),
- client
- .from("partInventory")
- .select("defaultShelfId")
- .eq("partId", partId)
- .eq("companyId", row.companyId!)
- .eq("locationId", row.locationId!)
- .maybeSingle(),
- ]);
-
- const partCost = part?.data?.partCost?.[0];
- const partReplenishment = part?.data?.partReplenishment?.[0];
-
- if (part.error || partSupplier.error || inventory.error) {
- onError();
- return;
- }
+ switch (row.invoiceLineType) {
+ case "Part":
+ const [item, part, itemSupplier, inventory] = await Promise.all([
+ client
+ .from("item")
+ .select(
+ "name, readableId, itemCost(unitCost), itemReplenishment(purchasingUnitOfMeasureCode, conversionFactor, purchasingLeadTime)"
+ )
+ .eq("id", itemId)
+ .eq("companyId", row.companyId!)
+ .single(),
+ client
+ .from("part")
+ .select("unitOfMeasureCode")
+ .eq("itemId", itemId)
+ .eq("companyId", row.companyId!)
+ .single(),
+ client
+ .from("itemSupplier")
+ .select("*")
+ .eq("itemId", itemId)
+ .eq("companyId", row.companyId!)
+ .eq("supplierId", supplierId)
+ .maybeSingle(),
+ client
+ .from("itemInventory")
+ .select("defaultShelfId")
+ .eq("itemId", itemId)
+ .eq("companyId", row.companyId!)
+ .eq("locationId", row.locationId!)
+ .maybeSingle(),
+ ]);
- onUpdate({
- partId: partId,
- locationId: options.defaultLocationId,
- description: part.data?.name ?? "",
- quantity: partSupplier?.data?.minimumOrderQuantity ?? 1,
- unitPrice: partSupplier?.data?.unitPrice ?? partCost?.unitCost ?? 0,
- purchaseUnitOfMeasureCode:
- partReplenishment?.purchasingUnitOfMeasureCode ??
- part.data?.unitOfMeasureCode ??
- "EA",
-
- conversionFactor: partReplenishment?.conversionFactor ?? 1,
- shelfId: inventory.data?.defaultShelfId ?? null,
- });
+ const itemCost = item?.data?.itemCost?.[0];
+ const itemReplenishment = item?.data?.itemReplenishment?.[0];
- try {
- const { error } = await client
- .from("purchaseInvoiceLine")
- .update({
- partId: partId,
+ if (
+ item.error ||
+ part.error ||
+ itemSupplier.error ||
+ inventory.error
+ ) {
+ onError();
+ return;
+ }
+
+ onUpdate({
+ itemId: itemId,
+ itemReadableId: item.data?.readableId,
locationId: options.defaultLocationId,
- description: part.data?.name ?? "",
- quantity: partSupplier?.data?.minimumOrderQuantity ?? 1,
- unitPrice: partSupplier?.data?.unitPrice ?? partCost?.unitCost ?? 0,
+ description: item.data?.name ?? "",
+ quantity: itemSupplier?.data?.minimumOrderQuantity ?? 1,
+ unitPrice: itemSupplier?.data?.unitPrice ?? itemCost?.unitCost ?? 0,
purchaseUnitOfMeasureCode:
- partReplenishment?.purchasingUnitOfMeasureCode ??
+ itemReplenishment?.purchasingUnitOfMeasureCode ??
part.data?.unitOfMeasureCode ??
"EA",
- conversionFactor: partReplenishment?.conversionFactor ?? 1,
+ conversionFactor: itemReplenishment?.conversionFactor ?? 1,
shelfId: inventory.data?.defaultShelfId ?? null,
- updatedBy: userId,
- })
- .eq("id", row.id);
+ });
- if (error) onError();
- } catch (error) {
- console.error(error);
- onError();
- }
- };
+ try {
+ const { error } = await client
+ .from("purchaseInvoiceLine")
+ .update({
+ itemId: itemId,
+ itemReadableId: item.data?.readableId,
+ locationId: options.defaultLocationId,
+ description: item.data?.name ?? "",
+ quantity: itemSupplier?.data?.minimumOrderQuantity ?? 1,
+ unitPrice:
+ itemSupplier?.data?.unitPrice ?? itemCost?.unitCost ?? 0,
+ purchaseUnitOfMeasureCode:
+ itemReplenishment?.purchasingUnitOfMeasureCode ??
+ part.data?.unitOfMeasureCode ??
+ "EA",
- const onServiceChange = async (serviceId: string) => {
- if (!client) throw new Error("Supabase client not found");
- const service = await client
- .from("service")
- .select("name")
- .eq("id", serviceId)
- .eq("companyId", row.companyId)
- .single();
+ conversionFactor: itemReplenishment?.conversionFactor ?? 1,
+ shelfId: inventory.data?.defaultShelfId ?? null,
+ updatedBy: userId,
+ })
+ .eq("id", row.id);
- if (service.error) {
- onError();
- return;
- }
+ if (error) onError();
+ } catch (error) {
+ console.error(error);
+ onError();
+ }
+ break;
+ case "Service":
+ const service = await client
+ .from("item")
+ .select("readableId, name")
+ .eq("id", itemId)
+ .eq("companyId", row.companyId)
+ .single();
- onUpdate({
- serviceId,
- description: service.data?.name,
- });
+ if (service.error) {
+ onError();
+ return;
+ }
- try {
- const { error } = await client
- .from("purchaseInvoiceLine")
- .update({
- serviceId: serviceId,
- updatedBy: userId,
- })
- .eq("id", row.id);
+ onUpdate({
+ itemId: itemId,
+ itemReadableId: service.data?.readableId,
+ description: service.data?.name,
+ });
- if (error) onError();
- } catch (error) {
- console.error(error);
- onError();
+ try {
+ const { error } = await client
+ .from("purchaseInvoiceLine")
+ .update({
+ itemId: itemId,
+ itemReadableId: service.data?.readableId,
+ description: service.data?.name,
+ updatedBy: userId,
+ })
+ .eq("id", row.id);
+
+ if (error) onError();
+ } catch (error) {
+ console.error(error);
+ onError();
+ }
+ break;
+ default:
+ throw new Error(
+ `Invalid invoice line type: ${row.invoiceLineType} is not implemented`
+ );
}
};
const onChange = (newValue: string | null) => {
if (!newValue) return;
- if (row.invoiceLineType === "Part") {
- onPartChange(newValue);
+ if (
+ [
+ "Part",
+ "Service",
+ "Material",
+ "Tool",
+ "Fixture",
+ "Hardware",
+ "Consumable",
+ ].includes(row.invoiceLineType)
+ ) {
+ onItemChange(newValue);
} else if (row.invoiceLineType === "G/L Account") {
onAccountChange(newValue);
- } else if (row.invoiceLineType === "Service") {
- onServiceChange(newValue);
}
};
@@ -223,9 +255,14 @@ export default EditablePurchaseInvoiceLineNumber;
function getValue(row: PurchaseInvoiceLine) {
switch (row.invoiceLineType) {
case "Part":
- return row.partId;
case "Service":
- return row.serviceId;
+ case "Material":
+ case "Tool":
+ case "Fixture":
+ case "Hardware":
+ case "Consumable":
+ return row.itemId;
+
case "G/L Account":
return row.accountNumber;
case "Fixed Asset":
diff --git a/apps/carbon/app/components/Editable/EditablePurchaseOrderLineNumber.tsx b/apps/carbon/app/components/Editable/EditablePurchaseOrderLineNumber.tsx
index 7a810a4317..9d2502bdcd 100644
--- a/apps/carbon/app/components/Editable/EditablePurchaseOrderLineNumber.tsx
+++ b/apps/carbon/app/components/Editable/EditablePurchaseOrderLineNumber.tsx
@@ -7,6 +7,7 @@ import type {
import { Combobox } from "~/components";
import type { EditableTableCellComponentProps } from "~/components/Editable";
import type { PurchaseOrderLine } from "~/modules/purchasing";
+import type { Item } from "~/stores";
const EditablePurchaseOrderLineNumber =
(
@@ -17,11 +18,10 @@ const EditablePurchaseOrderLineNumber =
) => Promise<PostgrestSingleResponse<unknown>>,
options: {
client?: SupabaseClient<Database>;
- parts: { label: string; value: string }[];
- services: { label: string; value: string }[];
+ items: Item[];
accounts: { label: string; value: string }[];
defaultLocationId: string | null;
- supplerId: string;
+ supplierId: string;
userId: string;
}
) =>
@@ -32,26 +32,32 @@ const EditablePurchaseOrderLineNumber =
onError,
onUpdate,
}: EditableTableCellComponentProps<PurchaseOrderLine>) => {
- const { client, parts, services, accounts, supplerId, userId } = options;
+ const { client, items, accounts, supplierId, userId } = options;
const selectOptions =
- row.purchaseOrderLineType === "Part"
- ? parts
- : row.purchaseOrderLineType === "Service"
- ? services
- : row.purchaseOrderLineType === "G/L Account"
+ row.purchaseOrderLineType === "G/L Account"
? accounts
- : [];
+ : items
+ .filter((item) => item.type === row.purchaseOrderLineType)
+ .map((item) => ({
+ label: item.name,
+ value: item.id,
+ }));
const onAccountChange = async (accountNumber: string) => {
if (!client) throw new Error("Supabase client not found");
+ if (!row.companyId) throw new Error("Company ID not found");
+ if (!row.id) throw new Error("Purchase order line ID not found");
const account = await client
.from("account")
.select("name")
.eq("number", accountNumber)
+ .eq("companyId", row.companyId)
.single();
onUpdate({
+ itemId: null,
+ itemReadableId: null,
description: account.data?.name ?? "",
accountNumber: accountNumber,
});
@@ -60,11 +66,13 @@ const EditablePurchaseOrderLineNumber =
const { error } = await client
.from("purchaseOrderLine")
.update({
+ itemId: null,
+ itemReadableId: null,
accountNumber: accountNumber,
description: account.data?.name ?? "",
updatedBy: userId,
})
- .eq("id", row.id!);
+ .eq("id", row.id);
if (error) onError();
} catch (error) {
@@ -73,133 +81,162 @@ const EditablePurchaseOrderLineNumber =
}
};
- const onPartChange = async (partId: string) => {
+ const onItemChange = async (itemId: string) => {
if (!client) throw new Error("Supabase client not found");
- const [part, partSupplier, inventory] = await Promise.all([
- client
- .from("part")
- .select(
- `
- name, unitOfMeasureCode,
- partCost(unitCost),
- partReplenishment(purchasingUnitOfMeasureCode, conversionFactor, purchasingLeadTime)
- `
- )
- .eq("id", partId)
- .eq("companyId", row.companyId!)
- .single(),
- client
- .from("partSupplier")
- .select("*")
- .eq("partId", partId)
- .eq("companyId", row.companyId!)
- .eq("supplierId", supplerId)
- .maybeSingle(),
- client
- .from("partInventory")
- .select("defaultShelfId")
- .eq("partId", partId)
- .eq("companyId", row.companyId!)
- .eq("locationId", row.locationId!)
- .maybeSingle(),
- ]);
-
- const partCost = part?.data?.partCost?.[0];
- const partReplenishment = part?.data?.partReplenishment?.[0];
-
- if (part.error || partSupplier.error || inventory.error) {
- onError();
- return;
- }
+ if (!row.companyId) throw new Error("Company ID not found");
+ if (!row.id) throw new Error("Purchase order line ID not found");
- onUpdate({
- partId: partId,
- locationId: options.defaultLocationId,
- description: part.data?.name ?? "",
- purchaseQuantity: partSupplier?.data?.minimumOrderQuantity ?? 1,
- unitPrice: partSupplier?.data?.unitPrice ?? partCost?.unitCost ?? 0,
- purchaseUnitOfMeasureCode:
- partReplenishment?.purchasingUnitOfMeasureCode ??
- part.data?.unitOfMeasureCode ??
- "EA",
-
- conversionFactor: partReplenishment?.conversionFactor ?? 1,
- shelfId: inventory.data?.defaultShelfId ?? "",
- });
+ switch (row.purchaseOrderLineType) {
+ case "Part":
+ const [item, part, itemSupplier, inventory] = await Promise.all([
+ client
+ .from("item")
+ .select(
+ "name, readableId, itemCost(unitCost), itemReplenishment(purchasingUnitOfMeasureCode, conversionFactor, purchasingLeadTime)"
+ )
+ .eq("id", itemId)
+ .eq("companyId", row.companyId!)
+ .single(),
+ client
+ .from("part")
+ .select("unitOfMeasureCode")
+ .eq("itemId", itemId)
+ .eq("companyId", row.companyId!)
+ .single(),
+ client
+ .from("itemSupplier")
+ .select("*")
+ .eq("itemId", itemId)
+ .eq("companyId", row.companyId!)
+ .eq("supplierId", supplierId)
+ .maybeSingle(),
+ client
+ .from("itemInventory")
+ .select("defaultShelfId")
+ .eq("itemId", itemId)
+ .eq("companyId", row.companyId!)
+ .eq("locationId", row.locationId!)
+ .maybeSingle(),
+ ]);
- try {
- const { error } = await client
- .from("purchaseOrderLine")
- .update({
- partId: partId,
+ const itemCost = item?.data?.itemCost?.[0];
+ const itemReplenishment = item?.data?.itemReplenishment?.[0];
+
+ if (
+ item.error ||
+ part.error ||
+ itemSupplier.error ||
+ inventory.error
+ ) {
+ onError();
+ return;
+ }
+
+ onUpdate({
+ itemId: itemId,
+ itemReadableId: item.data?.readableId,
locationId: options.defaultLocationId,
- description: part.data?.name ?? "",
- purchaseQuantity: partSupplier?.data?.minimumOrderQuantity ?? 1,
- unitPrice: partSupplier?.data?.unitPrice ?? partCost?.unitCost ?? 0,
+ description: item.data?.name ?? "",
+ quantity: itemSupplier?.data?.minimumOrderQuantity ?? 1,
+ unitPrice: itemSupplier?.data?.unitPrice ?? itemCost?.unitCost ?? 0,
purchaseUnitOfMeasureCode:
- partReplenishment?.purchasingUnitOfMeasureCode ??
+ itemReplenishment?.purchasingUnitOfMeasureCode ??
part.data?.unitOfMeasureCode ??
"EA",
- conversionFactor: partReplenishment?.conversionFactor ?? 1,
+ conversionFactor: itemReplenishment?.conversionFactor ?? 1,
shelfId: inventory.data?.defaultShelfId ?? null,
- updatedBy: userId,
- })
- .eq("id", row.id!);
+ });
- if (error) onError();
- } catch (error) {
- console.error(error);
- onError();
- }
- };
+ try {
+ const { error } = await client
+ .from("purchaseOrderLine")
+ .update({
+ itemId: itemId,
+ itemReadableId: item.data?.readableId,
+ locationId: options.defaultLocationId,
+ description: item.data?.name ?? "",
+ quantity: itemSupplier?.data?.minimumOrderQuantity ?? 1,
+ unitPrice:
+ itemSupplier?.data?.unitPrice ?? itemCost?.unitCost ?? 0,
+ purchaseUnitOfMeasureCode:
+ itemReplenishment?.purchasingUnitOfMeasureCode ??
+ part.data?.unitOfMeasureCode ??
+ "EA",
- const onServiceChange = async (serviceId: string) => {
- if (!client) throw new Error("Supabase client not found");
- const service = await client
- .from("service")
- .select("name")
- .eq("id", serviceId)
- .single();
+ conversionFactor: itemReplenishment?.conversionFactor ?? 1,
+ shelfId: inventory.data?.defaultShelfId ?? null,
+ updatedBy: userId,
+ })
+ .eq("id", row.id);
- if (service.error) {
- onError();
- return;
- }
+ if (error) onError();
+ } catch (error) {
+ console.error(error);
+ onError();
+ }
+ break;
+ case "Service":
+ const service = await client
+ .from("item")
+ .select("name, readableId")
+ .eq("id", itemId)
+ .eq("companyId", row.companyId)
+ .single();
- onUpdate({
- serviceId: serviceId,
- description: service.data?.name,
- purchaseUnitOfMeasureCode: "EA",
- });
+ if (service.error) {
+ onError();
+ return;
+ }
- try {
- const { error } = await client
- .from("purchaseOrderLine")
- .update({
- serviceId: serviceId,
+ onUpdate({
+ itemId: itemId,
+ itemReadableId: service.data?.readableId,
description: service.data?.name,
- purchaseUnitOfMeasureCode: "EA",
- updatedBy: userId,
- })
- .eq("id", row.id!);
+ });
- if (error) onError();
- } catch (error) {
- console.error(error);
- onError();
+ try {
+ const { error } = await client
+ .from("purchaseOrderLine")
+ .update({
+ itemId: itemId,
+ itemReadableId: service.data?.readableId,
+ description: service.data?.name,
+ updatedBy: userId,
+ })
+ .eq("id", row.id);
+
+ if (error) onError();
+ } catch (error) {
+ console.error(error);
+ onError();
+ }
+ break;
+ default:
+ throw new Error(
+ `Invalid invoice line type: ${row.purchaseOrderLineType} is not implemented`
+ );
}
};
const onChange = (newValue: string | null) => {
if (!newValue) return;
+ if (!row.purchaseOrderLineType) return;
- if (row.purchaseOrderLineType === "Part") {
- onPartChange(newValue);
+ if (
+ [
+ "Part",
+ "Service",
+ "Material",
+ "Tool",
+ "Fixture",
+ "Hardware",
+ "Consumable",
+ ].includes(row.purchaseOrderLineType)
+ ) {
+ onItemChange(newValue);
} else if (row.purchaseOrderLineType === "G/L Account") {
onAccountChange(newValue);
- } else if (row.purchaseOrderLineType === "Service") {
- onServiceChange(newValue);
}
};
@@ -223,9 +260,14 @@ export default EditablePurchaseOrderLineNumber;
function getValue(row: PurchaseOrderLine) {
switch (row.purchaseOrderLineType) {
case "Part":
- return row.partId;
case "Service":
- return row.serviceId;
+ case "Material":
+ case "Tool":
+ case "Fixture":
+ case "Hardware":
+ case "Consumable":
+ return row.itemId;
+
case "G/L Account":
return row.accountNumber;
case "Fixed Asset":
diff --git a/apps/carbon/app/components/Form/Item.tsx b/apps/carbon/app/components/Form/Item.tsx
new file mode 100644
index 0000000000..cfcd252934
--- /dev/null
+++ b/apps/carbon/app/components/Form/Item.tsx
@@ -0,0 +1,69 @@
+import type { Database } from "@carbon/database";
+import { useDisclosure } from "@carbon/react";
+import { useMemo, useRef, useState } from "react";
+import { PartForm } from "~/modules/parts";
+import { useItems } from "~/stores";
+import type { ComboboxProps } from "./Combobox";
+import CreatableCombobox from "./CreatableCombobox";
+
+type ItemSelectProps = Omit<ComboboxProps, "options" | "type"> & {
+ type: Database["public"]["Enums"]["itemType"];
+};
+
+const Item = ({ type, ...props }: ItemSelectProps) => {
+ const [items] = useItems();
+ const newItemsModal = useDisclosure();
+ const [created, setCreated] = useState<string>("");
+ const triggerRef = useRef<HTMLButtonElement>(null);
+
+ const options = useMemo(
+ () =>
+ items
+ .filter((item) => item.type === type)
+ .map((item) => ({
+ value: item.id,
+ label: item.readableId,
+ helper: item.name,
+ })) ?? [],
+ [items, type]
+ );
+
+ return (
+ <>
+ <CreatableCombobox
+ ref={triggerRef}
+ options={options}
+ {...props}
+ label={props?.label ?? "Item"}
+ onCreateOption={(option) => {
+ newItemsModal.onOpen();
+ setCreated(option);
+ }}
+ />
+ {type === "Part" && newItemsModal.isOpen && (
+ <PartForm
+ type="modal"
+ onClose={() => {
+ setCreated("");
+ newItemsModal.onClose();
+ triggerRef.current?.click();
+ }}
+ initialValues={{
+ id: "",
+ name: created,
+ description: "",
+ partType: "Inventory" as "Inventory",
+ replenishmentSystem: "Buy and Make",
+ unitOfMeasureCode: "EA",
+ blocked: false,
+ active: true,
+ }}
+ />
+ )}
+ </>
+ );
+};
+
+Item.displayName = "Item";
+
+export default Item;
diff --git a/apps/carbon/app/components/Form/Part.tsx b/apps/carbon/app/components/Form/Part.tsx
index 9575d346d5..6aee81079c 100644
--- a/apps/carbon/app/components/Form/Part.tsx
+++ b/apps/carbon/app/components/Form/Part.tsx
@@ -1,38 +1,28 @@
import { useDisclosure } from "@carbon/react";
import { useMemo, useRef, useState } from "react";
-import { PartForm, type PartReplenishmentSystem } from "~/modules/parts";
+import { PartForm, type ItemReplenishmentSystem } from "~/modules/parts";
import { useParts } from "~/stores";
import type { ComboboxProps } from "./Combobox";
import CreatableCombobox from "./CreatableCombobox";
type PartSelectProps = Omit<ComboboxProps, "options"> & {
- partReplenishmentSystem?: PartReplenishmentSystem;
+ partReplenishmentSystem?: ItemReplenishmentSystem;
};
const Part = ({ partReplenishmentSystem, ...props }: PartSelectProps) => {
- const [parts] = useParts();
+ const parts = useParts();
const newPartsModal = useDisclosure();
const [created, setCreated] = useState<string>("");
const triggerRef = useRef<HTMLButtonElement>(null);
const options = useMemo(
() =>
- parts
- .filter((part) => {
- if (partReplenishmentSystem === "Buy") {
- return ["Buy", "Buy and Make"].includes(part.replenishmentSystem);
- } else if (partReplenishmentSystem === "Make") {
- return ["Make", "Buy and Make"].includes(part.replenishmentSystem);
- } else {
- return true;
- }
- })
- .map((part) => ({
- value: part.id,
- label: part.id,
- helper: part.name,
- })) ?? [],
- [partReplenishmentSystem, parts]
+ parts.map((part) => ({
+ value: part.id,
+ label: part.id,
+ helper: part.name,
+ })) ?? [],
+ [parts]
);
return (
@@ -60,10 +50,10 @@ const Part = ({ partReplenishmentSystem, ...props }: PartSelectProps) => {
name: created,
description: "",
partType: "Inventory" as "Inventory",
- replenishmentSystem: partReplenishmentSystem ?? ("Buy" as "Buy"),
+ replenishmentSystem: partReplenishmentSystem ?? "Buy and Make",
unitOfMeasureCode: "EA",
blocked: false,
- active: false,
+ active: true,
}}
/>
)}
diff --git a/apps/carbon/app/components/Form/Service.tsx b/apps/carbon/app/components/Form/Service.tsx
index 9c251238a8..64b325675b 100644
--- a/apps/carbon/app/components/Form/Service.tsx
+++ b/apps/carbon/app/components/Form/Service.tsx
@@ -1,8 +1,6 @@
-import { useMount } from "@carbon/react";
-import { useFetcher } from "@remix-run/react";
import { useMemo } from "react";
-import type { ServiceType, getServicesList } from "~/modules/parts";
-import { path } from "~/utils/path";
+import type { ServiceType } from "~/modules/parts";
+import { useServices } from "~/stores";
import type { ComboboxProps } from "./Combobox";
import Combobox from "./Combobox";
@@ -11,7 +9,16 @@ type ServiceSelectProps = Omit<ComboboxProps, "options"> & {
};
const Service = ({ serviceType, ...props }: ServiceSelectProps) => {
- const options = useServices(serviceType);
+ const services = useServices();
+ const options = useMemo(
+ () =>
+ services.map((service) => ({
+ value: service.id,
+ label: service.id,
+ helper: service.name,
+ })) ?? [],
+ [services]
+ );
return (
<Combobox options={options} {...props} label={props?.label ?? "Service"} />
@@ -21,26 +28,3 @@ const Service = ({ serviceType, ...props }: ServiceSelectProps) => {
Service.displayName = "Service";
export default Service;
-
-export const useServices = (serviceType?: ServiceType) => {
- const servicesFetcher =
- useFetcher<Awaited<ReturnType<typeof getServicesList>>>();
-
- useMount(() => {
- const typeQueryParams = serviceType ? `type=${serviceType}` : "";
- servicesFetcher.load(`${path.to.api.services}?${typeQueryParams}`);
- });
-
- const options = useMemo(
- () =>
- servicesFetcher.data?.data
- ? servicesFetcher.data?.data.map((s) => ({
- value: s.id,
- label: `${s.id} - ${s.name}`,
- }))
- : [],
- [servicesFetcher.data]
- );
-
- return options;
-};
diff --git a/apps/carbon/app/components/Form/index.ts b/apps/carbon/app/components/Form/index.ts
index 59eea02d7e..c430ec9a21 100644
--- a/apps/carbon/app/components/Form/index.ts
+++ b/apps/carbon/app/components/Form/index.ts
@@ -25,6 +25,7 @@ import EquipmentType from "./EquipmentType";
import Hidden from "./Hidden";
import Input from "./Input";
import InputControlled from "./InputControlled";
+import Item from "./Item";
import ItemGroup from "./ItemGroup";
import Location from "./Location";
import Number from "./Number";
@@ -82,6 +83,7 @@ export {
Hidden,
Input,
InputControlled,
+ Item,
ItemGroup,
Location,
Number,
diff --git a/apps/carbon/app/modules/inventory/ui/Receipts/ReceiptLines.tsx b/apps/carbon/app/modules/inventory/ui/Receipts/ReceiptLines.tsx
index d9179e7122..e797f18fa7 100644
--- a/apps/carbon/app/modules/inventory/ui/Receipts/ReceiptLines.tsx
+++ b/apps/carbon/app/modules/inventory/ui/Receipts/ReceiptLines.tsx
@@ -30,7 +30,7 @@ const ReceiptLines = () => {
locations: ListItem[];
}>(path.to.receipt(receiptId));
- const [parts] = useParts();
+ const parts = useParts();
const receiptLineColumns = useMemo<ColumnDef<ReceiptLine>[]>(() => {
return [
diff --git a/apps/carbon/app/modules/invoicing/invoicing.models.ts b/apps/carbon/app/modules/invoicing/invoicing.models.ts
index ce16c3bc5e..f30d1e0aa3 100644
--- a/apps/carbon/app/modules/invoicing/invoicing.models.ts
+++ b/apps/carbon/app/modules/invoicing/invoicing.models.ts
@@ -4,8 +4,13 @@ import { zfd } from "zod-form-data";
export const purchaseInvoiceLineType = [
"Part",
"Service",
- "G/L Account",
+ "Material",
+ "Tool",
+ "Fixture",
+ "Hardware",
+ "Consumable",
"Fixed Asset",
+ "G/L Account",
"Comment",
] as const;
@@ -47,8 +52,8 @@ export const purchaseInvoiceLineValidator = z
}),
purchaseOrderId: zfd.text(z.string().optional()),
purchaseOrderLineId: zfd.text(z.string().optional()),
- partId: zfd.text(z.string().optional()),
- serviceId: zfd.text(z.string().optional()),
+ itemId: zfd.text(z.string().optional()),
+ itemReadableId: zfd.text(z.string().optional()),
accountNumber: zfd.text(z.string().optional()),
assetId: zfd.text(z.string().optional()),
description: zfd.text(z.string().optional()),
@@ -62,12 +67,36 @@ export const purchaseInvoiceLineValidator = z
currencyCode: zfd.text(z.string().optional()),
exchangeRate: zfd.numeric(z.number().optional()),
})
- .refine((data) => (data.invoiceLineType === "Part" ? data.partId : true), {
- message: "Part is required",
- path: ["partId"], // path of error
- })
.refine(
- (data) => (data.invoiceLineType === "Part" ? data.locationId : true),
+ (data) =>
+ [
+ "Part",
+ "Service",
+ "Material",
+ "Tool",
+ "Fixture",
+ "Hardware",
+ "Consumable",
+ ].includes(data.invoiceLineType)
+ ? data.itemId
+ : true,
+ {
+ message: "Item is required",
+ path: ["itemId"], // path of error
+ }
+ )
+ .refine(
+ (data) =>
+ [
+ "Part",
+ "Material",
+ "Tool",
+ "Fixture",
+ "Hardware",
+ "Consumable",
+ ].includes(data.invoiceLineType)
+ ? data.locationId
+ : true,
{
message: "Location is required",
path: ["locationId"], // path of error
diff --git a/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLineForm.tsx b/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLineForm.tsx
index 08b4bc4fe2..076a252758 100644
--- a/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLineForm.tsx
+++ b/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLineForm.tsx
@@ -23,10 +23,9 @@ import {
ConversionFactor,
CustomFormFields,
Hidden,
+ Item,
NumberControlled,
- Part,
Select,
- Service,
Submit,
UnitOfMeasure,
} from "~/components/Form";
@@ -76,18 +75,20 @@ const PurchaseInvoiceLineForm = ({
const [type, setType] = useState(initialValues.invoiceLineType);
const [locationId, setLocationId] = useState(defaults.locationId ?? "");
- const [partData, setPartData] = useState<{
- partId: string;
+ const [itemData, setItemData] = useState<{
+ itemId: string;
+ itemReadableId: string;
description: string;
quantity: number;
unitPrice: number;
purchaseUom: string;
inventoryUom: string;
conversionFactor: number;
- shelfId: string;
+ shelfId: string | null;
minimumOrderQuantity?: number;
}>({
- partId: initialValues.partId ?? "",
+ itemId: initialValues.itemId ?? "",
+ itemReadableId: initialValues.itemReadableId ?? "",
description: initialValues.description ?? "",
quantity: initialValues.quantity ?? 1,
unitPrice: initialValues.unitPrice ?? 0,
@@ -134,8 +135,9 @@ const PurchaseInvoiceLineForm = ({
const onTypeChange = (type: PurchaseInvoiceLineType) => {
setType(type);
- setPartData({
- partId: "",
+ setItemData({
+ itemId: "",
+ itemReadableId: "",
description: "",
quantity: 1,
unitPrice: 0,
@@ -147,76 +149,88 @@ const PurchaseInvoiceLineForm = ({
});
};
- const onPartChange = async (partId: string) => {
- if (!supabase || !company.id) return;
- const [part, partSupplier, inventory] = await Promise.all([
- supabase
- .from("part")
- .select(
- `
- name, unitOfMeasureCode,
- partCost(unitCost),
- partReplenishment(purchasingUnitOfMeasureCode, conversionFactor, purchasingLeadTime)
- `
- )
- .eq("id", partId)
- .eq("companyId", company.id)
- .single(),
- supabase
- .from("partSupplier")
- .select("*")
- .eq("partId", partId)
- .eq("companyId", company.id)
- .eq("supplierId", routeData?.purchaseInvoice?.supplierId!)
- .maybeSingle(),
- supabase
- .from("partInventory")
- .select("defaultShelfId")
- .eq("partId", partId)
- .eq("companyId", company.id)
- .eq("locationId", locationId)
- .single(),
- ]);
+ const onItemChange = async (itemId: string) => {
+ if (!supabase) throw new Error("Supabase client not found");
+ switch (type) {
+ case "Part":
+ const [item, part, itemSupplier, inventory] = await Promise.all([
+ supabase
+ .from("item")
+ .select(
+ "name, readableId, itemCost(unitCost), itemReplenishment(purchasingUnitOfMeasureCode, conversionFactor, purchasingLeadTime)"
+ )
+ .eq("id", itemId)
+ .eq("companyId", company.id)
+ .single(),
+ supabase
+ .from("part")
+ .select("unitOfMeasureCode")
+ .eq("itemId", itemId)
+ .eq("companyId", company.id)
+ .single(),
+ supabase
+ .from("itemSupplier")
+ .select("*")
+ .eq("itemId", itemId)
+ .eq("companyId", company.id)
+ .eq("supplierId", routeData?.purchaseInvoice.supplierId!)
+ .maybeSingle(),
+ supabase
+ .from("itemInventory")
+ .select("defaultShelfId")
+ .eq("itemId", itemId)
+ .eq("companyId", company.id)
+ .eq("locationId", locationId!)
+ .maybeSingle(),
+ ]);
- const partCost = part?.data?.partCost?.[0];
- const partReplenishment = part?.data?.partReplenishment?.[0];
+ const itemCost = item?.data?.itemCost?.[0];
+ const itemReplenishment = item?.data?.itemReplenishment?.[0];
- setPartData({
- partId,
- description: part.data?.name ?? "",
- quantity: partSupplier?.data?.minimumOrderQuantity ?? 1,
- unitPrice: partSupplier?.data?.unitPrice ?? partCost?.unitCost ?? 0,
- purchaseUom:
- partReplenishment?.purchasingUnitOfMeasureCode ??
- part.data?.unitOfMeasureCode ??
- "EA",
- inventoryUom: part.data?.unitOfMeasureCode ?? "EA",
- conversionFactor: partReplenishment?.conversionFactor ?? 1,
- shelfId: inventory.data?.defaultShelfId ?? "",
- minimumOrderQuantity: partSupplier?.data?.minimumOrderQuantity ?? 0,
- });
- };
+ setItemData({
+ itemId: itemId,
+ itemReadableId: item.data?.readableId ?? "",
+ description: item.data?.name ?? "",
+ quantity: itemSupplier?.data?.minimumOrderQuantity ?? 1,
+ unitPrice: itemSupplier?.data?.unitPrice ?? itemCost?.unitCost ?? 0,
+ purchaseUom:
+ itemReplenishment?.purchasingUnitOfMeasureCode ??
+ part.data?.unitOfMeasureCode ??
+ "EA",
+ inventoryUom: part.data?.unitOfMeasureCode ?? "EA",
- const onServiceChange = async (serviceId: string) => {
- if (!supabase || !company.id) return;
- const service = await supabase
- .from("service")
- .select("name")
- .eq("id", serviceId)
- .eq("companyId", company.id)
- .single();
+ conversionFactor: itemReplenishment?.conversionFactor ?? 1,
+ shelfId: inventory.data?.defaultShelfId ?? null,
+ });
- setPartData({
- partId: "",
- description: service.data?.name ?? "",
- quantity: 1,
- unitPrice: 0,
- purchaseUom: "EA",
- inventoryUom: "EA",
- conversionFactor: 1,
- shelfId: "",
- minimumOrderQuantity: undefined,
- });
+ break;
+ case "Service":
+ const service = await supabase
+ .from("item")
+ .select("readableId, name")
+ .eq("id", itemId)
+ .eq("companyId", company.id)
+ .single();
+
+ setItemData({
+ itemId: itemId,
+ itemReadableId: service.data?.readableId ?? "",
+ description: service.data?.name ?? "",
+ quantity: 1,
+ unitPrice: 0,
+ purchaseUom: "EA",
+ inventoryUom: "EA",
+ conversionFactor: 1,
+ shelfId: "",
+ minimumOrderQuantity: undefined,
+ });
+
+ break;
+ default:
+ throw new Error(
+ `Invalid invoice line type: ${type} is not implemented`
+ );
+ }
};
const onLocationChange = async (newLocation: { value: string } | null) => {
@@ -225,16 +239,16 @@ const PurchaseInvoiceLineForm = ({
throw new Error("locationId is not a string");
setLocationId(newLocation.value);
- if (!partData.partId) return;
+ if (!itemData.itemId) return;
const shelf = await supabase
- .from("partInventory")
+ .from("itemInventory")
.select("defaultShelfId")
- .eq("partId", partData.partId)
+ .eq("itemId", itemData.itemId)
.eq("companyId", company.id)
.eq("locationId", newLocation.value)
.maybeSingle();
- setPartData((d) => ({
+ setItemData((d) => ({
...d,
shelfId: shelf?.data?.defaultShelfId ?? "",
}));
@@ -267,10 +281,10 @@ const PurchaseInvoiceLineForm = ({
<DrawerBody>
<Hidden name="id" />
<Hidden name="invoiceId" />
- <Hidden name="description" value={partData.description} />
+ <Hidden name="description" value={itemData.description} />
<Hidden
name="inventoryUnitOfMeasureCode"
- value={partData?.inventoryUom}
+ value={itemData?.inventoryUom}
/>
<VStack spacing={4}>
<Select
@@ -281,24 +295,22 @@ const PurchaseInvoiceLineForm = ({
onTypeChange(value?.value as PurchaseInvoiceLineType);
}}
/>
- {type === "Part" && (
- <Part
- name="partId"
- label="Part"
- partReplenishmentSystem="Buy"
- onChange={(value) => {
- onPartChange(value?.value as string);
- }}
- />
- )}
-
- {type === "Service" && (
- <Service
- name="serviceId"
- label="Service"
- serviceType="External"
+ {[
+ "Part",
+ "Service",
+ "Material",
+ "Tool",
+ "Fixture",
+ "Hardware",
+ "Consumable",
+ ].includes(type) && (
+ <Item
+ name="itemId"
+ label={type}
+ // @ts-ignore
+ type={type}
onChange={(value) => {
- onServiceChange(value?.value as string);
+ onItemChange(value?.value as string);
}}
/>
)}
@@ -309,8 +321,9 @@ const PurchaseInvoiceLineForm = ({
label="Account"
classes={["Expense", "Asset"]}
onChange={(value) => {
- setPartData({
- partId: "",
+ setItemData({
+ itemId: "",
+ itemReadableId: "",
description: value?.label ?? "",
quantity: 1,
unitPrice: 0,
@@ -330,21 +343,21 @@ const PurchaseInvoiceLineForm = ({
<FormControl>
<FormLabel>Description</FormLabel>
<Input
- value={partData.description}
+ value={itemData.description}
onChange={(e) =>
- setPartData((d) => ({ ...d, description: e.target.value }))
+ setItemData((d) => ({ ...d, description: e.target.value }))
}
/>
</FormControl>
{type !== "Comment" && (
<>
<NumberControlled
- minValue={partData.minimumOrderQuantity}
+ minValue={itemData.minimumOrderQuantity}
name="quantity"
label="Quantity"
- value={partData.quantity}
+ value={itemData.quantity}
onChange={(value) => {
- setPartData((d) => ({
+ setItemData((d) => ({
...d,
quantity: value,
}));
@@ -353,24 +366,24 @@ const PurchaseInvoiceLineForm = ({
<NumberControlled
name="unitPrice"
label="Unit Price"
- value={partData.unitPrice}
+ value={itemData.unitPrice}
onChange={(value) =>
- setPartData((d) => ({
+ setItemData((d) => ({
...d,
unitPrice: value,
}))
}
/>
- {type === "Part" && (
+ {["Part", "Material", "Hardware"] && (
<>
<UnitOfMeasure
name="purchaseUnitOfMeasureCode"
label="Unit of Measure"
- value={partData.purchaseUom}
+ value={itemData.purchaseUom}
onChange={(newValue) => {
if (newValue) {
- setPartData((d) => ({
+ setItemData((d) => ({
...d,
purchaseUom: newValue?.value as string,
}));
@@ -379,11 +392,11 @@ const PurchaseInvoiceLineForm = ({
/>
<ConversionFactor
name="conversionFactor"
- purchasingCode={partData.purchaseUom}
- inventoryCode={partData.inventoryUom}
- value={partData.conversionFactor}
+ purchasingCode={itemData.purchaseUom}
+ inventoryCode={itemData.inventoryUom}
+ value={itemData.conversionFactor}
onChange={(value) => {
- setPartData((d) => ({
+ setItemData((d) => ({
...d,
conversionFactor: value,
}));
@@ -392,7 +405,16 @@ const PurchaseInvoiceLineForm = ({
</>
)}
- {["Part", "Service"].includes(type) && (
+ {[
+ "Part",
+ "Service",
+ "Material",
+ "Tool",
+ "Fixture",
+ "Hardware",
+ "Consumable",
+ "Fixed Asset",
+ ].includes(type) && (
<ComboboxControlled
name="locationId"
label="Location"
@@ -401,15 +423,24 @@ const PurchaseInvoiceLineForm = ({
onChange={onLocationChange}
/>
)}
- {type === "Part" && (
+ {[
+ "Part",
+ "Service",
+ "Material",
+ "Tool",
+ "Fixture",
+ "Hardware",
+ "Consumable",
+ "Fixed Asset",
+ ].includes(type) && (
<ComboboxControlled
name="shelfId"
label="Shelf"
options={shelfOptions}
- value={partData.shelfId}
+ value={itemData.shelfId ?? ""}
onChange={(newValue) => {
if (newValue) {
- setPartData((d) => ({
+ setItemData((d) => ({
...d,
shelfId: newValue.value,
}));
diff --git a/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLines/PurchaseInvoiceLines.tsx b/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLines/PurchaseInvoiceLines.tsx
index f74b569357..aa6b0efea5 100644
--- a/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLines/PurchaseInvoiceLines.tsx
+++ b/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLines/PurchaseInvoiceLines.tsx
@@ -30,6 +30,7 @@ import { useRealtime, useRouteData, useUser } from "~/hooks";
import { useCustomColumns } from "~/hooks/useCustomColumns";
import type { PurchaseInvoice, PurchaseInvoiceLine } from "~/modules/invoicing";
import { usePurchaseInvoiceTotals } from "~/modules/invoicing";
+import { useItems } from "~/stores";
import type { ListItem } from "~/types";
import { path } from "~/utils/path";
import usePurchaseInvoiceLines from "./usePurchaseInvoiceLines";
@@ -49,16 +50,10 @@ const PurchaseInvoiceLines = () => {
}>(path.to.purchaseInvoice(invoiceId));
const { defaults, id: userId } = useUser();
+ const [items] = useItems();
const unitOfMeasureOptions = useUnitOfMeasure();
- const {
- canEdit,
- canDelete,
- supabase,
- partOptions,
- serviceOptions,
- accountOptions,
- onCellEdit,
- } = usePurchaseInvoiceLines();
+ const { canEdit, canDelete, supabase, accountOptions, onCellEdit } =
+ usePurchaseInvoiceLines();
const [, setPurchaseInvoiceTotals] = usePurchaseInvoiceTotals();
const isEditable = !routeData?.purchaseInvoice?.postingDate;
@@ -112,14 +107,18 @@ const PurchaseInvoiceLines = () => {
),
},
{
- accessorKey: "partId",
+ accessorKey: "itemId",
header: "Number",
cell: ({ row }) => {
switch (row.original.invoiceLineType) {
case "Part":
- return <span>{row.original.partId}</span>;
case "Service":
- return <span>{row.original.serviceId}</span>;
+ case "Material":
+ case "Tool":
+ case "Fixture":
+ case "Hardware":
+ case "Consumable":
+ return <span>{row.original.itemId}</span>;
case "G/L Account":
return <span>{row.original.accountNumber}</span>;
case "Fixed Asset":
@@ -227,8 +226,7 @@ const PurchaseInvoiceLines = () => {
unitPrice: EditableNumber(onCellEdit),
partId: EditablePurchaseInvoiceLineNumber(onCellEdit, {
client: supabase,
- parts: partOptions,
- services: serviceOptions,
+ items: items,
accounts: accountOptions,
defaultLocationId: defaults.locationId,
supplierId: routeData?.purchaseInvoice.supplierId ?? "",
@@ -240,8 +238,7 @@ const PurchaseInvoiceLines = () => {
[
onCellEdit,
supabase,
- partOptions,
- serviceOptions,
+ items,
accountOptions,
defaults.locationId,
routeData?.purchaseInvoice.supplierId,
diff --git a/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLines/usePurchaseInvoiceLines.tsx b/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLines/usePurchaseInvoiceLines.tsx
index 47c2f4f089..edfd8d72d2 100644
--- a/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLines/usePurchaseInvoiceLines.tsx
+++ b/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLines/usePurchaseInvoiceLines.tsx
@@ -5,8 +5,6 @@ import { usePermissions, useUser } from "~/hooks";
import { useSupabase } from "~/lib/supabase";
import type { getAccountsList } from "~/modules/accounting";
import type { PurchaseInvoiceLine } from "~/modules/invoicing";
-import type { getServicesList } from "~/modules/parts";
-import { usePurchasedParts } from "~/stores/parts";
import { path } from "~/utils/path";
export default function usePurchaseInvoiceLines() {
@@ -17,16 +15,6 @@ export default function usePurchaseInvoiceLines() {
const canEdit = permissions.can("update", "invoicing");
const canDelete = permissions.can("delete", "invoicing");
- const parts = usePurchasedParts();
- const partOptions = useMemo(
- () =>
- parts.map((p) => ({
- value: p.id,
- label: p.id,
- })),
- [parts]
- );
-
const accountsFetcher =
useFetcher<Awaited<ReturnType<typeof getAccountsList>>>();
useMount(() => {
@@ -45,23 +33,6 @@ export default function usePurchaseInvoiceLines() {
[accountsFetcher.data]
);
- const servicesFetcher =
- useFetcher<Awaited<ReturnType<typeof getServicesList>>>();
- useMount(() => {
- servicesFetcher.load(`${path.to.api.services}?type=External`);
- });
-
- const serviceOptions = useMemo(
- () =>
- servicesFetcher.data?.data
- ? servicesFetcher.data?.data.map((s) => ({
- value: s.id,
- label: s.id,
- }))
- : [],
- [servicesFetcher.data]
- );
-
const onCellEdit = useCallback(
async (id: string, value: unknown, row: PurchaseInvoiceLine) => {
if (!supabase) throw new Error("Supabase client not found");
@@ -80,8 +51,6 @@ export default function usePurchaseInvoiceLines() {
accountOptions,
canDelete,
canEdit,
- partOptions,
- serviceOptions,
supabase,
onCellEdit,
};
diff --git a/apps/carbon/app/modules/parts/parts.models.ts b/apps/carbon/app/modules/parts/parts.models.ts
index 3e2ff0e312..5614fa6214 100644
--- a/apps/carbon/app/modules/parts/parts.models.ts
+++ b/apps/carbon/app/modules/parts/parts.models.ts
@@ -7,13 +7,13 @@ export const partReplenishmentSystems = [
"Make",
"Buy and Make",
] as const;
-export const partCostingMethods = [
+export const itemCostingMethods = [
"Standard",
"Average",
"FIFO",
"LIFO",
] as const;
-export const partReorderingPolicies = [
+export const itemReorderingPolicies = [
"Manual Reorder",
"Demand-Based Reorder",
"Fixed Reorder Quantity",
@@ -36,28 +36,9 @@ export const itemValidator = z.object({
active: zfd.checkbox(),
});
-export const partValidator = itemValidator.merge(
- z.object({
- id: z.string().min(1, { message: "Part ID is required" }).max(255),
- replenishmentSystem: z.enum(partReplenishmentSystems, {
- errorMap: (issue, ctx) => ({
- 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" }),
- })
-);
-
-export const partCostValidator = z.object({
- partId: z.string().min(1, { message: "Part ID is required" }),
- costingMethod: z.enum(partCostingMethods, {
+export const itemCostValidator = z.object({
+ itemId: z.string().min(1, { message: "Item ID is required" }),
+ costingMethod: z.enum(itemCostingMethods, {
errorMap: (issue, ctx) => ({
message: "Costing method is required",
}),
@@ -73,14 +54,14 @@ export const itemGroupValidator = z.object({
description: z.string().optional(),
});
-export const partInventoryValidator = z.object({
- partId: z.string().min(1, { message: "Part ID is required" }),
+export const itemInventoryValidator = z.object({
+ itemId: z.string().min(1, { message: "Item ID is required" }),
locationId: z.string().min(20, { message: "Location is required" }),
defaultShelfId: zfd.text(z.string().optional()),
});
-export const partManufacturingValidator = z.object({
- partId: z.string().min(1, { message: "Part ID is required" }),
+export const itemManufacturingValidator = z.object({
+ itemId: z.string().min(1, { message: "Item ID is required" }),
manufacturingPolicy: z.enum(partManufacturingPolicies, {
errorMap: (issue, ctx) => ({
message: "Manufacturing policy is required",
@@ -93,10 +74,10 @@ export const partManufacturingValidator = z.object({
lotSize: zfd.numeric(z.number().min(0)),
});
-export const partPlanningValidator = z.object({
- partId: z.string().min(1, { message: "Part ID is required" }),
+export const itemPlanningValidator = z.object({
+ itemId: z.string().min(1, { message: "Item ID is required" }),
locationId: z.string().min(20, { message: "Location is required" }),
- reorderingPolicy: z.enum(partReorderingPolicies, {
+ reorderingPolicy: z.enum(itemReorderingPolicies, {
errorMap: (issue, ctx) => ({
message: "Reordering policy is required",
}),
@@ -115,8 +96,8 @@ export const partPlanningValidator = z.object({
orderMultiple: zfd.numeric(z.number().min(1)),
});
-export const partPurchasingValidator = z.object({
- partId: z.string().min(1, { message: "Part ID is required" }),
+export const itemPurchasingValidator = z.object({
+ itemId: z.string().min(1, { message: "Item ID is required" }),
preferredSupplierId: zfd.text(z.string().optional()),
conversionFactor: zfd.numeric(z.number().min(0)),
purchasingLeadTime: zfd.numeric(z.number().min(0)),
@@ -124,9 +105,9 @@ export const partPurchasingValidator = z.object({
purchasingBlocked: zfd.checkbox(),
});
-export const partSupplierValidator = z.object({
+export const itemSupplierValidator = z.object({
id: zfd.text(z.string().optional()),
- partId: z.string().min(1, { message: "Part ID is required" }),
+ itemId: z.string().min(1, { message: "Item ID is required" }),
supplierId: z.string().min(36, { message: "Supplier ID is required" }),
supplierPartId: z.string().optional(),
supplierUnitOfMeasureCode: zfd.text(z.string().optional()),
@@ -135,8 +116,8 @@ export const partSupplierValidator = z.object({
unitPrice: zfd.numeric(z.number().min(0)),
});
-export const partUnitSalePriceValidator = z.object({
- partId: z.string().min(1, { message: "Part ID is required" }),
+export const itemUnitSalePriceValidator = z.object({
+ itemId: z.string().min(1, { message: "Item ID is required" }),
unitSalePrice: zfd.numeric(z.number().min(0)),
currencyCode: z.string().min(1, { message: "Currency is required" }),
salesUnitOfMeasureCode: z
@@ -147,6 +128,25 @@ export const partUnitSalePriceValidator = z.object({
allowInvoiceDiscount: zfd.checkbox(),
});
+export const partValidator = itemValidator.merge(
+ z.object({
+ id: z.string().min(1, { message: "Part ID is required" }).max(255),
+ replenishmentSystem: z.enum(partReplenishmentSystems, {
+ errorMap: (issue, ctx) => ({
+ 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" }),
+ })
+);
+
export const serviceValidator = itemValidator.merge(
z.object({
id: z.string().min(1, { message: "Service ID is required" }).max(255),
diff --git a/apps/carbon/app/modules/parts/parts.service.ts b/apps/carbon/app/modules/parts/parts.service.ts
index 5750c98754..57b2a5f62c 100644
--- a/apps/carbon/app/modules/parts/parts.service.ts
+++ b/apps/carbon/app/modules/parts/parts.service.ts
@@ -6,21 +6,21 @@ import type { GenericQueryFilters } from "~/utils/query";
import { setGenericQueryFilters } from "~/utils/query";
import { sanitize } from "~/utils/supabase";
import type {
+ itemCostValidator,
itemGroupValidator,
+ itemInventoryValidator,
+ itemManufacturingValidator,
+ itemPlanningValidator,
+ itemPurchasingValidator,
+ itemSupplierValidator,
+ itemUnitSalePriceValidator,
itemValidator,
- partCostValidator,
- partInventoryValidator,
- partManufacturingValidator,
- partPlanningValidator,
- partPurchasingValidator,
- partSupplierValidator,
- partUnitSalePriceValidator,
partValidator,
serviceSupplierValidator,
serviceValidator,
unitOfMeasureValidator,
} from "./parts.models";
-import type { PartReplenishmentSystem, ServiceType } from "./types";
+import type { ItemReplenishmentSystem, ServiceType } from "./types";
export async function deleteItemGroup(
client: SupabaseClient<Database>,
@@ -36,15 +36,15 @@ export async function deleteUnitOfMeasure(
return client.from("unitOfMeasure").delete().eq("id", id);
}
-export async function getPartCost(
+export async function getItemCost(
client: SupabaseClient<Database>,
- id: string,
+ itemId: string,
companyId: string
) {
return client
- .from("partCost")
+ .from("itemCost")
.select("*")
- .eq("partId", id)
+ .eq("itemId", itemId)
.eq("companyId", companyId)
.single();
}
@@ -92,58 +92,58 @@ export async function getItemGroupsList(
.order("name");
}
-export async function getPartInventory(
+export async function getItemInventory(
client: SupabaseClient<Database>,
- partId: string,
+ itemId: string,
companyId: string,
locationId: string
) {
return client
- .from("partInventory")
+ .from("itemInventory")
.select("*")
- .eq("partId", partId)
+ .eq("itemId", itemId)
.eq("companyId", companyId)
.eq("locationId", locationId)
.maybeSingle();
}
-export async function getPartManufacturing(
+export async function getItemManufacturing(
client: SupabaseClient<Database>,
id: string,
companyId: string
) {
return client
- .from("partReplenishment")
+ .from("itemReplenishment")
.select("*")
- .eq("partId", id)
+ .eq("itemId", id)
.eq("companyId", companyId)
.single();
}
-export async function getPartPlanning(
+export async function getItemPlanning(
client: SupabaseClient<Database>,
- partId: string,
+ itemId: string,
companyId: string,
locationId: string
) {
return client
- .from("partPlanning")
+ .from("itemPlanning")
.select("*")
- .eq("partId", partId)
+ .eq("itemId", itemId)
.eq("companyId", companyId)
.eq("locationId", locationId)
.maybeSingle();
}
-export async function getPartReplenishment(
+export async function getItemReplenishment(
client: SupabaseClient<Database>,
- id: string,
+ itemId: string,
companyId: string
) {
return client
- .from("partReplenishment")
+ .from("itemReplenishment")
.select("*")
- .eq("partId", id)
+ .eq("itemId", itemId)
.eq("companyId", companyId)
.single();
}
@@ -182,7 +182,7 @@ export async function getParts(
export async function getPartsList(
client: SupabaseClient<Database>,
companyId: string,
- replenishmentSystem: PartReplenishmentSystem | null
+ replenishmentSystem: ItemReplenishmentSystem | null
) {
let query = client
.from("part")
@@ -200,16 +200,16 @@ export async function getPartsList(
return query.order("name");
}
-export async function getPartQuantities(
+export async function getItemQuantities(
client: SupabaseClient<Database>,
- partId: string,
+ itemId: string,
companyId: string,
locationId: string
) {
return client
- .from("partQuantities")
+ .from("itemQuantities")
.select("*")
- .eq("partId", partId)
+ .eq("itemId", itemId)
.eq("companyId", companyId)
.eq("locationId", locationId)
.maybeSingle();
@@ -228,13 +228,13 @@ export async function getPart(
.single();
}
-export async function getPartSuppliers(
+export async function getItemSuppliers(
client: SupabaseClient<Database>,
id: string,
companyId: string
) {
return client
- .from("partSupplier")
+ .from("itemSupplier")
.select(
`
id, supplier(id, name),
@@ -245,19 +245,19 @@ export async function getPartSuppliers(
`
)
.eq("active", true)
- .eq("partId", id)
+ .eq("itemId", id)
.eq("companyId", companyId);
}
-export async function getPartUnitSalePrice(
+export async function getItemUnitSalePrice(
client: SupabaseClient<Database>,
id: string,
companyId: string
) {
return client
- .from("partUnitSalePrice")
+ .from("itemUnitSalePrice")
.select("*")
- .eq("partId", id)
+ .eq("itemId", id)
.eq("companyId", companyId)
.single();
}
@@ -461,7 +461,7 @@ export async function upsertPart(
.insert({
readableId: part.id,
name: part.name,
- type: "part",
+ type: "Part",
companyId: part.companyId,
createdBy: part.createdBy,
})
@@ -536,90 +536,90 @@ export async function updateItem(
.eq("companyId", item.companyId);
}
-export async function upsertPartCost(
+export async function upsertItemCost(
client: SupabaseClient<Database>,
- partCost: z.infer<typeof partCostValidator> & {
+ itemCost: z.infer<typeof itemCostValidator> & {
updatedBy: string;
customFields?: Json;
}
) {
return client
- .from("partCost")
- .update(sanitize(partCost))
- .eq("partId", partCost.partId);
+ .from("itemCost")
+ .update(sanitize(itemCost))
+ .eq("itemId", itemCost.itemId);
}
-export async function upsertPartInventory(
+export async function upsertItemInventory(
client: SupabaseClient<Database>,
- partInventory:
- | (z.infer<typeof partInventoryValidator> & {
+ itemInventory:
+ | (z.infer<typeof itemInventoryValidator> & {
companyId: string;
createdBy: string;
customFields?: Json;
})
- | (z.infer<typeof partInventoryValidator> & {
+ | (z.infer<typeof itemInventoryValidator> & {
updatedBy: string;
customFields?: Json;
})
) {
- if ("createdBy" in partInventory) {
- return client.from("partInventory").insert(partInventory);
+ if ("createdBy" in itemInventory) {
+ return client.from("itemInventory").insert(itemInventory);
}
return client
- .from("partInventory")
- .update(sanitize(partInventory))
- .eq("partId", partInventory.partId)
- .eq("locationId", partInventory.locationId);
+ .from("itemInventory")
+ .update(sanitize(itemInventory))
+ .eq("itemId", itemInventory.itemId)
+ .eq("locationId", itemInventory.locationId);
}
-export async function upsertPartManufacturing(
+export async function upsertItemManufacturing(
client: SupabaseClient<Database>,
- partManufacturing: z.infer<typeof partManufacturingValidator> & {
+ partManufacturing: z.infer<typeof itemManufacturingValidator> & {
updatedBy: string;
customFields?: Json;
}
) {
return client
- .from("partReplenishment")
+ .from("itemReplenishment")
.update(sanitize(partManufacturing))
- .eq("partId", partManufacturing.partId);
+ .eq("itemId", partManufacturing.itemId);
}
-export async function upsertPartPlanning(
+export async function upsertItemPlanning(
client: SupabaseClient<Database>,
partPlanning:
| {
companyId: string;
- partId: string;
+ itemId: string;
locationId: string;
createdBy: string;
}
- | (z.infer<typeof partPlanningValidator> & {
+ | (z.infer<typeof itemPlanningValidator> & {
updatedBy: string;
customFields?: Json;
})
) {
if ("createdBy" in partPlanning) {
- return client.from("partPlanning").insert(partPlanning);
+ return client.from("itemPlanning").insert(partPlanning);
}
return client
- .from("partPlanning")
+ .from("itemPlanning")
.update(sanitize(partPlanning))
- .eq("partId", partPlanning.partId)
+ .eq("itemId", partPlanning.itemId)
.eq("locationId", partPlanning.locationId);
}
-export async function upsertPartPurchasing(
+export async function upsertItemPurchasing(
client: SupabaseClient<Database>,
- partPurchasing: z.infer<typeof partPurchasingValidator> & {
+ itemPurchasing: z.infer<typeof itemPurchasingValidator> & {
updatedBy: string;
}
) {
return client
- .from("partReplenishment")
- .update(sanitize(partPurchasing))
- .eq("partId", partPurchasing.partId);
+ .from("itemReplenishment")
+ .update(sanitize(itemPurchasing))
+ .eq("itemId", itemPurchasing.itemId);
}
export async function upsertItemGroup(
@@ -650,46 +650,46 @@ export async function upsertItemGroup(
);
}
-export async function upsertPartSupplier(
+export async function upsertItemSupplier(
client: SupabaseClient<Database>,
- partSupplier:
- | (Omit<z.infer<typeof partSupplierValidator>, "id"> & {
+ itemSupplier:
+ | (Omit<z.infer<typeof itemSupplierValidator>, "id"> & {
companyId: string;
createdBy: string;
customFields?: Json;
})
- | (Omit<z.infer<typeof partSupplierValidator>, "id"> & {
+ | (Omit<z.infer<typeof itemSupplierValidator>, "id"> & {
id: string;
updatedBy: string;
customFields?: Json;
})
) {
- if ("createdBy" in partSupplier) {
+ if ("createdBy" in itemSupplier) {
return client
- .from("partSupplier")
- .insert([partSupplier])
+ .from("itemSupplier")
+ .insert([itemSupplier])
.select("id")
.single();
}
return client
- .from("partSupplier")
- .update(sanitize(partSupplier))
- .eq("id", partSupplier.id)
+ .from("itemSupplier")
+ .update(sanitize(itemSupplier))
+ .eq("id", itemSupplier.id)
.select("id")
.single();
}
-export async function upsertPartUnitSalePrice(
+export async function upsertItemUnitSalePrice(
client: SupabaseClient<Database>,
- partUnitSalePrice: z.infer<typeof partUnitSalePriceValidator> & {
+ itemUnitSalePrice: z.infer<typeof itemUnitSalePriceValidator> & {
updatedBy: string;
customFields?: Json;
}
) {
return client
- .from("partUnitSalePrice")
- .update(sanitize(partUnitSalePrice))
- .eq("partId", partUnitSalePrice.partId);
+ .from("itemUnitSalePrice")
+ .update(sanitize(itemUnitSalePrice))
+ .eq("itemId", itemUnitSalePrice.itemId);
}
export async function upsertService(
@@ -712,7 +712,7 @@ export async function upsertService(
.insert({
readableId: service.id,
name: service.name,
- type: "service",
+ type: "Service",
companyId: service.companyId,
createdBy: service.createdBy,
})
diff --git a/apps/carbon/app/modules/parts/types.ts b/apps/carbon/app/modules/parts/types.ts
index a2a0f71da4..83e6173a34 100644
--- a/apps/carbon/app/modules/parts/types.ts
+++ b/apps/carbon/app/modules/parts/types.ts
@@ -1,24 +1,23 @@
import type { Database } from "@carbon/database";
import type {
+ getItemCost,
getItemGroups,
getItemGroupsList,
+ getItemQuantities,
+ getItemSuppliers,
getPart,
- getPartCost,
- getPartQuantities,
- getPartSuppliers,
getParts,
- getServiceSuppliers,
getServices,
getUnitOfMeasure,
getUnitOfMeasuresList,
} from "./parts.service";
-export type PartCost = NonNullable<
- Awaited<ReturnType<typeof getPartCost>>
+export type ItemCost = NonNullable<
+ Awaited<ReturnType<typeof getItemCost>>
>["data"];
export type PartCostingMethod =
- Database["public"]["Enums"]["partCostingMethod"];
+ Database["public"]["Enums"]["itemCostingMethod"];
export type ItemGroup = NonNullable<
Awaited<ReturnType<typeof getItemGroups>>["data"]
@@ -28,22 +27,22 @@ export type ItemGroupListItem = NonNullable<
Awaited<ReturnType<typeof getItemGroupsList>>["data"]
>[number];
-export type PartQuantities = NonNullable<
- Awaited<ReturnType<typeof getPartQuantities>>["data"]
+export type ItemQuantities = NonNullable<
+ Awaited<ReturnType<typeof getItemQuantities>>["data"]
>;
-export type PartReorderingPolicy =
- Database["public"]["Enums"]["partReorderingPolicy"];
+export type ItemReorderingPolicy =
+ Database["public"]["Enums"]["itemReorderingPolicy"];
-export type PartReplenishmentSystem =
- Database["public"]["Enums"]["partReplenishmentSystem"];
+export type ItemReplenishmentSystem =
+ Database["public"]["Enums"]["itemReplenishmentSystem"];
export type PartSummary = NonNullable<
Awaited<ReturnType<typeof getPart>>
>["data"];
-export type PartSupplier = NonNullable<
- Awaited<ReturnType<typeof getPartSuppliers>>["data"]
+export type ItemSupplier = NonNullable<
+ Awaited<ReturnType<typeof getItemSuppliers>>["data"]
>[number];
export type PartManufacturingPolicy =
@@ -59,10 +58,6 @@ export type Service = NonNullable<
Awaited<ReturnType<typeof getServices>>["data"]
>[number];
-export type ServiceSupplier = NonNullable<
- Awaited<ReturnType<typeof getServiceSuppliers>>["data"]
->[number];
-
export type ServiceType = Database["public"]["Enums"]["serviceType"];
export type UnitOfMeasure = NonNullable<
diff --git a/apps/carbon/app/modules/parts/ui/Part/PartCostingForm.tsx b/apps/carbon/app/modules/parts/ui/Part/PartCostingForm.tsx
index e2b8950b73..3dab65d66d 100644
--- a/apps/carbon/app/modules/parts/ui/Part/PartCostingForm.tsx
+++ b/apps/carbon/app/modules/parts/ui/Part/PartCostingForm.tsx
@@ -17,10 +17,10 @@ import {
Submit,
} from "~/components/Form";
import { usePermissions } from "~/hooks";
-import { partCostValidator, partCostingMethods } from "~/modules/parts";
+import { itemCostValidator, itemCostingMethods } from "~/modules/parts";
type PartCostingFormProps = {
- initialValues: z.infer<typeof partCostValidator>;
+ initialValues: z.infer<typeof itemCostValidator>;
};
const currency = "USD"; // TODO: get from settings
@@ -31,7 +31,7 @@ const PartCostingForm = ({ initialValues }: PartCostingFormProps) => {
initialValues.costingMethod
);
- const partCostingMethodOptions = partCostingMethods.map(
+ const partCostingMethodOptions = itemCostingMethods.map(
(partCostingMethod) => ({
label: partCostingMethod,
value: partCostingMethod,
@@ -41,7 +41,7 @@ const PartCostingForm = ({ initialValues }: PartCostingFormProps) => {
return (
<ValidatedForm
method="post"
- validator={partCostValidator}
+ validator={itemCostValidator}
defaultValues={initialValues}
>
<Card>
@@ -49,7 +49,7 @@ const PartCostingForm = ({ initialValues }: PartCostingFormProps) => {
<CardTitle>Costing & Posting</CardTitle>
</CardHeader>
<CardContent>
- <Hidden name="partId" />
+ <Hidden name="itemId" />
<div className="grid grid-cols-1 lg:grid-cols-3 gap-x-8 gap-y-2 w-full">
<Select
name="costingMethod"
diff --git a/apps/carbon/app/modules/parts/ui/Part/PartPlanningForm.tsx b/apps/carbon/app/modules/parts/ui/Part/PartPlanningForm.tsx
index 9493982ece..31d0034bfd 100644
--- a/apps/carbon/app/modules/parts/ui/Part/PartPlanningForm.tsx
+++ b/apps/carbon/app/modules/parts/ui/Part/PartPlanningForm.tsx
@@ -19,7 +19,7 @@ import {
Submit,
} from "~/components/Form";
import { usePermissions } from "~/hooks";
-import { partPlanningValidator, partReorderingPolicies } from "~/modules/parts";
+import { itemReorderingPolicies, partPlanningValidator } from "~/modules/parts";
import type { ListItem } from "~/types";
import { path } from "~/utils/path";
@@ -71,7 +71,7 @@ const PartPlanningForm = ({
<SelectForm
name="reorderingPolicy"
label="Reordering Policy"
- options={partReorderingPolicies.map((policy) => ({
+ options={itemReorderingPolicies.map((policy) => ({
label: policy,
value: policy,
}))}
diff --git a/apps/carbon/app/modules/parts/ui/Part/PartSuppliers/PartSuppliers.tsx b/apps/carbon/app/modules/parts/ui/Part/PartSuppliers/PartSuppliers.tsx
index 6b12a47697..ae914f24c8 100644
--- a/apps/carbon/app/modules/parts/ui/Part/PartSuppliers/PartSuppliers.tsx
+++ b/apps/carbon/app/modules/parts/ui/Part/PartSuppliers/PartSuppliers.tsx
@@ -18,12 +18,12 @@ import {
import Grid from "~/components/Grid";
import { useRouteData } from "~/hooks";
import { useCustomColumns } from "~/hooks/useCustomColumns";
-import type { PartSupplier, UnitOfMeasureListItem } from "~/modules/parts";
+import type { ItemSupplier, UnitOfMeasureListItem } from "~/modules/parts";
import { path } from "~/utils/path";
-import usePartSuppliers from "./usePartSuppliers";
+import useItemSuppliers from "./useItemSuppliers";
-type PartSuppliersProps = {
- partSuppliers: PartSupplier[];
+type ItemSuppliersProps = {
+ partSuppliers: ItemSupplier[];
};
// TODO: make dynamic
@@ -32,9 +32,9 @@ const formatter = new Intl.NumberFormat("en-US", {
currency: "USD",
});
-const PartSuppliers = ({ partSuppliers }: PartSuppliersProps) => {
+const ItemSuppliers = ({ partSuppliers }: ItemSuppliersProps) => {
const navigate = useNavigate();
- const { canEdit, onCellEdit } = usePartSuppliers();
+ const { canEdit, onCellEdit } = useItemSuppliers();
const sharedPartData = useRouteData<{
unitOfMeasures: UnitOfMeasureListItem[];
}>(path.to.partRoot);
@@ -48,10 +48,10 @@ const PartSuppliers = ({ partSuppliers }: PartSuppliersProps) => {
);
}, [sharedPartData?.unitOfMeasures]);
- const customColumns = useCustomColumns<PartSupplier>("partSupplier");
+ const customColumns = useCustomColumns<ItemSupplier>("partSupplier");
- const columns = useMemo<ColumnDef<PartSupplier>[]>(() => {
- const defaultColumns: ColumnDef<PartSupplier>[] = [
+ const columns = useMemo<ColumnDef<ItemSupplier>[]>(() => {
+ const defaultColumns: ColumnDef<ItemSupplier>[] = [
{
accessorKey: "supplier.id",
header: "Supplier",
@@ -128,7 +128,7 @@ const PartSuppliers = ({ partSuppliers }: PartSuppliersProps) => {
<CardAction>{canEdit && <New to="new" />}</CardAction>
</HStack>
<CardContent>
- <Grid<PartSupplier>
+ <Grid<ItemSupplier>
data={partSuppliers}
columns={columns}
canEdit={canEdit}
@@ -142,4 +142,4 @@ const PartSuppliers = ({ partSuppliers }: PartSuppliersProps) => {
);
};
-export default PartSuppliers;
+export default ItemSuppliers;
diff --git a/apps/carbon/app/modules/parts/ui/Part/PartSuppliers/usePartSuppliers.tsx b/apps/carbon/app/modules/parts/ui/Part/PartSuppliers/useItemSuppliers.tsx
similarity index 76%
rename from apps/carbon/app/modules/parts/ui/Part/PartSuppliers/usePartSuppliers.tsx
rename to apps/carbon/app/modules/parts/ui/Part/PartSuppliers/useItemSuppliers.tsx
index 92bff697b6..47be8b70e7 100644
--- a/apps/carbon/app/modules/parts/ui/Part/PartSuppliers/usePartSuppliers.tsx
+++ b/apps/carbon/app/modules/parts/ui/Part/PartSuppliers/useItemSuppliers.tsx
@@ -1,9 +1,9 @@
import { useCallback } from "react";
import { usePermissions } from "~/hooks";
import { useSupabase } from "~/lib/supabase";
-import type { PartSupplier } from "~/modules/parts";
+import type { ItemSupplier } from "~/modules/parts";
-export default function usePartSuppliers() {
+export default function useItemSuppliers() {
const { supabase } = useSupabase();
const permissions = usePermissions();
@@ -11,10 +11,10 @@ export default function usePartSuppliers() {
const canDelete = permissions.can("delete", "parts");
const onCellEdit = useCallback(
- async (id: string, value: unknown, row: PartSupplier) => {
+ async (id: string, value: unknown, row: ItemSupplier) => {
if (!supabase) throw new Error("Supabase client not found");
return await supabase
- .from("partSupplier")
+ .from("itemSupplier")
.update({
[id]: value,
})
diff --git a/apps/carbon/app/modules/purchasing/purchasing.models.ts b/apps/carbon/app/modules/purchasing/purchasing.models.ts
index 57fe0f0e22..c6a5115e8a 100644
--- a/apps/carbon/app/modules/purchasing/purchasing.models.ts
+++ b/apps/carbon/app/modules/purchasing/purchasing.models.ts
@@ -90,8 +90,8 @@ export const purchaseOrderLineValidator = z
message: "Type is required",
}),
}),
- partId: zfd.text(z.string().optional()),
- serviceId: zfd.text(z.string().optional()),
+ itemId: zfd.text(z.string().optional()),
+ itemReadableId: zfd.text(z.string().optional()),
accountNumber: zfd.text(z.string().optional()),
assetId: zfd.text(z.string().optional()),
description: zfd.text(z.string().optional()),
@@ -105,7 +105,18 @@ export const purchaseOrderLineValidator = z
shelfId: zfd.text(z.string().optional()),
})
.refine(
- (data) => (data.purchaseOrderLineType === "Part" ? data.partId : true),
+ (data) =>
+ [
+ "Part",
+ "Service",
+ "Material",
+ "Tool",
+ "Fixture",
+ "Hardware",
+ "Consumable",
+ ].includes(data.purchaseOrderLineType)
+ ? data.itemId
+ : true,
{
message: "Part is required",
path: ["partId"], // path of error
diff --git a/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLines/usePurchaseOrderLines.tsx b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLines/usePurchaseOrderLines.tsx
index e3f53da73a..e51f782151 100644
--- a/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLines/usePurchaseOrderLines.tsx
+++ b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLines/usePurchaseOrderLines.tsx
@@ -6,7 +6,7 @@ import { useSupabase } from "~/lib/supabase";
import type { getAccountsList } from "~/modules/accounting";
import type { getServicesList } from "~/modules/parts";
import type { PurchaseOrderLine } from "~/modules/purchasing";
-import { usePurchasedParts } from "~/stores/parts";
+import { usePurchasedParts } from "~/stores/items";
import { path } from "~/utils/path";
export default function usePurchaseOrderLines() {
diff --git a/apps/carbon/app/modules/purchasing/ui/RequestForQuotes/RequestForQuotesTable.tsx b/apps/carbon/app/modules/purchasing/ui/RequestForQuotes/RequestForQuotesTable.tsx
index 1d5196f535..cf88c69e28 100644
--- a/apps/carbon/app/modules/purchasing/ui/RequestForQuotes/RequestForQuotesTable.tsx
+++ b/apps/carbon/app/modules/purchasing/ui/RequestForQuotes/RequestForQuotesTable.tsx
@@ -29,7 +29,7 @@ const RequestForQuotesTable = memo(
const fetcher = useFetcher();
const optimisticFavorite = useOptimisticFavorite();
- const [parts] = useParts();
+ const parts = useParts();
const [people] = usePeople();
const [suppliers] = useSuppliers();
diff --git a/apps/carbon/app/modules/sales/ui/Quotation/QuotationMaterialLines.tsx b/apps/carbon/app/modules/sales/ui/Quotation/QuotationMaterialLines.tsx
index 7bd4a2422d..7027d4ddc2 100644
--- a/apps/carbon/app/modules/sales/ui/Quotation/QuotationMaterialLines.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotation/QuotationMaterialLines.tsx
@@ -23,7 +23,7 @@ import {
type Quotation,
type QuotationMaterial,
} from "~/modules/sales";
-import { useParts } from "~/stores/parts";
+import { useParts } from "~/stores/items";
import { path } from "~/utils/path";
type QuotationMaterialLinesProps = {
@@ -47,7 +47,7 @@ const QuotationMaterialLines = ({
const canEdit = permissions.can("update", "sales");
const canDelete = permissions.can("delete", "sales");
- const [parts] = useParts();
+ const parts = useParts();
const partOptions = useMemo(
() =>
parts.map((p) => ({
diff --git a/apps/carbon/app/modules/sales/ui/Quotations/QuotationsTable.tsx b/apps/carbon/app/modules/sales/ui/Quotations/QuotationsTable.tsx
index da95c233de..5c21108010 100644
--- a/apps/carbon/app/modules/sales/ui/Quotations/QuotationsTable.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotations/QuotationsTable.tsx
@@ -42,7 +42,7 @@ const QuotationsTable = memo(({ data, count }: QuotationsTableProps) => {
const deleteQuotationModal = useDisclosure();
const [customers] = useCustomers();
- const [parts] = useParts();
+ const parts = useParts();
const [people] = usePeople();
const fetcher = useFetcher();
diff --git a/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderLines/useSalesOrderLines.tsx b/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderLines/useSalesOrderLines.tsx
index bf107b3211..ae61d1bee4 100644
--- a/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderLines/useSalesOrderLines.tsx
+++ b/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderLines/useSalesOrderLines.tsx
@@ -5,7 +5,7 @@ import { usePermissions, useUser } from "~/hooks";
import { useSupabase } from "~/lib/supabase";
import type { getServicesList } from "~/modules/parts";
import type { SalesOrderLine } from "~/modules/sales";
-import { useParts } from "~/stores/parts";
+import { useParts } from "~/stores/items";
import { path } from "~/utils/path";
export default function useSalesOrderLines() {
@@ -16,7 +16,7 @@ export default function useSalesOrderLines() {
const canEdit = permissions.can("update", "sales");
const canDelete = permissions.can("delete", "sales");
- const [parts] = useParts();
+ const parts = useParts();
const partOptions = useMemo(
() =>
parts.map((p) => ({
diff --git a/apps/carbon/app/modules/shared/ui/Realtime/RealtimeDataProvider.tsx b/apps/carbon/app/modules/shared/ui/Realtime/RealtimeDataProvider.tsx
index b45725a434..5c35378760 100644
--- a/apps/carbon/app/modules/shared/ui/Realtime/RealtimeDataProvider.tsx
+++ b/apps/carbon/app/modules/shared/ui/Realtime/RealtimeDataProvider.tsx
@@ -2,8 +2,8 @@ import idb from "localforage";
import { useEffect } from "react";
import { useUser } from "~/hooks";
import { useSupabase } from "~/lib/supabase";
-import { useCustomers, useParts, usePeople, useSuppliers } from "~/stores";
-import type { Part } from "~/stores/parts";
+import { useCustomers, useItems, usePeople, useSuppliers } from "~/stores";
+import type { Item } from "~/stores/items";
import type { ListItem } from "~/types";
let hydratedFromIdb = false;
@@ -15,7 +15,7 @@ const RealtimeDataProvider = ({ children }: { children: React.ReactNode }) => {
company: { id: companyId },
} = useUser();
- const [, setParts] = useParts();
+ const [, setItems] = useItems();
const [, setSuppliers] = useSuppliers();
const [, setCustomers] = useCustomers();
const [, setPeople] = usePeople();
@@ -27,8 +27,8 @@ const RealtimeDataProvider = ({ children }: { children: React.ReactNode }) => {
idb.getItem("customers").then((data) => {
if (data && !hydratedFromServer) setCustomers(data as ListItem[], true);
});
- idb.getItem("parts").then((data) => {
- if (data && !hydratedFromServer) setParts(data as Part[], true);
+ idb.getItem("items").then((data) => {
+ if (data && !hydratedFromServer) setItems(data as Item[], true);
});
idb.getItem("suppliers").then((data) => {
if (data && !hydratedFromServer) setSuppliers(data as ListItem[], true);
@@ -41,10 +41,10 @@ const RealtimeDataProvider = ({ children }: { children: React.ReactNode }) => {
if (!supabase || !accessToken) return;
- const [parts, suppliers, customers, people] = await Promise.all([
+ const [items, suppliers, customers, people] = await Promise.all([
supabase
- .from("parts")
- .select("id, name, replenishmentSystem")
+ .from("item")
+ .select("id, readableId, name, type")
.eq("companyId", companyId)
.eq("active", true)
.eq("blocked", false)
@@ -66,8 +66,8 @@ const RealtimeDataProvider = ({ children }: { children: React.ReactNode }) => {
.order("name"),
]);
- if (parts.error) {
- throw new Error("Failed to fetch parts");
+ if (items.error) {
+ throw new Error("Failed to fetch items");
}
if (suppliers.error) {
throw new Error("Failed to fetch suppliers");
@@ -82,7 +82,7 @@ const RealtimeDataProvider = ({ children }: { children: React.ReactNode }) => {
hydratedFromServer = true;
// @ts-ignore
- setParts(parts.data ?? []);
+ setItems(items.data ?? []);
setSuppliers(suppliers.data ?? []);
setCustomers(customers.data ?? []);
// @ts-ignore
@@ -111,13 +111,14 @@ const RealtimeDataProvider = ({ children }: { children: React.ReactNode }) => {
case "INSERT":
const { new: inserted } = payload;
if (inserted.active && !inserted.blocked) {
- setParts((parts) =>
+ setItems((items) =>
[
- ...parts,
+ ...items,
{
id: inserted.id,
+ readableId: inserted.readableId,
name: inserted.name,
- replenishmentSystem: inserted.replenishmentSystem,
+ type: inserted.type,
},
].sort((a, b) => a.name.localeCompare(b.name))
);
@@ -125,24 +126,25 @@ const RealtimeDataProvider = ({ children }: { children: React.ReactNode }) => {
break;
case "UPDATE":
const { new: updated } = payload;
- setParts((parts) =>
- parts
- .map((p) => {
- if (p.id === updated.id) {
+ setItems((items) =>
+ items
+ .map((i) => {
+ if (i.id === updated.id) {
return {
- ...p,
+ ...i,
+ readableId: updated.readableId,
name: updated.name,
- replenishmentSystem: updated.replenishmentSystem,
+ description: updated.description,
};
}
- return p;
+ return i;
})
.sort((a, b) => a.name.localeCompare(b.name))
);
break;
case "DELETE":
const { old: deleted } = payload;
- setParts((parts) => parts.filter((p) => p.id !== deleted.id));
+ setItems((items) => items.filter((p) => p.id !== deleted.id));
break;
default:
break;
diff --git a/apps/carbon/app/routes/x+/part+/$partId.costing.tsx b/apps/carbon/app/routes/x+/part+/$itemId.costing.tsx
similarity index 68%
rename from apps/carbon/app/routes/x+/part+/$partId.costing.tsx
rename to apps/carbon/app/routes/x+/part+/$itemId.costing.tsx
index 4bea631597..160ca35eb8 100644
--- a/apps/carbon/app/routes/x+/part+/$partId.costing.tsx
+++ b/apps/carbon/app/routes/x+/part+/$itemId.costing.tsx
@@ -5,9 +5,9 @@ import { useLoaderData } from "@remix-run/react";
import { getAccountsList } from "~/modules/accounting";
import {
PartCostingForm,
- getPartCost,
- partCostValidator,
- upsertPartCost,
+ getItemCost,
+ itemCostValidator,
+ upsertItemCost,
} from "~/modules/parts";
import { requirePermissions } from "~/services/auth/auth.server";
import { flash } from "~/services/session.server";
@@ -21,18 +21,18 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
view: "parts",
});
- const { partId } = params;
- if (!partId) throw new Error("Could not find partId");
+ const { itemId } = params;
+ if (!itemId) throw new Error("Could not find itemId");
- const [partCost, accounts] = await Promise.all([
- getPartCost(client, partId, companyId),
+ const [itemCost, accounts] = await Promise.all([
+ getItemCost(client, itemId, companyId),
getAccountsList(client, companyId),
]);
- if (partCost.error) {
+ if (itemCost.error) {
throw redirect(
path.to.parts,
- await flash(request, error(partCost.error, "Failed to load part costing"))
+ await flash(request, error(itemCost.error, "Failed to load part costing"))
);
}
if (accounts.error) {
@@ -43,7 +43,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
}
return json({
- partCost: partCost.data,
+ itemCost: itemCost.data,
accounts: accounts.data,
});
}
@@ -54,44 +54,44 @@ export async function action({ request, params }: ActionFunctionArgs) {
update: "parts",
});
- const { partId } = params;
- if (!partId) throw new Error("Could not find partId");
+ const { itemId } = params;
+ if (!itemId) throw new Error("Could not find itemId");
const formData = await request.formData();
- const validation = await validator(partCostValidator).validate(formData);
+ const validation = await validator(itemCostValidator).validate(formData);
if (validation.error) {
return validationError(validation.error);
}
- const updatePartCost = await upsertPartCost(client, {
+ const updateItemCost = await upsertItemCost(client, {
...validation.data,
- partId,
+ itemId,
updatedBy: userId,
customFields: setCustomFields(formData),
});
- if (updatePartCost.error) {
+ if (updateItemCost.error) {
throw redirect(
- path.to.part(partId),
+ path.to.part(itemId),
await flash(
request,
- error(updatePartCost.error, "Failed to update part costing")
+ error(updateItemCost.error, "Failed to update part costing")
)
);
}
throw redirect(
- path.to.partCosting(partId),
+ path.to.partCosting(itemId),
await flash(request, success("Updated part costing"))
);
}
export default function PartCostingRoute() {
- const { partCost } = useLoaderData<typeof loader>();
+ const { itemCost } = useLoaderData<typeof loader>();
return (
<PartCostingForm
- key={partCost.partId}
- initialValues={{ ...partCost, ...getCustomFields(partCost.customFields) }}
+ key={itemCost.itemId}
+ initialValues={{ ...itemCost, ...getCustomFields(itemCost.customFields) }}
/>
);
}
diff --git a/apps/carbon/app/routes/x+/part+/$partId.inventory.tsx b/apps/carbon/app/routes/x+/part+/$itemId.inventory.tsx
similarity index 77%
rename from apps/carbon/app/routes/x+/part+/$partId.inventory.tsx
rename to apps/carbon/app/routes/x+/part+/$itemId.inventory.tsx
index 053c0e25f9..5a5b281470 100644
--- a/apps/carbon/app/routes/x+/part+/$partId.inventory.tsx
+++ b/apps/carbon/app/routes/x+/part+/$itemId.inventory.tsx
@@ -5,11 +5,11 @@ import { useLoaderData } from "@remix-run/react";
import { useRouteData } from "~/hooks";
import {
PartInventoryForm,
- getPartInventory,
- getPartQuantities,
+ getItemInventory,
+ getItemQuantities,
getShelvesList,
- partInventoryValidator,
- upsertPartInventory,
+ itemInventoryValidator,
+ upsertItemInventory,
} from "~/modules/parts";
import { getLocationsList } from "~/modules/resources";
import { getUserDefaults } from "~/modules/users/users.server";
@@ -26,8 +26,8 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
view: "parts",
});
- const { partId } = params;
- if (!partId) throw new Error("Could not find partId");
+ const { itemId } = params;
+ if (!itemId) throw new Error("Could not find itemId");
const url = new URL(request.url);
const searchParams = new URLSearchParams(url.search);
@@ -37,7 +37,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
const userDefaults = await getUserDefaults(client, userId, companyId);
if (userDefaults.error) {
throw redirect(
- path.to.part(partId),
+ path.to.part(itemId),
await flash(
request,
error(userDefaults.error, "Failed to load default location")
@@ -52,7 +52,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
const locations = await getLocationsList(client, companyId);
if (locations.error || !locations.data?.length) {
throw redirect(
- path.to.part(partId),
+ path.to.part(itemId),
await flash(
request,
error(locations.error, "Failed to load any locations")
@@ -63,38 +63,38 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
}
let [partInventory, shelves] = await Promise.all([
- getPartInventory(client, partId, companyId, locationId),
+ getItemInventory(client, itemId, companyId, locationId),
getShelvesList(client, locationId),
]);
if (partInventory.error || !partInventory.data) {
- const insertPartInventory = await upsertPartInventory(client, {
- partId,
+ const insertItemInventory = await upsertItemInventory(client, {
+ itemId,
companyId,
locationId,
customFields: {},
createdBy: userId,
});
- if (insertPartInventory.error) {
+ if (insertItemInventory.error) {
throw redirect(
- path.to.part(partId),
+ path.to.part(itemId),
await flash(
request,
- error(insertPartInventory.error, "Failed to insert part inventory")
+ error(insertItemInventory.error, "Failed to insert part inventory")
)
);
}
- partInventory = await getPartInventory(
+ partInventory = await getItemInventory(
client,
- partId,
+ itemId,
companyId,
locationId
);
if (partInventory.error || !partInventory.data) {
throw redirect(
- path.to.part(partId),
+ path.to.part(itemId),
await flash(
request,
error(partInventory.error, "Failed to load part inventory")
@@ -110,9 +110,9 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
);
}
- const quantities = await getPartQuantities(
+ const quantities = await getItemQuantities(
client,
- partId,
+ itemId,
companyId,
locationId
);
@@ -136,12 +136,12 @@ export async function action({ request, params }: ActionFunctionArgs) {
update: "parts",
});
- const { partId } = params;
- if (!partId) throw new Error("Could not find partId");
+ const { itemId } = params;
+ if (!itemId) throw new Error("Could not find itemId");
const formData = await request.formData();
// validate with partsValidator
- const validation = await validator(partInventoryValidator).validate(formData);
+ const validation = await validator(itemInventoryValidator).validate(formData);
if (validation.error) {
return validationError(validation.error);
@@ -149,30 +149,30 @@ export async function action({ request, params }: ActionFunctionArgs) {
const { ...update } = validation.data;
- const updatePartInventory = await upsertPartInventory(client, {
+ const updateItemInventory = await upsertItemInventory(client, {
...update,
- partId,
+ itemId,
customFields: setCustomFields(formData),
updatedBy: userId,
});
- if (updatePartInventory.error) {
+ if (updateItemInventory.error) {
throw redirect(
- path.to.part(partId),
+ path.to.part(itemId),
await flash(
request,
- error(updatePartInventory.error, "Failed to update part inventory")
+ error(updateItemInventory.error, "Failed to update part inventory")
)
);
}
throw redirect(
- path.to.partInventoryLocation(partId, update.locationId),
+ path.to.partInventoryLocation(itemId, update.locationId),
await flash(request, success("Updated part inventory"))
);
}
export default function PartInventoryRoute() {
- const sharedPartsData = useRouteData<{ locations: ListItem[] }>(
+ const sharedPartssData = useRouteData<{ locations: ListItem[] }>(
path.to.partRoot
);
const { partInventory, quantities, shelves } = useLoaderData<typeof loader>();
@@ -184,10 +184,10 @@ export default function PartInventoryRoute() {
};
return (
<PartInventoryForm
- key={initialValues.partId}
+ key={initialValues.itemId}
initialValues={initialValues}
quantities={quantities}
- locations={sharedPartsData?.locations ?? []}
+ locations={sharedPartssData?.locations ?? []}
shelves={shelves}
/>
);
diff --git a/apps/carbon/app/routes/x+/part+/$partId.manufacturing.tsx b/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.tsx
similarity index 80%
rename from apps/carbon/app/routes/x+/part+/$partId.manufacturing.tsx
rename to apps/carbon/app/routes/x+/part+/$itemId.manufacturing.tsx
index 03c539840e..40a05ea0da 100644
--- a/apps/carbon/app/routes/x+/part+/$partId.manufacturing.tsx
+++ b/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.tsx
@@ -4,9 +4,9 @@ import { json, redirect } from "@remix-run/node";
import { useLoaderData } from "@remix-run/react";
import {
PartManufacturingForm,
- getPartManufacturing,
- partManufacturingValidator,
- upsertPartManufacturing,
+ getItemManufacturing,
+ itemManufacturingValidator,
+ upsertItemManufacturing,
} from "~/modules/parts";
import { requirePermissions } from "~/services/auth/auth.server";
import { flash } from "~/services/session.server";
@@ -20,12 +20,12 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
view: "parts",
});
- const { partId } = params;
- if (!partId) throw new Error("Could not find partId");
+ const { itemId } = params;
+ if (!itemId) throw new Error("Could not find itemId");
- const partManufacturing = await getPartManufacturing(
+ const partManufacturing = await getItemManufacturing(
client,
- partId,
+ itemId,
companyId
);
@@ -53,11 +53,11 @@ export async function action({ request, params }: ActionFunctionArgs) {
update: "parts",
});
- const { partId } = params;
- if (!partId) throw new Error("Could not find partId");
+ const { itemId } = params;
+ if (!itemId) throw new Error("Could not find itemId");
const formData = await request.formData();
- const validation = await validator(partManufacturingValidator).validate(
+ const validation = await validator(itemManufacturingValidator).validate(
formData
);
@@ -65,15 +65,15 @@ export async function action({ request, params }: ActionFunctionArgs) {
return validationError(validation.error);
}
- const updatePartManufacturing = await upsertPartManufacturing(client, {
+ const updatePartManufacturing = await upsertItemManufacturing(client, {
...validation.data,
- partId,
+ itemId,
updatedBy: userId,
customFields: setCustomFields(formData),
});
if (updatePartManufacturing.error) {
throw redirect(
- path.to.part(partId),
+ path.to.part(itemId),
await flash(
request,
error(
@@ -85,7 +85,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
}
throw redirect(
- path.to.partManufacturing(partId),
+ path.to.partManufacturing(itemId),
await flash(request, success("Updated part manufacturing"))
);
}
@@ -101,7 +101,7 @@ export default function PartManufacturingRoute() {
return (
<PartManufacturingForm
- key={initialValues.partId}
+ key={initialValues.itemId}
initialValues={initialValues}
/>
);
diff --git a/apps/carbon/app/routes/x+/part+/$partId.planning.tsx b/apps/carbon/app/routes/x+/part+/$itemId.planning.tsx
similarity index 81%
rename from apps/carbon/app/routes/x+/part+/$partId.planning.tsx
rename to apps/carbon/app/routes/x+/part+/$itemId.planning.tsx
index f3d7cceb70..4b3d0cebe3 100644
--- a/apps/carbon/app/routes/x+/part+/$partId.planning.tsx
+++ b/apps/carbon/app/routes/x+/part+/$itemId.planning.tsx
@@ -5,9 +5,9 @@ import { useLoaderData } from "@remix-run/react";
import { useRouteData } from "~/hooks";
import {
PartPlanningForm,
- getPartPlanning,
- partPlanningValidator,
- upsertPartPlanning,
+ getItemPlanning,
+ itemPlanningValidator,
+ upsertItemPlanning,
} from "~/modules/parts";
import { getLocationsList } from "~/modules/resources";
import { getUserDefaults } from "~/modules/users/users.server";
@@ -24,8 +24,8 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
view: "parts",
});
- const { partId } = params;
- if (!partId) throw new Error("Could not find partId");
+ const { itemId } = params;
+ if (!itemId) throw new Error("Could not find itemId");
const url = new URL(request.url);
const searchParams = new URLSearchParams(url.search);
@@ -35,7 +35,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
const userDefaults = await getUserDefaults(client, userId, companyId);
if (userDefaults.error) {
throw redirect(
- path.to.part(partId),
+ path.to.part(itemId),
await flash(
request,
error(userDefaults.error, "Failed to load default location")
@@ -50,7 +50,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
const locations = await getLocationsList(client, companyId);
if (locations.error || !locations.data?.length) {
throw redirect(
- path.to.part(partId),
+ path.to.part(itemId),
await flash(
request,
error(locations.error, "Failed to load any locations")
@@ -60,16 +60,16 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
locationId = locations.data?.[0].id as string;
}
- let partPlanning = await getPartPlanning(
+ let partPlanning = await getItemPlanning(
client,
- partId,
+ itemId,
companyId,
locationId
);
if (partPlanning.error || !partPlanning.data) {
- const insertPartPlanning = await upsertPartPlanning(client, {
- partId,
+ const insertPartPlanning = await upsertItemPlanning(client, {
+ itemId,
companyId,
locationId,
createdBy: userId,
@@ -77,7 +77,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
if (insertPartPlanning.error) {
throw redirect(
- path.to.part(partId),
+ path.to.part(itemId),
await flash(
request,
error(insertPartPlanning.error, "Failed to insert part planning")
@@ -85,10 +85,10 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
);
}
- partPlanning = await getPartPlanning(client, partId, companyId, locationId);
+ partPlanning = await getItemPlanning(client, itemId, companyId, locationId);
if (partPlanning.error || !partPlanning.data) {
throw redirect(
- path.to.part(partId),
+ path.to.part(itemId),
await flash(
request,
error(partPlanning.error, "Failed to load part planning")
@@ -108,25 +108,25 @@ export async function action({ request, params }: ActionFunctionArgs) {
update: "parts",
});
- const { partId } = params;
- if (!partId) throw new Error("Could not find partId");
+ const { itemId } = params;
+ if (!itemId) throw new Error("Could not find itemId");
const formData = await request.formData();
- const validation = await validator(partPlanningValidator).validate(formData);
+ const validation = await validator(itemPlanningValidator).validate(formData);
if (validation.error) {
return validationError(validation.error);
}
- const updatePartPlanning = await upsertPartPlanning(client, {
+ const updatePartPlanning = await upsertItemPlanning(client, {
...validation.data,
- partId,
+ itemId,
updatedBy: userId,
customFields: setCustomFields(formData),
});
if (updatePartPlanning.error) {
throw redirect(
- path.to.part(partId),
+ path.to.part(itemId),
await flash(
request,
error(updatePartPlanning.error, "Failed to update part planning")
@@ -135,7 +135,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
}
throw redirect(
- path.to.partPlanningLocation(partId, validation.data.locationId),
+ path.to.partPlanningLocation(itemId, validation.data.locationId),
await flash(request, success("Updated part planning"))
);
}
@@ -151,7 +151,7 @@ export default function PartPlanningRoute() {
return (
<PartPlanningForm
- key={partPlanning.partId}
+ key={partPlanning.itemId}
initialValues={{
...partPlanning,
...getCustomFields(partPlanning.customFields),
diff --git a/apps/carbon/app/routes/x+/part+/$partId.purchasing.tsx b/apps/carbon/app/routes/x+/part+/$itemId.purchasing.tsx
similarity index 80%
rename from apps/carbon/app/routes/x+/part+/$partId.purchasing.tsx
rename to apps/carbon/app/routes/x+/part+/$itemId.purchasing.tsx
index fa8faf5254..94dfba8375 100644
--- a/apps/carbon/app/routes/x+/part+/$partId.purchasing.tsx
+++ b/apps/carbon/app/routes/x+/part+/$itemId.purchasing.tsx
@@ -4,9 +4,9 @@ import { json, redirect } from "@remix-run/node";
import { useLoaderData } from "@remix-run/react";
import {
PartPurchasingForm,
- getPartReplenishment,
- partPurchasingValidator,
- upsertPartPurchasing,
+ getItemReplenishment,
+ itemPurchasingValidator,
+ upsertItemPurchasing,
} from "~/modules/parts";
import { requirePermissions } from "~/services/auth/auth.server";
import { flash } from "~/services/session.server";
@@ -19,10 +19,10 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
view: "parts",
});
- const { partId } = params;
- if (!partId) throw new Error("Could not find partId");
+ const { itemId } = params;
+ if (!itemId) throw new Error("Could not find itemId");
- const partPurchasing = await getPartReplenishment(client, partId, companyId);
+ const partPurchasing = await getItemReplenishment(client, itemId, companyId);
if (partPurchasing.error) {
throw redirect(
@@ -45,11 +45,11 @@ export async function action({ request, params }: ActionFunctionArgs) {
update: "parts",
});
- const { partId } = params;
- if (!partId) throw new Error("Could not find partId");
+ const { itemId } = params;
+ if (!itemId) throw new Error("Could not find itemId");
// validate with partsValidator
- const validation = await validator(partPurchasingValidator).validate(
+ const validation = await validator(itemPurchasingValidator).validate(
await request.formData()
);
@@ -57,14 +57,14 @@ export async function action({ request, params }: ActionFunctionArgs) {
return validationError(validation.error);
}
- const updatePartPurchasing = await upsertPartPurchasing(client, {
+ const updatePartPurchasing = await upsertItemPurchasing(client, {
...validation.data,
- partId,
+ itemId,
updatedBy: userId,
});
if (updatePartPurchasing.error) {
throw redirect(
- path.to.part(partId),
+ path.to.part(itemId),
await flash(
request,
error(updatePartPurchasing.error, "Failed to update part purchasing")
@@ -73,7 +73,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
}
throw redirect(
- path.to.partPurchasing(partId),
+ path.to.partPurchasing(itemId),
await flash(request, success("Updated part purchasing"))
);
}
@@ -93,7 +93,7 @@ export default function PartPurchasingRoute() {
return (
<PartPurchasingForm
- key={initialValues.partId}
+ key={initialValues.itemId}
initialValues={initialValues}
/>
);
diff --git a/apps/carbon/app/routes/x+/part+/$partId.sale-price.tsx b/apps/carbon/app/routes/x+/part+/$itemId.sale-price.tsx
similarity index 80%
rename from apps/carbon/app/routes/x+/part+/$partId.sale-price.tsx
rename to apps/carbon/app/routes/x+/part+/$itemId.sale-price.tsx
index 86f685b790..ffa7909ab4 100644
--- a/apps/carbon/app/routes/x+/part+/$partId.sale-price.tsx
+++ b/apps/carbon/app/routes/x+/part+/$itemId.sale-price.tsx
@@ -4,9 +4,9 @@ import { json, redirect } from "@remix-run/node";
import { useLoaderData } from "@remix-run/react";
import {
PartSalePriceForm,
- getPartUnitSalePrice,
- partUnitSalePriceValidator,
- upsertPartUnitSalePrice,
+ getItemUnitSalePrice,
+ itemUnitSalePriceValidator,
+ upsertItemUnitSalePrice,
} from "~/modules/parts";
import { requirePermissions } from "~/services/auth/auth.server";
import { flash } from "~/services/session.server";
@@ -20,11 +20,11 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
view: "parts",
});
- const { partId } = params;
- if (!partId) throw new Error("Could not find partId");
+ const { itemId } = params;
+ if (!itemId) throw new Error("Could not find itemId");
const [partUnitSalePrice] = await Promise.all([
- getPartUnitSalePrice(client, partId, companyId),
+ getItemUnitSalePrice(client, itemId, companyId),
]);
if (partUnitSalePrice.error) {
@@ -48,11 +48,11 @@ export async function action({ request, params }: ActionFunctionArgs) {
update: "parts",
});
- const { partId } = params;
- if (!partId) throw new Error("Could not find partId");
+ const { itemId } = params;
+ if (!itemId) throw new Error("Could not find itemId");
const formData = await request.formData();
- const validation = await validator(partUnitSalePriceValidator).validate(
+ const validation = await validator(itemUnitSalePriceValidator).validate(
formData
);
@@ -60,15 +60,15 @@ export async function action({ request, params }: ActionFunctionArgs) {
return validationError(validation.error);
}
- const updatePartUnitSalePrice = await upsertPartUnitSalePrice(client, {
+ const updatePartUnitSalePrice = await upsertItemUnitSalePrice(client, {
...validation.data,
- partId,
+ itemId,
updatedBy: userId,
customFields: setCustomFields(formData),
});
if (updatePartUnitSalePrice.error) {
throw redirect(
- path.to.part(partId),
+ path.to.part(itemId),
await flash(
request,
error(updatePartUnitSalePrice.error, "Failed to update part sale price")
@@ -77,7 +77,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
}
throw redirect(
- path.to.partSalePrice(partId),
+ path.to.partSalePrice(itemId),
await flash(request, success("Updated part sale price"))
);
}
@@ -93,7 +93,7 @@ export default function PartSalePriceRoute() {
return (
<PartSalePriceForm
- key={initialValues.partId}
+ key={initialValues.itemId}
initialValues={initialValues}
/>
);
diff --git a/apps/carbon/app/routes/x+/part+/$partId.suppliers.new.tsx b/apps/carbon/app/routes/x+/part+/$itemId.suppliers.new.tsx
similarity index 77%
rename from apps/carbon/app/routes/x+/part+/$partId.suppliers.new.tsx
rename to apps/carbon/app/routes/x+/part+/$itemId.suppliers.new.tsx
index 0dfdf295a4..27c27ae09e 100644
--- a/apps/carbon/app/routes/x+/part+/$partId.suppliers.new.tsx
+++ b/apps/carbon/app/routes/x+/part+/$itemId.suppliers.new.tsx
@@ -4,8 +4,8 @@ import { redirect } from "@remix-run/node";
import { useParams } from "@remix-run/react";
import {
PartSupplierForm,
- partSupplierValidator,
- upsertPartSupplier,
+ itemSupplierValidator,
+ upsertItemSupplier,
} from "~/modules/parts";
import { requirePermissions } from "~/services/auth/auth.server";
import { flash } from "~/services/session.server";
@@ -20,11 +20,11 @@ export async function action({ request, params }: ActionFunctionArgs) {
create: "parts",
});
- const { partId } = params;
- if (!partId) throw new Error("Could not find partId");
+ const { itemId } = params;
+ if (!itemId) throw new Error("Could not find itemId");
const formData = await request.formData();
- const validation = await validator(partSupplierValidator).validate(formData);
+ const validation = await validator(itemSupplierValidator).validate(formData);
if (validation.error) {
return validationError(validation.error);
@@ -32,7 +32,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
const { id, ...data } = validation.data;
- const createPartSupplier = await upsertPartSupplier(client, {
+ const createPartSupplier = await upsertItemSupplier(client, {
...data,
companyId,
createdBy: userId,
@@ -41,7 +41,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
if (createPartSupplier.error) {
throw redirect(
- path.to.partSuppliers(partId),
+ path.to.partSuppliers(itemId),
await flash(
request,
error(createPartSupplier.error, "Failed to create part supplier")
@@ -49,16 +49,16 @@ export async function action({ request, params }: ActionFunctionArgs) {
);
}
- throw redirect(path.to.partSuppliers(partId));
+ throw redirect(path.to.partSuppliers(itemId));
}
export default function NewPartSupplierRoute() {
- const { partId } = useParams();
+ const { itemId } = useParams();
- if (!partId) throw new Error("partId not found");
+ if (!itemId) throw new Error("itemId not found");
const initialValues = {
- partId: partId,
+ itemId: itemId,
supplierId: "",
supplierPartId: "",
unitPrice: 0,
diff --git a/apps/carbon/app/routes/x+/part+/$partId.suppliers.tsx b/apps/carbon/app/routes/x+/part+/$itemId.suppliers.tsx
similarity index 81%
rename from apps/carbon/app/routes/x+/part+/$partId.suppliers.tsx
rename to apps/carbon/app/routes/x+/part+/$itemId.suppliers.tsx
index b80f928ee5..e062888bbe 100644
--- a/apps/carbon/app/routes/x+/part+/$partId.suppliers.tsx
+++ b/apps/carbon/app/routes/x+/part+/$itemId.suppliers.tsx
@@ -1,7 +1,7 @@
import type { LoaderFunctionArgs } from "@remix-run/node";
import { json, redirect } from "@remix-run/node";
import { useLoaderData } from "@remix-run/react";
-import { PartSuppliers, getPartSuppliers } from "~/modules/parts";
+import { PartSuppliers, getItemSuppliers } from "~/modules/parts";
import { requirePermissions } from "~/services/auth/auth.server";
import { flash } from "~/services/session.server";
import { path } from "~/utils/path";
@@ -12,16 +12,16 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
view: "parts",
});
- const { partId } = params;
- if (!partId) throw new Error("Could not find partId");
+ const { itemId } = params;
+ if (!itemId) throw new Error("Could not find itemId");
const [partSuppliers] = await Promise.all([
- getPartSuppliers(client, partId, companyId),
+ getItemSuppliers(client, itemId, companyId),
]);
if (partSuppliers.error) {
throw redirect(
- path.to.part(partId),
+ path.to.part(itemId),
await flash(
request,
error(partSuppliers.error, "Failed to load part suppliers")
diff --git a/apps/carbon/app/stores/index.ts b/apps/carbon/app/stores/index.ts
index 44e13ab31d..99aeb06bee 100644
--- a/apps/carbon/app/stores/index.ts
+++ b/apps/carbon/app/stores/index.ts
@@ -1,4 +1,4 @@
export * from "./customers";
-export * from "./parts";
+export * from "./items";
export * from "./people";
export * from "./suppliers";
diff --git a/apps/carbon/app/stores/items.ts b/apps/carbon/app/stores/items.ts
new file mode 100644
index 0000000000..65f9f56b32
--- /dev/null
+++ b/apps/carbon/app/stores/items.ts
@@ -0,0 +1,29 @@
+import type { Database } from "@carbon/database";
+import { useStore as useValue } from "@nanostores/react";
+import { atom, computed } from "nanostores";
+import { useNanoStore } from "~/hooks";
+import type { ListItem } from "~/types";
+
+export type Item = ListItem & {
+ readableId: string;
+ type: Database["public"]["Enums"]["itemType"];
+};
+
+const $itemsStore = atom<Item[]>([]);
+
+const $partsStore = computed($itemsStore, (item) =>
+ item.filter((i) => i.type === "Part")
+);
+
+const $serivceStore = computed($itemsStore, (item) =>
+ item.filter((i) => i.type === "Service")
+);
+
+const $materialsStore = computed($itemsStore, (item) =>
+ item.filter((i) => i.type === "Material")
+);
+
+export const useItems = () => useNanoStore<Item[]>($itemsStore, "items");
+export const useParts = () => useValue($partsStore);
+export const useServices = () => useValue($serivceStore);
+export const useMaterials = () => useValue($materialsStore);
diff --git a/apps/carbon/app/stores/parts.ts b/apps/carbon/app/stores/parts.ts
deleted file mode 100644
index 60892113a0..0000000000
--- a/apps/carbon/app/stores/parts.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-import { useStore as useValue } from "@nanostores/react";
-import { atom, computed } from "nanostores";
-import { useNanoStore } from "~/hooks";
-import type { ListItem } from "~/types";
-
-export type Part = ListItem & {
- replenishmentSystem: "Buy" | "Make" | "Buy and Make";
-};
-
-const $partsStore = atom<Part[]>([]);
-
-const $purchasedPartsStore = computed($partsStore, (part) =>
- part.filter((i) => i.replenishmentSystem === "Buy")
-);
-
-const $manufacturedPartsStore = computed($partsStore, (part) =>
- part.filter((i) => i.replenishmentSystem === "Make")
-);
-
-export const useParts = () => useNanoStore<Part[]>($partsStore, "parts");
-export const usePurchasedParts = () => useValue($purchasedPartsStore);
-export const useManufacturedParts = () => useValue($manufacturedPartsStore);
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index 68a705ec68..6c6bb70355 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -2114,13 +2114,13 @@ export type Database = {
createdAt: string
documentId: string | null
documentType:
- | Database["public"]["Enums"]["partLedgerDocumentType"]
+ | Database["public"]["Enums"]["itemLedgerDocumentType"]
| null
entryNumber: number
externalDocumentId: string | null
id: string
- partId: string | null
- partLedgerType: Database["public"]["Enums"]["partLedgerType"]
+ itemId: string | null
+ itemLedgerType: Database["public"]["Enums"]["itemLedgerType"]
postingDate: string
quantity: number
}
@@ -2133,13 +2133,13 @@ export type Database = {
createdAt?: string
documentId?: string | null
documentType?:
- | Database["public"]["Enums"]["partLedgerDocumentType"]
+ | Database["public"]["Enums"]["itemLedgerDocumentType"]
| null
entryNumber?: number
externalDocumentId?: string | null
id?: string
- partId?: string | null
- partLedgerType: Database["public"]["Enums"]["partLedgerType"]
+ itemId?: string | null
+ itemLedgerType: Database["public"]["Enums"]["itemLedgerType"]
postingDate?: string
quantity?: number
}
@@ -2152,13 +2152,13 @@ export type Database = {
createdAt?: string
documentId?: string | null
documentType?:
- | Database["public"]["Enums"]["partLedgerDocumentType"]
+ | Database["public"]["Enums"]["itemLedgerDocumentType"]
| null
entryNumber?: number
externalDocumentId?: string | null
id?: string
- partId?: string | null
- partLedgerType?: Database["public"]["Enums"]["partLedgerType"]
+ itemId?: string | null
+ itemLedgerType?: Database["public"]["Enums"]["itemLedgerType"]
postingDate?: string
quantity?: number
}
@@ -4460,15 +4460,15 @@ export type Database = {
foreignKeyName: "employeeJob_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "location"
- referencedColumns: ["id"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["locationId"]
},
{
foreignKeyName: "employeeJob_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["locationId"]
+ referencedRelation: "location"
+ referencedColumns: ["id"]
},
{
foreignKeyName: "employeeJob_locationId_fkey"
@@ -4872,15 +4872,15 @@ export type Database = {
foreignKeyName: "equipment_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "location"
- referencedColumns: ["id"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["locationId"]
},
{
foreignKeyName: "equipment_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["locationId"]
+ referencedRelation: "location"
+ referencedColumns: ["id"]
},
{
foreignKeyName: "equipment_locationId_fkey"
@@ -5566,72 +5566,89 @@ export type Database = {
},
]
}
- itemGroup: {
+ itemCost: {
Row: {
- active: boolean
companyId: string
+ costingMethod: Database["public"]["Enums"]["itemCostingMethod"]
+ costIsAdjusted: boolean
createdAt: string
createdBy: string
customFields: Json | null
- description: string | null
- id: string
- name: string
+ itemId: string
+ standardCost: number
+ unitCost: number
updatedAt: string | null
updatedBy: string | null
}
Insert: {
- active?: boolean
companyId: string
+ costingMethod: Database["public"]["Enums"]["itemCostingMethod"]
+ costIsAdjusted?: boolean
createdAt?: string
createdBy: string
customFields?: Json | null
- description?: string | null
- id?: string
- name: string
+ itemId: string
+ standardCost?: number
+ unitCost?: number
updatedAt?: string | null
updatedBy?: string | null
}
Update: {
- active?: boolean
companyId?: string
+ costingMethod?: Database["public"]["Enums"]["itemCostingMethod"]
+ costIsAdjusted?: boolean
createdAt?: string
createdBy?: string
customFields?: Json | null
- description?: string | null
- id?: string
- name?: string
+ itemId?: string
+ standardCost?: number
+ unitCost?: number
updatedAt?: string | null
updatedBy?: string | null
}
Relationships: [
{
- foreignKeyName: "itemGroup_companyId_fkey"
+ foreignKeyName: "itemCost_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "companies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "itemGroup_companyId_fkey"
+ foreignKeyName: "itemCost_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "company"
referencedColumns: ["id"]
},
{
- foreignKeyName: "itemGroup_companyId_fkey"
+ foreignKeyName: "itemCost_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "customFieldTables"
referencedColumns: ["companyId"]
},
{
- foreignKeyName: "itemGroup_companyId_fkey"
+ foreignKeyName: "itemCost_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "integrations"
referencedColumns: ["companyId"]
},
+ {
+ foreignKeyName: "itemCost_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "item"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemCost_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
+ },
{
foreignKeyName: "itemGroup_createdBy_fkey"
columns: ["createdBy"]
@@ -5704,1021 +5721,884 @@ export type Database = {
},
]
}
- journal: {
+ itemGroup: {
Row: {
- accountingPeriodId: string | null
+ active: boolean
companyId: string
createdAt: string
+ createdBy: string
customFields: Json | null
description: string | null
- id: number
- postingDate: string
+ id: string
+ name: string
+ updatedAt: string | null
+ updatedBy: string | null
}
Insert: {
- accountingPeriodId?: string | null
+ active?: boolean
companyId: string
createdAt?: string
+ createdBy: string
customFields?: Json | null
description?: string | null
- id?: number
- postingDate?: string
+ id?: string
+ name: string
+ updatedAt?: string | null
+ updatedBy?: string | null
}
Update: {
- accountingPeriodId?: string | null
+ active?: boolean
companyId?: string
createdAt?: string
+ createdBy?: string
customFields?: Json | null
description?: string | null
- id?: number
- postingDate?: string
+ id?: string
+ name?: string
+ updatedAt?: string | null
+ updatedBy?: string | null
}
Relationships: [
{
- foreignKeyName: "journal_accountPeriodId_fkey"
- columns: ["accountingPeriodId"]
- isOneToOne: false
- referencedRelation: "accountingPeriod"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "journal_companyId_fkey"
+ foreignKeyName: "itemGroup_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "companies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "journal_companyId_fkey"
+ foreignKeyName: "itemGroup_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "company"
referencedColumns: ["id"]
},
{
- foreignKeyName: "journal_companyId_fkey"
+ foreignKeyName: "itemGroup_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "customFieldTables"
referencedColumns: ["companyId"]
},
{
- foreignKeyName: "journal_companyId_fkey"
+ foreignKeyName: "itemGroup_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "integrations"
referencedColumns: ["companyId"]
},
+ {
+ foreignKeyName: "itemGroup_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemGroup_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemGroup_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemGroup_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemGroup_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "itemGroup_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemGroup_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemGroup_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemGroup_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemGroup_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
]
}
- journalLine: {
+ itemInventory: {
Row: {
- accountNumber: string
- accrual: boolean
- amount: number
companyId: string
createdAt: string
+ createdBy: string
customFields: Json | null
- description: string | null
- documentId: string | null
- documentLineReference: string | null
- documentType:
- | Database["public"]["Enums"]["journalLineDocumentType"]
- | null
- externalDocumentId: string | null
- id: string
- journalId: number
- journalLineReference: string
- quantity: number
+ defaultShelfId: string | null
+ itemId: string
+ locationId: string
+ updatedAt: string | null
+ updatedBy: string | null
}
Insert: {
- accountNumber: string
- accrual?: boolean
- amount: number
companyId: string
createdAt?: string
+ createdBy: string
customFields?: Json | null
- description?: string | null
- documentId?: string | null
- documentLineReference?: string | null
- documentType?:
- | Database["public"]["Enums"]["journalLineDocumentType"]
- | null
- externalDocumentId?: string | null
- id?: string
- journalId: number
- journalLineReference: string
- quantity?: number
+ defaultShelfId?: string | null
+ itemId: string
+ locationId: string
+ updatedAt?: string | null
+ updatedBy?: string | null
}
Update: {
- accountNumber?: string
- accrual?: boolean
- amount?: number
companyId?: string
createdAt?: string
+ createdBy?: string
customFields?: Json | null
- description?: string | null
- documentId?: string | null
- documentLineReference?: string | null
- documentType?:
- | Database["public"]["Enums"]["journalLineDocumentType"]
- | null
- externalDocumentId?: string | null
- id?: string
- journalId?: number
- journalLineReference?: string
- quantity?: number
+ defaultShelfId?: string | null
+ itemId?: string
+ locationId?: string
+ updatedAt?: string | null
+ updatedBy?: string | null
}
Relationships: [
{
- foreignKeyName: "journalLine_accountNumber_fkey"
- columns: ["accountNumber", "companyId"]
- isOneToOne: false
- referencedRelation: "account"
- referencedColumns: ["number", "companyId"]
- },
- {
- foreignKeyName: "journalLine_accountNumber_fkey"
- columns: ["accountNumber", "companyId"]
- isOneToOne: false
- referencedRelation: "accounts"
- referencedColumns: ["number", "companyId"]
- },
- {
- foreignKeyName: "journalLine_companyId_fkey"
+ foreignKeyName: "itemInventory_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "companies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "journalLine_companyId_fkey"
+ foreignKeyName: "itemInventory_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "company"
referencedColumns: ["id"]
},
{
- foreignKeyName: "journalLine_companyId_fkey"
+ foreignKeyName: "itemInventory_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "customFieldTables"
referencedColumns: ["companyId"]
},
{
- foreignKeyName: "journalLine_companyId_fkey"
+ foreignKeyName: "itemInventory_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "integrations"
referencedColumns: ["companyId"]
},
- ]
- }
- location: {
- Row: {
- addressLine1: string
- addressLine2: string | null
- city: string
- companyId: string
- countryCode: string | null
- createdAt: string
- createdBy: string
- customFields: Json | null
- id: string
- latitude: number | null
- longitude: number | null
- name: string
- postalCode: string
- state: string
- timezone: string
- updatedAt: string | null
- updatedBy: string | null
- }
- Insert: {
- addressLine1: string
- addressLine2?: string | null
- city: string
- companyId: string
- countryCode?: string | null
- createdAt?: string
- createdBy: string
- customFields?: Json | null
- id?: string
- latitude?: number | null
- longitude?: number | null
- name: string
- postalCode: string
- state: string
- timezone: string
- updatedAt?: string | null
- updatedBy?: string | null
- }
- Update: {
- addressLine1?: string
- addressLine2?: string | null
- city?: string
- companyId?: string
- countryCode?: string | null
- createdAt?: string
- createdBy?: string
- customFields?: Json | null
- id?: string
- latitude?: number | null
- longitude?: number | null
- name?: string
- postalCode?: string
- state?: string
- timezone?: string
- updatedAt?: string | null
- updatedBy?: string | null
- }
- Relationships: [
- {
- foreignKeyName: "location_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "companies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "location_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "company"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "location_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "customFieldTables"
- referencedColumns: ["companyId"]
- },
- {
- foreignKeyName: "location_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "integrations"
- referencedColumns: ["companyId"]
- },
- ]
- }
- membership: {
- Row: {
- groupId: string
- id: number
- memberGroupId: string | null
- memberUserId: string | null
- }
- Insert: {
- groupId: string
- id?: number
- memberGroupId?: string | null
- memberUserId?: string | null
- }
- Update: {
- groupId?: string
- id?: number
- memberGroupId?: string | null
- memberUserId?: string | null
- }
- Relationships: [
- {
- foreignKeyName: "membership_groupId_fkey"
- columns: ["groupId"]
- isOneToOne: false
- referencedRelation: "group"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "membership_memberGroupId_fkey"
- columns: ["memberGroupId"]
- isOneToOne: false
- referencedRelation: "group"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "membership_memberUserId_fkey"
- columns: ["memberUserId"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "membership_memberUserId_fkey"
- columns: ["memberUserId"]
- isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "membership_memberUserId_fkey"
- columns: ["memberUserId"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "membership_memberUserId_fkey"
- columns: ["memberUserId"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "membership_memberUserId_fkey"
- columns: ["memberUserId"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
- ]
- }
- note: {
- Row: {
- active: boolean
- companyId: string
- createdAt: string
- createdBy: string
- documentId: string
- id: string
- note: string
- noteRichText: Json
- updatedAt: string | null
- }
- Insert: {
- active?: boolean
- companyId: string
- createdAt?: string
- createdBy: string
- documentId: string
- id?: string
- note: string
- noteRichText?: Json
- updatedAt?: string | null
- }
- Update: {
- active?: boolean
- companyId?: string
- createdAt?: string
- createdBy?: string
- documentId?: string
- id?: string
- note?: string
- noteRichText?: Json
- updatedAt?: string | null
- }
- Relationships: [
- {
- foreignKeyName: "notes_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "companies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "notes_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "company"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "notes_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "customFieldTables"
- referencedColumns: ["companyId"]
- },
{
- foreignKeyName: "notes_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "integrations"
- referencedColumns: ["companyId"]
- },
- {
- foreignKeyName: "notes_createdBy_fkey"
+ foreignKeyName: "itemInventory_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "notes_createdBy_fkey"
+ foreignKeyName: "itemInventory_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "notes_createdBy_fkey"
+ foreignKeyName: "itemInventory_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "notes_createdBy_fkey"
+ foreignKeyName: "itemInventory_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "notes_createdBy_fkey"
+ foreignKeyName: "itemInventory_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
- ]
- }
- part: {
- Row: {
- approved: boolean
- approvedBy: string | null
- assignee: string | null
- companyId: string
- createdAt: string
- createdBy: string
- customFields: Json | null
- fromDate: string | null
- id: string
- itemId: string
- partType: Database["public"]["Enums"]["partType"]
- replenishmentSystem: Database["public"]["Enums"]["partReplenishmentSystem"]
- toDate: string | null
- unitOfMeasureCode: string
- updatedAt: string | null
- updatedBy: string | null
- }
- Insert: {
- approved?: boolean
- approvedBy?: string | null
- assignee?: string | null
- companyId: string
- createdAt?: string
- createdBy: string
- customFields?: Json | null
- fromDate?: string | null
- id: string
- itemId: string
- partType: Database["public"]["Enums"]["partType"]
- replenishmentSystem: Database["public"]["Enums"]["partReplenishmentSystem"]
- toDate?: string | null
- unitOfMeasureCode: string
- updatedAt?: string | null
- updatedBy?: string | null
- }
- Update: {
- approved?: boolean
- approvedBy?: string | null
- assignee?: string | null
- companyId?: string
- createdAt?: string
- createdBy?: string
- customFields?: Json | null
- fromDate?: string | null
- id?: string
- itemId?: string
- partType?: Database["public"]["Enums"]["partType"]
- replenishmentSystem?: Database["public"]["Enums"]["partReplenishmentSystem"]
- toDate?: string | null
- unitOfMeasureCode?: string
- updatedAt?: string | null
- updatedBy?: string | null
- }
- Relationships: [
{
- foreignKeyName: "part_approvedBy_fkey"
- columns: ["approvedBy"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "part_approvedBy_fkey"
- columns: ["approvedBy"]
- isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "part_approvedBy_fkey"
- columns: ["approvedBy"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "part_approvedBy_fkey"
- columns: ["approvedBy"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "part_approvedBy_fkey"
- columns: ["approvedBy"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
- {
- foreignKeyName: "part_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "part_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "part_assignee_fkey"
- columns: ["assignee"]
+ foreignKeyName: "itemInventory_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "employeeSummary"
+ referencedRelation: "item"
referencedColumns: ["id"]
},
{
- foreignKeyName: "part_assignee_fkey"
- columns: ["assignee"]
+ foreignKeyName: "itemInventory_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
},
{
- foreignKeyName: "part_assignee_fkey"
- columns: ["assignee"]
+ foreignKeyName: "itemInventory_locationId_fkey"
+ columns: ["locationId"]
isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["locationId"]
},
{
- foreignKeyName: "part_companyId_fkey"
- columns: ["companyId"]
+ foreignKeyName: "itemInventory_locationId_fkey"
+ columns: ["locationId"]
isOneToOne: false
- referencedRelation: "companies"
+ referencedRelation: "location"
referencedColumns: ["id"]
},
{
- foreignKeyName: "part_companyId_fkey"
- columns: ["companyId"]
+ foreignKeyName: "itemInventory_locationId_fkey"
+ columns: ["locationId"]
isOneToOne: false
- referencedRelation: "company"
- referencedColumns: ["id"]
+ referencedRelation: "purchaseOrders"
+ referencedColumns: ["locationId"]
},
{
- foreignKeyName: "part_companyId_fkey"
- columns: ["companyId"]
+ foreignKeyName: "itemInventory_locationId_fkey"
+ columns: ["locationId"]
isOneToOne: false
- referencedRelation: "customFieldTables"
- referencedColumns: ["companyId"]
+ referencedRelation: "salesOrders"
+ referencedColumns: ["locationId"]
},
{
- foreignKeyName: "part_companyId_fkey"
- columns: ["companyId"]
+ foreignKeyName: "itemInventory_shelfId_fkey"
+ columns: ["defaultShelfId", "locationId"]
isOneToOne: false
- referencedRelation: "integrations"
- referencedColumns: ["companyId"]
+ referencedRelation: "shelf"
+ referencedColumns: ["id", "locationId"]
},
{
- foreignKeyName: "part_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "itemInventory_updatedBy_fkey"
+ columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "part_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "itemInventory_updatedBy_fkey"
+ columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "part_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "itemInventory_updatedBy_fkey"
+ columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "part_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "itemInventory_updatedBy_fkey"
+ columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "part_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "itemInventory_updatedBy_fkey"
+ columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
+ ]
+ }
+ itemLedger: {
+ Row: {
+ companyId: string
+ createdAt: string
+ documentId: string | null
+ documentType:
+ | Database["public"]["Enums"]["itemLedgerDocumentType"]
+ | null
+ entryNumber: number
+ entryType: Database["public"]["Enums"]["itemLedgerType"]
+ externalDocumentId: string | null
+ id: string
+ itemId: string
+ locationId: string | null
+ postingDate: string
+ quantity: number
+ shelfId: string | null
+ }
+ Insert: {
+ companyId: string
+ createdAt?: string
+ documentId?: string | null
+ documentType?:
+ | Database["public"]["Enums"]["itemLedgerDocumentType"]
+ | null
+ entryNumber?: number
+ entryType: Database["public"]["Enums"]["itemLedgerType"]
+ externalDocumentId?: string | null
+ id?: string
+ itemId: string
+ locationId?: string | null
+ postingDate?: string
+ quantity: number
+ shelfId?: string | null
+ }
+ Update: {
+ companyId?: string
+ createdAt?: string
+ documentId?: string | null
+ documentType?:
+ | Database["public"]["Enums"]["itemLedgerDocumentType"]
+ | null
+ entryNumber?: number
+ entryType?: Database["public"]["Enums"]["itemLedgerType"]
+ externalDocumentId?: string | null
+ id?: string
+ itemId?: string
+ locationId?: string | null
+ postingDate?: string
+ quantity?: number
+ shelfId?: string | null
+ }
+ Relationships: [
{
- foreignKeyName: "part_id_fkey"
+ foreignKeyName: "itemLedger_itemId_fkey"
columns: ["itemId"]
isOneToOne: false
referencedRelation: "item"
referencedColumns: ["id"]
},
{
- foreignKeyName: "part_unitOfMeasureCode_fkey"
- columns: ["unitOfMeasureCode", "companyId"]
+ foreignKeyName: "itemLedger_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "unitOfMeasure"
- referencedColumns: ["code", "companyId"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
},
{
- foreignKeyName: "part_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "itemLedger_locationId_fkey"
+ columns: ["locationId"]
isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["locationId"]
},
{
- foreignKeyName: "part_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "itemLedger_locationId_fkey"
+ columns: ["locationId"]
isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
+ referencedRelation: "location"
referencedColumns: ["id"]
},
{
- foreignKeyName: "part_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "itemLedger_locationId_fkey"
+ columns: ["locationId"]
isOneToOne: false
- referencedRelation: "employeeSummary"
+ referencedRelation: "purchaseOrders"
+ referencedColumns: ["locationId"]
+ },
+ {
+ foreignKeyName: "itemLedger_locationId_fkey"
+ columns: ["locationId"]
+ isOneToOne: false
+ referencedRelation: "salesOrders"
+ referencedColumns: ["locationId"]
+ },
+ {
+ foreignKeyName: "itemLedger_shelfId_fkey"
+ columns: ["shelfId", "locationId"]
+ isOneToOne: false
+ referencedRelation: "shelf"
+ referencedColumns: ["id", "locationId"]
+ },
+ {
+ foreignKeyName: "partLeger_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "part_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "partLeger_companyId_fkey"
+ columns: ["companyId"]
isOneToOne: false
- referencedRelation: "user"
+ referencedRelation: "company"
referencedColumns: ["id"]
},
{
- foreignKeyName: "part_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "partLeger_companyId_fkey"
+ columns: ["companyId"]
isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "partLeger_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
},
]
}
- partCost: {
+ itemPlanning: {
Row: {
companyId: string
- costingMethod: Database["public"]["Enums"]["partCostingMethod"]
- costIsAdjusted: boolean
createdAt: string
createdBy: string
+ critical: boolean
customFields: Json | null
- partId: string
- standardCost: number
- unitCost: number
+ demandAccumulationIncludesInventory: boolean
+ demandAccumulationPeriod: number
+ demandReschedulingPeriod: number
+ itemId: string
+ locationId: string
+ maximumOrderQuantity: number
+ minimumOrderQuantity: number
+ orderMultiple: number
+ reorderingPolicy: Database["public"]["Enums"]["itemReorderingPolicy"]
+ reorderMaximumInventory: number
+ reorderPoint: number
+ reorderQuantity: number
+ safetyStockLeadTime: number
+ safetyStockQuantity: number
updatedAt: string | null
updatedBy: string | null
}
Insert: {
companyId: string
- costingMethod: Database["public"]["Enums"]["partCostingMethod"]
- costIsAdjusted?: boolean
createdAt?: string
createdBy: string
+ critical?: boolean
customFields?: Json | null
- partId: string
- standardCost?: number
- unitCost?: number
+ demandAccumulationIncludesInventory?: boolean
+ demandAccumulationPeriod?: number
+ demandReschedulingPeriod?: number
+ itemId: string
+ locationId: string
+ maximumOrderQuantity?: number
+ minimumOrderQuantity?: number
+ orderMultiple?: number
+ reorderingPolicy?: Database["public"]["Enums"]["itemReorderingPolicy"]
+ reorderMaximumInventory?: number
+ reorderPoint?: number
+ reorderQuantity?: number
+ safetyStockLeadTime?: number
+ safetyStockQuantity?: number
updatedAt?: string | null
updatedBy?: string | null
}
Update: {
companyId?: string
- costingMethod?: Database["public"]["Enums"]["partCostingMethod"]
- costIsAdjusted?: boolean
createdAt?: string
createdBy?: string
+ critical?: boolean
customFields?: Json | null
- partId?: string
- standardCost?: number
- unitCost?: number
+ demandAccumulationIncludesInventory?: boolean
+ demandAccumulationPeriod?: number
+ demandReschedulingPeriod?: number
+ itemId?: string
+ locationId?: string
+ maximumOrderQuantity?: number
+ minimumOrderQuantity?: number
+ orderMultiple?: number
+ reorderingPolicy?: Database["public"]["Enums"]["itemReorderingPolicy"]
+ reorderMaximumInventory?: number
+ reorderPoint?: number
+ reorderQuantity?: number
+ safetyStockLeadTime?: number
+ safetyStockQuantity?: number
updatedAt?: string | null
updatedBy?: string | null
}
Relationships: [
{
- foreignKeyName: "itemGroup_createdBy_fkey"
+ foreignKeyName: "itemPlanning_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemPlanning_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemPlanning_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "itemPlanning_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "itemPlanning_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "itemGroup_createdBy_fkey"
+ foreignKeyName: "itemPlanning_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "itemGroup_createdBy_fkey"
+ foreignKeyName: "itemPlanning_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "itemGroup_createdBy_fkey"
+ foreignKeyName: "itemPlanning_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "itemGroup_createdBy_fkey"
+ foreignKeyName: "itemPlanning_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
{
- foreignKeyName: "itemGroup_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "itemPlanning_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "employees"
+ referencedRelation: "item"
referencedColumns: ["id"]
},
{
- foreignKeyName: "itemGroup_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "itemPlanning_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
},
{
- foreignKeyName: "itemGroup_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "itemPlanning_locationId_fkey"
+ columns: ["locationId"]
isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["locationId"]
},
{
- foreignKeyName: "itemGroup_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "itemPlanning_locationId_fkey"
+ columns: ["locationId"]
isOneToOne: false
- referencedRelation: "user"
+ referencedRelation: "location"
referencedColumns: ["id"]
},
{
- foreignKeyName: "itemGroup_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "itemPlanning_locationId_fkey"
+ columns: ["locationId"]
isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
+ referencedRelation: "purchaseOrders"
+ referencedColumns: ["locationId"]
},
{
- foreignKeyName: "partCost_companyId_fkey"
- columns: ["companyId"]
+ foreignKeyName: "itemPlanning_locationId_fkey"
+ columns: ["locationId"]
isOneToOne: false
- referencedRelation: "companies"
- referencedColumns: ["id"]
+ referencedRelation: "salesOrders"
+ referencedColumns: ["locationId"]
},
{
- foreignKeyName: "partCost_companyId_fkey"
- columns: ["companyId"]
+ foreignKeyName: "itemPlanning_updatedBy_fkey"
+ columns: ["updatedBy"]
isOneToOne: false
- referencedRelation: "company"
+ referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partCost_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "customFieldTables"
- referencedColumns: ["companyId"]
- },
- {
- foreignKeyName: "partCost_companyId_fkey"
- columns: ["companyId"]
+ foreignKeyName: "itemPlanning_updatedBy_fkey"
+ columns: ["updatedBy"]
isOneToOne: false
- referencedRelation: "integrations"
- referencedColumns: ["companyId"]
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "partCost_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "itemPlanning_updatedBy_fkey"
+ columns: ["updatedBy"]
isOneToOne: false
- referencedRelation: "part"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "partCost_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "itemPlanning_updatedBy_fkey"
+ columns: ["updatedBy"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["partId", "companyId"]
+ referencedRelation: "user"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "partCost_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "itemPlanning_updatedBy_fkey"
+ columns: ["updatedBy"]
isOneToOne: false
- referencedRelation: "parts"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
},
]
}
- partInventory: {
+ itemReplenishment: {
Row: {
companyId: string
+ conversionFactor: number
createdAt: string
createdBy: string
customFields: Json | null
- defaultShelfId: string | null
- locationId: string
- partId: string
+ itemId: string
+ lotSize: number | null
+ manufacturingBlocked: boolean
+ manufacturingLeadTime: number
+ manufacturingPolicy: Database["public"]["Enums"]["partManufacturingPolicy"]
+ preferredSupplierId: string | null
+ purchasingBlocked: boolean
+ purchasingLeadTime: number
+ purchasingUnitOfMeasureCode: string | null
+ requiresConfiguration: boolean
+ scrapPercentage: number
updatedAt: string | null
updatedBy: string | null
}
Insert: {
companyId: string
+ conversionFactor?: number
createdAt?: string
createdBy: string
customFields?: Json | null
- defaultShelfId?: string | null
- locationId: string
- partId: string
+ itemId: string
+ lotSize?: number | null
+ manufacturingBlocked?: boolean
+ manufacturingLeadTime?: number
+ manufacturingPolicy?: Database["public"]["Enums"]["partManufacturingPolicy"]
+ preferredSupplierId?: string | null
+ purchasingBlocked?: boolean
+ purchasingLeadTime?: number
+ purchasingUnitOfMeasureCode?: string | null
+ requiresConfiguration?: boolean
+ scrapPercentage?: number
updatedAt?: string | null
updatedBy?: string | null
}
Update: {
companyId?: string
+ conversionFactor?: number
createdAt?: string
createdBy?: string
customFields?: Json | null
- defaultShelfId?: string | null
- locationId?: string
- partId?: string
+ itemId?: string
+ lotSize?: number | null
+ manufacturingBlocked?: boolean
+ manufacturingLeadTime?: number
+ manufacturingPolicy?: Database["public"]["Enums"]["partManufacturingPolicy"]
+ preferredSupplierId?: string | null
+ purchasingBlocked?: boolean
+ purchasingLeadTime?: number
+ purchasingUnitOfMeasureCode?: string | null
+ requiresConfiguration?: boolean
+ scrapPercentage?: number
updatedAt?: string | null
updatedBy?: string | null
}
Relationships: [
{
- foreignKeyName: "partInventory_companyId_fkey"
+ foreignKeyName: "itemReplenishment_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "companies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partInventory_companyId_fkey"
+ foreignKeyName: "itemReplenishment_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "company"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partInventory_companyId_fkey"
+ foreignKeyName: "itemReplenishment_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "customFieldTables"
referencedColumns: ["companyId"]
},
{
- foreignKeyName: "partInventory_companyId_fkey"
+ foreignKeyName: "itemReplenishment_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "integrations"
referencedColumns: ["companyId"]
},
{
- foreignKeyName: "partInventory_createdBy_fkey"
+ foreignKeyName: "itemReplenishment_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partInventory_createdBy_fkey"
+ foreignKeyName: "itemReplenishment_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partInventory_createdBy_fkey"
+ foreignKeyName: "itemReplenishment_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partInventory_createdBy_fkey"
+ foreignKeyName: "itemReplenishment_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partInventory_createdBy_fkey"
+ foreignKeyName: "itemReplenishment_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
{
- foreignKeyName: "partInventory_locationId_fkey"
- columns: ["locationId"]
+ foreignKeyName: "itemReplenishment_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "location"
+ referencedRelation: "item"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partInventory_locationId_fkey"
- columns: ["locationId"]
+ foreignKeyName: "itemReplenishment_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["locationId"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
},
{
- foreignKeyName: "partInventory_locationId_fkey"
- columns: ["locationId"]
+ foreignKeyName: "itemReplenishment_preferredSupplierId_fkey"
+ columns: ["preferredSupplierId"]
isOneToOne: false
- referencedRelation: "purchaseOrders"
- referencedColumns: ["locationId"]
+ referencedRelation: "contractors"
+ referencedColumns: ["supplierId"]
},
{
- foreignKeyName: "partInventory_locationId_fkey"
- columns: ["locationId"]
+ foreignKeyName: "itemReplenishment_preferredSupplierId_fkey"
+ columns: ["preferredSupplierId"]
isOneToOne: false
- referencedRelation: "salesOrders"
- referencedColumns: ["locationId"]
+ referencedRelation: "partners"
+ referencedColumns: ["supplierId"]
},
{
- foreignKeyName: "partInventory_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "itemReplenishment_preferredSupplierId_fkey"
+ columns: ["preferredSupplierId"]
isOneToOne: false
- referencedRelation: "part"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "purchaseOrderSuppliers"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "partInventory_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "itemReplenishment_preferredSupplierId_fkey"
+ columns: ["preferredSupplierId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["partId", "companyId"]
+ referencedRelation: "supplier"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "partInventory_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "itemReplenishment_preferredSupplierId_fkey"
+ columns: ["preferredSupplierId"]
isOneToOne: false
- referencedRelation: "parts"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "suppliers"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "partInventory_shelfId_fkey"
- columns: ["defaultShelfId", "locationId"]
+ foreignKeyName: "itemReplenishment_purchaseUnitOfMeasureCode_fkey"
+ columns: ["purchasingUnitOfMeasureCode", "companyId"]
isOneToOne: false
- referencedRelation: "shelf"
- referencedColumns: ["id", "locationId"]
+ referencedRelation: "unitOfMeasure"
+ referencedColumns: ["code", "companyId"]
},
{
- foreignKeyName: "partInventory_updatedBy_fkey"
+ foreignKeyName: "itemReplenishment_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partInventory_updatedBy_fkey"
+ foreignKeyName: "itemReplenishment_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partInventory_updatedBy_fkey"
+ foreignKeyName: "itemReplenishment_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partInventory_updatedBy_fkey"
+ foreignKeyName: "itemReplenishment_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partInventory_updatedBy_fkey"
+ foreignKeyName: "itemReplenishment_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "userDefaults"
@@ -6726,290 +6606,376 @@ export type Database = {
},
]
}
- partLedger: {
+ itemSupplier: {
Row: {
+ active: boolean
companyId: string
+ conversionFactor: number
createdAt: string
- documentId: string | null
- documentType:
- | Database["public"]["Enums"]["partLedgerDocumentType"]
- | null
- entryNumber: number
- entryType: Database["public"]["Enums"]["partLedgerType"]
- externalDocumentId: string | null
+ createdBy: string
+ customFields: Json | null
id: string
- locationId: string | null
- partId: string
- postingDate: string
- quantity: number
- shelfId: string | null
+ itemId: string
+ minimumOrderQuantity: number | null
+ supplierId: string
+ supplierPartId: string | null
+ supplierUnitOfMeasureCode: string | null
+ unitPrice: number | null
+ updatedAt: string | null
+ updatedBy: string | null
}
Insert: {
+ active?: boolean
companyId: string
+ conversionFactor?: number
createdAt?: string
- documentId?: string | null
- documentType?:
- | Database["public"]["Enums"]["partLedgerDocumentType"]
- | null
- entryNumber?: number
- entryType: Database["public"]["Enums"]["partLedgerType"]
- externalDocumentId?: string | null
+ createdBy: string
+ customFields?: Json | null
id?: string
- locationId?: string | null
- partId: string
- postingDate?: string
- quantity: number
- shelfId?: string | null
+ itemId: string
+ minimumOrderQuantity?: number | null
+ supplierId: string
+ supplierPartId?: string | null
+ supplierUnitOfMeasureCode?: string | null
+ unitPrice?: number | null
+ updatedAt?: string | null
+ updatedBy?: string | null
}
Update: {
+ active?: boolean
companyId?: string
+ conversionFactor?: number
createdAt?: string
- documentId?: string | null
- documentType?:
- | Database["public"]["Enums"]["partLedgerDocumentType"]
- | null
- entryNumber?: number
- entryType?: Database["public"]["Enums"]["partLedgerType"]
- externalDocumentId?: string | null
+ createdBy?: string
+ customFields?: Json | null
id?: string
- locationId?: string | null
- partId?: string
- postingDate?: string
- quantity?: number
- shelfId?: string | null
+ itemId?: string
+ minimumOrderQuantity?: number | null
+ supplierId?: string
+ supplierPartId?: string | null
+ supplierUnitOfMeasureCode?: string | null
+ unitPrice?: number | null
+ updatedAt?: string | null
+ updatedBy?: string | null
}
Relationships: [
{
- foreignKeyName: "partLedger_locationId_fkey"
- columns: ["locationId"]
+ foreignKeyName: "itemSupplier_companyId_fkey"
+ columns: ["companyId"]
isOneToOne: false
- referencedRelation: "location"
+ referencedRelation: "companies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partLedger_locationId_fkey"
- columns: ["locationId"]
+ foreignKeyName: "itemSupplier_companyId_fkey"
+ columns: ["companyId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["locationId"]
+ referencedRelation: "company"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "partLedger_locationId_fkey"
- columns: ["locationId"]
+ foreignKeyName: "itemSupplier_companyId_fkey"
+ columns: ["companyId"]
isOneToOne: false
- referencedRelation: "purchaseOrders"
- referencedColumns: ["locationId"]
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
},
{
- foreignKeyName: "partLedger_locationId_fkey"
- columns: ["locationId"]
+ foreignKeyName: "itemSupplier_companyId_fkey"
+ columns: ["companyId"]
isOneToOne: false
- referencedRelation: "salesOrders"
- referencedColumns: ["locationId"]
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
},
{
- foreignKeyName: "partLedger_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "itemSupplier_createdBy_fkey"
+ columns: ["createdBy"]
isOneToOne: false
- referencedRelation: "part"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "partLedger_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "itemSupplier_createdBy_fkey"
+ columns: ["createdBy"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["partId", "companyId"]
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "partLedger_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "itemSupplier_createdBy_fkey"
+ columns: ["createdBy"]
isOneToOne: false
- referencedRelation: "parts"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "partLedger_shelfId_fkey"
- columns: ["shelfId", "locationId"]
+ foreignKeyName: "itemSupplier_createdBy_fkey"
+ columns: ["createdBy"]
isOneToOne: false
- referencedRelation: "shelf"
- referencedColumns: ["id", "locationId"]
+ referencedRelation: "user"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "partLeger_companyId_fkey"
- columns: ["companyId"]
+ foreignKeyName: "itemSupplier_createdBy_fkey"
+ columns: ["createdBy"]
isOneToOne: false
- referencedRelation: "companies"
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "itemSupplier_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "item"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partLeger_companyId_fkey"
- columns: ["companyId"]
+ foreignKeyName: "itemSupplier_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "company"
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
+ },
+ {
+ foreignKeyName: "itemSupplier_supplierId_fkey"
+ columns: ["supplierId"]
+ isOneToOne: false
+ referencedRelation: "contractors"
+ referencedColumns: ["supplierId"]
+ },
+ {
+ foreignKeyName: "itemSupplier_supplierId_fkey"
+ columns: ["supplierId"]
+ isOneToOne: false
+ referencedRelation: "partners"
+ referencedColumns: ["supplierId"]
+ },
+ {
+ foreignKeyName: "itemSupplier_supplierId_fkey"
+ columns: ["supplierId"]
+ isOneToOne: false
+ referencedRelation: "purchaseOrderSuppliers"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partLeger_companyId_fkey"
- columns: ["companyId"]
+ foreignKeyName: "itemSupplier_supplierId_fkey"
+ columns: ["supplierId"]
isOneToOne: false
- referencedRelation: "customFieldTables"
- referencedColumns: ["companyId"]
+ referencedRelation: "supplier"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "partLeger_companyId_fkey"
- columns: ["companyId"]
+ foreignKeyName: "itemSupplier_supplierId_fkey"
+ columns: ["supplierId"]
+ isOneToOne: false
+ referencedRelation: "suppliers"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemSupplier_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemSupplier_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemSupplier_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemSupplier_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemSupplier_updatedBy_fkey"
+ columns: ["updatedBy"]
isOneToOne: false
- referencedRelation: "integrations"
- referencedColumns: ["companyId"]
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
},
]
}
- partner: {
+ itemUnitSalePrice: {
Row: {
- abilityId: string
- active: boolean
+ allowInvoiceDiscount: boolean
companyId: string
createdAt: string
createdBy: string
+ currencyCode: string
customFields: Json | null
- hoursPerWeek: number
- id: string
+ itemId: string
+ priceIncludesTax: boolean
+ salesBlocked: boolean
+ salesUnitOfMeasureCode: string | null
+ unitSalePrice: number
updatedAt: string | null
updatedBy: string | null
}
Insert: {
- abilityId: string
- active?: boolean
+ allowInvoiceDiscount?: boolean
companyId: string
createdAt?: string
createdBy: string
+ currencyCode: string
customFields?: Json | null
- hoursPerWeek?: number
- id: string
+ itemId: string
+ priceIncludesTax?: boolean
+ salesBlocked?: boolean
+ salesUnitOfMeasureCode?: string | null
+ unitSalePrice?: number
updatedAt?: string | null
updatedBy?: string | null
}
Update: {
- abilityId?: string
- active?: boolean
+ allowInvoiceDiscount?: boolean
companyId?: string
createdAt?: string
createdBy?: string
+ currencyCode?: string
customFields?: Json | null
- hoursPerWeek?: number
- id?: string
+ itemId?: string
+ priceIncludesTax?: boolean
+ salesBlocked?: boolean
+ salesUnitOfMeasureCode?: string | null
+ unitSalePrice?: number
updatedAt?: string | null
updatedBy?: string | null
}
Relationships: [
{
- foreignKeyName: "partner_abilityId_fkey"
- columns: ["abilityId"]
- isOneToOne: false
- referencedRelation: "ability"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "partner_companyId_fkey"
+ foreignKeyName: "itemUnitSalePrice_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "companies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partner_companyId_fkey"
+ foreignKeyName: "itemUnitSalePrice_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "company"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partner_companyId_fkey"
+ foreignKeyName: "itemUnitSalePrice_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "customFieldTables"
referencedColumns: ["companyId"]
},
{
- foreignKeyName: "partner_companyId_fkey"
+ foreignKeyName: "itemUnitSalePrice_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "integrations"
referencedColumns: ["companyId"]
},
{
- foreignKeyName: "partner_createdBy_fkey"
+ foreignKeyName: "itemUnitSalePrice_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partner_createdBy_fkey"
+ foreignKeyName: "itemUnitSalePrice_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partner_createdBy_fkey"
+ foreignKeyName: "itemUnitSalePrice_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partner_createdBy_fkey"
+ foreignKeyName: "itemUnitSalePrice_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partner_createdBy_fkey"
+ foreignKeyName: "itemUnitSalePrice_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
{
- foreignKeyName: "partner_id_fkey"
- columns: ["id"]
+ foreignKeyName: "itemUnitSalePrice_currencyCode_fkey"
+ columns: ["currencyCode", "companyId"]
isOneToOne: false
- referencedRelation: "supplierLocation"
+ referencedRelation: "currency"
+ referencedColumns: ["code", "companyId"]
+ },
+ {
+ foreignKeyName: "itemUnitSalePrice_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "item"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partner_updatedBy_fkey"
+ foreignKeyName: "itemUnitSalePrice_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
+ },
+ {
+ foreignKeyName: "itemUnitSalePrice_salesUnitOfMeasureId_fkey"
+ columns: ["salesUnitOfMeasureCode", "companyId"]
+ isOneToOne: false
+ referencedRelation: "unitOfMeasure"
+ referencedColumns: ["code", "companyId"]
+ },
+ {
+ foreignKeyName: "itemUnitSalePrice_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partner_updatedBy_fkey"
+ foreignKeyName: "itemUnitSalePrice_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partner_updatedBy_fkey"
+ foreignKeyName: "itemUnitSalePrice_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partner_updatedBy_fkey"
+ foreignKeyName: "itemUnitSalePrice_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partner_updatedBy_fkey"
+ foreignKeyName: "itemUnitSalePrice_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "userDefaults"
@@ -7017,653 +6983,675 @@ export type Database = {
},
]
}
- partPlanning: {
+ journal: {
Row: {
+ accountingPeriodId: string | null
companyId: string
createdAt: string
- createdBy: string
- critical: boolean
customFields: Json | null
- demandAccumulationIncludesInventory: boolean
- demandAccumulationPeriod: number
- demandReschedulingPeriod: number
- locationId: string
- maximumOrderQuantity: number
- minimumOrderQuantity: number
- orderMultiple: number
- partId: string
- reorderingPolicy: Database["public"]["Enums"]["partReorderingPolicy"]
- reorderMaximumInventory: number
- reorderPoint: number
- reorderQuantity: number
- safetyStockLeadTime: number
- safetyStockQuantity: number
- updatedAt: string | null
- updatedBy: string | null
+ description: string | null
+ id: number
+ postingDate: string
}
Insert: {
+ accountingPeriodId?: string | null
companyId: string
createdAt?: string
- createdBy: string
- critical?: boolean
customFields?: Json | null
- demandAccumulationIncludesInventory?: boolean
- demandAccumulationPeriod?: number
- demandReschedulingPeriod?: number
- locationId: string
- maximumOrderQuantity?: number
- minimumOrderQuantity?: number
- orderMultiple?: number
- partId: string
- reorderingPolicy?: Database["public"]["Enums"]["partReorderingPolicy"]
- reorderMaximumInventory?: number
- reorderPoint?: number
- reorderQuantity?: number
- safetyStockLeadTime?: number
- safetyStockQuantity?: number
- updatedAt?: string | null
- updatedBy?: string | null
+ description?: string | null
+ id?: number
+ postingDate?: string
}
Update: {
+ accountingPeriodId?: string | null
companyId?: string
createdAt?: string
- createdBy?: string
- critical?: boolean
customFields?: Json | null
- demandAccumulationIncludesInventory?: boolean
- demandAccumulationPeriod?: number
- demandReschedulingPeriod?: number
- locationId?: string
- maximumOrderQuantity?: number
- minimumOrderQuantity?: number
- orderMultiple?: number
- partId?: string
- reorderingPolicy?: Database["public"]["Enums"]["partReorderingPolicy"]
- reorderMaximumInventory?: number
- reorderPoint?: number
- reorderQuantity?: number
- safetyStockLeadTime?: number
- safetyStockQuantity?: number
- updatedAt?: string | null
- updatedBy?: string | null
+ description?: string | null
+ id?: number
+ postingDate?: string
}
Relationships: [
{
- foreignKeyName: "partPlanning_companyId_fkey"
+ foreignKeyName: "journal_accountPeriodId_fkey"
+ columns: ["accountingPeriodId"]
+ isOneToOne: false
+ referencedRelation: "accountingPeriod"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "journal_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "companies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partPlanning_companyId_fkey"
+ foreignKeyName: "journal_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "company"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partPlanning_companyId_fkey"
+ foreignKeyName: "journal_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "customFieldTables"
referencedColumns: ["companyId"]
},
{
- foreignKeyName: "partPlanning_companyId_fkey"
+ foreignKeyName: "journal_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "integrations"
referencedColumns: ["companyId"]
},
+ ]
+ }
+ journalLine: {
+ Row: {
+ accountNumber: string
+ accrual: boolean
+ amount: number
+ companyId: string
+ createdAt: string
+ customFields: Json | null
+ description: string | null
+ documentId: string | null
+ documentLineReference: string | null
+ documentType:
+ | Database["public"]["Enums"]["journalLineDocumentType"]
+ | null
+ externalDocumentId: string | null
+ id: string
+ journalId: number
+ journalLineReference: string
+ quantity: number
+ }
+ Insert: {
+ accountNumber: string
+ accrual?: boolean
+ amount: number
+ companyId: string
+ createdAt?: string
+ customFields?: Json | null
+ description?: string | null
+ documentId?: string | null
+ documentLineReference?: string | null
+ documentType?:
+ | Database["public"]["Enums"]["journalLineDocumentType"]
+ | null
+ externalDocumentId?: string | null
+ id?: string
+ journalId: number
+ journalLineReference: string
+ quantity?: number
+ }
+ Update: {
+ accountNumber?: string
+ accrual?: boolean
+ amount?: number
+ companyId?: string
+ createdAt?: string
+ customFields?: Json | null
+ description?: string | null
+ documentId?: string | null
+ documentLineReference?: string | null
+ documentType?:
+ | Database["public"]["Enums"]["journalLineDocumentType"]
+ | null
+ externalDocumentId?: string | null
+ id?: string
+ journalId?: number
+ journalLineReference?: string
+ quantity?: number
+ }
+ Relationships: [
{
- foreignKeyName: "partPlanning_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "partPlanning_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "partPlanning_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "partPlanning_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "partPlanning_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
- {
- foreignKeyName: "partPlanning_locationId_fkey"
- columns: ["locationId"]
- isOneToOne: false
- referencedRelation: "location"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "partPlanning_locationId_fkey"
- columns: ["locationId"]
- isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["locationId"]
- },
- {
- foreignKeyName: "partPlanning_locationId_fkey"
- columns: ["locationId"]
- isOneToOne: false
- referencedRelation: "purchaseOrders"
- referencedColumns: ["locationId"]
- },
- {
- foreignKeyName: "partPlanning_locationId_fkey"
- columns: ["locationId"]
- isOneToOne: false
- referencedRelation: "salesOrders"
- referencedColumns: ["locationId"]
- },
- {
- foreignKeyName: "partPlanning_partId_fkey"
- columns: ["partId", "companyId"]
- isOneToOne: false
- referencedRelation: "part"
- referencedColumns: ["id", "companyId"]
- },
- {
- foreignKeyName: "partPlanning_partId_fkey"
- columns: ["partId", "companyId"]
- isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["partId", "companyId"]
- },
- {
- foreignKeyName: "partPlanning_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "journalLine_accountNumber_fkey"
+ columns: ["accountNumber", "companyId"]
isOneToOne: false
- referencedRelation: "parts"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "account"
+ referencedColumns: ["number", "companyId"]
},
{
- foreignKeyName: "partPlanning_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "journalLine_accountNumber_fkey"
+ columns: ["accountNumber", "companyId"]
isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
+ referencedRelation: "accounts"
+ referencedColumns: ["number", "companyId"]
},
{
- foreignKeyName: "partPlanning_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "journalLine_companyId_fkey"
+ columns: ["companyId"]
isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
+ referencedRelation: "companies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partPlanning_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "journalLine_companyId_fkey"
+ columns: ["companyId"]
isOneToOne: false
- referencedRelation: "employeeSummary"
+ referencedRelation: "company"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partPlanning_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "journalLine_companyId_fkey"
+ columns: ["companyId"]
isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
},
{
- foreignKeyName: "partPlanning_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "journalLine_companyId_fkey"
+ columns: ["companyId"]
isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
},
]
}
- partReplenishment: {
+ location: {
Row: {
+ addressLine1: string
+ addressLine2: string | null
+ city: string
companyId: string
- conversionFactor: number
+ countryCode: string | null
createdAt: string
createdBy: string
customFields: Json | null
- lotSize: number | null
- manufacturingBlocked: boolean
- manufacturingLeadTime: number
- manufacturingPolicy: Database["public"]["Enums"]["partManufacturingPolicy"]
- partId: string
- preferredSupplierId: string | null
- purchasingBlocked: boolean
- purchasingLeadTime: number
- purchasingUnitOfMeasureCode: string | null
- requiresConfiguration: boolean
- scrapPercentage: number
+ id: string
+ latitude: number | null
+ longitude: number | null
+ name: string
+ postalCode: string
+ state: string
+ timezone: string
updatedAt: string | null
updatedBy: string | null
}
Insert: {
+ addressLine1: string
+ addressLine2?: string | null
+ city: string
companyId: string
- conversionFactor?: number
+ countryCode?: string | null
createdAt?: string
createdBy: string
customFields?: Json | null
- lotSize?: number | null
- manufacturingBlocked?: boolean
- manufacturingLeadTime?: number
- manufacturingPolicy?: Database["public"]["Enums"]["partManufacturingPolicy"]
- partId: string
- preferredSupplierId?: string | null
- purchasingBlocked?: boolean
- purchasingLeadTime?: number
- purchasingUnitOfMeasureCode?: string | null
- requiresConfiguration?: boolean
- scrapPercentage?: number
+ id?: string
+ latitude?: number | null
+ longitude?: number | null
+ name: string
+ postalCode: string
+ state: string
+ timezone: string
updatedAt?: string | null
updatedBy?: string | null
}
Update: {
+ addressLine1?: string
+ addressLine2?: string | null
+ city?: string
companyId?: string
- conversionFactor?: number
+ countryCode?: string | null
createdAt?: string
createdBy?: string
customFields?: Json | null
- lotSize?: number | null
- manufacturingBlocked?: boolean
- manufacturingLeadTime?: number
- manufacturingPolicy?: Database["public"]["Enums"]["partManufacturingPolicy"]
- partId?: string
- preferredSupplierId?: string | null
- purchasingBlocked?: boolean
- purchasingLeadTime?: number
- purchasingUnitOfMeasureCode?: string | null
- requiresConfiguration?: boolean
- scrapPercentage?: number
+ id?: string
+ latitude?: number | null
+ longitude?: number | null
+ name?: string
+ postalCode?: string
+ state?: string
+ timezone?: string
updatedAt?: string | null
updatedBy?: string | null
}
Relationships: [
{
- foreignKeyName: "partReplenishment_companyId_fkey"
+ foreignKeyName: "location_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "companies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partReplenishment_companyId_fkey"
+ foreignKeyName: "location_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "company"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partReplenishment_companyId_fkey"
+ foreignKeyName: "location_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "customFieldTables"
referencedColumns: ["companyId"]
},
{
- foreignKeyName: "partReplenishment_companyId_fkey"
+ foreignKeyName: "location_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "integrations"
referencedColumns: ["companyId"]
},
+ ]
+ }
+ membership: {
+ Row: {
+ groupId: string
+ id: number
+ memberGroupId: string | null
+ memberUserId: string | null
+ }
+ Insert: {
+ groupId: string
+ id?: number
+ memberGroupId?: string | null
+ memberUserId?: string | null
+ }
+ Update: {
+ groupId?: string
+ id?: number
+ memberGroupId?: string | null
+ memberUserId?: string | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "membership_groupId_fkey"
+ columns: ["groupId"]
+ isOneToOne: false
+ referencedRelation: "group"
+ referencedColumns: ["id"]
+ },
{
- foreignKeyName: "partReplenishment_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "membership_memberGroupId_fkey"
+ columns: ["memberGroupId"]
+ isOneToOne: false
+ referencedRelation: "group"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "membership_memberUserId_fkey"
+ columns: ["memberUserId"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partReplenishment_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "membership_memberUserId_fkey"
+ columns: ["memberUserId"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partReplenishment_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "membership_memberUserId_fkey"
+ columns: ["memberUserId"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partReplenishment_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "membership_memberUserId_fkey"
+ columns: ["memberUserId"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partReplenishment_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "membership_memberUserId_fkey"
+ columns: ["memberUserId"]
isOneToOne: false
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
+ ]
+ }
+ note: {
+ Row: {
+ active: boolean
+ companyId: string
+ createdAt: string
+ createdBy: string
+ documentId: string
+ id: string
+ note: string
+ noteRichText: Json
+ updatedAt: string | null
+ }
+ Insert: {
+ active?: boolean
+ companyId: string
+ createdAt?: string
+ createdBy: string
+ documentId: string
+ id?: string
+ note: string
+ noteRichText?: Json
+ updatedAt?: string | null
+ }
+ Update: {
+ active?: boolean
+ companyId?: string
+ createdAt?: string
+ createdBy?: string
+ documentId?: string
+ id?: string
+ note?: string
+ noteRichText?: Json
+ updatedAt?: string | null
+ }
+ Relationships: [
{
- foreignKeyName: "partReplenishment_partId_fkey"
- columns: ["partId", "companyId"]
- isOneToOne: false
- referencedRelation: "part"
- referencedColumns: ["id", "companyId"]
- },
- {
- foreignKeyName: "partReplenishment_partId_fkey"
- columns: ["partId", "companyId"]
- isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["partId", "companyId"]
- },
- {
- foreignKeyName: "partReplenishment_partId_fkey"
- columns: ["partId", "companyId"]
- isOneToOne: false
- referencedRelation: "parts"
- referencedColumns: ["id", "companyId"]
- },
- {
- foreignKeyName: "partReplenishment_preferredSupplierId_fkey"
- columns: ["preferredSupplierId"]
- isOneToOne: false
- referencedRelation: "contractors"
- referencedColumns: ["supplierId"]
- },
- {
- foreignKeyName: "partReplenishment_preferredSupplierId_fkey"
- columns: ["preferredSupplierId"]
- isOneToOne: false
- referencedRelation: "partners"
- referencedColumns: ["supplierId"]
- },
- {
- foreignKeyName: "partReplenishment_preferredSupplierId_fkey"
- columns: ["preferredSupplierId"]
+ foreignKeyName: "notes_companyId_fkey"
+ columns: ["companyId"]
isOneToOne: false
- referencedRelation: "purchaseOrderSuppliers"
+ referencedRelation: "companies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partReplenishment_preferredSupplierId_fkey"
- columns: ["preferredSupplierId"]
+ foreignKeyName: "notes_companyId_fkey"
+ columns: ["companyId"]
isOneToOne: false
- referencedRelation: "supplier"
+ referencedRelation: "company"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partReplenishment_preferredSupplierId_fkey"
- columns: ["preferredSupplierId"]
+ foreignKeyName: "notes_companyId_fkey"
+ columns: ["companyId"]
isOneToOne: false
- referencedRelation: "suppliers"
- referencedColumns: ["id"]
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
},
{
- foreignKeyName: "partReplenishment_purchaseUnitOfMeasureCode_fkey"
- columns: ["purchasingUnitOfMeasureCode", "companyId"]
+ foreignKeyName: "notes_companyId_fkey"
+ columns: ["companyId"]
isOneToOne: false
- referencedRelation: "unitOfMeasure"
- referencedColumns: ["code", "companyId"]
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
},
{
- foreignKeyName: "partReplenishment_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "notes_createdBy_fkey"
+ columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partReplenishment_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "notes_createdBy_fkey"
+ columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partReplenishment_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "notes_createdBy_fkey"
+ columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partReplenishment_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "notes_createdBy_fkey"
+ columns: ["createdBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partReplenishment_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "notes_createdBy_fkey"
+ columns: ["createdBy"]
isOneToOne: false
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
]
}
- partSupplier: {
+ part: {
Row: {
- active: boolean
+ approved: boolean
+ approvedBy: string | null
+ assignee: string | null
companyId: string
- conversionFactor: number
createdAt: string
createdBy: string
customFields: Json | null
+ fromDate: string | null
id: string
- minimumOrderQuantity: number | null
- partId: string
- supplierId: string
- supplierPartId: string | null
- supplierUnitOfMeasureCode: string | null
- unitPrice: number | null
+ itemId: string
+ partType: Database["public"]["Enums"]["partType"]
+ replenishmentSystem: Database["public"]["Enums"]["itemReplenishmentSystem"]
+ toDate: string | null
+ unitOfMeasureCode: string
updatedAt: string | null
updatedBy: string | null
}
Insert: {
- active?: boolean
+ approved?: boolean
+ approvedBy?: string | null
+ assignee?: string | null
companyId: string
- conversionFactor?: number
createdAt?: string
createdBy: string
customFields?: Json | null
- id?: string
- minimumOrderQuantity?: number | null
- partId: string
- supplierId: string
- supplierPartId?: string | null
- supplierUnitOfMeasureCode?: string | null
- unitPrice?: number | null
+ fromDate?: string | null
+ id: string
+ itemId: string
+ partType: Database["public"]["Enums"]["partType"]
+ replenishmentSystem: Database["public"]["Enums"]["itemReplenishmentSystem"]
+ toDate?: string | null
+ unitOfMeasureCode: string
updatedAt?: string | null
updatedBy?: string | null
}
Update: {
- active?: boolean
+ approved?: boolean
+ approvedBy?: string | null
+ assignee?: string | null
companyId?: string
- conversionFactor?: number
createdAt?: string
createdBy?: string
customFields?: Json | null
+ fromDate?: string | null
id?: string
- minimumOrderQuantity?: number | null
- partId?: string
- supplierId?: string
- supplierPartId?: string | null
- supplierUnitOfMeasureCode?: string | null
- unitPrice?: number | null
+ itemId?: string
+ partType?: Database["public"]["Enums"]["partType"]
+ replenishmentSystem?: Database["public"]["Enums"]["itemReplenishmentSystem"]
+ toDate?: string | null
+ unitOfMeasureCode?: string
updatedAt?: string | null
updatedBy?: string | null
}
Relationships: [
{
- foreignKeyName: "partSupplier_companyId_fkey"
- columns: ["companyId"]
+ foreignKeyName: "part_approvedBy_fkey"
+ columns: ["approvedBy"]
isOneToOne: false
- referencedRelation: "companies"
+ referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partSupplier_companyId_fkey"
- columns: ["companyId"]
+ foreignKeyName: "part_approvedBy_fkey"
+ columns: ["approvedBy"]
isOneToOne: false
- referencedRelation: "company"
+ referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partSupplier_companyId_fkey"
- columns: ["companyId"]
+ foreignKeyName: "part_approvedBy_fkey"
+ columns: ["approvedBy"]
isOneToOne: false
- referencedRelation: "customFieldTables"
- referencedColumns: ["companyId"]
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "partSupplier_companyId_fkey"
- columns: ["companyId"]
+ foreignKeyName: "part_approvedBy_fkey"
+ columns: ["approvedBy"]
isOneToOne: false
- referencedRelation: "integrations"
- referencedColumns: ["companyId"]
+ referencedRelation: "user"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "partSupplier_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "part_approvedBy_fkey"
+ columns: ["approvedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "part_assignee_fkey"
+ columns: ["assignee"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partSupplier_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "part_assignee_fkey"
+ columns: ["assignee"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partSupplier_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "part_assignee_fkey"
+ columns: ["assignee"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partSupplier_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "part_assignee_fkey"
+ columns: ["assignee"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partSupplier_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "part_assignee_fkey"
+ columns: ["assignee"]
isOneToOne: false
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
{
- foreignKeyName: "partSupplier_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "part_companyId_fkey"
+ columns: ["companyId"]
isOneToOne: false
- referencedRelation: "part"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "partSupplier_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "part_companyId_fkey"
+ columns: ["companyId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["partId", "companyId"]
+ referencedRelation: "company"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "partSupplier_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "part_companyId_fkey"
+ columns: ["companyId"]
isOneToOne: false
- referencedRelation: "parts"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
},
{
- foreignKeyName: "partSupplier_supplierId_fkey"
- columns: ["supplierId"]
+ foreignKeyName: "part_companyId_fkey"
+ columns: ["companyId"]
isOneToOne: false
- referencedRelation: "contractors"
- referencedColumns: ["supplierId"]
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
},
{
- foreignKeyName: "partSupplier_supplierId_fkey"
- columns: ["supplierId"]
+ foreignKeyName: "part_createdBy_fkey"
+ columns: ["createdBy"]
isOneToOne: false
- referencedRelation: "partners"
- referencedColumns: ["supplierId"]
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "partSupplier_supplierId_fkey"
- columns: ["supplierId"]
+ foreignKeyName: "part_createdBy_fkey"
+ columns: ["createdBy"]
isOneToOne: false
- referencedRelation: "purchaseOrderSuppliers"
+ referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partSupplier_supplierId_fkey"
- columns: ["supplierId"]
+ foreignKeyName: "part_createdBy_fkey"
+ columns: ["createdBy"]
isOneToOne: false
- referencedRelation: "supplier"
+ referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partSupplier_supplierId_fkey"
- columns: ["supplierId"]
+ foreignKeyName: "part_createdBy_fkey"
+ columns: ["createdBy"]
isOneToOne: false
- referencedRelation: "suppliers"
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "part_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "part_id_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "item"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partSupplier_updatedBy_fkey"
+ foreignKeyName: "part_id_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
+ },
+ {
+ foreignKeyName: "part_unitOfMeasureCode_fkey"
+ columns: ["unitOfMeasureCode", "companyId"]
+ isOneToOne: false
+ referencedRelation: "unitOfMeasure"
+ referencedColumns: ["code", "companyId"]
+ },
+ {
+ foreignKeyName: "part_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partSupplier_updatedBy_fkey"
+ foreignKeyName: "part_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partSupplier_updatedBy_fkey"
+ foreignKeyName: "part_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partSupplier_updatedBy_fkey"
+ foreignKeyName: "part_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partSupplier_updatedBy_fkey"
+ foreignKeyName: "part_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "userDefaults"
@@ -7671,181 +7659,151 @@ export type Database = {
},
]
}
- partUnitSalePrice: {
+ partner: {
Row: {
- allowInvoiceDiscount: boolean
+ abilityId: string
+ active: boolean
companyId: string
createdAt: string
createdBy: string
- currencyCode: string
customFields: Json | null
- partId: string
- priceIncludesTax: boolean
- salesBlocked: boolean
- salesUnitOfMeasureCode: string | null
- unitSalePrice: number
+ hoursPerWeek: number
+ id: string
updatedAt: string | null
updatedBy: string | null
}
Insert: {
- allowInvoiceDiscount?: boolean
+ abilityId: string
+ active?: boolean
companyId: string
createdAt?: string
createdBy: string
- currencyCode: string
customFields?: Json | null
- partId: string
- priceIncludesTax?: boolean
- salesBlocked?: boolean
- salesUnitOfMeasureCode?: string | null
- unitSalePrice?: number
+ hoursPerWeek?: number
+ id: string
updatedAt?: string | null
updatedBy?: string | null
}
Update: {
- allowInvoiceDiscount?: boolean
+ abilityId?: string
+ active?: boolean
companyId?: string
createdAt?: string
createdBy?: string
- currencyCode?: string
customFields?: Json | null
- partId?: string
- priceIncludesTax?: boolean
- salesBlocked?: boolean
- salesUnitOfMeasureCode?: string | null
- unitSalePrice?: number
+ hoursPerWeek?: number
+ id?: string
updatedAt?: string | null
updatedBy?: string | null
}
Relationships: [
{
- foreignKeyName: "partUnitSalePrice_companyId_fkey"
+ foreignKeyName: "partner_abilityId_fkey"
+ columns: ["abilityId"]
+ isOneToOne: false
+ referencedRelation: "ability"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "partner_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "companies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partUnitSalePrice_companyId_fkey"
+ foreignKeyName: "partner_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "company"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partUnitSalePrice_companyId_fkey"
+ foreignKeyName: "partner_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "customFieldTables"
referencedColumns: ["companyId"]
},
{
- foreignKeyName: "partUnitSalePrice_companyId_fkey"
+ foreignKeyName: "partner_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "integrations"
referencedColumns: ["companyId"]
},
{
- foreignKeyName: "partUnitSalePrice_createdBy_fkey"
+ foreignKeyName: "partner_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partUnitSalePrice_createdBy_fkey"
+ foreignKeyName: "partner_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partUnitSalePrice_createdBy_fkey"
+ foreignKeyName: "partner_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "partUnitSalePrice_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "partUnitSalePrice_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
- {
- foreignKeyName: "partUnitSalePrice_currencyCode_fkey"
- columns: ["currencyCode", "companyId"]
- isOneToOne: false
- referencedRelation: "currency"
- referencedColumns: ["code", "companyId"]
- },
- {
- foreignKeyName: "partUnitSalePrice_partId_fkey"
- columns: ["partId", "companyId"]
- isOneToOne: false
- referencedRelation: "part"
- referencedColumns: ["id", "companyId"]
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "partUnitSalePrice_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "partner_createdBy_fkey"
+ columns: ["createdBy"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["partId", "companyId"]
+ referencedRelation: "user"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "partUnitSalePrice_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "partner_createdBy_fkey"
+ columns: ["createdBy"]
isOneToOne: false
- referencedRelation: "parts"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
},
{
- foreignKeyName: "partUnitSalePrice_salesUnitOfMeasureId_fkey"
- columns: ["salesUnitOfMeasureCode", "companyId"]
+ foreignKeyName: "partner_id_fkey"
+ columns: ["id"]
isOneToOne: false
- referencedRelation: "unitOfMeasure"
- referencedColumns: ["code", "companyId"]
+ referencedRelation: "supplierLocation"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "partUnitSalePrice_updatedBy_fkey"
+ foreignKeyName: "partner_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partUnitSalePrice_updatedBy_fkey"
+ foreignKeyName: "partner_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partUnitSalePrice_updatedBy_fkey"
+ foreignKeyName: "partner_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partUnitSalePrice_updatedBy_fkey"
+ foreignKeyName: "partner_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partUnitSalePrice_updatedBy_fkey"
+ foreignKeyName: "partner_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "userDefaults"
@@ -8202,15 +8160,15 @@ export type Database = {
foreignKeyName: "postingGroupInventory_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "location"
- referencedColumns: ["id"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["locationId"]
},
{
foreignKeyName: "postingGroupInventory_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["locationId"]
+ referencedRelation: "location"
+ referencedColumns: ["id"]
},
{
foreignKeyName: "postingGroupInventory_locationId_fkey"
@@ -9079,8 +9037,9 @@ export type Database = {
inventoryUnitOfMeasureCode: string | null
invoiceId: string
invoiceLineType: Database["public"]["Enums"]["payableLineType"]
+ itemId: string | null
+ itemReadableId: string | null
locationId: string | null
- partId: string | null
purchaseOrderId: string | null
purchaseOrderLineId: string | null
purchaseUnitOfMeasureCode: string | null
@@ -9107,8 +9066,9 @@ export type Database = {
inventoryUnitOfMeasureCode?: string | null
invoiceId: string
invoiceLineType: Database["public"]["Enums"]["payableLineType"]
+ itemId?: string | null
+ itemReadableId?: string | null
locationId?: string | null
- partId?: string | null
purchaseOrderId?: string | null
purchaseOrderLineId?: string | null
purchaseUnitOfMeasureCode?: string | null
@@ -9135,8 +9095,9 @@ export type Database = {
inventoryUnitOfMeasureCode?: string | null
invoiceId?: string
invoiceLineType?: Database["public"]["Enums"]["payableLineType"]
+ itemId?: string | null
+ itemReadableId?: string | null
locationId?: string | null
- partId?: string | null
purchaseOrderId?: string | null
purchaseOrderLineId?: string | null
purchaseUnitOfMeasureCode?: string | null
@@ -9255,53 +9216,46 @@ export type Database = {
referencedColumns: ["id"]
},
{
- foreignKeyName: "purchaseInvoiceLines_locationId_fkey"
- columns: ["locationId"]
+ foreignKeyName: "purchaseInvoiceLines_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "location"
+ referencedRelation: "item"
referencedColumns: ["id"]
},
{
- foreignKeyName: "purchaseInvoiceLines_locationId_fkey"
- columns: ["locationId"]
+ foreignKeyName: "purchaseInvoiceLines_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["locationId"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
},
{
foreignKeyName: "purchaseInvoiceLines_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "purchaseOrders"
+ referencedRelation: "itemQuantities"
referencedColumns: ["locationId"]
},
{
foreignKeyName: "purchaseInvoiceLines_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "salesOrders"
- referencedColumns: ["locationId"]
- },
- {
- foreignKeyName: "purchaseInvoiceLines_partId_fkey"
- columns: ["partId", "companyId"]
- isOneToOne: false
- referencedRelation: "part"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "location"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "purchaseInvoiceLines_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "purchaseInvoiceLines_locationId_fkey"
+ columns: ["locationId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["partId", "companyId"]
+ referencedRelation: "purchaseOrders"
+ referencedColumns: ["locationId"]
},
{
- foreignKeyName: "purchaseInvoiceLines_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "purchaseInvoiceLines_locationId_fkey"
+ columns: ["locationId"]
isOneToOne: false
- referencedRelation: "parts"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "salesOrders"
+ referencedColumns: ["locationId"]
},
{
foreignKeyName: "purchaseInvoiceLines_purchaseOrderId_fkey"
@@ -9345,20 +9299,6 @@ export type Database = {
referencedRelation: "unitOfMeasure"
referencedColumns: ["code", "companyId"]
},
- {
- foreignKeyName: "purchaseInvoiceLines_serviceId_fkey"
- columns: ["serviceId", "companyId"]
- isOneToOne: false
- referencedRelation: "service"
- referencedColumns: ["id", "companyId"]
- },
- {
- foreignKeyName: "purchaseInvoiceLines_serviceId_fkey"
- columns: ["serviceId", "companyId"]
- isOneToOne: false
- referencedRelation: "services"
- referencedColumns: ["id", "companyId"]
- },
{
foreignKeyName: "purchaseInvoiceLines_shelfId_fkey"
columns: ["shelfId", "locationId"]
@@ -9965,15 +9905,15 @@ export type Database = {
foreignKeyName: "purchaseOrderDelivery_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "location"
- referencedColumns: ["id"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["locationId"]
},
{
foreignKeyName: "purchaseOrderDelivery_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["locationId"]
+ referencedRelation: "location"
+ referencedColumns: ["id"]
},
{
foreignKeyName: "purchaseOrderDelivery_locationId_fkey"
@@ -10125,8 +10065,9 @@ export type Database = {
id: string
inventoryUnitOfMeasureCode: string | null
invoicedComplete: boolean
+ itemId: string | null
+ itemReadableId: string | null
locationId: string | null
- partId: string | null
purchaseOrderId: string
purchaseOrderLineType: Database["public"]["Enums"]["purchaseOrderLineType"]
purchaseQuantity: number | null
@@ -10137,7 +10078,6 @@ export type Database = {
quantityToReceive: number | null
receivedComplete: boolean
requiresInspection: boolean
- serviceId: string | null
setupPrice: number | null
shelfId: string | null
unitPrice: number | null
@@ -10156,8 +10096,9 @@ export type Database = {
id?: string
inventoryUnitOfMeasureCode?: string | null
invoicedComplete?: boolean
+ itemId?: string | null
+ itemReadableId?: string | null
locationId?: string | null
- partId?: string | null
purchaseOrderId: string
purchaseOrderLineType: Database["public"]["Enums"]["purchaseOrderLineType"]
purchaseQuantity?: number | null
@@ -10168,7 +10109,6 @@ export type Database = {
quantityToReceive?: number | null
receivedComplete?: boolean
requiresInspection?: boolean
- serviceId?: string | null
setupPrice?: number | null
shelfId?: string | null
unitPrice?: number | null
@@ -10187,8 +10127,9 @@ export type Database = {
id?: string
inventoryUnitOfMeasureCode?: string | null
invoicedComplete?: boolean
+ itemId?: string | null
+ itemReadableId?: string | null
locationId?: string | null
- partId?: string | null
purchaseOrderId?: string
purchaseOrderLineType?: Database["public"]["Enums"]["purchaseOrderLineType"]
purchaseQuantity?: number | null
@@ -10199,7 +10140,6 @@ export type Database = {
quantityToReceive?: number | null
receivedComplete?: boolean
requiresInspection?: boolean
- serviceId?: string | null
setupPrice?: number | null
shelfId?: string | null
unitPrice?: number | null
@@ -10264,25 +10204,18 @@ export type Database = {
referencedColumns: ["code", "companyId"]
},
{
- foreignKeyName: "purchaseOrderLine_partId_fkey"
- columns: ["partId", "companyId"]
- isOneToOne: false
- referencedRelation: "part"
- referencedColumns: ["id", "companyId"]
- },
- {
- foreignKeyName: "purchaseOrderLine_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "purchaseOrderLine_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["partId", "companyId"]
+ referencedRelation: "item"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "purchaseOrderLine_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "purchaseOrderLine_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "parts"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
},
{
foreignKeyName: "purchaseOrderLine_purchaseOrderId_fkey"
@@ -10312,20 +10245,6 @@ export type Database = {
referencedRelation: "unitOfMeasure"
referencedColumns: ["code", "companyId"]
},
- {
- foreignKeyName: "purchaseOrderLine_serviceId_fkey"
- columns: ["serviceId", "companyId"]
- isOneToOne: false
- referencedRelation: "service"
- referencedColumns: ["id", "companyId"]
- },
- {
- foreignKeyName: "purchaseOrderLine_serviceId_fkey"
- columns: ["serviceId", "companyId"]
- isOneToOne: false
- referencedRelation: "services"
- referencedColumns: ["id", "companyId"]
- },
{
foreignKeyName: "purchaseOrderLine_shelfId_fkey"
columns: ["shelfId", "locationId"]
@@ -11053,15 +10972,15 @@ export type Database = {
foreignKeyName: "quote_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "location"
- referencedColumns: ["id"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["locationId"]
},
{
foreignKeyName: "quote_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["locationId"]
+ referencedRelation: "location"
+ referencedColumns: ["id"]
},
{
foreignKeyName: "quote_locationId_fkey"
@@ -11122,8 +11041,8 @@ export type Database = {
customFields: Json | null
description: string | null
id: string
+ itemId: string
parentAssemblyId: string | null
- partId: string
quantityPerParent: number
quoteId: string
quoteLineId: string
@@ -11138,8 +11057,8 @@ export type Database = {
customFields?: Json | null
description?: string | null
id?: string
+ itemId: string
parentAssemblyId?: string | null
- partId: string
quantityPerParent?: number
quoteId: string
quoteLineId: string
@@ -11154,8 +11073,8 @@ export type Database = {
customFields?: Json | null
description?: string | null
id?: string
+ itemId?: string
parentAssemblyId?: string | null
- partId?: string
quantityPerParent?: number
quoteId?: string
quoteLineId?: string
@@ -11228,32 +11147,25 @@ export type Database = {
referencedColumns: ["userId"]
},
{
- foreignKeyName: "quoteAssembly_parentAssemblyId_fkey"
- columns: ["parentAssemblyId"]
+ foreignKeyName: "quoteAssembly_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "quoteAssembly"
+ referencedRelation: "item"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteAssembly_partId_fkey"
- columns: ["partId", "companyId"]
- isOneToOne: false
- referencedRelation: "part"
- referencedColumns: ["id", "companyId"]
- },
- {
- foreignKeyName: "quoteAssembly_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "quoteAssembly_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["partId", "companyId"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
},
{
- foreignKeyName: "quoteAssembly_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "quoteAssembly_parentAssemblyId_fkey"
+ columns: ["parentAssemblyId"]
isOneToOne: false
- referencedRelation: "parts"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "quoteAssembly"
+ referencedColumns: ["id"]
},
{
foreignKeyName: "quoteAssembly_quoteId_fkey"
@@ -11415,7 +11327,7 @@ export type Database = {
customFields: Json | null
description: string
id: string
- partId: string
+ itemId: string
quoteId: string
quoteRevisionId: number
replenishmentSystem: string | null
@@ -11432,7 +11344,7 @@ export type Database = {
customFields?: Json | null
description: string
id?: string
- partId: string
+ itemId: string
quoteId: string
quoteRevisionId?: number
replenishmentSystem?: string | null
@@ -11449,7 +11361,7 @@ export type Database = {
customFields?: Json | null
description?: string
id?: string
- partId?: string
+ itemId?: string
quoteId?: string
quoteRevisionId?: number
replenishmentSystem?: string | null
@@ -11523,25 +11435,18 @@ export type Database = {
referencedColumns: ["userId"]
},
{
- foreignKeyName: "quoteLine_partId_fkey"
- columns: ["partId", "companyId"]
- isOneToOne: false
- referencedRelation: "part"
- referencedColumns: ["id", "companyId"]
- },
- {
- foreignKeyName: "quoteLine_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "quoteLine_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["partId", "companyId"]
+ referencedRelation: "item"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteLine_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "quoteLine_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "parts"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
},
{
foreignKeyName: "quoteLine_quoteId_fkey"
@@ -11770,7 +11675,7 @@ export type Database = {
customFields: Json | null
description: string
id: string
- partId: string
+ itemId: string
quantity: number
quoteId: string
quoteLineId: string
@@ -11787,7 +11692,7 @@ export type Database = {
customFields?: Json | null
description: string
id?: string
- partId: string
+ itemId: string
quantity?: number
quoteId: string
quoteLineId: string
@@ -11804,7 +11709,7 @@ export type Database = {
customFields?: Json | null
description?: string
id?: string
- partId?: string
+ itemId?: string
quantity?: number
quoteId?: string
quoteLineId?: string
@@ -11879,25 +11784,18 @@ export type Database = {
referencedColumns: ["userId"]
},
{
- foreignKeyName: "quoteMaterial_partId_fkey"
- columns: ["partId", "companyId"]
- isOneToOne: false
- referencedRelation: "part"
- referencedColumns: ["id", "companyId"]
- },
- {
- foreignKeyName: "quoteMaterial_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "quoteMaterial_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["partId", "companyId"]
+ referencedRelation: "item"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteMaterial_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "quoteMaterial_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "parts"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
},
{
foreignKeyName: "quoteMaterial_quoteId_fkey"
@@ -12376,15 +12274,15 @@ export type Database = {
foreignKeyName: "receipt_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "location"
- referencedColumns: ["id"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["locationId"]
},
{
foreignKeyName: "receipt_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["locationId"]
+ referencedRelation: "location"
+ referencedColumns: ["id"]
},
{
foreignKeyName: "receipt_locationId_fkey"
@@ -12479,11 +12377,11 @@ export type Database = {
createdAt: string
createdBy: string
id: string
+ itemId: string
lineId: string | null
locationId: string | null
orderQuantity: number
outstandingQuantity: number
- partId: string
receiptId: string
receivedQuantity: number
shelfId: string | null
@@ -12498,11 +12396,11 @@ export type Database = {
createdAt?: string
createdBy: string
id?: string
+ itemId: string
lineId?: string | null
locationId?: string | null
orderQuantity: number
outstandingQuantity?: number
- partId: string
receiptId: string
receivedQuantity?: number
shelfId?: string | null
@@ -12517,11 +12415,11 @@ export type Database = {
createdAt?: string
createdBy?: string
id?: string
+ itemId?: string
lineId?: string | null
locationId?: string | null
orderQuantity?: number
outstandingQuantity?: number
- partId?: string
receiptId?: string
receivedQuantity?: number
shelfId?: string | null
@@ -12567,53 +12465,46 @@ export type Database = {
referencedColumns: ["userId"]
},
{
- foreignKeyName: "receiptLine_locationId_fkey"
- columns: ["locationId"]
+ foreignKeyName: "receiptLine_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "location"
+ referencedRelation: "item"
referencedColumns: ["id"]
},
{
- foreignKeyName: "receiptLine_locationId_fkey"
- columns: ["locationId"]
+ foreignKeyName: "receiptLine_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["locationId"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
},
{
foreignKeyName: "receiptLine_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "purchaseOrders"
+ referencedRelation: "itemQuantities"
referencedColumns: ["locationId"]
},
{
foreignKeyName: "receiptLine_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "salesOrders"
- referencedColumns: ["locationId"]
- },
- {
- foreignKeyName: "receiptLine_partId_fkey"
- columns: ["partId", "companyId"]
- isOneToOne: false
- referencedRelation: "part"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "location"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "receiptLine_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "receiptLine_locationId_fkey"
+ columns: ["locationId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["partId", "companyId"]
+ referencedRelation: "purchaseOrders"
+ referencedColumns: ["locationId"]
},
{
- foreignKeyName: "receiptLine_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "receiptLine_locationId_fkey"
+ columns: ["locationId"]
isOneToOne: false
- referencedRelation: "parts"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "salesOrders"
+ referencedColumns: ["locationId"]
},
{
foreignKeyName: "receiptLine_receiptId_fkey"
@@ -12831,15 +12722,15 @@ export type Database = {
foreignKeyName: "requestForQuote_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "location"
- referencedColumns: ["id"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["locationId"]
},
{
foreignKeyName: "requestForQuote_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["locationId"]
+ referencedRelation: "location"
+ referencedColumns: ["id"]
},
{
foreignKeyName: "requestForQuote_locationId_fkey"
@@ -12965,8 +12856,8 @@ export type Database = {
customFields: Json | null
description: string | null
id: string
+ itemId: string
locationId: string | null
- partId: string
quantity: number
requestForQuoteId: string
shelfId: string | null
@@ -12982,8 +12873,8 @@ export type Database = {
customFields?: Json | null
description?: string | null
id?: string
+ itemId: string
locationId?: string | null
- partId: string
quantity: number
requestForQuoteId: string
shelfId?: string | null
@@ -12999,8 +12890,8 @@ export type Database = {
customFields?: Json | null
description?: string | null
id?: string
+ itemId?: string
locationId?: string | null
- partId?: string
quantity?: number
requestForQuoteId?: string
shelfId?: string | null
@@ -13074,53 +12965,46 @@ export type Database = {
referencedColumns: ["userId"]
},
{
- foreignKeyName: "requestForQuoteLine_locationId_fkey"
- columns: ["locationId"]
+ foreignKeyName: "requestForQuoteLine_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "location"
+ referencedRelation: "item"
referencedColumns: ["id"]
},
{
- foreignKeyName: "requestForQuoteLine_locationId_fkey"
- columns: ["locationId"]
+ foreignKeyName: "requestForQuoteLine_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["locationId"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
},
{
foreignKeyName: "requestForQuoteLine_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "purchaseOrders"
+ referencedRelation: "itemQuantities"
referencedColumns: ["locationId"]
},
{
foreignKeyName: "requestForQuoteLine_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "salesOrders"
- referencedColumns: ["locationId"]
- },
- {
- foreignKeyName: "requestForQuoteLine_partId_fkey"
- columns: ["partId", "companyId"]
- isOneToOne: false
- referencedRelation: "part"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "location"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "requestForQuoteLine_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "requestForQuoteLine_locationId_fkey"
+ columns: ["locationId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["partId", "companyId"]
+ referencedRelation: "purchaseOrders"
+ referencedColumns: ["locationId"]
},
{
- foreignKeyName: "requestForQuoteLine_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "requestForQuoteLine_locationId_fkey"
+ columns: ["locationId"]
isOneToOne: false
- referencedRelation: "parts"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "salesOrders"
+ referencedColumns: ["locationId"]
},
{
foreignKeyName: "requestForQuoteLine_requestForQuoteId_fkey"
@@ -13329,15 +13213,15 @@ export type Database = {
foreignKeyName: "requestForQuoteSupplier_supplierLocationId_fkey"
columns: ["supplierLocationId"]
isOneToOne: false
- referencedRelation: "location"
- referencedColumns: ["id"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["locationId"]
},
{
foreignKeyName: "requestForQuoteSupplier_supplierLocationId_fkey"
columns: ["supplierLocationId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["locationId"]
+ referencedRelation: "location"
+ referencedColumns: ["id"]
},
{
foreignKeyName: "requestForQuoteSupplier_supplierLocationId_fkey"
@@ -13888,8 +13772,8 @@ export type Database = {
description: string | null
id: string
invoicedComplete: boolean
+ itemId: string | null
locationId: string | null
- partId: string | null
quantityInvoiced: number | null
quantitySent: number | null
quantityToInvoice: number | null
@@ -13899,7 +13783,6 @@ export type Database = {
salesOrderId: string
salesOrderLineType: Database["public"]["Enums"]["salesOrderLineType"]
sentComplete: boolean
- serviceId: string | null
setupPrice: number | null
shelfId: string | null
unitOfMeasureCode: string | null
@@ -13917,8 +13800,8 @@ export type Database = {
description?: string | null
id?: string
invoicedComplete?: boolean
+ itemId?: string | null
locationId?: string | null
- partId?: string | null
quantityInvoiced?: number | null
quantitySent?: number | null
quantityToInvoice?: number | null
@@ -13928,7 +13811,6 @@ export type Database = {
salesOrderId: string
salesOrderLineType: Database["public"]["Enums"]["salesOrderLineType"]
sentComplete?: boolean
- serviceId?: string | null
setupPrice?: number | null
shelfId?: string | null
unitOfMeasureCode?: string | null
@@ -13946,8 +13828,8 @@ export type Database = {
description?: string | null
id?: string
invoicedComplete?: boolean
+ itemId?: string | null
locationId?: string | null
- partId?: string | null
quantityInvoiced?: number | null
quantitySent?: number | null
quantityToInvoice?: number | null
@@ -13957,7 +13839,6 @@ export type Database = {
salesOrderId?: string
salesOrderLineType?: Database["public"]["Enums"]["salesOrderLineType"]
sentComplete?: boolean
- serviceId?: string | null
setupPrice?: number | null
shelfId?: string | null
unitOfMeasureCode?: string | null
@@ -14016,25 +13897,18 @@ export type Database = {
referencedColumns: ["userId"]
},
{
- foreignKeyName: "salesOrderLine_partId_fkey"
- columns: ["partId", "companyId"]
- isOneToOne: false
- referencedRelation: "part"
- referencedColumns: ["id", "companyId"]
- },
- {
- foreignKeyName: "salesOrderLine_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "salesOrderLine_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["partId", "companyId"]
+ referencedRelation: "item"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "salesOrderLine_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "salesOrderLine_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "parts"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
},
{
foreignKeyName: "salesOrderLine_salesOrderId_fkey"
@@ -14050,20 +13924,6 @@ export type Database = {
referencedRelation: "salesOrders"
referencedColumns: ["id"]
},
- {
- foreignKeyName: "salesOrderLine_serviceId_fkey"
- columns: ["serviceId", "companyId"]
- isOneToOne: false
- referencedRelation: "service"
- referencedColumns: ["id", "companyId"]
- },
- {
- foreignKeyName: "salesOrderLine_serviceId_fkey"
- columns: ["serviceId", "companyId"]
- isOneToOne: false
- referencedRelation: "services"
- referencedColumns: ["id", "companyId"]
- },
{
foreignKeyName: "salesOrderLine_shelfId_fkey"
columns: ["shelfId", "locationId"]
@@ -14423,15 +14283,15 @@ export type Database = {
foreignKeyName: "salesOrderShipment_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "location"
- referencedColumns: ["id"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["locationId"]
},
{
foreignKeyName: "salesOrderShipment_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["locationId"]
+ referencedRelation: "location"
+ referencedColumns: ["id"]
},
{
foreignKeyName: "salesOrderShipment_locationId_fkey"
@@ -15004,6 +14864,13 @@ export type Database = {
referencedRelation: "item"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "service_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
+ },
{
foreignKeyName: "service_updatedBy_fkey"
columns: ["updatedBy"]
@@ -15336,15 +15203,15 @@ export type Database = {
foreignKeyName: "shelf_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "location"
- referencedColumns: ["id"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["locationId"]
},
{
foreignKeyName: "shelf_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["locationId"]
+ referencedRelation: "location"
+ referencedColumns: ["id"]
},
{
foreignKeyName: "shelf_locationId_fkey"
@@ -15536,15 +15403,15 @@ export type Database = {
foreignKeyName: "shifts_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "location"
- referencedColumns: ["id"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["locationId"]
},
{
foreignKeyName: "shifts_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["locationId"]
+ referencedRelation: "location"
+ referencedColumns: ["id"]
},
{
foreignKeyName: "shifts_locationId_fkey"
@@ -18077,15 +17944,15 @@ export type Database = {
foreignKeyName: "warehouse_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "location"
- referencedColumns: ["id"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["locationId"]
},
{
foreignKeyName: "warehouse_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["locationId"]
+ referencedRelation: "location"
+ referencedColumns: ["id"]
},
{
foreignKeyName: "warehouse_locationId_fkey"
@@ -18265,15 +18132,15 @@ export type Database = {
foreignKeyName: "workCell_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "location"
- referencedColumns: ["id"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["locationId"]
},
{
foreignKeyName: "workCell_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["locationId"]
+ referencedRelation: "location"
+ referencedColumns: ["id"]
},
{
foreignKeyName: "workCell_locationId_fkey"
@@ -19640,6 +19507,48 @@ export type Database = {
}
Relationships: []
}
+ itemQuantities: {
+ Row: {
+ companyId: string | null
+ itemId: string | null
+ locationId: string | null
+ quantityAvailable: number | null
+ quantityOnHand: number | null
+ quantityOnProdOrder: number | null
+ quantityOnPurchaseOrder: number | null
+ quantityOnSalesOrder: number | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "item_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "item_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "item_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "item_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ ]
+ }
modules: {
Row: {
name: Database["public"]["Enums"]["module"] | null
@@ -19787,48 +19696,6 @@ export type Database = {
},
]
}
- partQuantities: {
- Row: {
- companyId: string | null
- locationId: string | null
- partId: string | null
- quantityAvailable: number | null
- quantityOnHand: number | null
- quantityOnProdOrder: number | null
- quantityOnPurchaseOrder: number | null
- quantityOnSalesOrder: number | null
- }
- Relationships: [
- {
- foreignKeyName: "part_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "company"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "part_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "companies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "part_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "customFieldTables"
- referencedColumns: ["companyId"]
- },
- {
- foreignKeyName: "part_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "integrations"
- referencedColumns: ["companyId"]
- },
- ]
- }
parts: {
Row: {
active: boolean | null
@@ -19849,7 +19716,7 @@ export type Database = {
name: string | null
partType: Database["public"]["Enums"]["partType"] | null
replenishmentSystem:
- | Database["public"]["Enums"]["partReplenishmentSystem"]
+ | Database["public"]["Enums"]["itemReplenishmentSystem"]
| null
supplierIds: string[] | null
toDate: string | null
@@ -20005,6 +19872,13 @@ export type Database = {
referencedRelation: "item"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "part_id_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
+ },
{
foreignKeyName: "part_unitOfMeasureCode_fkey"
columns: ["unitOfMeasureCode", "companyId"]
@@ -20311,8 +20185,11 @@ export type Database = {
id: string | null
inventoryUnitOfMeasureCode: string | null
invoicedComplete: boolean | null
+ itemDescription: string | null
+ itemId: string | null
+ itemName: string | null
+ itemReadableId: string | null
locationId: string | null
- partId: string | null
purchaseOrderId: string | null
purchaseOrderLineType:
| Database["public"]["Enums"]["purchaseOrderLineType"]
@@ -20325,12 +20202,10 @@ export type Database = {
quantityToReceive: number | null
receivedComplete: boolean | null
requiresInspection: boolean | null
- serviceId: string | null
setupPrice: number | null
shelfId: string | null
supplierId: string | null
supplierPartId: string | null
- supplierServiceId: string | null
unitPrice: number | null
updatedAt: string | null
updatedBy: string | null
@@ -20428,25 +20303,18 @@ export type Database = {
referencedColumns: ["code", "companyId"]
},
{
- foreignKeyName: "purchaseOrderLine_partId_fkey"
- columns: ["partId", "companyId"]
- isOneToOne: false
- referencedRelation: "part"
- referencedColumns: ["id", "companyId"]
- },
- {
- foreignKeyName: "purchaseOrderLine_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "purchaseOrderLine_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["partId", "companyId"]
+ referencedRelation: "item"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "purchaseOrderLine_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "purchaseOrderLine_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "parts"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
},
{
foreignKeyName: "purchaseOrderLine_purchaseOrderId_fkey"
@@ -20476,20 +20344,6 @@ export type Database = {
referencedRelation: "unitOfMeasure"
referencedColumns: ["code", "companyId"]
},
- {
- foreignKeyName: "purchaseOrderLine_serviceId_fkey"
- columns: ["serviceId", "companyId"]
- isOneToOne: false
- referencedRelation: "service"
- referencedColumns: ["id", "companyId"]
- },
- {
- foreignKeyName: "purchaseOrderLine_serviceId_fkey"
- columns: ["serviceId", "companyId"]
- isOneToOne: false
- referencedRelation: "services"
- referencedColumns: ["id", "companyId"]
- },
{
foreignKeyName: "purchaseOrderLine_shelfId_fkey"
columns: ["shelfId", "locationId"]
@@ -20896,7 +20750,7 @@ export type Database = {
customFields: Json | null
description: string | null
id: string | null
- partId: string | null
+ itemId: string | null
pricingDiscountPercent: number | null
pricingExtendedPrice: number | null
pricingLeadTime: number | null
@@ -20976,25 +20830,18 @@ export type Database = {
referencedColumns: ["userId"]
},
{
- foreignKeyName: "quoteLine_partId_fkey"
- columns: ["partId", "companyId"]
- isOneToOne: false
- referencedRelation: "part"
- referencedColumns: ["id", "companyId"]
- },
- {
- foreignKeyName: "quoteLine_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "quoteLine_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["partId", "companyId"]
+ referencedRelation: "item"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteLine_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "quoteLine_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "parts"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
},
{
foreignKeyName: "quoteLine_quoteId_fkey"
@@ -21075,11 +20922,11 @@ export type Database = {
expirationDate: string | null
favorite: boolean | null
id: string | null
+ itemIds: string[] | null
locationId: string | null
locationName: string | null
name: string | null
notes: string | null
- partIds: string[] | null
quoteDate: string | null
quoteId: string | null
revisionId: number | null
@@ -21232,7 +21079,7 @@ export type Database = {
foreignKeyName: "quote_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "partQuantities"
+ referencedRelation: "itemQuantities"
referencedColumns: ["locationId"]
},
{
@@ -21420,7 +21267,7 @@ export type Database = {
foreignKeyName: "receipt_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "partQuantities"
+ referencedRelation: "itemQuantities"
referencedColumns: ["locationId"]
},
{
@@ -21519,11 +21366,11 @@ export type Database = {
expirationDate: string | null
favorite: boolean | null
id: string | null
+ itemIds: string[] | null
locationId: string | null
locationName: string | null
name: string | null
notes: string | null
- partIds: string[] | null
receiptDate: string | null
requestForQuoteId: string | null
revisionId: number | null
@@ -21642,7 +21489,7 @@ export type Database = {
foreignKeyName: "requestForQuote_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "partQuantities"
+ referencedRelation: "itemQuantities"
referencedColumns: ["locationId"]
},
{
@@ -21745,8 +21592,10 @@ export type Database = {
description: string | null
id: string | null
invoicedComplete: boolean | null
+ itemDescription: string | null
+ itemId: string | null
+ itemName: string | null
locationId: string | null
- partId: string | null
quantityInvoiced: number | null
quantitySent: number | null
quantityToInvoice: number | null
@@ -21758,7 +21607,6 @@ export type Database = {
| Database["public"]["Enums"]["salesOrderLineType"]
| null
sentComplete: boolean | null
- serviceId: string | null
setupPrice: number | null
shelfId: string | null
unitOfMeasureCode: string | null
@@ -21838,25 +21686,18 @@ export type Database = {
referencedColumns: ["userId"]
},
{
- foreignKeyName: "salesOrderLine_partId_fkey"
- columns: ["partId", "companyId"]
- isOneToOne: false
- referencedRelation: "part"
- referencedColumns: ["id", "companyId"]
- },
- {
- foreignKeyName: "salesOrderLine_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "salesOrderLine_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["partId", "companyId"]
+ referencedRelation: "item"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "salesOrderLine_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "salesOrderLine_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "parts"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
},
{
foreignKeyName: "salesOrderLine_salesOrderId_fkey"
@@ -21872,20 +21713,6 @@ export type Database = {
referencedRelation: "salesOrders"
referencedColumns: ["id"]
},
- {
- foreignKeyName: "salesOrderLine_serviceId_fkey"
- columns: ["serviceId", "companyId"]
- isOneToOne: false
- referencedRelation: "service"
- referencedColumns: ["id", "companyId"]
- },
- {
- foreignKeyName: "salesOrderLine_serviceId_fkey"
- columns: ["serviceId", "companyId"]
- isOneToOne: false
- referencedRelation: "services"
- referencedColumns: ["id", "companyId"]
- },
{
foreignKeyName: "salesOrderLine_shelfId_fkey"
columns: ["shelfId", "locationId"]
@@ -22383,6 +22210,13 @@ export type Database = {
referencedRelation: "item"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "service_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
+ },
{
foreignKeyName: "service_updatedBy_fkey"
columns: ["updatedBy"]
@@ -22518,7 +22352,7 @@ export type Database = {
foreignKeyName: "shifts_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "partQuantities"
+ referencedRelation: "itemQuantities"
referencedColumns: ["locationId"]
},
{
@@ -22796,7 +22630,7 @@ export type Database = {
foreignKeyName: "employeeJob_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "partQuantities"
+ referencedRelation: "itemQuantities"
referencedColumns: ["locationId"]
},
{
@@ -23071,14 +22905,49 @@ export type Database = {
glAccountType: "Posting" | "Total" | "Begin Total" | "End Total"
glConsolidatedRate: "Average" | "Current" | "Historical"
glIncomeBalance: "Balance Sheet" | "Income Statement"
+ itemCostingMethod: "Standard" | "Average" | "LIFO" | "FIFO"
+ itemLedgerDocumentType:
+ | "Sales Shipment"
+ | "Sales Invoice"
+ | "Sales Return Receipt"
+ | "Sales Credit Memo"
+ | "Purchase Receipt"
+ | "Purchase Invoice"
+ | "Purchase Return Shipment"
+ | "Purchase Credit Memo"
+ | "Transfer Shipment"
+ | "Transfer Receipt"
+ | "Service Shipment"
+ | "Service Invoice"
+ | "Service Credit Memo"
+ | "Posted Assembly"
+ | "Inventory Receipt"
+ | "Inventory Shipment"
+ | "Direct Transfer"
+ itemLedgerType:
+ | "Purchase"
+ | "Sale"
+ | "Positive Adjmt."
+ | "Negative Adjmt."
+ | "Transfer"
+ | "Consumption"
+ | "Output"
+ | "Assembly Consumption"
+ | "Assembly Output"
+ itemReorderingPolicy:
+ | "Manual Reorder"
+ | "Demand-Based Reorder"
+ | "Fixed Reorder Quantity"
+ | "Maximum Quantity"
+ itemReplenishmentSystem: "Buy" | "Make" | "Buy and Make"
itemType:
- | "part"
- | "material"
- | "tool"
- | "hardware"
- | "service"
- | "consumable"
- | "fixture"
+ | "Part"
+ | "Material"
+ | "Tool"
+ | "Hardware"
+ | "Service"
+ | "Consumable"
+ | "Fixture"
journalLineDocumentType:
| "Receipt"
| "Invoice"
@@ -23113,49 +22982,19 @@ export type Database = {
| "October"
| "November"
| "December"
- partCostingMethod: "Standard" | "Average" | "LIFO" | "FIFO"
- partLedgerDocumentType:
- | "Sales Shipment"
- | "Sales Invoice"
- | "Sales Return Receipt"
- | "Sales Credit Memo"
- | "Purchase Receipt"
- | "Purchase Invoice"
- | "Purchase Return Shipment"
- | "Purchase Credit Memo"
- | "Transfer Shipment"
- | "Transfer Receipt"
- | "Service Shipment"
- | "Service Invoice"
- | "Service Credit Memo"
- | "Posted Assembly"
- | "Inventory Receipt"
- | "Inventory Shipment"
- | "Direct Transfer"
- partLedgerType:
- | "Purchase"
- | "Sale"
- | "Positive Adjmt."
- | "Negative Adjmt."
- | "Transfer"
- | "Consumption"
- | "Output"
- | "Assembly Consumption"
- | "Assembly Output"
partManufacturingPolicy: "Make to Order" | "Make to Stock"
- partReorderingPolicy:
- | "Manual Reorder"
- | "Demand-Based Reorder"
- | "Fixed Reorder Quantity"
- | "Maximum Quantity"
- partReplenishmentSystem: "Buy" | "Make" | "Buy and Make"
partType: "Inventory" | "Non-Inventory"
payableLineType:
+ | "Comment"
| "G/L Account"
+ | "Fixed Asset"
| "Part"
+ | "Material"
+ | "Tool"
+ | "Hardware"
| "Service"
- | "Fixed Asset"
- | "Comment"
+ | "Consumable"
+ | "Fixture"
paymentTermCalculationMethod: "Net" | "End of Month" | "Day of Month"
purchaseInvoiceStatus:
| "Draft"
@@ -23170,9 +23009,14 @@ export type Database = {
purchaseOrderLineType:
| "Comment"
| "G/L Account"
+ | "Fixed Asset"
| "Part"
+ | "Material"
+ | "Tool"
+ | "Hardware"
| "Service"
- | "Fixed Asset"
+ | "Consumable"
+ | "Fixture"
purchaseOrderStatus:
| "Draft"
| "To Review"
@@ -23213,7 +23057,17 @@ export type Database = {
| "Manufacturing Output"
receiptStatus: "Draft" | "Pending" | "Posted"
requestForQuoteStatus: "Draft" | "Sent" | "Expired" | "Closed"
- salesOrderLineType: "Comment" | "Part" | "Service"
+ salesOrderLineType:
+ | "Comment"
+ | "G/L Account"
+ | "Fixed Asset"
+ | "Part"
+ | "Material"
+ | "Tool"
+ | "Hardware"
+ | "Service"
+ | "Consumable"
+ | "Fixture"
salesOrderStatus:
| "Draft"
| "Needs Approval"
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index 68a705ec68..6c6bb70355 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -2114,13 +2114,13 @@ export type Database = {
createdAt: string
documentId: string | null
documentType:
- | Database["public"]["Enums"]["partLedgerDocumentType"]
+ | Database["public"]["Enums"]["itemLedgerDocumentType"]
| null
entryNumber: number
externalDocumentId: string | null
id: string
- partId: string | null
- partLedgerType: Database["public"]["Enums"]["partLedgerType"]
+ itemId: string | null
+ itemLedgerType: Database["public"]["Enums"]["itemLedgerType"]
postingDate: string
quantity: number
}
@@ -2133,13 +2133,13 @@ export type Database = {
createdAt?: string
documentId?: string | null
documentType?:
- | Database["public"]["Enums"]["partLedgerDocumentType"]
+ | Database["public"]["Enums"]["itemLedgerDocumentType"]
| null
entryNumber?: number
externalDocumentId?: string | null
id?: string
- partId?: string | null
- partLedgerType: Database["public"]["Enums"]["partLedgerType"]
+ itemId?: string | null
+ itemLedgerType: Database["public"]["Enums"]["itemLedgerType"]
postingDate?: string
quantity?: number
}
@@ -2152,13 +2152,13 @@ export type Database = {
createdAt?: string
documentId?: string | null
documentType?:
- | Database["public"]["Enums"]["partLedgerDocumentType"]
+ | Database["public"]["Enums"]["itemLedgerDocumentType"]
| null
entryNumber?: number
externalDocumentId?: string | null
id?: string
- partId?: string | null
- partLedgerType?: Database["public"]["Enums"]["partLedgerType"]
+ itemId?: string | null
+ itemLedgerType?: Database["public"]["Enums"]["itemLedgerType"]
postingDate?: string
quantity?: number
}
@@ -4460,15 +4460,15 @@ export type Database = {
foreignKeyName: "employeeJob_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "location"
- referencedColumns: ["id"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["locationId"]
},
{
foreignKeyName: "employeeJob_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["locationId"]
+ referencedRelation: "location"
+ referencedColumns: ["id"]
},
{
foreignKeyName: "employeeJob_locationId_fkey"
@@ -4872,15 +4872,15 @@ export type Database = {
foreignKeyName: "equipment_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "location"
- referencedColumns: ["id"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["locationId"]
},
{
foreignKeyName: "equipment_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["locationId"]
+ referencedRelation: "location"
+ referencedColumns: ["id"]
},
{
foreignKeyName: "equipment_locationId_fkey"
@@ -5566,72 +5566,89 @@ export type Database = {
},
]
}
- itemGroup: {
+ itemCost: {
Row: {
- active: boolean
companyId: string
+ costingMethod: Database["public"]["Enums"]["itemCostingMethod"]
+ costIsAdjusted: boolean
createdAt: string
createdBy: string
customFields: Json | null
- description: string | null
- id: string
- name: string
+ itemId: string
+ standardCost: number
+ unitCost: number
updatedAt: string | null
updatedBy: string | null
}
Insert: {
- active?: boolean
companyId: string
+ costingMethod: Database["public"]["Enums"]["itemCostingMethod"]
+ costIsAdjusted?: boolean
createdAt?: string
createdBy: string
customFields?: Json | null
- description?: string | null
- id?: string
- name: string
+ itemId: string
+ standardCost?: number
+ unitCost?: number
updatedAt?: string | null
updatedBy?: string | null
}
Update: {
- active?: boolean
companyId?: string
+ costingMethod?: Database["public"]["Enums"]["itemCostingMethod"]
+ costIsAdjusted?: boolean
createdAt?: string
createdBy?: string
customFields?: Json | null
- description?: string | null
- id?: string
- name?: string
+ itemId?: string
+ standardCost?: number
+ unitCost?: number
updatedAt?: string | null
updatedBy?: string | null
}
Relationships: [
{
- foreignKeyName: "itemGroup_companyId_fkey"
+ foreignKeyName: "itemCost_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "companies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "itemGroup_companyId_fkey"
+ foreignKeyName: "itemCost_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "company"
referencedColumns: ["id"]
},
{
- foreignKeyName: "itemGroup_companyId_fkey"
+ foreignKeyName: "itemCost_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "customFieldTables"
referencedColumns: ["companyId"]
},
{
- foreignKeyName: "itemGroup_companyId_fkey"
+ foreignKeyName: "itemCost_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "integrations"
referencedColumns: ["companyId"]
},
+ {
+ foreignKeyName: "itemCost_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "item"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemCost_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
+ },
{
foreignKeyName: "itemGroup_createdBy_fkey"
columns: ["createdBy"]
@@ -5704,1021 +5721,884 @@ export type Database = {
},
]
}
- journal: {
+ itemGroup: {
Row: {
- accountingPeriodId: string | null
+ active: boolean
companyId: string
createdAt: string
+ createdBy: string
customFields: Json | null
description: string | null
- id: number
- postingDate: string
+ id: string
+ name: string
+ updatedAt: string | null
+ updatedBy: string | null
}
Insert: {
- accountingPeriodId?: string | null
+ active?: boolean
companyId: string
createdAt?: string
+ createdBy: string
customFields?: Json | null
description?: string | null
- id?: number
- postingDate?: string
+ id?: string
+ name: string
+ updatedAt?: string | null
+ updatedBy?: string | null
}
Update: {
- accountingPeriodId?: string | null
+ active?: boolean
companyId?: string
createdAt?: string
+ createdBy?: string
customFields?: Json | null
description?: string | null
- id?: number
- postingDate?: string
+ id?: string
+ name?: string
+ updatedAt?: string | null
+ updatedBy?: string | null
}
Relationships: [
{
- foreignKeyName: "journal_accountPeriodId_fkey"
- columns: ["accountingPeriodId"]
- isOneToOne: false
- referencedRelation: "accountingPeriod"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "journal_companyId_fkey"
+ foreignKeyName: "itemGroup_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "companies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "journal_companyId_fkey"
+ foreignKeyName: "itemGroup_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "company"
referencedColumns: ["id"]
},
{
- foreignKeyName: "journal_companyId_fkey"
+ foreignKeyName: "itemGroup_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "customFieldTables"
referencedColumns: ["companyId"]
},
{
- foreignKeyName: "journal_companyId_fkey"
+ foreignKeyName: "itemGroup_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "integrations"
referencedColumns: ["companyId"]
},
+ {
+ foreignKeyName: "itemGroup_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemGroup_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemGroup_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemGroup_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemGroup_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "itemGroup_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemGroup_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemGroup_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemGroup_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemGroup_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
]
}
- journalLine: {
+ itemInventory: {
Row: {
- accountNumber: string
- accrual: boolean
- amount: number
companyId: string
createdAt: string
+ createdBy: string
customFields: Json | null
- description: string | null
- documentId: string | null
- documentLineReference: string | null
- documentType:
- | Database["public"]["Enums"]["journalLineDocumentType"]
- | null
- externalDocumentId: string | null
- id: string
- journalId: number
- journalLineReference: string
- quantity: number
+ defaultShelfId: string | null
+ itemId: string
+ locationId: string
+ updatedAt: string | null
+ updatedBy: string | null
}
Insert: {
- accountNumber: string
- accrual?: boolean
- amount: number
companyId: string
createdAt?: string
+ createdBy: string
customFields?: Json | null
- description?: string | null
- documentId?: string | null
- documentLineReference?: string | null
- documentType?:
- | Database["public"]["Enums"]["journalLineDocumentType"]
- | null
- externalDocumentId?: string | null
- id?: string
- journalId: number
- journalLineReference: string
- quantity?: number
+ defaultShelfId?: string | null
+ itemId: string
+ locationId: string
+ updatedAt?: string | null
+ updatedBy?: string | null
}
Update: {
- accountNumber?: string
- accrual?: boolean
- amount?: number
companyId?: string
createdAt?: string
+ createdBy?: string
customFields?: Json | null
- description?: string | null
- documentId?: string | null
- documentLineReference?: string | null
- documentType?:
- | Database["public"]["Enums"]["journalLineDocumentType"]
- | null
- externalDocumentId?: string | null
- id?: string
- journalId?: number
- journalLineReference?: string
- quantity?: number
+ defaultShelfId?: string | null
+ itemId?: string
+ locationId?: string
+ updatedAt?: string | null
+ updatedBy?: string | null
}
Relationships: [
{
- foreignKeyName: "journalLine_accountNumber_fkey"
- columns: ["accountNumber", "companyId"]
- isOneToOne: false
- referencedRelation: "account"
- referencedColumns: ["number", "companyId"]
- },
- {
- foreignKeyName: "journalLine_accountNumber_fkey"
- columns: ["accountNumber", "companyId"]
- isOneToOne: false
- referencedRelation: "accounts"
- referencedColumns: ["number", "companyId"]
- },
- {
- foreignKeyName: "journalLine_companyId_fkey"
+ foreignKeyName: "itemInventory_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "companies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "journalLine_companyId_fkey"
+ foreignKeyName: "itemInventory_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "company"
referencedColumns: ["id"]
},
{
- foreignKeyName: "journalLine_companyId_fkey"
+ foreignKeyName: "itemInventory_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "customFieldTables"
referencedColumns: ["companyId"]
},
{
- foreignKeyName: "journalLine_companyId_fkey"
+ foreignKeyName: "itemInventory_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "integrations"
referencedColumns: ["companyId"]
},
- ]
- }
- location: {
- Row: {
- addressLine1: string
- addressLine2: string | null
- city: string
- companyId: string
- countryCode: string | null
- createdAt: string
- createdBy: string
- customFields: Json | null
- id: string
- latitude: number | null
- longitude: number | null
- name: string
- postalCode: string
- state: string
- timezone: string
- updatedAt: string | null
- updatedBy: string | null
- }
- Insert: {
- addressLine1: string
- addressLine2?: string | null
- city: string
- companyId: string
- countryCode?: string | null
- createdAt?: string
- createdBy: string
- customFields?: Json | null
- id?: string
- latitude?: number | null
- longitude?: number | null
- name: string
- postalCode: string
- state: string
- timezone: string
- updatedAt?: string | null
- updatedBy?: string | null
- }
- Update: {
- addressLine1?: string
- addressLine2?: string | null
- city?: string
- companyId?: string
- countryCode?: string | null
- createdAt?: string
- createdBy?: string
- customFields?: Json | null
- id?: string
- latitude?: number | null
- longitude?: number | null
- name?: string
- postalCode?: string
- state?: string
- timezone?: string
- updatedAt?: string | null
- updatedBy?: string | null
- }
- Relationships: [
- {
- foreignKeyName: "location_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "companies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "location_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "company"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "location_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "customFieldTables"
- referencedColumns: ["companyId"]
- },
- {
- foreignKeyName: "location_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "integrations"
- referencedColumns: ["companyId"]
- },
- ]
- }
- membership: {
- Row: {
- groupId: string
- id: number
- memberGroupId: string | null
- memberUserId: string | null
- }
- Insert: {
- groupId: string
- id?: number
- memberGroupId?: string | null
- memberUserId?: string | null
- }
- Update: {
- groupId?: string
- id?: number
- memberGroupId?: string | null
- memberUserId?: string | null
- }
- Relationships: [
- {
- foreignKeyName: "membership_groupId_fkey"
- columns: ["groupId"]
- isOneToOne: false
- referencedRelation: "group"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "membership_memberGroupId_fkey"
- columns: ["memberGroupId"]
- isOneToOne: false
- referencedRelation: "group"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "membership_memberUserId_fkey"
- columns: ["memberUserId"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "membership_memberUserId_fkey"
- columns: ["memberUserId"]
- isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "membership_memberUserId_fkey"
- columns: ["memberUserId"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "membership_memberUserId_fkey"
- columns: ["memberUserId"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "membership_memberUserId_fkey"
- columns: ["memberUserId"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
- ]
- }
- note: {
- Row: {
- active: boolean
- companyId: string
- createdAt: string
- createdBy: string
- documentId: string
- id: string
- note: string
- noteRichText: Json
- updatedAt: string | null
- }
- Insert: {
- active?: boolean
- companyId: string
- createdAt?: string
- createdBy: string
- documentId: string
- id?: string
- note: string
- noteRichText?: Json
- updatedAt?: string | null
- }
- Update: {
- active?: boolean
- companyId?: string
- createdAt?: string
- createdBy?: string
- documentId?: string
- id?: string
- note?: string
- noteRichText?: Json
- updatedAt?: string | null
- }
- Relationships: [
- {
- foreignKeyName: "notes_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "companies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "notes_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "company"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "notes_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "customFieldTables"
- referencedColumns: ["companyId"]
- },
{
- foreignKeyName: "notes_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "integrations"
- referencedColumns: ["companyId"]
- },
- {
- foreignKeyName: "notes_createdBy_fkey"
+ foreignKeyName: "itemInventory_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "notes_createdBy_fkey"
+ foreignKeyName: "itemInventory_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "notes_createdBy_fkey"
+ foreignKeyName: "itemInventory_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "notes_createdBy_fkey"
+ foreignKeyName: "itemInventory_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "notes_createdBy_fkey"
+ foreignKeyName: "itemInventory_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
- ]
- }
- part: {
- Row: {
- approved: boolean
- approvedBy: string | null
- assignee: string | null
- companyId: string
- createdAt: string
- createdBy: string
- customFields: Json | null
- fromDate: string | null
- id: string
- itemId: string
- partType: Database["public"]["Enums"]["partType"]
- replenishmentSystem: Database["public"]["Enums"]["partReplenishmentSystem"]
- toDate: string | null
- unitOfMeasureCode: string
- updatedAt: string | null
- updatedBy: string | null
- }
- Insert: {
- approved?: boolean
- approvedBy?: string | null
- assignee?: string | null
- companyId: string
- createdAt?: string
- createdBy: string
- customFields?: Json | null
- fromDate?: string | null
- id: string
- itemId: string
- partType: Database["public"]["Enums"]["partType"]
- replenishmentSystem: Database["public"]["Enums"]["partReplenishmentSystem"]
- toDate?: string | null
- unitOfMeasureCode: string
- updatedAt?: string | null
- updatedBy?: string | null
- }
- Update: {
- approved?: boolean
- approvedBy?: string | null
- assignee?: string | null
- companyId?: string
- createdAt?: string
- createdBy?: string
- customFields?: Json | null
- fromDate?: string | null
- id?: string
- itemId?: string
- partType?: Database["public"]["Enums"]["partType"]
- replenishmentSystem?: Database["public"]["Enums"]["partReplenishmentSystem"]
- toDate?: string | null
- unitOfMeasureCode?: string
- updatedAt?: string | null
- updatedBy?: string | null
- }
- Relationships: [
{
- foreignKeyName: "part_approvedBy_fkey"
- columns: ["approvedBy"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "part_approvedBy_fkey"
- columns: ["approvedBy"]
- isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "part_approvedBy_fkey"
- columns: ["approvedBy"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "part_approvedBy_fkey"
- columns: ["approvedBy"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "part_approvedBy_fkey"
- columns: ["approvedBy"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
- {
- foreignKeyName: "part_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "part_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "part_assignee_fkey"
- columns: ["assignee"]
+ foreignKeyName: "itemInventory_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "employeeSummary"
+ referencedRelation: "item"
referencedColumns: ["id"]
},
{
- foreignKeyName: "part_assignee_fkey"
- columns: ["assignee"]
+ foreignKeyName: "itemInventory_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
},
{
- foreignKeyName: "part_assignee_fkey"
- columns: ["assignee"]
+ foreignKeyName: "itemInventory_locationId_fkey"
+ columns: ["locationId"]
isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["locationId"]
},
{
- foreignKeyName: "part_companyId_fkey"
- columns: ["companyId"]
+ foreignKeyName: "itemInventory_locationId_fkey"
+ columns: ["locationId"]
isOneToOne: false
- referencedRelation: "companies"
+ referencedRelation: "location"
referencedColumns: ["id"]
},
{
- foreignKeyName: "part_companyId_fkey"
- columns: ["companyId"]
+ foreignKeyName: "itemInventory_locationId_fkey"
+ columns: ["locationId"]
isOneToOne: false
- referencedRelation: "company"
- referencedColumns: ["id"]
+ referencedRelation: "purchaseOrders"
+ referencedColumns: ["locationId"]
},
{
- foreignKeyName: "part_companyId_fkey"
- columns: ["companyId"]
+ foreignKeyName: "itemInventory_locationId_fkey"
+ columns: ["locationId"]
isOneToOne: false
- referencedRelation: "customFieldTables"
- referencedColumns: ["companyId"]
+ referencedRelation: "salesOrders"
+ referencedColumns: ["locationId"]
},
{
- foreignKeyName: "part_companyId_fkey"
- columns: ["companyId"]
+ foreignKeyName: "itemInventory_shelfId_fkey"
+ columns: ["defaultShelfId", "locationId"]
isOneToOne: false
- referencedRelation: "integrations"
- referencedColumns: ["companyId"]
+ referencedRelation: "shelf"
+ referencedColumns: ["id", "locationId"]
},
{
- foreignKeyName: "part_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "itemInventory_updatedBy_fkey"
+ columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "part_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "itemInventory_updatedBy_fkey"
+ columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "part_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "itemInventory_updatedBy_fkey"
+ columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "part_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "itemInventory_updatedBy_fkey"
+ columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "part_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "itemInventory_updatedBy_fkey"
+ columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
+ ]
+ }
+ itemLedger: {
+ Row: {
+ companyId: string
+ createdAt: string
+ documentId: string | null
+ documentType:
+ | Database["public"]["Enums"]["itemLedgerDocumentType"]
+ | null
+ entryNumber: number
+ entryType: Database["public"]["Enums"]["itemLedgerType"]
+ externalDocumentId: string | null
+ id: string
+ itemId: string
+ locationId: string | null
+ postingDate: string
+ quantity: number
+ shelfId: string | null
+ }
+ Insert: {
+ companyId: string
+ createdAt?: string
+ documentId?: string | null
+ documentType?:
+ | Database["public"]["Enums"]["itemLedgerDocumentType"]
+ | null
+ entryNumber?: number
+ entryType: Database["public"]["Enums"]["itemLedgerType"]
+ externalDocumentId?: string | null
+ id?: string
+ itemId: string
+ locationId?: string | null
+ postingDate?: string
+ quantity: number
+ shelfId?: string | null
+ }
+ Update: {
+ companyId?: string
+ createdAt?: string
+ documentId?: string | null
+ documentType?:
+ | Database["public"]["Enums"]["itemLedgerDocumentType"]
+ | null
+ entryNumber?: number
+ entryType?: Database["public"]["Enums"]["itemLedgerType"]
+ externalDocumentId?: string | null
+ id?: string
+ itemId?: string
+ locationId?: string | null
+ postingDate?: string
+ quantity?: number
+ shelfId?: string | null
+ }
+ Relationships: [
{
- foreignKeyName: "part_id_fkey"
+ foreignKeyName: "itemLedger_itemId_fkey"
columns: ["itemId"]
isOneToOne: false
referencedRelation: "item"
referencedColumns: ["id"]
},
{
- foreignKeyName: "part_unitOfMeasureCode_fkey"
- columns: ["unitOfMeasureCode", "companyId"]
+ foreignKeyName: "itemLedger_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "unitOfMeasure"
- referencedColumns: ["code", "companyId"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
},
{
- foreignKeyName: "part_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "itemLedger_locationId_fkey"
+ columns: ["locationId"]
isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["locationId"]
},
{
- foreignKeyName: "part_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "itemLedger_locationId_fkey"
+ columns: ["locationId"]
isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
+ referencedRelation: "location"
referencedColumns: ["id"]
},
{
- foreignKeyName: "part_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "itemLedger_locationId_fkey"
+ columns: ["locationId"]
isOneToOne: false
- referencedRelation: "employeeSummary"
+ referencedRelation: "purchaseOrders"
+ referencedColumns: ["locationId"]
+ },
+ {
+ foreignKeyName: "itemLedger_locationId_fkey"
+ columns: ["locationId"]
+ isOneToOne: false
+ referencedRelation: "salesOrders"
+ referencedColumns: ["locationId"]
+ },
+ {
+ foreignKeyName: "itemLedger_shelfId_fkey"
+ columns: ["shelfId", "locationId"]
+ isOneToOne: false
+ referencedRelation: "shelf"
+ referencedColumns: ["id", "locationId"]
+ },
+ {
+ foreignKeyName: "partLeger_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "part_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "partLeger_companyId_fkey"
+ columns: ["companyId"]
isOneToOne: false
- referencedRelation: "user"
+ referencedRelation: "company"
referencedColumns: ["id"]
},
{
- foreignKeyName: "part_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "partLeger_companyId_fkey"
+ columns: ["companyId"]
isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "partLeger_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
},
]
}
- partCost: {
+ itemPlanning: {
Row: {
companyId: string
- costingMethod: Database["public"]["Enums"]["partCostingMethod"]
- costIsAdjusted: boolean
createdAt: string
createdBy: string
+ critical: boolean
customFields: Json | null
- partId: string
- standardCost: number
- unitCost: number
+ demandAccumulationIncludesInventory: boolean
+ demandAccumulationPeriod: number
+ demandReschedulingPeriod: number
+ itemId: string
+ locationId: string
+ maximumOrderQuantity: number
+ minimumOrderQuantity: number
+ orderMultiple: number
+ reorderingPolicy: Database["public"]["Enums"]["itemReorderingPolicy"]
+ reorderMaximumInventory: number
+ reorderPoint: number
+ reorderQuantity: number
+ safetyStockLeadTime: number
+ safetyStockQuantity: number
updatedAt: string | null
updatedBy: string | null
}
Insert: {
companyId: string
- costingMethod: Database["public"]["Enums"]["partCostingMethod"]
- costIsAdjusted?: boolean
createdAt?: string
createdBy: string
+ critical?: boolean
customFields?: Json | null
- partId: string
- standardCost?: number
- unitCost?: number
+ demandAccumulationIncludesInventory?: boolean
+ demandAccumulationPeriod?: number
+ demandReschedulingPeriod?: number
+ itemId: string
+ locationId: string
+ maximumOrderQuantity?: number
+ minimumOrderQuantity?: number
+ orderMultiple?: number
+ reorderingPolicy?: Database["public"]["Enums"]["itemReorderingPolicy"]
+ reorderMaximumInventory?: number
+ reorderPoint?: number
+ reorderQuantity?: number
+ safetyStockLeadTime?: number
+ safetyStockQuantity?: number
updatedAt?: string | null
updatedBy?: string | null
}
Update: {
companyId?: string
- costingMethod?: Database["public"]["Enums"]["partCostingMethod"]
- costIsAdjusted?: boolean
createdAt?: string
createdBy?: string
+ critical?: boolean
customFields?: Json | null
- partId?: string
- standardCost?: number
- unitCost?: number
+ demandAccumulationIncludesInventory?: boolean
+ demandAccumulationPeriod?: number
+ demandReschedulingPeriod?: number
+ itemId?: string
+ locationId?: string
+ maximumOrderQuantity?: number
+ minimumOrderQuantity?: number
+ orderMultiple?: number
+ reorderingPolicy?: Database["public"]["Enums"]["itemReorderingPolicy"]
+ reorderMaximumInventory?: number
+ reorderPoint?: number
+ reorderQuantity?: number
+ safetyStockLeadTime?: number
+ safetyStockQuantity?: number
updatedAt?: string | null
updatedBy?: string | null
}
Relationships: [
{
- foreignKeyName: "itemGroup_createdBy_fkey"
+ foreignKeyName: "itemPlanning_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemPlanning_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemPlanning_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "itemPlanning_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "itemPlanning_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "itemGroup_createdBy_fkey"
+ foreignKeyName: "itemPlanning_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "itemGroup_createdBy_fkey"
+ foreignKeyName: "itemPlanning_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "itemGroup_createdBy_fkey"
+ foreignKeyName: "itemPlanning_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "itemGroup_createdBy_fkey"
+ foreignKeyName: "itemPlanning_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
{
- foreignKeyName: "itemGroup_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "itemPlanning_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "employees"
+ referencedRelation: "item"
referencedColumns: ["id"]
},
{
- foreignKeyName: "itemGroup_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "itemPlanning_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
},
{
- foreignKeyName: "itemGroup_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "itemPlanning_locationId_fkey"
+ columns: ["locationId"]
isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["locationId"]
},
{
- foreignKeyName: "itemGroup_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "itemPlanning_locationId_fkey"
+ columns: ["locationId"]
isOneToOne: false
- referencedRelation: "user"
+ referencedRelation: "location"
referencedColumns: ["id"]
},
{
- foreignKeyName: "itemGroup_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "itemPlanning_locationId_fkey"
+ columns: ["locationId"]
isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
+ referencedRelation: "purchaseOrders"
+ referencedColumns: ["locationId"]
},
{
- foreignKeyName: "partCost_companyId_fkey"
- columns: ["companyId"]
+ foreignKeyName: "itemPlanning_locationId_fkey"
+ columns: ["locationId"]
isOneToOne: false
- referencedRelation: "companies"
- referencedColumns: ["id"]
+ referencedRelation: "salesOrders"
+ referencedColumns: ["locationId"]
},
{
- foreignKeyName: "partCost_companyId_fkey"
- columns: ["companyId"]
+ foreignKeyName: "itemPlanning_updatedBy_fkey"
+ columns: ["updatedBy"]
isOneToOne: false
- referencedRelation: "company"
+ referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partCost_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "customFieldTables"
- referencedColumns: ["companyId"]
- },
- {
- foreignKeyName: "partCost_companyId_fkey"
- columns: ["companyId"]
+ foreignKeyName: "itemPlanning_updatedBy_fkey"
+ columns: ["updatedBy"]
isOneToOne: false
- referencedRelation: "integrations"
- referencedColumns: ["companyId"]
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "partCost_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "itemPlanning_updatedBy_fkey"
+ columns: ["updatedBy"]
isOneToOne: false
- referencedRelation: "part"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "partCost_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "itemPlanning_updatedBy_fkey"
+ columns: ["updatedBy"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["partId", "companyId"]
+ referencedRelation: "user"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "partCost_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "itemPlanning_updatedBy_fkey"
+ columns: ["updatedBy"]
isOneToOne: false
- referencedRelation: "parts"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
},
]
}
- partInventory: {
+ itemReplenishment: {
Row: {
companyId: string
+ conversionFactor: number
createdAt: string
createdBy: string
customFields: Json | null
- defaultShelfId: string | null
- locationId: string
- partId: string
+ itemId: string
+ lotSize: number | null
+ manufacturingBlocked: boolean
+ manufacturingLeadTime: number
+ manufacturingPolicy: Database["public"]["Enums"]["partManufacturingPolicy"]
+ preferredSupplierId: string | null
+ purchasingBlocked: boolean
+ purchasingLeadTime: number
+ purchasingUnitOfMeasureCode: string | null
+ requiresConfiguration: boolean
+ scrapPercentage: number
updatedAt: string | null
updatedBy: string | null
}
Insert: {
companyId: string
+ conversionFactor?: number
createdAt?: string
createdBy: string
customFields?: Json | null
- defaultShelfId?: string | null
- locationId: string
- partId: string
+ itemId: string
+ lotSize?: number | null
+ manufacturingBlocked?: boolean
+ manufacturingLeadTime?: number
+ manufacturingPolicy?: Database["public"]["Enums"]["partManufacturingPolicy"]
+ preferredSupplierId?: string | null
+ purchasingBlocked?: boolean
+ purchasingLeadTime?: number
+ purchasingUnitOfMeasureCode?: string | null
+ requiresConfiguration?: boolean
+ scrapPercentage?: number
updatedAt?: string | null
updatedBy?: string | null
}
Update: {
companyId?: string
+ conversionFactor?: number
createdAt?: string
createdBy?: string
customFields?: Json | null
- defaultShelfId?: string | null
- locationId?: string
- partId?: string
+ itemId?: string
+ lotSize?: number | null
+ manufacturingBlocked?: boolean
+ manufacturingLeadTime?: number
+ manufacturingPolicy?: Database["public"]["Enums"]["partManufacturingPolicy"]
+ preferredSupplierId?: string | null
+ purchasingBlocked?: boolean
+ purchasingLeadTime?: number
+ purchasingUnitOfMeasureCode?: string | null
+ requiresConfiguration?: boolean
+ scrapPercentage?: number
updatedAt?: string | null
updatedBy?: string | null
}
Relationships: [
{
- foreignKeyName: "partInventory_companyId_fkey"
+ foreignKeyName: "itemReplenishment_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "companies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partInventory_companyId_fkey"
+ foreignKeyName: "itemReplenishment_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "company"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partInventory_companyId_fkey"
+ foreignKeyName: "itemReplenishment_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "customFieldTables"
referencedColumns: ["companyId"]
},
{
- foreignKeyName: "partInventory_companyId_fkey"
+ foreignKeyName: "itemReplenishment_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "integrations"
referencedColumns: ["companyId"]
},
{
- foreignKeyName: "partInventory_createdBy_fkey"
+ foreignKeyName: "itemReplenishment_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partInventory_createdBy_fkey"
+ foreignKeyName: "itemReplenishment_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partInventory_createdBy_fkey"
+ foreignKeyName: "itemReplenishment_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partInventory_createdBy_fkey"
+ foreignKeyName: "itemReplenishment_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partInventory_createdBy_fkey"
+ foreignKeyName: "itemReplenishment_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
{
- foreignKeyName: "partInventory_locationId_fkey"
- columns: ["locationId"]
+ foreignKeyName: "itemReplenishment_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "location"
+ referencedRelation: "item"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partInventory_locationId_fkey"
- columns: ["locationId"]
+ foreignKeyName: "itemReplenishment_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["locationId"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
},
{
- foreignKeyName: "partInventory_locationId_fkey"
- columns: ["locationId"]
+ foreignKeyName: "itemReplenishment_preferredSupplierId_fkey"
+ columns: ["preferredSupplierId"]
isOneToOne: false
- referencedRelation: "purchaseOrders"
- referencedColumns: ["locationId"]
+ referencedRelation: "contractors"
+ referencedColumns: ["supplierId"]
},
{
- foreignKeyName: "partInventory_locationId_fkey"
- columns: ["locationId"]
+ foreignKeyName: "itemReplenishment_preferredSupplierId_fkey"
+ columns: ["preferredSupplierId"]
isOneToOne: false
- referencedRelation: "salesOrders"
- referencedColumns: ["locationId"]
+ referencedRelation: "partners"
+ referencedColumns: ["supplierId"]
},
{
- foreignKeyName: "partInventory_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "itemReplenishment_preferredSupplierId_fkey"
+ columns: ["preferredSupplierId"]
isOneToOne: false
- referencedRelation: "part"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "purchaseOrderSuppliers"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "partInventory_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "itemReplenishment_preferredSupplierId_fkey"
+ columns: ["preferredSupplierId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["partId", "companyId"]
+ referencedRelation: "supplier"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "partInventory_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "itemReplenishment_preferredSupplierId_fkey"
+ columns: ["preferredSupplierId"]
isOneToOne: false
- referencedRelation: "parts"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "suppliers"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "partInventory_shelfId_fkey"
- columns: ["defaultShelfId", "locationId"]
+ foreignKeyName: "itemReplenishment_purchaseUnitOfMeasureCode_fkey"
+ columns: ["purchasingUnitOfMeasureCode", "companyId"]
isOneToOne: false
- referencedRelation: "shelf"
- referencedColumns: ["id", "locationId"]
+ referencedRelation: "unitOfMeasure"
+ referencedColumns: ["code", "companyId"]
},
{
- foreignKeyName: "partInventory_updatedBy_fkey"
+ foreignKeyName: "itemReplenishment_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partInventory_updatedBy_fkey"
+ foreignKeyName: "itemReplenishment_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partInventory_updatedBy_fkey"
+ foreignKeyName: "itemReplenishment_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partInventory_updatedBy_fkey"
+ foreignKeyName: "itemReplenishment_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partInventory_updatedBy_fkey"
+ foreignKeyName: "itemReplenishment_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "userDefaults"
@@ -6726,290 +6606,376 @@ export type Database = {
},
]
}
- partLedger: {
+ itemSupplier: {
Row: {
+ active: boolean
companyId: string
+ conversionFactor: number
createdAt: string
- documentId: string | null
- documentType:
- | Database["public"]["Enums"]["partLedgerDocumentType"]
- | null
- entryNumber: number
- entryType: Database["public"]["Enums"]["partLedgerType"]
- externalDocumentId: string | null
+ createdBy: string
+ customFields: Json | null
id: string
- locationId: string | null
- partId: string
- postingDate: string
- quantity: number
- shelfId: string | null
+ itemId: string
+ minimumOrderQuantity: number | null
+ supplierId: string
+ supplierPartId: string | null
+ supplierUnitOfMeasureCode: string | null
+ unitPrice: number | null
+ updatedAt: string | null
+ updatedBy: string | null
}
Insert: {
+ active?: boolean
companyId: string
+ conversionFactor?: number
createdAt?: string
- documentId?: string | null
- documentType?:
- | Database["public"]["Enums"]["partLedgerDocumentType"]
- | null
- entryNumber?: number
- entryType: Database["public"]["Enums"]["partLedgerType"]
- externalDocumentId?: string | null
+ createdBy: string
+ customFields?: Json | null
id?: string
- locationId?: string | null
- partId: string
- postingDate?: string
- quantity: number
- shelfId?: string | null
+ itemId: string
+ minimumOrderQuantity?: number | null
+ supplierId: string
+ supplierPartId?: string | null
+ supplierUnitOfMeasureCode?: string | null
+ unitPrice?: number | null
+ updatedAt?: string | null
+ updatedBy?: string | null
}
Update: {
+ active?: boolean
companyId?: string
+ conversionFactor?: number
createdAt?: string
- documentId?: string | null
- documentType?:
- | Database["public"]["Enums"]["partLedgerDocumentType"]
- | null
- entryNumber?: number
- entryType?: Database["public"]["Enums"]["partLedgerType"]
- externalDocumentId?: string | null
+ createdBy?: string
+ customFields?: Json | null
id?: string
- locationId?: string | null
- partId?: string
- postingDate?: string
- quantity?: number
- shelfId?: string | null
+ itemId?: string
+ minimumOrderQuantity?: number | null
+ supplierId?: string
+ supplierPartId?: string | null
+ supplierUnitOfMeasureCode?: string | null
+ unitPrice?: number | null
+ updatedAt?: string | null
+ updatedBy?: string | null
}
Relationships: [
{
- foreignKeyName: "partLedger_locationId_fkey"
- columns: ["locationId"]
+ foreignKeyName: "itemSupplier_companyId_fkey"
+ columns: ["companyId"]
isOneToOne: false
- referencedRelation: "location"
+ referencedRelation: "companies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partLedger_locationId_fkey"
- columns: ["locationId"]
+ foreignKeyName: "itemSupplier_companyId_fkey"
+ columns: ["companyId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["locationId"]
+ referencedRelation: "company"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "partLedger_locationId_fkey"
- columns: ["locationId"]
+ foreignKeyName: "itemSupplier_companyId_fkey"
+ columns: ["companyId"]
isOneToOne: false
- referencedRelation: "purchaseOrders"
- referencedColumns: ["locationId"]
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
},
{
- foreignKeyName: "partLedger_locationId_fkey"
- columns: ["locationId"]
+ foreignKeyName: "itemSupplier_companyId_fkey"
+ columns: ["companyId"]
isOneToOne: false
- referencedRelation: "salesOrders"
- referencedColumns: ["locationId"]
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
},
{
- foreignKeyName: "partLedger_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "itemSupplier_createdBy_fkey"
+ columns: ["createdBy"]
isOneToOne: false
- referencedRelation: "part"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "partLedger_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "itemSupplier_createdBy_fkey"
+ columns: ["createdBy"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["partId", "companyId"]
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "partLedger_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "itemSupplier_createdBy_fkey"
+ columns: ["createdBy"]
isOneToOne: false
- referencedRelation: "parts"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "partLedger_shelfId_fkey"
- columns: ["shelfId", "locationId"]
+ foreignKeyName: "itemSupplier_createdBy_fkey"
+ columns: ["createdBy"]
isOneToOne: false
- referencedRelation: "shelf"
- referencedColumns: ["id", "locationId"]
+ referencedRelation: "user"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "partLeger_companyId_fkey"
- columns: ["companyId"]
+ foreignKeyName: "itemSupplier_createdBy_fkey"
+ columns: ["createdBy"]
isOneToOne: false
- referencedRelation: "companies"
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "itemSupplier_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "item"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partLeger_companyId_fkey"
- columns: ["companyId"]
+ foreignKeyName: "itemSupplier_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "company"
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
+ },
+ {
+ foreignKeyName: "itemSupplier_supplierId_fkey"
+ columns: ["supplierId"]
+ isOneToOne: false
+ referencedRelation: "contractors"
+ referencedColumns: ["supplierId"]
+ },
+ {
+ foreignKeyName: "itemSupplier_supplierId_fkey"
+ columns: ["supplierId"]
+ isOneToOne: false
+ referencedRelation: "partners"
+ referencedColumns: ["supplierId"]
+ },
+ {
+ foreignKeyName: "itemSupplier_supplierId_fkey"
+ columns: ["supplierId"]
+ isOneToOne: false
+ referencedRelation: "purchaseOrderSuppliers"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partLeger_companyId_fkey"
- columns: ["companyId"]
+ foreignKeyName: "itemSupplier_supplierId_fkey"
+ columns: ["supplierId"]
isOneToOne: false
- referencedRelation: "customFieldTables"
- referencedColumns: ["companyId"]
+ referencedRelation: "supplier"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "partLeger_companyId_fkey"
- columns: ["companyId"]
+ foreignKeyName: "itemSupplier_supplierId_fkey"
+ columns: ["supplierId"]
+ isOneToOne: false
+ referencedRelation: "suppliers"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemSupplier_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemSupplier_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemSupplier_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemSupplier_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemSupplier_updatedBy_fkey"
+ columns: ["updatedBy"]
isOneToOne: false
- referencedRelation: "integrations"
- referencedColumns: ["companyId"]
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
},
]
}
- partner: {
+ itemUnitSalePrice: {
Row: {
- abilityId: string
- active: boolean
+ allowInvoiceDiscount: boolean
companyId: string
createdAt: string
createdBy: string
+ currencyCode: string
customFields: Json | null
- hoursPerWeek: number
- id: string
+ itemId: string
+ priceIncludesTax: boolean
+ salesBlocked: boolean
+ salesUnitOfMeasureCode: string | null
+ unitSalePrice: number
updatedAt: string | null
updatedBy: string | null
}
Insert: {
- abilityId: string
- active?: boolean
+ allowInvoiceDiscount?: boolean
companyId: string
createdAt?: string
createdBy: string
+ currencyCode: string
customFields?: Json | null
- hoursPerWeek?: number
- id: string
+ itemId: string
+ priceIncludesTax?: boolean
+ salesBlocked?: boolean
+ salesUnitOfMeasureCode?: string | null
+ unitSalePrice?: number
updatedAt?: string | null
updatedBy?: string | null
}
Update: {
- abilityId?: string
- active?: boolean
+ allowInvoiceDiscount?: boolean
companyId?: string
createdAt?: string
createdBy?: string
+ currencyCode?: string
customFields?: Json | null
- hoursPerWeek?: number
- id?: string
+ itemId?: string
+ priceIncludesTax?: boolean
+ salesBlocked?: boolean
+ salesUnitOfMeasureCode?: string | null
+ unitSalePrice?: number
updatedAt?: string | null
updatedBy?: string | null
}
Relationships: [
{
- foreignKeyName: "partner_abilityId_fkey"
- columns: ["abilityId"]
- isOneToOne: false
- referencedRelation: "ability"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "partner_companyId_fkey"
+ foreignKeyName: "itemUnitSalePrice_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "companies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partner_companyId_fkey"
+ foreignKeyName: "itemUnitSalePrice_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "company"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partner_companyId_fkey"
+ foreignKeyName: "itemUnitSalePrice_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "customFieldTables"
referencedColumns: ["companyId"]
},
{
- foreignKeyName: "partner_companyId_fkey"
+ foreignKeyName: "itemUnitSalePrice_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "integrations"
referencedColumns: ["companyId"]
},
{
- foreignKeyName: "partner_createdBy_fkey"
+ foreignKeyName: "itemUnitSalePrice_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partner_createdBy_fkey"
+ foreignKeyName: "itemUnitSalePrice_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partner_createdBy_fkey"
+ foreignKeyName: "itemUnitSalePrice_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partner_createdBy_fkey"
+ foreignKeyName: "itemUnitSalePrice_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partner_createdBy_fkey"
+ foreignKeyName: "itemUnitSalePrice_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
{
- foreignKeyName: "partner_id_fkey"
- columns: ["id"]
+ foreignKeyName: "itemUnitSalePrice_currencyCode_fkey"
+ columns: ["currencyCode", "companyId"]
isOneToOne: false
- referencedRelation: "supplierLocation"
+ referencedRelation: "currency"
+ referencedColumns: ["code", "companyId"]
+ },
+ {
+ foreignKeyName: "itemUnitSalePrice_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "item"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partner_updatedBy_fkey"
+ foreignKeyName: "itemUnitSalePrice_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
+ },
+ {
+ foreignKeyName: "itemUnitSalePrice_salesUnitOfMeasureId_fkey"
+ columns: ["salesUnitOfMeasureCode", "companyId"]
+ isOneToOne: false
+ referencedRelation: "unitOfMeasure"
+ referencedColumns: ["code", "companyId"]
+ },
+ {
+ foreignKeyName: "itemUnitSalePrice_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partner_updatedBy_fkey"
+ foreignKeyName: "itemUnitSalePrice_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partner_updatedBy_fkey"
+ foreignKeyName: "itemUnitSalePrice_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partner_updatedBy_fkey"
+ foreignKeyName: "itemUnitSalePrice_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partner_updatedBy_fkey"
+ foreignKeyName: "itemUnitSalePrice_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "userDefaults"
@@ -7017,653 +6983,675 @@ export type Database = {
},
]
}
- partPlanning: {
+ journal: {
Row: {
+ accountingPeriodId: string | null
companyId: string
createdAt: string
- createdBy: string
- critical: boolean
customFields: Json | null
- demandAccumulationIncludesInventory: boolean
- demandAccumulationPeriod: number
- demandReschedulingPeriod: number
- locationId: string
- maximumOrderQuantity: number
- minimumOrderQuantity: number
- orderMultiple: number
- partId: string
- reorderingPolicy: Database["public"]["Enums"]["partReorderingPolicy"]
- reorderMaximumInventory: number
- reorderPoint: number
- reorderQuantity: number
- safetyStockLeadTime: number
- safetyStockQuantity: number
- updatedAt: string | null
- updatedBy: string | null
+ description: string | null
+ id: number
+ postingDate: string
}
Insert: {
+ accountingPeriodId?: string | null
companyId: string
createdAt?: string
- createdBy: string
- critical?: boolean
customFields?: Json | null
- demandAccumulationIncludesInventory?: boolean
- demandAccumulationPeriod?: number
- demandReschedulingPeriod?: number
- locationId: string
- maximumOrderQuantity?: number
- minimumOrderQuantity?: number
- orderMultiple?: number
- partId: string
- reorderingPolicy?: Database["public"]["Enums"]["partReorderingPolicy"]
- reorderMaximumInventory?: number
- reorderPoint?: number
- reorderQuantity?: number
- safetyStockLeadTime?: number
- safetyStockQuantity?: number
- updatedAt?: string | null
- updatedBy?: string | null
+ description?: string | null
+ id?: number
+ postingDate?: string
}
Update: {
+ accountingPeriodId?: string | null
companyId?: string
createdAt?: string
- createdBy?: string
- critical?: boolean
customFields?: Json | null
- demandAccumulationIncludesInventory?: boolean
- demandAccumulationPeriod?: number
- demandReschedulingPeriod?: number
- locationId?: string
- maximumOrderQuantity?: number
- minimumOrderQuantity?: number
- orderMultiple?: number
- partId?: string
- reorderingPolicy?: Database["public"]["Enums"]["partReorderingPolicy"]
- reorderMaximumInventory?: number
- reorderPoint?: number
- reorderQuantity?: number
- safetyStockLeadTime?: number
- safetyStockQuantity?: number
- updatedAt?: string | null
- updatedBy?: string | null
+ description?: string | null
+ id?: number
+ postingDate?: string
}
Relationships: [
{
- foreignKeyName: "partPlanning_companyId_fkey"
+ foreignKeyName: "journal_accountPeriodId_fkey"
+ columns: ["accountingPeriodId"]
+ isOneToOne: false
+ referencedRelation: "accountingPeriod"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "journal_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "companies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partPlanning_companyId_fkey"
+ foreignKeyName: "journal_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "company"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partPlanning_companyId_fkey"
+ foreignKeyName: "journal_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "customFieldTables"
referencedColumns: ["companyId"]
},
{
- foreignKeyName: "partPlanning_companyId_fkey"
+ foreignKeyName: "journal_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "integrations"
referencedColumns: ["companyId"]
},
+ ]
+ }
+ journalLine: {
+ Row: {
+ accountNumber: string
+ accrual: boolean
+ amount: number
+ companyId: string
+ createdAt: string
+ customFields: Json | null
+ description: string | null
+ documentId: string | null
+ documentLineReference: string | null
+ documentType:
+ | Database["public"]["Enums"]["journalLineDocumentType"]
+ | null
+ externalDocumentId: string | null
+ id: string
+ journalId: number
+ journalLineReference: string
+ quantity: number
+ }
+ Insert: {
+ accountNumber: string
+ accrual?: boolean
+ amount: number
+ companyId: string
+ createdAt?: string
+ customFields?: Json | null
+ description?: string | null
+ documentId?: string | null
+ documentLineReference?: string | null
+ documentType?:
+ | Database["public"]["Enums"]["journalLineDocumentType"]
+ | null
+ externalDocumentId?: string | null
+ id?: string
+ journalId: number
+ journalLineReference: string
+ quantity?: number
+ }
+ Update: {
+ accountNumber?: string
+ accrual?: boolean
+ amount?: number
+ companyId?: string
+ createdAt?: string
+ customFields?: Json | null
+ description?: string | null
+ documentId?: string | null
+ documentLineReference?: string | null
+ documentType?:
+ | Database["public"]["Enums"]["journalLineDocumentType"]
+ | null
+ externalDocumentId?: string | null
+ id?: string
+ journalId?: number
+ journalLineReference?: string
+ quantity?: number
+ }
+ Relationships: [
{
- foreignKeyName: "partPlanning_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "partPlanning_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "partPlanning_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "partPlanning_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "partPlanning_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
- {
- foreignKeyName: "partPlanning_locationId_fkey"
- columns: ["locationId"]
- isOneToOne: false
- referencedRelation: "location"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "partPlanning_locationId_fkey"
- columns: ["locationId"]
- isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["locationId"]
- },
- {
- foreignKeyName: "partPlanning_locationId_fkey"
- columns: ["locationId"]
- isOneToOne: false
- referencedRelation: "purchaseOrders"
- referencedColumns: ["locationId"]
- },
- {
- foreignKeyName: "partPlanning_locationId_fkey"
- columns: ["locationId"]
- isOneToOne: false
- referencedRelation: "salesOrders"
- referencedColumns: ["locationId"]
- },
- {
- foreignKeyName: "partPlanning_partId_fkey"
- columns: ["partId", "companyId"]
- isOneToOne: false
- referencedRelation: "part"
- referencedColumns: ["id", "companyId"]
- },
- {
- foreignKeyName: "partPlanning_partId_fkey"
- columns: ["partId", "companyId"]
- isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["partId", "companyId"]
- },
- {
- foreignKeyName: "partPlanning_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "journalLine_accountNumber_fkey"
+ columns: ["accountNumber", "companyId"]
isOneToOne: false
- referencedRelation: "parts"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "account"
+ referencedColumns: ["number", "companyId"]
},
{
- foreignKeyName: "partPlanning_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "journalLine_accountNumber_fkey"
+ columns: ["accountNumber", "companyId"]
isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
+ referencedRelation: "accounts"
+ referencedColumns: ["number", "companyId"]
},
{
- foreignKeyName: "partPlanning_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "journalLine_companyId_fkey"
+ columns: ["companyId"]
isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
+ referencedRelation: "companies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partPlanning_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "journalLine_companyId_fkey"
+ columns: ["companyId"]
isOneToOne: false
- referencedRelation: "employeeSummary"
+ referencedRelation: "company"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partPlanning_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "journalLine_companyId_fkey"
+ columns: ["companyId"]
isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
},
{
- foreignKeyName: "partPlanning_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "journalLine_companyId_fkey"
+ columns: ["companyId"]
isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
},
]
}
- partReplenishment: {
+ location: {
Row: {
+ addressLine1: string
+ addressLine2: string | null
+ city: string
companyId: string
- conversionFactor: number
+ countryCode: string | null
createdAt: string
createdBy: string
customFields: Json | null
- lotSize: number | null
- manufacturingBlocked: boolean
- manufacturingLeadTime: number
- manufacturingPolicy: Database["public"]["Enums"]["partManufacturingPolicy"]
- partId: string
- preferredSupplierId: string | null
- purchasingBlocked: boolean
- purchasingLeadTime: number
- purchasingUnitOfMeasureCode: string | null
- requiresConfiguration: boolean
- scrapPercentage: number
+ id: string
+ latitude: number | null
+ longitude: number | null
+ name: string
+ postalCode: string
+ state: string
+ timezone: string
updatedAt: string | null
updatedBy: string | null
}
Insert: {
+ addressLine1: string
+ addressLine2?: string | null
+ city: string
companyId: string
- conversionFactor?: number
+ countryCode?: string | null
createdAt?: string
createdBy: string
customFields?: Json | null
- lotSize?: number | null
- manufacturingBlocked?: boolean
- manufacturingLeadTime?: number
- manufacturingPolicy?: Database["public"]["Enums"]["partManufacturingPolicy"]
- partId: string
- preferredSupplierId?: string | null
- purchasingBlocked?: boolean
- purchasingLeadTime?: number
- purchasingUnitOfMeasureCode?: string | null
- requiresConfiguration?: boolean
- scrapPercentage?: number
+ id?: string
+ latitude?: number | null
+ longitude?: number | null
+ name: string
+ postalCode: string
+ state: string
+ timezone: string
updatedAt?: string | null
updatedBy?: string | null
}
Update: {
+ addressLine1?: string
+ addressLine2?: string | null
+ city?: string
companyId?: string
- conversionFactor?: number
+ countryCode?: string | null
createdAt?: string
createdBy?: string
customFields?: Json | null
- lotSize?: number | null
- manufacturingBlocked?: boolean
- manufacturingLeadTime?: number
- manufacturingPolicy?: Database["public"]["Enums"]["partManufacturingPolicy"]
- partId?: string
- preferredSupplierId?: string | null
- purchasingBlocked?: boolean
- purchasingLeadTime?: number
- purchasingUnitOfMeasureCode?: string | null
- requiresConfiguration?: boolean
- scrapPercentage?: number
+ id?: string
+ latitude?: number | null
+ longitude?: number | null
+ name?: string
+ postalCode?: string
+ state?: string
+ timezone?: string
updatedAt?: string | null
updatedBy?: string | null
}
Relationships: [
{
- foreignKeyName: "partReplenishment_companyId_fkey"
+ foreignKeyName: "location_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "companies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partReplenishment_companyId_fkey"
+ foreignKeyName: "location_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "company"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partReplenishment_companyId_fkey"
+ foreignKeyName: "location_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "customFieldTables"
referencedColumns: ["companyId"]
},
{
- foreignKeyName: "partReplenishment_companyId_fkey"
+ foreignKeyName: "location_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "integrations"
referencedColumns: ["companyId"]
},
+ ]
+ }
+ membership: {
+ Row: {
+ groupId: string
+ id: number
+ memberGroupId: string | null
+ memberUserId: string | null
+ }
+ Insert: {
+ groupId: string
+ id?: number
+ memberGroupId?: string | null
+ memberUserId?: string | null
+ }
+ Update: {
+ groupId?: string
+ id?: number
+ memberGroupId?: string | null
+ memberUserId?: string | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "membership_groupId_fkey"
+ columns: ["groupId"]
+ isOneToOne: false
+ referencedRelation: "group"
+ referencedColumns: ["id"]
+ },
{
- foreignKeyName: "partReplenishment_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "membership_memberGroupId_fkey"
+ columns: ["memberGroupId"]
+ isOneToOne: false
+ referencedRelation: "group"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "membership_memberUserId_fkey"
+ columns: ["memberUserId"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partReplenishment_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "membership_memberUserId_fkey"
+ columns: ["memberUserId"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partReplenishment_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "membership_memberUserId_fkey"
+ columns: ["memberUserId"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partReplenishment_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "membership_memberUserId_fkey"
+ columns: ["memberUserId"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partReplenishment_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "membership_memberUserId_fkey"
+ columns: ["memberUserId"]
isOneToOne: false
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
+ ]
+ }
+ note: {
+ Row: {
+ active: boolean
+ companyId: string
+ createdAt: string
+ createdBy: string
+ documentId: string
+ id: string
+ note: string
+ noteRichText: Json
+ updatedAt: string | null
+ }
+ Insert: {
+ active?: boolean
+ companyId: string
+ createdAt?: string
+ createdBy: string
+ documentId: string
+ id?: string
+ note: string
+ noteRichText?: Json
+ updatedAt?: string | null
+ }
+ Update: {
+ active?: boolean
+ companyId?: string
+ createdAt?: string
+ createdBy?: string
+ documentId?: string
+ id?: string
+ note?: string
+ noteRichText?: Json
+ updatedAt?: string | null
+ }
+ Relationships: [
{
- foreignKeyName: "partReplenishment_partId_fkey"
- columns: ["partId", "companyId"]
- isOneToOne: false
- referencedRelation: "part"
- referencedColumns: ["id", "companyId"]
- },
- {
- foreignKeyName: "partReplenishment_partId_fkey"
- columns: ["partId", "companyId"]
- isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["partId", "companyId"]
- },
- {
- foreignKeyName: "partReplenishment_partId_fkey"
- columns: ["partId", "companyId"]
- isOneToOne: false
- referencedRelation: "parts"
- referencedColumns: ["id", "companyId"]
- },
- {
- foreignKeyName: "partReplenishment_preferredSupplierId_fkey"
- columns: ["preferredSupplierId"]
- isOneToOne: false
- referencedRelation: "contractors"
- referencedColumns: ["supplierId"]
- },
- {
- foreignKeyName: "partReplenishment_preferredSupplierId_fkey"
- columns: ["preferredSupplierId"]
- isOneToOne: false
- referencedRelation: "partners"
- referencedColumns: ["supplierId"]
- },
- {
- foreignKeyName: "partReplenishment_preferredSupplierId_fkey"
- columns: ["preferredSupplierId"]
+ foreignKeyName: "notes_companyId_fkey"
+ columns: ["companyId"]
isOneToOne: false
- referencedRelation: "purchaseOrderSuppliers"
+ referencedRelation: "companies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partReplenishment_preferredSupplierId_fkey"
- columns: ["preferredSupplierId"]
+ foreignKeyName: "notes_companyId_fkey"
+ columns: ["companyId"]
isOneToOne: false
- referencedRelation: "supplier"
+ referencedRelation: "company"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partReplenishment_preferredSupplierId_fkey"
- columns: ["preferredSupplierId"]
+ foreignKeyName: "notes_companyId_fkey"
+ columns: ["companyId"]
isOneToOne: false
- referencedRelation: "suppliers"
- referencedColumns: ["id"]
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
},
{
- foreignKeyName: "partReplenishment_purchaseUnitOfMeasureCode_fkey"
- columns: ["purchasingUnitOfMeasureCode", "companyId"]
+ foreignKeyName: "notes_companyId_fkey"
+ columns: ["companyId"]
isOneToOne: false
- referencedRelation: "unitOfMeasure"
- referencedColumns: ["code", "companyId"]
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
},
{
- foreignKeyName: "partReplenishment_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "notes_createdBy_fkey"
+ columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partReplenishment_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "notes_createdBy_fkey"
+ columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partReplenishment_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "notes_createdBy_fkey"
+ columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partReplenishment_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "notes_createdBy_fkey"
+ columns: ["createdBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partReplenishment_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "notes_createdBy_fkey"
+ columns: ["createdBy"]
isOneToOne: false
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
]
}
- partSupplier: {
+ part: {
Row: {
- active: boolean
+ approved: boolean
+ approvedBy: string | null
+ assignee: string | null
companyId: string
- conversionFactor: number
createdAt: string
createdBy: string
customFields: Json | null
+ fromDate: string | null
id: string
- minimumOrderQuantity: number | null
- partId: string
- supplierId: string
- supplierPartId: string | null
- supplierUnitOfMeasureCode: string | null
- unitPrice: number | null
+ itemId: string
+ partType: Database["public"]["Enums"]["partType"]
+ replenishmentSystem: Database["public"]["Enums"]["itemReplenishmentSystem"]
+ toDate: string | null
+ unitOfMeasureCode: string
updatedAt: string | null
updatedBy: string | null
}
Insert: {
- active?: boolean
+ approved?: boolean
+ approvedBy?: string | null
+ assignee?: string | null
companyId: string
- conversionFactor?: number
createdAt?: string
createdBy: string
customFields?: Json | null
- id?: string
- minimumOrderQuantity?: number | null
- partId: string
- supplierId: string
- supplierPartId?: string | null
- supplierUnitOfMeasureCode?: string | null
- unitPrice?: number | null
+ fromDate?: string | null
+ id: string
+ itemId: string
+ partType: Database["public"]["Enums"]["partType"]
+ replenishmentSystem: Database["public"]["Enums"]["itemReplenishmentSystem"]
+ toDate?: string | null
+ unitOfMeasureCode: string
updatedAt?: string | null
updatedBy?: string | null
}
Update: {
- active?: boolean
+ approved?: boolean
+ approvedBy?: string | null
+ assignee?: string | null
companyId?: string
- conversionFactor?: number
createdAt?: string
createdBy?: string
customFields?: Json | null
+ fromDate?: string | null
id?: string
- minimumOrderQuantity?: number | null
- partId?: string
- supplierId?: string
- supplierPartId?: string | null
- supplierUnitOfMeasureCode?: string | null
- unitPrice?: number | null
+ itemId?: string
+ partType?: Database["public"]["Enums"]["partType"]
+ replenishmentSystem?: Database["public"]["Enums"]["itemReplenishmentSystem"]
+ toDate?: string | null
+ unitOfMeasureCode?: string
updatedAt?: string | null
updatedBy?: string | null
}
Relationships: [
{
- foreignKeyName: "partSupplier_companyId_fkey"
- columns: ["companyId"]
+ foreignKeyName: "part_approvedBy_fkey"
+ columns: ["approvedBy"]
isOneToOne: false
- referencedRelation: "companies"
+ referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partSupplier_companyId_fkey"
- columns: ["companyId"]
+ foreignKeyName: "part_approvedBy_fkey"
+ columns: ["approvedBy"]
isOneToOne: false
- referencedRelation: "company"
+ referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partSupplier_companyId_fkey"
- columns: ["companyId"]
+ foreignKeyName: "part_approvedBy_fkey"
+ columns: ["approvedBy"]
isOneToOne: false
- referencedRelation: "customFieldTables"
- referencedColumns: ["companyId"]
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "partSupplier_companyId_fkey"
- columns: ["companyId"]
+ foreignKeyName: "part_approvedBy_fkey"
+ columns: ["approvedBy"]
isOneToOne: false
- referencedRelation: "integrations"
- referencedColumns: ["companyId"]
+ referencedRelation: "user"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "partSupplier_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "part_approvedBy_fkey"
+ columns: ["approvedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "part_assignee_fkey"
+ columns: ["assignee"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partSupplier_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "part_assignee_fkey"
+ columns: ["assignee"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partSupplier_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "part_assignee_fkey"
+ columns: ["assignee"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partSupplier_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "part_assignee_fkey"
+ columns: ["assignee"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partSupplier_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "part_assignee_fkey"
+ columns: ["assignee"]
isOneToOne: false
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
{
- foreignKeyName: "partSupplier_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "part_companyId_fkey"
+ columns: ["companyId"]
isOneToOne: false
- referencedRelation: "part"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "partSupplier_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "part_companyId_fkey"
+ columns: ["companyId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["partId", "companyId"]
+ referencedRelation: "company"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "partSupplier_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "part_companyId_fkey"
+ columns: ["companyId"]
isOneToOne: false
- referencedRelation: "parts"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
},
{
- foreignKeyName: "partSupplier_supplierId_fkey"
- columns: ["supplierId"]
+ foreignKeyName: "part_companyId_fkey"
+ columns: ["companyId"]
isOneToOne: false
- referencedRelation: "contractors"
- referencedColumns: ["supplierId"]
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
},
{
- foreignKeyName: "partSupplier_supplierId_fkey"
- columns: ["supplierId"]
+ foreignKeyName: "part_createdBy_fkey"
+ columns: ["createdBy"]
isOneToOne: false
- referencedRelation: "partners"
- referencedColumns: ["supplierId"]
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "partSupplier_supplierId_fkey"
- columns: ["supplierId"]
+ foreignKeyName: "part_createdBy_fkey"
+ columns: ["createdBy"]
isOneToOne: false
- referencedRelation: "purchaseOrderSuppliers"
+ referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partSupplier_supplierId_fkey"
- columns: ["supplierId"]
+ foreignKeyName: "part_createdBy_fkey"
+ columns: ["createdBy"]
isOneToOne: false
- referencedRelation: "supplier"
+ referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partSupplier_supplierId_fkey"
- columns: ["supplierId"]
+ foreignKeyName: "part_createdBy_fkey"
+ columns: ["createdBy"]
isOneToOne: false
- referencedRelation: "suppliers"
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "part_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "part_id_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "item"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partSupplier_updatedBy_fkey"
+ foreignKeyName: "part_id_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
+ },
+ {
+ foreignKeyName: "part_unitOfMeasureCode_fkey"
+ columns: ["unitOfMeasureCode", "companyId"]
+ isOneToOne: false
+ referencedRelation: "unitOfMeasure"
+ referencedColumns: ["code", "companyId"]
+ },
+ {
+ foreignKeyName: "part_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partSupplier_updatedBy_fkey"
+ foreignKeyName: "part_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partSupplier_updatedBy_fkey"
+ foreignKeyName: "part_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partSupplier_updatedBy_fkey"
+ foreignKeyName: "part_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partSupplier_updatedBy_fkey"
+ foreignKeyName: "part_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "userDefaults"
@@ -7671,181 +7659,151 @@ export type Database = {
},
]
}
- partUnitSalePrice: {
+ partner: {
Row: {
- allowInvoiceDiscount: boolean
+ abilityId: string
+ active: boolean
companyId: string
createdAt: string
createdBy: string
- currencyCode: string
customFields: Json | null
- partId: string
- priceIncludesTax: boolean
- salesBlocked: boolean
- salesUnitOfMeasureCode: string | null
- unitSalePrice: number
+ hoursPerWeek: number
+ id: string
updatedAt: string | null
updatedBy: string | null
}
Insert: {
- allowInvoiceDiscount?: boolean
+ abilityId: string
+ active?: boolean
companyId: string
createdAt?: string
createdBy: string
- currencyCode: string
customFields?: Json | null
- partId: string
- priceIncludesTax?: boolean
- salesBlocked?: boolean
- salesUnitOfMeasureCode?: string | null
- unitSalePrice?: number
+ hoursPerWeek?: number
+ id: string
updatedAt?: string | null
updatedBy?: string | null
}
Update: {
- allowInvoiceDiscount?: boolean
+ abilityId?: string
+ active?: boolean
companyId?: string
createdAt?: string
createdBy?: string
- currencyCode?: string
customFields?: Json | null
- partId?: string
- priceIncludesTax?: boolean
- salesBlocked?: boolean
- salesUnitOfMeasureCode?: string | null
- unitSalePrice?: number
+ hoursPerWeek?: number
+ id?: string
updatedAt?: string | null
updatedBy?: string | null
}
Relationships: [
{
- foreignKeyName: "partUnitSalePrice_companyId_fkey"
+ foreignKeyName: "partner_abilityId_fkey"
+ columns: ["abilityId"]
+ isOneToOne: false
+ referencedRelation: "ability"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "partner_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "companies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partUnitSalePrice_companyId_fkey"
+ foreignKeyName: "partner_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "company"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partUnitSalePrice_companyId_fkey"
+ foreignKeyName: "partner_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "customFieldTables"
referencedColumns: ["companyId"]
},
{
- foreignKeyName: "partUnitSalePrice_companyId_fkey"
+ foreignKeyName: "partner_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "integrations"
referencedColumns: ["companyId"]
},
{
- foreignKeyName: "partUnitSalePrice_createdBy_fkey"
+ foreignKeyName: "partner_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partUnitSalePrice_createdBy_fkey"
+ foreignKeyName: "partner_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partUnitSalePrice_createdBy_fkey"
+ foreignKeyName: "partner_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "partUnitSalePrice_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "partUnitSalePrice_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
- {
- foreignKeyName: "partUnitSalePrice_currencyCode_fkey"
- columns: ["currencyCode", "companyId"]
- isOneToOne: false
- referencedRelation: "currency"
- referencedColumns: ["code", "companyId"]
- },
- {
- foreignKeyName: "partUnitSalePrice_partId_fkey"
- columns: ["partId", "companyId"]
- isOneToOne: false
- referencedRelation: "part"
- referencedColumns: ["id", "companyId"]
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "partUnitSalePrice_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "partner_createdBy_fkey"
+ columns: ["createdBy"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["partId", "companyId"]
+ referencedRelation: "user"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "partUnitSalePrice_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "partner_createdBy_fkey"
+ columns: ["createdBy"]
isOneToOne: false
- referencedRelation: "parts"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
},
{
- foreignKeyName: "partUnitSalePrice_salesUnitOfMeasureId_fkey"
- columns: ["salesUnitOfMeasureCode", "companyId"]
+ foreignKeyName: "partner_id_fkey"
+ columns: ["id"]
isOneToOne: false
- referencedRelation: "unitOfMeasure"
- referencedColumns: ["code", "companyId"]
+ referencedRelation: "supplierLocation"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "partUnitSalePrice_updatedBy_fkey"
+ foreignKeyName: "partner_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partUnitSalePrice_updatedBy_fkey"
+ foreignKeyName: "partner_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partUnitSalePrice_updatedBy_fkey"
+ foreignKeyName: "partner_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partUnitSalePrice_updatedBy_fkey"
+ foreignKeyName: "partner_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "partUnitSalePrice_updatedBy_fkey"
+ foreignKeyName: "partner_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "userDefaults"
@@ -8202,15 +8160,15 @@ export type Database = {
foreignKeyName: "postingGroupInventory_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "location"
- referencedColumns: ["id"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["locationId"]
},
{
foreignKeyName: "postingGroupInventory_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["locationId"]
+ referencedRelation: "location"
+ referencedColumns: ["id"]
},
{
foreignKeyName: "postingGroupInventory_locationId_fkey"
@@ -9079,8 +9037,9 @@ export type Database = {
inventoryUnitOfMeasureCode: string | null
invoiceId: string
invoiceLineType: Database["public"]["Enums"]["payableLineType"]
+ itemId: string | null
+ itemReadableId: string | null
locationId: string | null
- partId: string | null
purchaseOrderId: string | null
purchaseOrderLineId: string | null
purchaseUnitOfMeasureCode: string | null
@@ -9107,8 +9066,9 @@ export type Database = {
inventoryUnitOfMeasureCode?: string | null
invoiceId: string
invoiceLineType: Database["public"]["Enums"]["payableLineType"]
+ itemId?: string | null
+ itemReadableId?: string | null
locationId?: string | null
- partId?: string | null
purchaseOrderId?: string | null
purchaseOrderLineId?: string | null
purchaseUnitOfMeasureCode?: string | null
@@ -9135,8 +9095,9 @@ export type Database = {
inventoryUnitOfMeasureCode?: string | null
invoiceId?: string
invoiceLineType?: Database["public"]["Enums"]["payableLineType"]
+ itemId?: string | null
+ itemReadableId?: string | null
locationId?: string | null
- partId?: string | null
purchaseOrderId?: string | null
purchaseOrderLineId?: string | null
purchaseUnitOfMeasureCode?: string | null
@@ -9255,53 +9216,46 @@ export type Database = {
referencedColumns: ["id"]
},
{
- foreignKeyName: "purchaseInvoiceLines_locationId_fkey"
- columns: ["locationId"]
+ foreignKeyName: "purchaseInvoiceLines_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "location"
+ referencedRelation: "item"
referencedColumns: ["id"]
},
{
- foreignKeyName: "purchaseInvoiceLines_locationId_fkey"
- columns: ["locationId"]
+ foreignKeyName: "purchaseInvoiceLines_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["locationId"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
},
{
foreignKeyName: "purchaseInvoiceLines_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "purchaseOrders"
+ referencedRelation: "itemQuantities"
referencedColumns: ["locationId"]
},
{
foreignKeyName: "purchaseInvoiceLines_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "salesOrders"
- referencedColumns: ["locationId"]
- },
- {
- foreignKeyName: "purchaseInvoiceLines_partId_fkey"
- columns: ["partId", "companyId"]
- isOneToOne: false
- referencedRelation: "part"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "location"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "purchaseInvoiceLines_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "purchaseInvoiceLines_locationId_fkey"
+ columns: ["locationId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["partId", "companyId"]
+ referencedRelation: "purchaseOrders"
+ referencedColumns: ["locationId"]
},
{
- foreignKeyName: "purchaseInvoiceLines_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "purchaseInvoiceLines_locationId_fkey"
+ columns: ["locationId"]
isOneToOne: false
- referencedRelation: "parts"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "salesOrders"
+ referencedColumns: ["locationId"]
},
{
foreignKeyName: "purchaseInvoiceLines_purchaseOrderId_fkey"
@@ -9345,20 +9299,6 @@ export type Database = {
referencedRelation: "unitOfMeasure"
referencedColumns: ["code", "companyId"]
},
- {
- foreignKeyName: "purchaseInvoiceLines_serviceId_fkey"
- columns: ["serviceId", "companyId"]
- isOneToOne: false
- referencedRelation: "service"
- referencedColumns: ["id", "companyId"]
- },
- {
- foreignKeyName: "purchaseInvoiceLines_serviceId_fkey"
- columns: ["serviceId", "companyId"]
- isOneToOne: false
- referencedRelation: "services"
- referencedColumns: ["id", "companyId"]
- },
{
foreignKeyName: "purchaseInvoiceLines_shelfId_fkey"
columns: ["shelfId", "locationId"]
@@ -9965,15 +9905,15 @@ export type Database = {
foreignKeyName: "purchaseOrderDelivery_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "location"
- referencedColumns: ["id"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["locationId"]
},
{
foreignKeyName: "purchaseOrderDelivery_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["locationId"]
+ referencedRelation: "location"
+ referencedColumns: ["id"]
},
{
foreignKeyName: "purchaseOrderDelivery_locationId_fkey"
@@ -10125,8 +10065,9 @@ export type Database = {
id: string
inventoryUnitOfMeasureCode: string | null
invoicedComplete: boolean
+ itemId: string | null
+ itemReadableId: string | null
locationId: string | null
- partId: string | null
purchaseOrderId: string
purchaseOrderLineType: Database["public"]["Enums"]["purchaseOrderLineType"]
purchaseQuantity: number | null
@@ -10137,7 +10078,6 @@ export type Database = {
quantityToReceive: number | null
receivedComplete: boolean
requiresInspection: boolean
- serviceId: string | null
setupPrice: number | null
shelfId: string | null
unitPrice: number | null
@@ -10156,8 +10096,9 @@ export type Database = {
id?: string
inventoryUnitOfMeasureCode?: string | null
invoicedComplete?: boolean
+ itemId?: string | null
+ itemReadableId?: string | null
locationId?: string | null
- partId?: string | null
purchaseOrderId: string
purchaseOrderLineType: Database["public"]["Enums"]["purchaseOrderLineType"]
purchaseQuantity?: number | null
@@ -10168,7 +10109,6 @@ export type Database = {
quantityToReceive?: number | null
receivedComplete?: boolean
requiresInspection?: boolean
- serviceId?: string | null
setupPrice?: number | null
shelfId?: string | null
unitPrice?: number | null
@@ -10187,8 +10127,9 @@ export type Database = {
id?: string
inventoryUnitOfMeasureCode?: string | null
invoicedComplete?: boolean
+ itemId?: string | null
+ itemReadableId?: string | null
locationId?: string | null
- partId?: string | null
purchaseOrderId?: string
purchaseOrderLineType?: Database["public"]["Enums"]["purchaseOrderLineType"]
purchaseQuantity?: number | null
@@ -10199,7 +10140,6 @@ export type Database = {
quantityToReceive?: number | null
receivedComplete?: boolean
requiresInspection?: boolean
- serviceId?: string | null
setupPrice?: number | null
shelfId?: string | null
unitPrice?: number | null
@@ -10264,25 +10204,18 @@ export type Database = {
referencedColumns: ["code", "companyId"]
},
{
- foreignKeyName: "purchaseOrderLine_partId_fkey"
- columns: ["partId", "companyId"]
- isOneToOne: false
- referencedRelation: "part"
- referencedColumns: ["id", "companyId"]
- },
- {
- foreignKeyName: "purchaseOrderLine_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "purchaseOrderLine_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["partId", "companyId"]
+ referencedRelation: "item"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "purchaseOrderLine_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "purchaseOrderLine_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "parts"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
},
{
foreignKeyName: "purchaseOrderLine_purchaseOrderId_fkey"
@@ -10312,20 +10245,6 @@ export type Database = {
referencedRelation: "unitOfMeasure"
referencedColumns: ["code", "companyId"]
},
- {
- foreignKeyName: "purchaseOrderLine_serviceId_fkey"
- columns: ["serviceId", "companyId"]
- isOneToOne: false
- referencedRelation: "service"
- referencedColumns: ["id", "companyId"]
- },
- {
- foreignKeyName: "purchaseOrderLine_serviceId_fkey"
- columns: ["serviceId", "companyId"]
- isOneToOne: false
- referencedRelation: "services"
- referencedColumns: ["id", "companyId"]
- },
{
foreignKeyName: "purchaseOrderLine_shelfId_fkey"
columns: ["shelfId", "locationId"]
@@ -11053,15 +10972,15 @@ export type Database = {
foreignKeyName: "quote_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "location"
- referencedColumns: ["id"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["locationId"]
},
{
foreignKeyName: "quote_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["locationId"]
+ referencedRelation: "location"
+ referencedColumns: ["id"]
},
{
foreignKeyName: "quote_locationId_fkey"
@@ -11122,8 +11041,8 @@ export type Database = {
customFields: Json | null
description: string | null
id: string
+ itemId: string
parentAssemblyId: string | null
- partId: string
quantityPerParent: number
quoteId: string
quoteLineId: string
@@ -11138,8 +11057,8 @@ export type Database = {
customFields?: Json | null
description?: string | null
id?: string
+ itemId: string
parentAssemblyId?: string | null
- partId: string
quantityPerParent?: number
quoteId: string
quoteLineId: string
@@ -11154,8 +11073,8 @@ export type Database = {
customFields?: Json | null
description?: string | null
id?: string
+ itemId?: string
parentAssemblyId?: string | null
- partId?: string
quantityPerParent?: number
quoteId?: string
quoteLineId?: string
@@ -11228,32 +11147,25 @@ export type Database = {
referencedColumns: ["userId"]
},
{
- foreignKeyName: "quoteAssembly_parentAssemblyId_fkey"
- columns: ["parentAssemblyId"]
+ foreignKeyName: "quoteAssembly_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "quoteAssembly"
+ referencedRelation: "item"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteAssembly_partId_fkey"
- columns: ["partId", "companyId"]
- isOneToOne: false
- referencedRelation: "part"
- referencedColumns: ["id", "companyId"]
- },
- {
- foreignKeyName: "quoteAssembly_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "quoteAssembly_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["partId", "companyId"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
},
{
- foreignKeyName: "quoteAssembly_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "quoteAssembly_parentAssemblyId_fkey"
+ columns: ["parentAssemblyId"]
isOneToOne: false
- referencedRelation: "parts"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "quoteAssembly"
+ referencedColumns: ["id"]
},
{
foreignKeyName: "quoteAssembly_quoteId_fkey"
@@ -11415,7 +11327,7 @@ export type Database = {
customFields: Json | null
description: string
id: string
- partId: string
+ itemId: string
quoteId: string
quoteRevisionId: number
replenishmentSystem: string | null
@@ -11432,7 +11344,7 @@ export type Database = {
customFields?: Json | null
description: string
id?: string
- partId: string
+ itemId: string
quoteId: string
quoteRevisionId?: number
replenishmentSystem?: string | null
@@ -11449,7 +11361,7 @@ export type Database = {
customFields?: Json | null
description?: string
id?: string
- partId?: string
+ itemId?: string
quoteId?: string
quoteRevisionId?: number
replenishmentSystem?: string | null
@@ -11523,25 +11435,18 @@ export type Database = {
referencedColumns: ["userId"]
},
{
- foreignKeyName: "quoteLine_partId_fkey"
- columns: ["partId", "companyId"]
- isOneToOne: false
- referencedRelation: "part"
- referencedColumns: ["id", "companyId"]
- },
- {
- foreignKeyName: "quoteLine_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "quoteLine_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["partId", "companyId"]
+ referencedRelation: "item"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteLine_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "quoteLine_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "parts"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
},
{
foreignKeyName: "quoteLine_quoteId_fkey"
@@ -11770,7 +11675,7 @@ export type Database = {
customFields: Json | null
description: string
id: string
- partId: string
+ itemId: string
quantity: number
quoteId: string
quoteLineId: string
@@ -11787,7 +11692,7 @@ export type Database = {
customFields?: Json | null
description: string
id?: string
- partId: string
+ itemId: string
quantity?: number
quoteId: string
quoteLineId: string
@@ -11804,7 +11709,7 @@ export type Database = {
customFields?: Json | null
description?: string
id?: string
- partId?: string
+ itemId?: string
quantity?: number
quoteId?: string
quoteLineId?: string
@@ -11879,25 +11784,18 @@ export type Database = {
referencedColumns: ["userId"]
},
{
- foreignKeyName: "quoteMaterial_partId_fkey"
- columns: ["partId", "companyId"]
- isOneToOne: false
- referencedRelation: "part"
- referencedColumns: ["id", "companyId"]
- },
- {
- foreignKeyName: "quoteMaterial_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "quoteMaterial_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["partId", "companyId"]
+ referencedRelation: "item"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteMaterial_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "quoteMaterial_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "parts"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
},
{
foreignKeyName: "quoteMaterial_quoteId_fkey"
@@ -12376,15 +12274,15 @@ export type Database = {
foreignKeyName: "receipt_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "location"
- referencedColumns: ["id"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["locationId"]
},
{
foreignKeyName: "receipt_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["locationId"]
+ referencedRelation: "location"
+ referencedColumns: ["id"]
},
{
foreignKeyName: "receipt_locationId_fkey"
@@ -12479,11 +12377,11 @@ export type Database = {
createdAt: string
createdBy: string
id: string
+ itemId: string
lineId: string | null
locationId: string | null
orderQuantity: number
outstandingQuantity: number
- partId: string
receiptId: string
receivedQuantity: number
shelfId: string | null
@@ -12498,11 +12396,11 @@ export type Database = {
createdAt?: string
createdBy: string
id?: string
+ itemId: string
lineId?: string | null
locationId?: string | null
orderQuantity: number
outstandingQuantity?: number
- partId: string
receiptId: string
receivedQuantity?: number
shelfId?: string | null
@@ -12517,11 +12415,11 @@ export type Database = {
createdAt?: string
createdBy?: string
id?: string
+ itemId?: string
lineId?: string | null
locationId?: string | null
orderQuantity?: number
outstandingQuantity?: number
- partId?: string
receiptId?: string
receivedQuantity?: number
shelfId?: string | null
@@ -12567,53 +12465,46 @@ export type Database = {
referencedColumns: ["userId"]
},
{
- foreignKeyName: "receiptLine_locationId_fkey"
- columns: ["locationId"]
+ foreignKeyName: "receiptLine_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "location"
+ referencedRelation: "item"
referencedColumns: ["id"]
},
{
- foreignKeyName: "receiptLine_locationId_fkey"
- columns: ["locationId"]
+ foreignKeyName: "receiptLine_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["locationId"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
},
{
foreignKeyName: "receiptLine_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "purchaseOrders"
+ referencedRelation: "itemQuantities"
referencedColumns: ["locationId"]
},
{
foreignKeyName: "receiptLine_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "salesOrders"
- referencedColumns: ["locationId"]
- },
- {
- foreignKeyName: "receiptLine_partId_fkey"
- columns: ["partId", "companyId"]
- isOneToOne: false
- referencedRelation: "part"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "location"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "receiptLine_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "receiptLine_locationId_fkey"
+ columns: ["locationId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["partId", "companyId"]
+ referencedRelation: "purchaseOrders"
+ referencedColumns: ["locationId"]
},
{
- foreignKeyName: "receiptLine_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "receiptLine_locationId_fkey"
+ columns: ["locationId"]
isOneToOne: false
- referencedRelation: "parts"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "salesOrders"
+ referencedColumns: ["locationId"]
},
{
foreignKeyName: "receiptLine_receiptId_fkey"
@@ -12831,15 +12722,15 @@ export type Database = {
foreignKeyName: "requestForQuote_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "location"
- referencedColumns: ["id"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["locationId"]
},
{
foreignKeyName: "requestForQuote_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["locationId"]
+ referencedRelation: "location"
+ referencedColumns: ["id"]
},
{
foreignKeyName: "requestForQuote_locationId_fkey"
@@ -12965,8 +12856,8 @@ export type Database = {
customFields: Json | null
description: string | null
id: string
+ itemId: string
locationId: string | null
- partId: string
quantity: number
requestForQuoteId: string
shelfId: string | null
@@ -12982,8 +12873,8 @@ export type Database = {
customFields?: Json | null
description?: string | null
id?: string
+ itemId: string
locationId?: string | null
- partId: string
quantity: number
requestForQuoteId: string
shelfId?: string | null
@@ -12999,8 +12890,8 @@ export type Database = {
customFields?: Json | null
description?: string | null
id?: string
+ itemId?: string
locationId?: string | null
- partId?: string
quantity?: number
requestForQuoteId?: string
shelfId?: string | null
@@ -13074,53 +12965,46 @@ export type Database = {
referencedColumns: ["userId"]
},
{
- foreignKeyName: "requestForQuoteLine_locationId_fkey"
- columns: ["locationId"]
+ foreignKeyName: "requestForQuoteLine_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "location"
+ referencedRelation: "item"
referencedColumns: ["id"]
},
{
- foreignKeyName: "requestForQuoteLine_locationId_fkey"
- columns: ["locationId"]
+ foreignKeyName: "requestForQuoteLine_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["locationId"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
},
{
foreignKeyName: "requestForQuoteLine_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "purchaseOrders"
+ referencedRelation: "itemQuantities"
referencedColumns: ["locationId"]
},
{
foreignKeyName: "requestForQuoteLine_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "salesOrders"
- referencedColumns: ["locationId"]
- },
- {
- foreignKeyName: "requestForQuoteLine_partId_fkey"
- columns: ["partId", "companyId"]
- isOneToOne: false
- referencedRelation: "part"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "location"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "requestForQuoteLine_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "requestForQuoteLine_locationId_fkey"
+ columns: ["locationId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["partId", "companyId"]
+ referencedRelation: "purchaseOrders"
+ referencedColumns: ["locationId"]
},
{
- foreignKeyName: "requestForQuoteLine_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "requestForQuoteLine_locationId_fkey"
+ columns: ["locationId"]
isOneToOne: false
- referencedRelation: "parts"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "salesOrders"
+ referencedColumns: ["locationId"]
},
{
foreignKeyName: "requestForQuoteLine_requestForQuoteId_fkey"
@@ -13329,15 +13213,15 @@ export type Database = {
foreignKeyName: "requestForQuoteSupplier_supplierLocationId_fkey"
columns: ["supplierLocationId"]
isOneToOne: false
- referencedRelation: "location"
- referencedColumns: ["id"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["locationId"]
},
{
foreignKeyName: "requestForQuoteSupplier_supplierLocationId_fkey"
columns: ["supplierLocationId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["locationId"]
+ referencedRelation: "location"
+ referencedColumns: ["id"]
},
{
foreignKeyName: "requestForQuoteSupplier_supplierLocationId_fkey"
@@ -13888,8 +13772,8 @@ export type Database = {
description: string | null
id: string
invoicedComplete: boolean
+ itemId: string | null
locationId: string | null
- partId: string | null
quantityInvoiced: number | null
quantitySent: number | null
quantityToInvoice: number | null
@@ -13899,7 +13783,6 @@ export type Database = {
salesOrderId: string
salesOrderLineType: Database["public"]["Enums"]["salesOrderLineType"]
sentComplete: boolean
- serviceId: string | null
setupPrice: number | null
shelfId: string | null
unitOfMeasureCode: string | null
@@ -13917,8 +13800,8 @@ export type Database = {
description?: string | null
id?: string
invoicedComplete?: boolean
+ itemId?: string | null
locationId?: string | null
- partId?: string | null
quantityInvoiced?: number | null
quantitySent?: number | null
quantityToInvoice?: number | null
@@ -13928,7 +13811,6 @@ export type Database = {
salesOrderId: string
salesOrderLineType: Database["public"]["Enums"]["salesOrderLineType"]
sentComplete?: boolean
- serviceId?: string | null
setupPrice?: number | null
shelfId?: string | null
unitOfMeasureCode?: string | null
@@ -13946,8 +13828,8 @@ export type Database = {
description?: string | null
id?: string
invoicedComplete?: boolean
+ itemId?: string | null
locationId?: string | null
- partId?: string | null
quantityInvoiced?: number | null
quantitySent?: number | null
quantityToInvoice?: number | null
@@ -13957,7 +13839,6 @@ export type Database = {
salesOrderId?: string
salesOrderLineType?: Database["public"]["Enums"]["salesOrderLineType"]
sentComplete?: boolean
- serviceId?: string | null
setupPrice?: number | null
shelfId?: string | null
unitOfMeasureCode?: string | null
@@ -14016,25 +13897,18 @@ export type Database = {
referencedColumns: ["userId"]
},
{
- foreignKeyName: "salesOrderLine_partId_fkey"
- columns: ["partId", "companyId"]
- isOneToOne: false
- referencedRelation: "part"
- referencedColumns: ["id", "companyId"]
- },
- {
- foreignKeyName: "salesOrderLine_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "salesOrderLine_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["partId", "companyId"]
+ referencedRelation: "item"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "salesOrderLine_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "salesOrderLine_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "parts"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
},
{
foreignKeyName: "salesOrderLine_salesOrderId_fkey"
@@ -14050,20 +13924,6 @@ export type Database = {
referencedRelation: "salesOrders"
referencedColumns: ["id"]
},
- {
- foreignKeyName: "salesOrderLine_serviceId_fkey"
- columns: ["serviceId", "companyId"]
- isOneToOne: false
- referencedRelation: "service"
- referencedColumns: ["id", "companyId"]
- },
- {
- foreignKeyName: "salesOrderLine_serviceId_fkey"
- columns: ["serviceId", "companyId"]
- isOneToOne: false
- referencedRelation: "services"
- referencedColumns: ["id", "companyId"]
- },
{
foreignKeyName: "salesOrderLine_shelfId_fkey"
columns: ["shelfId", "locationId"]
@@ -14423,15 +14283,15 @@ export type Database = {
foreignKeyName: "salesOrderShipment_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "location"
- referencedColumns: ["id"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["locationId"]
},
{
foreignKeyName: "salesOrderShipment_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["locationId"]
+ referencedRelation: "location"
+ referencedColumns: ["id"]
},
{
foreignKeyName: "salesOrderShipment_locationId_fkey"
@@ -15004,6 +14864,13 @@ export type Database = {
referencedRelation: "item"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "service_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
+ },
{
foreignKeyName: "service_updatedBy_fkey"
columns: ["updatedBy"]
@@ -15336,15 +15203,15 @@ export type Database = {
foreignKeyName: "shelf_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "location"
- referencedColumns: ["id"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["locationId"]
},
{
foreignKeyName: "shelf_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["locationId"]
+ referencedRelation: "location"
+ referencedColumns: ["id"]
},
{
foreignKeyName: "shelf_locationId_fkey"
@@ -15536,15 +15403,15 @@ export type Database = {
foreignKeyName: "shifts_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "location"
- referencedColumns: ["id"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["locationId"]
},
{
foreignKeyName: "shifts_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["locationId"]
+ referencedRelation: "location"
+ referencedColumns: ["id"]
},
{
foreignKeyName: "shifts_locationId_fkey"
@@ -18077,15 +17944,15 @@ export type Database = {
foreignKeyName: "warehouse_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "location"
- referencedColumns: ["id"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["locationId"]
},
{
foreignKeyName: "warehouse_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["locationId"]
+ referencedRelation: "location"
+ referencedColumns: ["id"]
},
{
foreignKeyName: "warehouse_locationId_fkey"
@@ -18265,15 +18132,15 @@ export type Database = {
foreignKeyName: "workCell_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "location"
- referencedColumns: ["id"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["locationId"]
},
{
foreignKeyName: "workCell_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["locationId"]
+ referencedRelation: "location"
+ referencedColumns: ["id"]
},
{
foreignKeyName: "workCell_locationId_fkey"
@@ -19640,6 +19507,48 @@ export type Database = {
}
Relationships: []
}
+ itemQuantities: {
+ Row: {
+ companyId: string | null
+ itemId: string | null
+ locationId: string | null
+ quantityAvailable: number | null
+ quantityOnHand: number | null
+ quantityOnProdOrder: number | null
+ quantityOnPurchaseOrder: number | null
+ quantityOnSalesOrder: number | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "item_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "item_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "item_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "item_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ ]
+ }
modules: {
Row: {
name: Database["public"]["Enums"]["module"] | null
@@ -19787,48 +19696,6 @@ export type Database = {
},
]
}
- partQuantities: {
- Row: {
- companyId: string | null
- locationId: string | null
- partId: string | null
- quantityAvailable: number | null
- quantityOnHand: number | null
- quantityOnProdOrder: number | null
- quantityOnPurchaseOrder: number | null
- quantityOnSalesOrder: number | null
- }
- Relationships: [
- {
- foreignKeyName: "part_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "company"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "part_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "companies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "part_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "customFieldTables"
- referencedColumns: ["companyId"]
- },
- {
- foreignKeyName: "part_companyId_fkey"
- columns: ["companyId"]
- isOneToOne: false
- referencedRelation: "integrations"
- referencedColumns: ["companyId"]
- },
- ]
- }
parts: {
Row: {
active: boolean | null
@@ -19849,7 +19716,7 @@ export type Database = {
name: string | null
partType: Database["public"]["Enums"]["partType"] | null
replenishmentSystem:
- | Database["public"]["Enums"]["partReplenishmentSystem"]
+ | Database["public"]["Enums"]["itemReplenishmentSystem"]
| null
supplierIds: string[] | null
toDate: string | null
@@ -20005,6 +19872,13 @@ export type Database = {
referencedRelation: "item"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "part_id_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
+ },
{
foreignKeyName: "part_unitOfMeasureCode_fkey"
columns: ["unitOfMeasureCode", "companyId"]
@@ -20311,8 +20185,11 @@ export type Database = {
id: string | null
inventoryUnitOfMeasureCode: string | null
invoicedComplete: boolean | null
+ itemDescription: string | null
+ itemId: string | null
+ itemName: string | null
+ itemReadableId: string | null
locationId: string | null
- partId: string | null
purchaseOrderId: string | null
purchaseOrderLineType:
| Database["public"]["Enums"]["purchaseOrderLineType"]
@@ -20325,12 +20202,10 @@ export type Database = {
quantityToReceive: number | null
receivedComplete: boolean | null
requiresInspection: boolean | null
- serviceId: string | null
setupPrice: number | null
shelfId: string | null
supplierId: string | null
supplierPartId: string | null
- supplierServiceId: string | null
unitPrice: number | null
updatedAt: string | null
updatedBy: string | null
@@ -20428,25 +20303,18 @@ export type Database = {
referencedColumns: ["code", "companyId"]
},
{
- foreignKeyName: "purchaseOrderLine_partId_fkey"
- columns: ["partId", "companyId"]
- isOneToOne: false
- referencedRelation: "part"
- referencedColumns: ["id", "companyId"]
- },
- {
- foreignKeyName: "purchaseOrderLine_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "purchaseOrderLine_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["partId", "companyId"]
+ referencedRelation: "item"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "purchaseOrderLine_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "purchaseOrderLine_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "parts"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
},
{
foreignKeyName: "purchaseOrderLine_purchaseOrderId_fkey"
@@ -20476,20 +20344,6 @@ export type Database = {
referencedRelation: "unitOfMeasure"
referencedColumns: ["code", "companyId"]
},
- {
- foreignKeyName: "purchaseOrderLine_serviceId_fkey"
- columns: ["serviceId", "companyId"]
- isOneToOne: false
- referencedRelation: "service"
- referencedColumns: ["id", "companyId"]
- },
- {
- foreignKeyName: "purchaseOrderLine_serviceId_fkey"
- columns: ["serviceId", "companyId"]
- isOneToOne: false
- referencedRelation: "services"
- referencedColumns: ["id", "companyId"]
- },
{
foreignKeyName: "purchaseOrderLine_shelfId_fkey"
columns: ["shelfId", "locationId"]
@@ -20896,7 +20750,7 @@ export type Database = {
customFields: Json | null
description: string | null
id: string | null
- partId: string | null
+ itemId: string | null
pricingDiscountPercent: number | null
pricingExtendedPrice: number | null
pricingLeadTime: number | null
@@ -20976,25 +20830,18 @@ export type Database = {
referencedColumns: ["userId"]
},
{
- foreignKeyName: "quoteLine_partId_fkey"
- columns: ["partId", "companyId"]
- isOneToOne: false
- referencedRelation: "part"
- referencedColumns: ["id", "companyId"]
- },
- {
- foreignKeyName: "quoteLine_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "quoteLine_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["partId", "companyId"]
+ referencedRelation: "item"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteLine_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "quoteLine_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "parts"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
},
{
foreignKeyName: "quoteLine_quoteId_fkey"
@@ -21075,11 +20922,11 @@ export type Database = {
expirationDate: string | null
favorite: boolean | null
id: string | null
+ itemIds: string[] | null
locationId: string | null
locationName: string | null
name: string | null
notes: string | null
- partIds: string[] | null
quoteDate: string | null
quoteId: string | null
revisionId: number | null
@@ -21232,7 +21079,7 @@ export type Database = {
foreignKeyName: "quote_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "partQuantities"
+ referencedRelation: "itemQuantities"
referencedColumns: ["locationId"]
},
{
@@ -21420,7 +21267,7 @@ export type Database = {
foreignKeyName: "receipt_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "partQuantities"
+ referencedRelation: "itemQuantities"
referencedColumns: ["locationId"]
},
{
@@ -21519,11 +21366,11 @@ export type Database = {
expirationDate: string | null
favorite: boolean | null
id: string | null
+ itemIds: string[] | null
locationId: string | null
locationName: string | null
name: string | null
notes: string | null
- partIds: string[] | null
receiptDate: string | null
requestForQuoteId: string | null
revisionId: number | null
@@ -21642,7 +21489,7 @@ export type Database = {
foreignKeyName: "requestForQuote_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "partQuantities"
+ referencedRelation: "itemQuantities"
referencedColumns: ["locationId"]
},
{
@@ -21745,8 +21592,10 @@ export type Database = {
description: string | null
id: string | null
invoicedComplete: boolean | null
+ itemDescription: string | null
+ itemId: string | null
+ itemName: string | null
locationId: string | null
- partId: string | null
quantityInvoiced: number | null
quantitySent: number | null
quantityToInvoice: number | null
@@ -21758,7 +21607,6 @@ export type Database = {
| Database["public"]["Enums"]["salesOrderLineType"]
| null
sentComplete: boolean | null
- serviceId: string | null
setupPrice: number | null
shelfId: string | null
unitOfMeasureCode: string | null
@@ -21838,25 +21686,18 @@ export type Database = {
referencedColumns: ["userId"]
},
{
- foreignKeyName: "salesOrderLine_partId_fkey"
- columns: ["partId", "companyId"]
- isOneToOne: false
- referencedRelation: "part"
- referencedColumns: ["id", "companyId"]
- },
- {
- foreignKeyName: "salesOrderLine_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "salesOrderLine_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "partQuantities"
- referencedColumns: ["partId", "companyId"]
+ referencedRelation: "item"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "salesOrderLine_partId_fkey"
- columns: ["partId", "companyId"]
+ foreignKeyName: "salesOrderLine_itemId_fkey"
+ columns: ["itemId"]
isOneToOne: false
- referencedRelation: "parts"
- referencedColumns: ["id", "companyId"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
},
{
foreignKeyName: "salesOrderLine_salesOrderId_fkey"
@@ -21872,20 +21713,6 @@ export type Database = {
referencedRelation: "salesOrders"
referencedColumns: ["id"]
},
- {
- foreignKeyName: "salesOrderLine_serviceId_fkey"
- columns: ["serviceId", "companyId"]
- isOneToOne: false
- referencedRelation: "service"
- referencedColumns: ["id", "companyId"]
- },
- {
- foreignKeyName: "salesOrderLine_serviceId_fkey"
- columns: ["serviceId", "companyId"]
- isOneToOne: false
- referencedRelation: "services"
- referencedColumns: ["id", "companyId"]
- },
{
foreignKeyName: "salesOrderLine_shelfId_fkey"
columns: ["shelfId", "locationId"]
@@ -22383,6 +22210,13 @@ export type Database = {
referencedRelation: "item"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "service_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
+ },
{
foreignKeyName: "service_updatedBy_fkey"
columns: ["updatedBy"]
@@ -22518,7 +22352,7 @@ export type Database = {
foreignKeyName: "shifts_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "partQuantities"
+ referencedRelation: "itemQuantities"
referencedColumns: ["locationId"]
},
{
@@ -22796,7 +22630,7 @@ export type Database = {
foreignKeyName: "employeeJob_locationId_fkey"
columns: ["locationId"]
isOneToOne: false
- referencedRelation: "partQuantities"
+ referencedRelation: "itemQuantities"
referencedColumns: ["locationId"]
},
{
@@ -23071,14 +22905,49 @@ export type Database = {
glAccountType: "Posting" | "Total" | "Begin Total" | "End Total"
glConsolidatedRate: "Average" | "Current" | "Historical"
glIncomeBalance: "Balance Sheet" | "Income Statement"
+ itemCostingMethod: "Standard" | "Average" | "LIFO" | "FIFO"
+ itemLedgerDocumentType:
+ | "Sales Shipment"
+ | "Sales Invoice"
+ | "Sales Return Receipt"
+ | "Sales Credit Memo"
+ | "Purchase Receipt"
+ | "Purchase Invoice"
+ | "Purchase Return Shipment"
+ | "Purchase Credit Memo"
+ | "Transfer Shipment"
+ | "Transfer Receipt"
+ | "Service Shipment"
+ | "Service Invoice"
+ | "Service Credit Memo"
+ | "Posted Assembly"
+ | "Inventory Receipt"
+ | "Inventory Shipment"
+ | "Direct Transfer"
+ itemLedgerType:
+ | "Purchase"
+ | "Sale"
+ | "Positive Adjmt."
+ | "Negative Adjmt."
+ | "Transfer"
+ | "Consumption"
+ | "Output"
+ | "Assembly Consumption"
+ | "Assembly Output"
+ itemReorderingPolicy:
+ | "Manual Reorder"
+ | "Demand-Based Reorder"
+ | "Fixed Reorder Quantity"
+ | "Maximum Quantity"
+ itemReplenishmentSystem: "Buy" | "Make" | "Buy and Make"
itemType:
- | "part"
- | "material"
- | "tool"
- | "hardware"
- | "service"
- | "consumable"
- | "fixture"
+ | "Part"
+ | "Material"
+ | "Tool"
+ | "Hardware"
+ | "Service"
+ | "Consumable"
+ | "Fixture"
journalLineDocumentType:
| "Receipt"
| "Invoice"
@@ -23113,49 +22982,19 @@ export type Database = {
| "October"
| "November"
| "December"
- partCostingMethod: "Standard" | "Average" | "LIFO" | "FIFO"
- partLedgerDocumentType:
- | "Sales Shipment"
- | "Sales Invoice"
- | "Sales Return Receipt"
- | "Sales Credit Memo"
- | "Purchase Receipt"
- | "Purchase Invoice"
- | "Purchase Return Shipment"
- | "Purchase Credit Memo"
- | "Transfer Shipment"
- | "Transfer Receipt"
- | "Service Shipment"
- | "Service Invoice"
- | "Service Credit Memo"
- | "Posted Assembly"
- | "Inventory Receipt"
- | "Inventory Shipment"
- | "Direct Transfer"
- partLedgerType:
- | "Purchase"
- | "Sale"
- | "Positive Adjmt."
- | "Negative Adjmt."
- | "Transfer"
- | "Consumption"
- | "Output"
- | "Assembly Consumption"
- | "Assembly Output"
partManufacturingPolicy: "Make to Order" | "Make to Stock"
- partReorderingPolicy:
- | "Manual Reorder"
- | "Demand-Based Reorder"
- | "Fixed Reorder Quantity"
- | "Maximum Quantity"
- partReplenishmentSystem: "Buy" | "Make" | "Buy and Make"
partType: "Inventory" | "Non-Inventory"
payableLineType:
+ | "Comment"
| "G/L Account"
+ | "Fixed Asset"
| "Part"
+ | "Material"
+ | "Tool"
+ | "Hardware"
| "Service"
- | "Fixed Asset"
- | "Comment"
+ | "Consumable"
+ | "Fixture"
paymentTermCalculationMethod: "Net" | "End of Month" | "Day of Month"
purchaseInvoiceStatus:
| "Draft"
@@ -23170,9 +23009,14 @@ export type Database = {
purchaseOrderLineType:
| "Comment"
| "G/L Account"
+ | "Fixed Asset"
| "Part"
+ | "Material"
+ | "Tool"
+ | "Hardware"
| "Service"
- | "Fixed Asset"
+ | "Consumable"
+ | "Fixture"
purchaseOrderStatus:
| "Draft"
| "To Review"
@@ -23213,7 +23057,17 @@ export type Database = {
| "Manufacturing Output"
receiptStatus: "Draft" | "Pending" | "Posted"
requestForQuoteStatus: "Draft" | "Sent" | "Expired" | "Closed"
- salesOrderLineType: "Comment" | "Part" | "Service"
+ salesOrderLineType:
+ | "Comment"
+ | "G/L Account"
+ | "Fixed Asset"
+ | "Part"
+ | "Material"
+ | "Tool"
+ | "Hardware"
+ | "Service"
+ | "Consumable"
+ | "Fixture"
salesOrderStatus:
| "Draft"
| "Needs Approval"
diff --git a/packages/database/supabase/migrations/20230330024716_parts.sql b/packages/database/supabase/migrations/20230330024716_parts.sql
index c100ef0823..b87c0605eb 100644
--- a/packages/database/supabase/migrations/20230330024716_parts.sql
+++ b/packages/database/supabase/migrations/20230330024716_parts.sql
@@ -52,13 +52,13 @@ CREATE POLICY "Employees with parts_delete can delete item groups" ON "itemGroup
CREATE TYPE "itemType" AS ENUM (
- 'part',
- 'material',
- 'tool',
- 'hardware',
- 'service',
- 'consumable',
- 'fixture'
+ 'Part',
+ 'Material',
+ 'Tool',
+ 'Hardware',
+ 'Service',
+ 'Consumable',
+ 'Fixture'
);
CREATE TABLE "item" (
@@ -93,7 +93,7 @@ CREATE TYPE "partType" AS ENUM (
'Non-Inventory'
);
-CREATE TYPE "partReplenishmentSystem" AS ENUM (
+CREATE TYPE "itemReplenishmentSystem" AS ENUM (
'Buy',
'Make',
'Buy and Make'
@@ -105,14 +105,14 @@ CREATE TYPE "partManufacturingPolicy" AS ENUM (
);
-CREATE TYPE "partCostingMethod" AS ENUM (
+CREATE TYPE "itemCostingMethod" AS ENUM (
'Standard',
'Average',
'LIFO',
'FIFO'
);
-CREATE TYPE "partReorderingPolicy" AS ENUM (
+CREATE TYPE "itemReorderingPolicy" AS ENUM (
'Manual Reorder',
'Demand-Based Reorder',
'Fixed Reorder Quantity',
@@ -178,7 +178,7 @@ CREATE POLICY "Employees with parts_delete can delete units of measure" ON "unit
CREATE TABLE "part" (
"id" TEXT NOT NULL,
"itemId" TEXT NOT NULL,
- "replenishmentSystem" "partReplenishmentSystem" NOT NULL,
+ "replenishmentSystem" "itemReplenishmentSystem" NOT NULL,
"partType" "partType" NOT NULL,
"unitOfMeasureCode" TEXT NOT NULL,
"approved" BOOLEAN NOT NULL DEFAULT false,
@@ -257,15 +257,15 @@ CREATE TRIGGER create_item_search_result
CREATE FUNCTION public.create_part_related_records()
RETURNS TRIGGER AS $$
BEGIN
- INSERT INTO public."partCost"("partId", "costingMethod", "createdBy", "companyId")
- VALUES (new.id, 'FIFO', new."createdBy", new."companyId");
+ INSERT INTO public."itemCost"("itemId", "costingMethod", "createdBy", "companyId")
+ VALUES (new."itemId", 'FIFO', new."createdBy", new."companyId");
- INSERT INTO public."partReplenishment"("partId", "createdBy", "companyId")
- VALUES (new.id, new."createdBy", new."companyId");
+ INSERT INTO public."itemReplenishment"("itemId", "createdBy", "companyId")
+ VALUES (new."itemId", new."createdBy", new."companyId");
- INSERT INTO public."partUnitSalePrice"("partId", "currencyCode", "createdBy", "companyId")
+ INSERT INTO public."itemUnitSalePrice"("itemId", "currencyCode", "createdBy", "companyId")
-- TODO: get default currency
- VALUES (new.id, 'USD', new."createdBy", new."companyId");
+ VALUES (new."itemId", 'USD', new."createdBy", new."companyId");
RETURN new;
END;
@@ -304,9 +304,9 @@ CREATE TRIGGER delete_item_search_result
AFTER DELETE on public.item
FOR EACH ROW EXECUTE PROCEDURE public.delete_item_search_result();
-CREATE TABLE "partCost" (
- "partId" TEXT NOT NULL,
- "costingMethod" "partCostingMethod" NOT NULL,
+CREATE TABLE "itemCost" (
+ "itemId" TEXT NOT NULL,
+ "costingMethod" "itemCostingMethod" NOT NULL,
"standardCost" NUMERIC(15,5) NOT NULL DEFAULT 0,
"unitCost" NUMERIC(15,5) NOT NULL DEFAULT 0,
"costIsAdjusted" BOOLEAN NOT NULL DEFAULT false,
@@ -318,32 +318,32 @@ CREATE TABLE "partCost" (
"customFields" JSONB,
- CONSTRAINT "partCost_partId_fkey" FOREIGN KEY ("partId", "companyId") REFERENCES "part"("id", "companyId") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "partCost_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company"("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "itemCost_itemId_fkey" FOREIGN KEY ("itemId") REFERENCES "item"("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "itemCost_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company"("id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "itemGroup_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id"),
CONSTRAINT "itemGroup_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id")
);
-CREATE INDEX "partCost_partId_idx" ON "partCost" ("partId");
+CREATE INDEX "itemCost_itemId_idx" ON "itemCost" ("itemId");
-ALTER TABLE "partCost" ENABLE ROW LEVEL SECURITY;
+ALTER TABLE "itemCost" ENABLE ROW LEVEL SECURITY;
-CREATE POLICY "Employees with parts_view can view part costs" ON "partCost"
+CREATE POLICY "Employees with parts_view can view part costs" ON "itemCost"
FOR SELECT
USING (
has_role('employee') AND
has_company_permission('parts_view', "companyId")
);
-CREATE POLICY "Employees with parts_update can update part costs" ON "partCost"
+CREATE POLICY "Employees with parts_update can update part costs" ON "itemCost"
FOR UPDATE
USING (
has_role('employee') AND
has_company_permission('parts_update', "companyId")
);
-CREATE TABLE "partUnitSalePrice" (
- "partId" TEXT NOT NULL,
+CREATE TABLE "itemUnitSalePrice" (
+ "itemId" TEXT NOT NULL,
"unitSalePrice" NUMERIC(15,5) NOT NULL DEFAULT 0,
"currencyCode" TEXT NOT NULL,
"salesUnitOfMeasureCode" TEXT,
@@ -357,36 +357,36 @@ CREATE TABLE "partUnitSalePrice" (
"updatedAt" TIMESTAMP WITH TIME ZONE,
"customFields" JSONB,
- CONSTRAINT "partUnitSalePrice_partId_fkey" FOREIGN KEY ("partId", "companyId") REFERENCES "part"("id", "companyId") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "partUnitSalePrice_currencyCode_fkey" FOREIGN KEY ("currencyCode", "companyId") REFERENCES "currency"("code", "companyId") ON DELETE SET NULL ON UPDATE CASCADE,
- CONSTRAINT "partUnitSalePrice_salesUnitOfMeasureId_fkey" FOREIGN KEY ("salesUnitOfMeasureCode", "companyId") REFERENCES "unitOfMeasure"("code", "companyId") ON DELETE SET NULL,
- CONSTRAINT "partUnitSalePrice_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company"("id") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "partUnitSalePrice_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id"),
- CONSTRAINT "partUnitSalePrice_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id")
+ CONSTRAINT "itemUnitSalePrice_itemId_fkey" FOREIGN KEY ("itemId") REFERENCES "item"("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "itemUnitSalePrice_currencyCode_fkey" FOREIGN KEY ("currencyCode", "companyId") REFERENCES "currency"("code", "companyId") ON DELETE SET NULL ON UPDATE CASCADE,
+ CONSTRAINT "itemUnitSalePrice_salesUnitOfMeasureId_fkey" FOREIGN KEY ("salesUnitOfMeasureCode", "companyId") REFERENCES "unitOfMeasure"("code", "companyId") ON DELETE SET NULL,
+ CONSTRAINT "itemUnitSalePrice_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company"("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "itemUnitSalePrice_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id"),
+ CONSTRAINT "itemUnitSalePrice_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id")
);
-CREATE INDEX "partUnitSalePrice_partId_idx" ON "partUnitSalePrice"("partId");
-CREATE INDEX "partUnitSalePrice_companyId_idx" ON "partUnitSalePrice"("companyId");
+CREATE INDEX "itemUnitSalePrice_itemId_idx" ON "itemUnitSalePrice"("itemId");
+CREATE INDEX "itemUnitSalePrice_companyId_idx" ON "itemUnitSalePrice"("companyId");
-ALTER TABLE "partUnitSalePrice" ENABLE ROW LEVEL SECURITY;
+ALTER TABLE "itemUnitSalePrice" ENABLE ROW LEVEL SECURITY;
-CREATE POLICY "Employees with part_view can view part sale prices" ON "partUnitSalePrice"
+CREATE POLICY "Employees with part_view can view part sale prices" ON "itemUnitSalePrice"
FOR SELECT
USING (
has_role('employee') AND
has_company_permission('parts_view', "companyId")
);
-CREATE POLICY "Employees with parts_update can update part sale prices" ON "partUnitSalePrice"
+CREATE POLICY "Employees with parts_update can update part sale prices" ON "itemUnitSalePrice"
FOR UPDATE
USING (
has_role('employee') AND
has_company_permission('parts_update', "companyId")
);
-CREATE TABLE "partSupplier" (
+CREATE TABLE "itemSupplier" (
"id" TEXT NOT NULL DEFAULT xid(),
- "partId" TEXT NOT NULL,
+ "itemId" TEXT NOT NULL,
"supplierId" TEXT NOT NULL,
"supplierPartId" TEXT,
"supplierUnitOfMeasureCode" TEXT,
@@ -400,21 +400,21 @@ CREATE TABLE "partSupplier" (
"updatedAt" TIMESTAMP WITH TIME ZONE,
"customFields" JSONB,
- CONSTRAINT "partSupplier_id_pkey" PRIMARY KEY ("id", "companyId"),
- CONSTRAINT "partSupplier_partId_fkey" FOREIGN KEY ("partId", "companyId") REFERENCES "part"("id", "companyId") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "partSupplier_supplierId_fkey" FOREIGN KEY ("supplierId") REFERENCES "supplier"("id") ON DELETE CASCADE,
- CONSTRAINT "partSupplier_part_supplier_unique" UNIQUE ("partId", "supplierId", "companyId"),
- CONSTRAINT "partSupplier_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company"("id") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "partSupplier_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id"),
- CONSTRAINT "partSupplier_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id")
+ CONSTRAINT "itemSupplier_id_pkey" PRIMARY KEY ("id", "companyId"),
+ CONSTRAINT "itemSupplier_itemId_fkey" FOREIGN KEY ("itemId") REFERENCES "item"("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "itemSupplier_supplierId_fkey" FOREIGN KEY ("supplierId") REFERENCES "supplier"("id") ON DELETE CASCADE,
+ CONSTRAINT "itemSupplier_part_supplier_unique" UNIQUE ("itemId", "supplierId", "companyId"),
+ CONSTRAINT "itemSupplier_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company"("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "itemSupplier_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id"),
+ CONSTRAINT "itemSupplier_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id")
);
-CREATE INDEX "partSupplier_partId_idx" ON "partSupplier"("partId");
-CREATE INDEX "partSupplier_companyId_idx" ON "partSupplier"("companyId");
+CREATE INDEX "itemSupplier_itemId_idx" ON "itemSupplier"("itemId");
+CREATE INDEX "itemSupplier_companyId_idx" ON "itemSupplier"("companyId");
-ALTER TABLE "partSupplier" ENABLE ROW LEVEL SECURITY;
+ALTER TABLE "itemSupplier" ENABLE ROW LEVEL SECURITY;
-CREATE POLICY "Employees with part/purchasing_view can view part suppliers" ON "partSupplier"
+CREATE POLICY "Employees with part/purchasing_view can view part suppliers" ON "itemSupplier"
FOR SELECT
USING (
(
@@ -424,28 +424,28 @@ CREATE POLICY "Employees with part/purchasing_view can view part suppliers" ON "
AND has_role('employee')
);
-CREATE POLICY "Employees with parts_create can create part suppliers" ON "partSupplier"
+CREATE POLICY "Employees with parts_create can create part suppliers" ON "itemSupplier"
FOR INSERT
WITH CHECK (
has_role('employee') AND
has_company_permission('parts_create', "companyId")
);
-CREATE POLICY "Employees with parts_update can update part suppliers" ON "partSupplier"
+CREATE POLICY "Employees with parts_update can update part suppliers" ON "itemSupplier"
FOR UPDATE
USING (
has_role('employee') AND
has_company_permission('parts_update', "companyId")
);
-CREATE POLICY "Employees with parts_delete can delete part suppliers" ON "partSupplier"
+CREATE POLICY "Employees with parts_delete can delete part suppliers" ON "itemSupplier"
FOR DELETE
USING (
has_role('employee') AND
has_company_permission('parts_delete', "companyId")
);
-CREATE POLICY "Suppliers with parts_view can view their own part suppliers" ON "partSupplier"
+CREATE POLICY "Suppliers with parts_view can view their own part suppliers" ON "itemSupplier"
FOR SELECT
USING (
has_role('supplier') AND
@@ -455,7 +455,7 @@ CREATE POLICY "Suppliers with parts_view can view their own part suppliers" ON "
)
);
-CREATE POLICY "Suppliers with parts_update can update their own part suppliers" ON "partSupplier"
+CREATE POLICY "Suppliers with parts_update can update their own part suppliers" ON "itemSupplier"
FOR UPDATE
USING (
has_role('supplier') AND
@@ -466,8 +466,8 @@ CREATE POLICY "Suppliers with parts_update can update their own part suppliers"
);
-CREATE TABLE "partReplenishment" (
- "partId" TEXT NOT NULL,
+CREATE TABLE "itemReplenishment" (
+ "itemId" TEXT NOT NULL,
"preferredSupplierId" TEXT,
"purchasingLeadTime" INTEGER NOT NULL DEFAULT 0,
"purchasingUnitOfMeasureCode" TEXT,
@@ -486,28 +486,28 @@ CREATE TABLE "partReplenishment" (
"updatedAt" TIMESTAMP WITH TIME ZONE,
"customFields" JSONB,
- CONSTRAINT "partReplenishment_partId_fkey" FOREIGN KEY ("partId", "companyId") REFERENCES "part"("id", "companyId") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "partReplenishment_preferredSupplierId_fkey" FOREIGN KEY ("preferredSupplierId") REFERENCES "supplier"("id") ON DELETE SET NULL,
- CONSTRAINT "partReplenishment_purchaseUnitOfMeasureCode_fkey" FOREIGN KEY ("purchasingUnitOfMeasureCode", "companyId") REFERENCES "unitOfMeasure"("code", "companyId") ON DELETE SET NULL ON UPDATE CASCADE,
- CONSTRAINT "partReplenishment_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company"("id") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "partReplenishment_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id"),
- CONSTRAINT "partReplenishment_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id")
+ CONSTRAINT "itemReplenishment_itemId_fkey" FOREIGN KEY ("itemId") REFERENCES "item"("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "itemReplenishment_preferredSupplierId_fkey" FOREIGN KEY ("preferredSupplierId") REFERENCES "supplier"("id") ON DELETE SET NULL,
+ CONSTRAINT "itemReplenishment_purchaseUnitOfMeasureCode_fkey" FOREIGN KEY ("purchasingUnitOfMeasureCode", "companyId") REFERENCES "unitOfMeasure"("code", "companyId") ON DELETE SET NULL ON UPDATE CASCADE,
+ CONSTRAINT "itemReplenishment_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company"("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "itemReplenishment_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id"),
+ CONSTRAINT "itemReplenishment_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id")
);
-CREATE INDEX "partReplenishment_partId_idx" ON "partReplenishment" ("partId");
-CREATE INDEX "partReplenishment_companyId_idx" ON "partReplenishment" ("companyId");
-CREATE INDEX "partReplenishment_preferredSupplierId_idx" ON "partReplenishment" ("preferredSupplierId");
+CREATE INDEX "itemReplenishment_itemId_idx" ON "itemReplenishment" ("itemId");
+CREATE INDEX "itemReplenishment_companyId_idx" ON "itemReplenishment" ("companyId");
+CREATE INDEX "itemReplenishment_preferredSupplierId_idx" ON "itemReplenishment" ("preferredSupplierId");
-ALTER TABLE "partReplenishment" ENABLE ROW LEVEL SECURITY;
+ALTER TABLE "itemReplenishment" ENABLE ROW LEVEL SECURITY;
-CREATE POLICY "Employees with part_view can view part costs" ON "partReplenishment"
+CREATE POLICY "Employees with part_view can view part costs" ON "itemReplenishment"
FOR SELECT
USING (
has_role('employee') AND
has_company_permission('parts_view', "companyId")
);
-CREATE POLICY "Employees with parts_update can update part costs" ON "partReplenishment"
+CREATE POLICY "Employees with parts_update can update part costs" ON "itemReplenishment"
FOR UPDATE
USING (
has_role('employee') AND
@@ -524,7 +524,7 @@ CREATE POLICY "Suppliers with parts can view parts they created or supply" ON "p
"createdBy" = auth.uid()::text
OR (
id IN (
- SELECT "partId" FROM "partSupplier" WHERE "supplierId" IN (
+ SELECT "itemId" FROM "itemSupplier" WHERE "supplierId" IN (
SELECT "supplierId" FROM "supplierAccount" WHERE id::uuid = auth.uid()
)
)
@@ -548,7 +548,7 @@ CREATE POLICY "Suppliers with parts_update can update parts that they created or
"createdBy" = auth.uid()::text
OR (
id IN (
- SELECT "partId" FROM "partSupplier" WHERE "supplierId" IN (
+ SELECT "itemId" FROM "itemSupplier" WHERE "supplierId" IN (
SELECT "supplierId" FROM "supplierAccount" WHERE id::uuid = auth.uid()
)
)
@@ -565,7 +565,7 @@ CREATE POLICY "Suppliers with parts_delete can delete parts that they created or
"createdBy" = auth.uid()::text
OR (
id IN (
- SELECT "partId" FROM "partSupplier" WHERE "supplierId" IN (
+ SELECT "itemId" FROM "itemSupplier" WHERE "supplierId" IN (
SELECT "supplierId" FROM "supplierAccount" WHERE id::uuid = auth.uid()
)
)
@@ -573,56 +573,56 @@ CREATE POLICY "Suppliers with parts_delete can delete parts that they created or
)
);
-CREATE POLICY "Suppliers with parts_view can view part costs they supply" ON "partCost"
+CREATE POLICY "Suppliers with parts_view can view part costs they supply" ON "itemCost"
FOR SELECT
USING (
has_role('supplier') AND
has_company_permission('parts_view', "companyId")
AND (
- "partId" IN (
- SELECT "partId" FROM "partSupplier" WHERE "supplierId" IN (
+ "itemId" IN (
+ SELECT "itemId" FROM "itemSupplier" WHERE "supplierId" IN (
SELECT "supplierId" FROM "supplierAccount" WHERE id::uuid = auth.uid()
)
)
)
);
-CREATE POLICY "Suppliers with parts_update can update parts costs that they supply" ON "partCost"
+CREATE POLICY "Suppliers with parts_update can update parts costs that they supply" ON "itemCost"
FOR UPDATE
USING (
has_role('supplier') AND
has_company_permission('parts_update', "companyId")
AND (
- "partId" IN (
- SELECT "partId" FROM "partSupplier" WHERE "supplierId" IN (
+ "itemId" IN (
+ SELECT "itemId" FROM "itemSupplier" WHERE "supplierId" IN (
SELECT "supplierId" FROM "supplierAccount" WHERE id::uuid = auth.uid()
)
)
)
);
-CREATE POLICY "Suppliers with parts_view can view part replenishments they supply" ON "partReplenishment"
+CREATE POLICY "Suppliers with parts_view can view part replenishments they supply" ON "itemReplenishment"
FOR SELECT
USING (
has_role('supplier') AND
has_company_permission('parts_create', "companyId")
AND (
- "partId" IN (
- SELECT "partId" FROM "partSupplier" WHERE "supplierId" IN (
+ "itemId" IN (
+ SELECT "itemId" FROM "itemSupplier" WHERE "supplierId" IN (
SELECT "supplierId" FROM "supplierAccount" WHERE id::uuid = auth.uid()
)
)
)
);
-CREATE POLICY "Suppliers with parts_update can update parts replenishments that they supply" ON "partReplenishment"
+CREATE POLICY "Suppliers with parts_update can update parts replenishments that they supply" ON "itemReplenishment"
FOR UPDATE
USING (
has_role('supplier') AND
has_company_permission('parts_update', "companyId")
AND (
- "partId" IN (
- SELECT "partId" FROM "partSupplier" WHERE "supplierId" IN (
+ "itemId" IN (
+ SELECT "itemId" FROM "itemSupplier" WHERE "supplierId" IN (
SELECT "supplierId" FROM "supplierAccount" WHERE id::uuid = auth.uid()
)
)
@@ -713,10 +713,10 @@ CREATE POLICY "Employees with parts_delete can delete shelves" ON "shelf"
has_company_permission('parts_delete', "companyId")
);
-CREATE TABLE "partPlanning" (
- "partId" TEXT NOT NULL,
+CREATE TABLE "itemPlanning" (
+ "itemId" TEXT NOT NULL,
"locationId" TEXT NOT NULL,
- "reorderingPolicy" "partReorderingPolicy" NOT NULL DEFAULT 'Demand-Based Reorder',
+ "reorderingPolicy" "itemReorderingPolicy" NOT NULL DEFAULT 'Demand-Based Reorder',
"critical" BOOLEAN NOT NULL DEFAULT false,
"safetyStockQuantity" INTEGER NOT NULL DEFAULT 0,
"safetyStockLeadTime" INTEGER NOT NULL DEFAULT 0,
@@ -737,18 +737,18 @@ CREATE TABLE "partPlanning" (
"customFields" JSONB,
- CONSTRAINT "partPlanning_partId_locationId_key" UNIQUE ("partId", "locationId"),
- CONSTRAINT "partPlanning_partId_fkey" FOREIGN KEY ("partId", "companyId") REFERENCES "part"("id", "companyId") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "partPlanning_locationId_fkey" FOREIGN KEY ("locationId") REFERENCES "location"("id") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "partPlanning_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company"("id") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "partPlanning_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id"),
- CONSTRAINT "partPlanning_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id")
+ CONSTRAINT "itemPlanning_itemId_locationId_key" UNIQUE ("itemId", "locationId"),
+ CONSTRAINT "itemPlanning_itemId_fkey" FOREIGN KEY ("itemId") REFERENCES "item"("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "itemPlanning_locationId_fkey" FOREIGN KEY ("locationId") REFERENCES "location"("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "itemPlanning_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company"("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "itemPlanning_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id"),
+ CONSTRAINT "itemPlanning_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id")
);
-CREATE INDEX "partPlanning_partId_locationId_idx" ON "partPlanning" ("partId", "locationId");
-ALTER TABLE "partPlanning" ENABLE ROW LEVEL SECURITY;
+CREATE INDEX "itemPlanning_itemId_locationId_idx" ON "itemPlanning" ("itemId", "locationId");
+ALTER TABLE "itemPlanning" ENABLE ROW LEVEL SECURITY;
-CREATE POLICY "Employees with parts can view part planning" ON "partPlanning"
+CREATE POLICY "Employees with parts can view part planning" ON "itemPlanning"
FOR SELECT
USING (
has_role('employee') AND
@@ -756,14 +756,14 @@ CREATE POLICY "Employees with parts can view part planning" ON "partPlanning"
);
-- these are records are created lazily when a user attempts to view them
-CREATE POLICY "Employees with parts can insert part planning" ON "partPlanning"
+CREATE POLICY "Employees with parts can insert part planning" ON "itemPlanning"
FOR INSERT
WITH CHECK (
has_role('employee') AND
has_company_permission('parts_view', "companyId")
);
-CREATE POLICY "Employees with parts_update can update part planning" ON "partPlanning"
+CREATE POLICY "Employees with parts_update can update part planning" ON "itemPlanning"
FOR UPDATE
USING (
has_role('employee') AND
@@ -771,8 +771,8 @@ CREATE POLICY "Employees with parts_update can update part planning" ON "partPla
);
-CREATE TABLE "partInventory" (
- "partId" TEXT NOT NULL,
+CREATE TABLE "itemInventory" (
+ "itemId" TEXT NOT NULL,
"locationId" TEXT NOT NULL,
"defaultShelfId" TEXT,
"companyId" TEXT NOT NULL,
@@ -782,21 +782,21 @@ CREATE TABLE "partInventory" (
"updatedAt" TIMESTAMP WITH TIME ZONE,
"customFields" JSONB,
- CONSTRAINT "partInventory_partId_locationId_key" UNIQUE ("partId", "locationId"),
- CONSTRAINT "partInventory_partId_fkey" FOREIGN KEY ("partId", "companyId") REFERENCES "part"("id", "companyId") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "partInventory_locationId_fkey" FOREIGN KEY ("locationId") REFERENCES "location"("id") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "partInventory_shelfId_fkey" FOREIGN KEY ("defaultShelfId", "locationId") REFERENCES "shelf"("id", "locationId") ON DELETE SET NULL,
- CONSTRAINT "partInventory_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company"("id") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "partInventory_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id"),
- CONSTRAINT "partInventory_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id")
+ CONSTRAINT "itemInventory_itemId_locationId_key" UNIQUE ("itemId", "locationId"),
+ CONSTRAINT "itemInventory_itemId_fkey" FOREIGN KEY ("itemId") REFERENCES "item"("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "itemInventory_locationId_fkey" FOREIGN KEY ("locationId") REFERENCES "location"("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "itemInventory_shelfId_fkey" FOREIGN KEY ("defaultShelfId", "locationId") REFERENCES "shelf"("id", "locationId") ON DELETE SET NULL,
+ CONSTRAINT "itemInventory_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company"("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "itemInventory_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id"),
+ CONSTRAINT "itemInventory_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id")
);
-CREATE INDEX "partInventory_partId_locationId_idx" ON "partInventory" ("partId", "locationId");
-CREATE INDEX "partInventory_shelfId_idx" ON "partInventory" ("defaultShelfId");
+CREATE INDEX "itemInventory_itemId_locationId_idx" ON "itemInventory" ("itemId", "locationId");
+CREATE INDEX "itemInventory_shelfId_idx" ON "itemInventory" ("defaultShelfId");
-ALTER TABLE "partInventory" ENABLE ROW LEVEL SECURITY;
+ALTER TABLE "itemInventory" ENABLE ROW LEVEL SECURITY;
-CREATE POLICY "Employees with part_view can view part planning" ON "partInventory"
+CREATE POLICY "Employees with part_view can view part planning" ON "itemInventory"
FOR SELECT
USING (
has_role('employee') AND
@@ -804,14 +804,14 @@ CREATE POLICY "Employees with part_view can view part planning" ON "partInventor
);
-- these are records are created lazily when a user attempts to view them
-CREATE POLICY "Employees with part_view can insert part planning" ON "partInventory"
+CREATE POLICY "Employees with part_view can insert part planning" ON "itemInventory"
FOR INSERT
WITH CHECK (
has_role('employee') AND
has_company_permission('parts_view', "companyId")
);
-CREATE POLICY "Employees with parts_update can update part planning" ON "partInventory"
+CREATE POLICY "Employees with parts_update can update part planning" ON "itemInventory"
FOR UPDATE
USING (
has_role('employee') AND
diff --git a/packages/database/supabase/migrations/20230510035345_purchasing.sql b/packages/database/supabase/migrations/20230510035345_purchasing.sql
index 269cdbcf88..e343a887d9 100644
--- a/packages/database/supabase/migrations/20230510035345_purchasing.sql
+++ b/packages/database/supabase/migrations/20230510035345_purchasing.sql
@@ -247,9 +247,14 @@ CREATE INDEX "purchaseOrder_companyId_idx" ON "purchaseOrder" ("companyId");
CREATE TYPE "purchaseOrderLineType" AS ENUM (
'Comment',
'G/L Account',
+ 'Fixed Asset',
'Part',
+ 'Material',
+ 'Tool',
+ 'Hardware',
'Service',
- 'Fixed Asset'
+ 'Consumable',
+ 'Fixture'
);
CREATE TABLE "purchaseOrderStatusHistory" (
@@ -283,8 +288,8 @@ CREATE TABLE "purchaseOrderLine" (
"id" TEXT NOT NULL DEFAULT xid(),
"purchaseOrderId" TEXT NOT NULL,
"purchaseOrderLineType" "purchaseOrderLineType" NOT NULL,
- "partId" TEXT,
- "serviceId" TEXT,
+ "itemId" TEXT,
+ "itemReadableId" TEXT,
"accountNumber" TEXT,
"assetId" TEXT,
"description" TEXT,
@@ -313,37 +318,33 @@ CREATE TABLE "purchaseOrderLine" (
CHECK (
(
"purchaseOrderLineType" = 'Comment' AND
- "partId" IS NULL AND
- "serviceId" IS NULL AND
+ "itemId" IS NULL AND
"accountNumber" IS NULL AND
"assetId" IS NULL AND
"description" IS NOT NULL
)
OR (
"purchaseOrderLineType" = 'G/L Account' AND
- "partId" IS NULL AND
- "serviceId" IS NULL AND
+ "itemId" IS NULL AND
"accountNumber" IS NOT NULL AND
"assetId" IS NULL
)
OR (
- "purchaseOrderLineType" = 'Part' AND
- "partId" IS NOT NULL AND
- "serviceId" IS NULL AND
+ (
+ "purchaseOrderLineType" = 'Part' OR
+ "purchaseOrderLineType" = 'Material' OR
+ "purchaseOrderLineType" = 'Tool' OR
+ "purchaseOrderLineType" = 'Hardware' OR
+ "purchaseOrderLineType" = 'Consumable' OR
+ "purchaseOrderLineType" = 'Fixture' OR
+ "purchaseOrderLineType" = 'Service'
+ ) AND
+ "itemId" IS NOT NULL AND
"accountNumber" IS NULL AND
"assetId" IS NULL
- )
- OR (
- "purchaseOrderLineType" = 'Service' AND
- "partId" IS NULL AND
- "serviceId" IS NOT NULL AND
- "accountNumber" IS NULL AND
- "assetId" IS NULL
- )
- OR (
+ ) OR (
"purchaseOrderLineType" = 'Fixed Asset' AND
- "partId" IS NULL AND
- "serviceId" IS NULL AND
+ "itemId" IS NULL AND
"accountNumber" IS NULL AND
"assetId" IS NOT NULL
)
@@ -351,8 +352,7 @@ CREATE TABLE "purchaseOrderLine" (
CONSTRAINT "purchaseOrderLine_pkey" PRIMARY KEY ("id"),
CONSTRAINT "purchaseOrderLine_purchaseOrderId_fkey" FOREIGN KEY ("purchaseOrderId") REFERENCES "purchaseOrder" ("id") ON DELETE CASCADE,
- CONSTRAINT "purchaseOrderLine_partId_fkey" FOREIGN KEY ("partId", "companyId") REFERENCES "part" ("id", "companyId") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "purchaseOrderLine_serviceId_fkey" FOREIGN KEY ("serviceId", "companyId") REFERENCES "service" ("id", "companyId") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "purchaseOrderLine_itemId_fkey" FOREIGN KEY ("itemId") REFERENCES "item" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "purchaseOrderLine_accountNumber_fkey" FOREIGN KEY ("accountNumber", "companyId") REFERENCES "account" ("number", "companyId") ON DELETE CASCADE ON UPDATE CASCADE,
-- TODO: Add assetId foreign key
CONSTRAINT "purchaseOrderLine_shelfId_fkey" FOREIGN KEY ("shelfId", "locationId") REFERENCES "shelf" ("id", "locationId") ON DELETE CASCADE,
diff --git a/packages/database/supabase/migrations/20230704160029_supplier-view.sql b/packages/database/supabase/migrations/20230704160029_supplier-view.sql
index 359bfb05a8..a6ab9a8470 100644
--- a/packages/database/supabase/migrations/20230704160029_supplier-view.sql
+++ b/packages/database/supabase/migrations/20230704160029_supplier-view.sql
@@ -7,7 +7,7 @@ CREATE OR REPLACE VIEW "suppliers" AS
s."supplierStatusId",
ss.name AS "status",
po.count AS "orderCount",
- p.count AS "partCount",
+ i.count AS "partCount",
s."customFields",
s."companyId"
FROM "supplier" s
@@ -24,9 +24,9 @@ CREATE OR REPLACE VIEW "suppliers" AS
SELECT
"supplierId",
COUNT(*) AS "count"
- FROM "partSupplier"
+ FROM "itemSupplier"
GROUP BY "supplierId"
- ) p ON p."supplierId" = s.id;
+ ) i ON i."supplierId" = s.id;
CREATE OR REPLACE VIEW "customers" AS
SELECT
diff --git a/packages/database/supabase/migrations/20230704161623_parts-view.sql b/packages/database/supabase/migrations/20230704161623_parts-view.sql
index 0384a0134a..eaddeab8b1 100644
--- a/packages/database/supabase/migrations/20230704161623_parts-view.sql
+++ b/packages/database/supabase/migrations/20230704161623_parts-view.sql
@@ -12,11 +12,11 @@ CREATE OR REPLACE VIEW "parts" AS
i.blocked,
p."customFields",
p."companyId",
- array_agg(ps."supplierId") AS "supplierIds"
+ array_agg(s."supplierId") AS "supplierIds"
FROM "part" p
INNER JOIN "item" i ON i.id = p."itemId"
LEFT JOIN "itemGroup" pg ON pg.id = i."itemGroupId"
- LEFT JOIN "partSupplier" ps ON ps."partId" = p.id
+ LEFT JOIN "itemSupplier" s ON s."itemId" = p."itemId"
GROUP BY p.id,
i.name,
i.description,
diff --git a/packages/database/supabase/migrations/20230705033432_ledgers.sql b/packages/database/supabase/migrations/20230705033432_ledgers.sql
index 8f163f7364..c4cf33c885 100644
--- a/packages/database/supabase/migrations/20230705033432_ledgers.sql
+++ b/packages/database/supabase/migrations/20230705033432_ledgers.sql
@@ -142,7 +142,7 @@ CREATE POLICY "Employees with accounting_create can insert journal lines" ON "jo
-- delete and update are not available for journal lines
-CREATE TYPE "partLedgerType" AS ENUM (
+CREATE TYPE "itemLedgerType" AS ENUM (
'Purchase',
'Sale',
'Positive Adjmt.',
@@ -163,7 +163,7 @@ CREATE TYPE "costLedgerType" AS ENUM (
'Total'
);
-CREATE TYPE "partLedgerDocumentType" AS ENUM (
+CREATE TYPE "itemLedgerDocumentType" AS ENUM (
'Sales Shipment',
'Sales Invoice',
'Sales Return Receipt',
@@ -187,13 +187,13 @@ CREATE TABLE "costLedger" (
"id" TEXT NOT NULL DEFAULT xid(),
"entryNumber" SERIAL,
"postingDate" DATE NOT NULL DEFAULT CURRENT_DATE,
- "partLedgerType" "partLedgerType" NOT NULL,
+ "itemLedgerType" "itemLedgerType" NOT NULL,
"costLedgerType" "costLedgerType" NOT NULL,
"adjustment" BOOLEAN NOT NULL DEFAULT false,
- "documentType" "partLedgerDocumentType",
+ "documentType" "itemLedgerDocumentType",
"documentId" TEXT,
"externalDocumentId" TEXT,
- "partId" TEXT,
+ "itemId" 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,
@@ -204,7 +204,7 @@ CREATE TABLE "costLedger" (
CONSTRAINT "costLedger_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company" ("id") ON DELETE CASCADE ON UPDATE CASCADE
);
-CREATE INDEX "costLedger_partId_idx" ON "costLedger" ("partId");
+CREATE INDEX "costLedger_itemId_idx" ON "costLedger" ("itemId");
CREATE INDEX "costLedger_companyId_idx" ON "costLedger" ("companyId");
ALTER TABLE "costLedger" ENABLE ROW LEVEL SECURITY;
@@ -217,31 +217,31 @@ CREATE POLICY "Employees with accounting_view can view the value ledger" ON "cos
);
-CREATE TABLE "partLedger" (
+CREATE TABLE "itemLedger" (
"id" TEXT NOT NULL DEFAULT xid(),
"entryNumber" SERIAL,
"postingDate" DATE NOT NULL DEFAULT CURRENT_DATE,
- "entryType" "partLedgerType" NOT NULL,
- "documentType" "partLedgerDocumentType",
+ "entryType" "itemLedgerType" NOT NULL,
+ "documentType" "itemLedgerDocumentType",
"documentId" TEXT,
"externalDocumentId" TEXT,
- "partId" TEXT NOT NULL,
+ "itemId" TEXT NOT NULL,
"locationId" TEXT,
"shelfId" TEXT,
"quantity" NUMERIC(12, 4) NOT NULL,
"companyId" TEXT NOT NULL,
"createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
- CONSTRAINT "partLedger_pkey" PRIMARY KEY ("id"),
- CONSTRAINT "partLedger_partId_fkey" FOREIGN KEY ("partId", "companyId") REFERENCES "part"("id", "companyId") ON UPDATE CASCADE ON DELETE CASCADE,
- CONSTRAINT "partLedger_locationId_fkey" FOREIGN KEY ("locationId") REFERENCES "location"("id") ON UPDATE CASCADE ON DELETE SET NULL,
- CONSTRAINT "partLedger_shelfId_fkey" FOREIGN KEY ("shelfId", "locationId") REFERENCES "shelf"("id", "locationId") ON UPDATE CASCADE ON DELETE SET NULL,
+ CONSTRAINT "itemLedger_pkey" PRIMARY KEY ("id"),
+ CONSTRAINT "itemLedger_itemId_fkey" FOREIGN KEY ("itemId") REFERENCES "item"("id") ON UPDATE CASCADE ON DELETE CASCADE,
+ CONSTRAINT "itemLedger_locationId_fkey" FOREIGN KEY ("locationId") REFERENCES "location"("id") ON UPDATE CASCADE ON DELETE SET NULL,
+ CONSTRAINT "itemLedger_shelfId_fkey" FOREIGN KEY ("shelfId", "locationId") REFERENCES "shelf"("id", "locationId") ON UPDATE CASCADE ON DELETE SET NULL,
CONSTRAINT "partLeger_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company" ("id") ON DELETE CASCADE ON UPDATE CASCADE
);
-ALTER TABLE "partLedger" ENABLE ROW LEVEL SECURITY;
+ALTER TABLE "itemLedger" ENABLE ROW LEVEL SECURITY;
-CREATE POLICY "Certain employees can view the parts ledger" ON "partLedger"
+CREATE POLICY "Certain employees can view the parts ledger" ON "itemLedger"
FOR SELECT
USING (
has_role('employee') AND
diff --git a/packages/database/supabase/migrations/20230728025201_receipts.sql b/packages/database/supabase/migrations/20230728025201_receipts.sql
index 822386e000..31396090b1 100644
--- a/packages/database/supabase/migrations/20230728025201_receipts.sql
+++ b/packages/database/supabase/migrations/20230728025201_receipts.sql
@@ -91,7 +91,7 @@ CREATE TABLE "receiptLine" (
"id" TEXT NOT NULL DEFAULT xid(),
"receiptId" TEXT NOT NULL,
"lineId" TEXT,
- "partId" TEXT NOT NULL,
+ "itemId" TEXT NOT NULL,
"orderQuantity" NUMERIC(18, 4) NOT NULL,
"outstandingQuantity" NUMERIC(18, 4) NOT NULL DEFAULT 0,
"receivedQuantity" NUMERIC(18, 4) NOT NULL DEFAULT 0,
@@ -107,7 +107,7 @@ CREATE TABLE "receiptLine" (
CONSTRAINT "receiptLine_pkey" PRIMARY KEY ("id"),
CONSTRAINT "receiptLine_receiptId_fkey" FOREIGN KEY ("receiptId") REFERENCES "receipt" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "receiptLine_partId_fkey" FOREIGN KEY ("partId", "companyId") REFERENCES "part" ("id", "companyId") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "receiptLine_itemId_fkey" FOREIGN KEY ("itemId") REFERENCES "item" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "receiptLine_locationId_fkey" FOREIGN KEY ("locationId") REFERENCES "location" ("id") ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT "receiptLine_shelfId_fkey" FOREIGN KEY ("shelfId", "locationId") REFERENCES "shelf" ("id", "locationId") ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT "receiptLine_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
diff --git a/packages/database/supabase/migrations/20230915193213_quantity-on-hand.sql b/packages/database/supabase/migrations/20230915193213_quantity-on-hand.sql
index d46fcda3ca..7b903d8840 100644
--- a/packages/database/supabase/migrations/20230915193213_quantity-on-hand.sql
+++ b/packages/database/supabase/migrations/20230915193213_quantity-on-hand.sql
@@ -1,20 +1,21 @@
-CREATE OR REPLACE VIEW "partQuantities" AS
+CREATE OR REPLACE VIEW "itemQuantities" AS
SELECT
- p."id" AS "partId",
- p."companyId",
+ i."id" AS "itemId",
+ i."companyId",
loc."id" AS "locationId",
- COALESCE(SUM(pl."quantity"), 0) AS "quantityOnHand",
+ COALESCE(SUM(il."quantity"), 0) AS "quantityOnHand",
COALESCE(pol."quantityToReceive", 0) AS "quantityOnPurchaseOrder",
0 AS "quantityOnSalesOrder",
0 AS "quantityOnProdOrder",
0 AS "quantityAvailable"
- FROM "part" p
+ FROM "item" i
CROSS JOIN "location" loc
- LEFT JOIN "partLedger" pl
- ON pl."partId" = p."id" AND pl."locationId" = loc."id"
+ LEFT JOIN "itemLedger" il
+ ON il."itemId" = i."id" AND il."locationId" = loc."id"
LEFT JOIN (
+ -- TODO: multiply by conversion factor
SELECT
- pol."partId",
+ pol."itemId",
pol."locationId",
COALESCE(SUM(GREATEST(pol."quantityToReceive", 0)), 0) AS "quantityToReceive"
FROM "purchaseOrderLine" pol
@@ -24,11 +25,11 @@ CREATE OR REPLACE VIEW "partQuantities" AS
AND po."status" != 'Rejected'
AND po."status" != 'Closed'
GROUP BY
- pol."partId",
+ pol."itemId",
pol."locationId"
- ) pol ON pol."partId" = p."id" AND pol."locationId" = loc."id"
+ ) pol ON pol."itemId" = i."id" AND pol."locationId" = loc."id"
GROUP BY
- p."id",
- p."companyId",
+ i."id",
+ i."companyId",
loc."id",
pol."quantityToReceive"
\ No newline at end of file
diff --git a/packages/database/supabase/migrations/20230924004608_accounts-payable.sql b/packages/database/supabase/migrations/20230924004608_accounts-payable.sql
index 714762b1c8..43db215e02 100644
--- a/packages/database/supabase/migrations/20230924004608_accounts-payable.sql
+++ b/packages/database/supabase/migrations/20230924004608_accounts-payable.sql
@@ -112,11 +112,16 @@ CREATE POLICY "Employees with invoicing_view can view AP invoices status history
CREATE TYPE "payableLineType" AS ENUM (
+ 'Comment',
'G/L Account',
+ 'Fixed Asset',
'Part',
+ 'Material',
+ 'Tool',
+ 'Hardware',
'Service',
- 'Fixed Asset',
- 'Comment'
+ 'Consumable',
+ 'Fixture'
);
CREATE TABLE "purchaseInvoiceLine" (
@@ -125,7 +130,8 @@ CREATE TABLE "purchaseInvoiceLine" (
"invoiceLineType" "payableLineType" NOT NULL,
"purchaseOrderId" TEXT,
"purchaseOrderLineId" TEXT,
- "partId" TEXT,
+ "itemId" TEXT,
+ "itemReadableId" TEXT,
"serviceId" TEXT,
"locationId" TEXT,
"shelfId" TEXT,
@@ -150,37 +156,34 @@ CREATE TABLE "purchaseInvoiceLine" (
CHECK (
(
"invoiceLineType" = 'Comment' AND
- "partId" IS NULL AND
- "serviceId" IS NULL AND
+ "itemId" IS NULL AND
"accountNumber" IS NULL AND
"assetId" IS NULL AND
"description" IS NOT NULL
)
OR (
"invoiceLineType" = 'G/L Account' AND
- "partId" IS NULL AND
- "serviceId" IS NULL AND
+ "itemId" IS NULL AND
"accountNumber" IS NOT NULL AND
"assetId" IS NULL
)
OR (
- "invoiceLineType" = 'Part' AND
- "partId" IS NOT NULL AND
- "serviceId" IS NULL AND
- "accountNumber" IS NULL AND
- "assetId" IS NULL
- )
- OR (
- "invoiceLineType" = 'Service' AND
- "partId" IS NULL AND
- "serviceId" IS NOT NULL AND
+ (
+ "invoiceLineType" = 'Part' OR
+ "invoiceLineType" = 'Material' OR
+ "invoiceLineType" = 'Tool' OR
+ "invoiceLineType" = 'Hardware' OR
+ "invoiceLineType" = 'Consumable' OR
+ "invoiceLineType" = 'Fixture' OR
+ "invoiceLineType" = 'Service'
+ ) AND
+ "itemId" IS NOT NULL AND
"accountNumber" IS NULL AND
"assetId" IS NULL
)
OR (
"invoiceLineType" = 'Fixed Asset' AND
- "partId" IS NULL AND
- "serviceId" IS NULL AND
+ "itemId" IS NULL AND
"accountNumber" IS NULL AND
"assetId" IS NOT NULL
)
@@ -190,8 +193,7 @@ CREATE TABLE "purchaseInvoiceLine" (
CONSTRAINT "purchaseInvoiceLines_invoiceId_fkey" FOREIGN KEY ("invoiceId") REFERENCES "purchaseInvoice" ("id") ON UPDATE CASCADE ON DELETE CASCADE,
CONSTRAINT "purchaseInvoiceLines_purchaseOrderId_fkey" FOREIGN KEY ("purchaseOrderId") REFERENCES "purchaseOrder" ("id") ON UPDATE CASCADE ON DELETE RESTRICT,
CONSTRAINT "purchaseInvoiceLines_purchaseOrderLineId_fkey" FOREIGN KEY ("purchaseOrderLineId") REFERENCES "purchaseOrderLine" ("id") ON UPDATE CASCADE ON DELETE RESTRICT,
- CONSTRAINT "purchaseInvoiceLines_partId_fkey" FOREIGN KEY ("partId", "companyId") REFERENCES "part" ("id", "companyId") ON UPDATE CASCADE ON DELETE RESTRICT,
- CONSTRAINT "purchaseInvoiceLines_serviceId_fkey" FOREIGN KEY ("serviceId", "companyId") REFERENCES "service" ("id", "companyId") ON UPDATE CASCADE ON DELETE RESTRICT,
+ CONSTRAINT "purchaseInvoiceLines_itemId_fkey" FOREIGN KEY ("itemId") REFERENCES "item" ("id") ON UPDATE CASCADE ON DELETE RESTRICT,
CONSTRAINT "purchaseInvoiceLines_locationId_fkey" FOREIGN KEY ("locationId") REFERENCES "location" ("id") ON UPDATE CASCADE ON DELETE RESTRICT,
CONSTRAINT "purchaseInvoiceLines_shelfId_fkey" FOREIGN KEY ("shelfId", "locationId") REFERENCES "shelf" ("id", "locationId") ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT "purchaseInvoiceLines_accountNumber_fkey" FOREIGN KEY ("accountNumber", "companyId") REFERENCES "account" ("number", "companyId") ON UPDATE CASCADE ON DELETE RESTRICT,
diff --git a/packages/database/supabase/migrations/20231222200612_purchase-order-document.sql b/packages/database/supabase/migrations/20231222200612_purchase-order-document.sql
index 41250cbc38..9b4fea500e 100644
--- a/packages/database/supabase/migrations/20231222200612_purchase-order-document.sql
+++ b/packages/database/supabase/migrations/20231222200612_purchase-order-document.sql
@@ -2,23 +2,15 @@ CREATE OR REPLACE VIEW "purchaseOrderLines" WITH(SECURITY_INVOKER=true) AS
SELECT
pol.*,
po."supplierId" ,
- -- p.name AS "partName",
- -- p.description AS "partDescription",
- ps."supplierPartId",
- -- s.name AS "serviceName",
- -- s.description AS "serviceDescription",
- ss."supplierServiceId"
+ i.name,
+ sup."supplierPartId"
FROM "purchaseOrderLine" pol
INNER JOIN "purchaseOrder" po
ON po.id = pol."purchaseOrderId"
- LEFT OUTER JOIN "part" p
- ON p.id = pol."partId"
- LEFT OUTER JOIN "partSupplier" ps
- ON p.id = ps."partId" AND po."supplierId" = ps."supplierId"
- LEFT OUTER JOIN "service" s
- ON s.id = pol."serviceId"
- LEFT OUTER JOIN "serviceSupplier" ss
- ON s.id = ss."serviceId" AND po."supplierId" = ss."supplierId";
+ LEFT OUTER JOIN "item" i
+ ON i.id = pol."itemId"
+ LEFT OUTER JOIN "itemSupplier" sup
+ ON i.id = sup."itemId" AND po."supplierId" = sup."supplierId";
CREATE OR REPLACE VIEW "purchaseOrderLocations" WITH(SECURITY_INVOKER=true) AS
SELECT
diff --git a/packages/database/supabase/migrations/20240204025905_rfq.sql b/packages/database/supabase/migrations/20240204025905_rfq.sql
index 6a6b0b7259..cf9b89ce5a 100644
--- a/packages/database/supabase/migrations/20240204025905_rfq.sql
+++ b/packages/database/supabase/migrations/20240204025905_rfq.sql
@@ -32,7 +32,7 @@ CREATE INDEX "requestForQuote_locationId_idx" ON "requestForQuote" ("locationId"
CREATE TABLE "requestForQuoteLine" (
"id" TEXT NOT NULL DEFAULT xid(),
"requestForQuoteId" TEXT NOT NULL,
- "partId" TEXT NOT NULL,
+ "itemId" TEXT NOT NULL,
"description" TEXT,
"quantity" NUMERIC(20, 2) NOT NULL,
"unitPrice" NUMERIC(20, 2) NOT NULL DEFAULT 0,
@@ -48,7 +48,7 @@ CREATE TABLE "requestForQuoteLine" (
CONSTRAINT "requestForQuoteLine_pkey" PRIMARY KEY ("id"),
CONSTRAINT "requestForQuoteLine_requestForQuoteId_fkey" FOREIGN KEY ("requestForQuoteId") REFERENCES "requestForQuote"("id") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "requestForQuoteLine_partId_fkey" FOREIGN KEY ("partId", "companyId") REFERENCES "part"("id", "companyId") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "requestForQuoteLine_itemId_fkey" FOREIGN KEY ("itemId") REFERENCES "item"("id") ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT "requestForQuoteLine_unitOfMeasureCode_fkey" FOREIGN KEY ("unitOfMeasureCode", "companyId") REFERENCES "unitOfMeasure"("code", "companyId") ON UPDATE CASCADE ON DELETE SET NULL,
CONSTRAINT "requestForQuoteLine_locationId_fkey" FOREIGN KEY ("locationId") REFERENCES "location"("id") ON UPDATE CASCADE ON DELETE SET NULL,
CONSTRAINT "requestForQuoteLine_shelfId_fkey" FOREIGN KEY ("shelfId", "locationId") REFERENCES "shelf" ("id", "locationId") ON DELETE CASCADE,
@@ -58,7 +58,7 @@ CREATE TABLE "requestForQuoteLine" (
);
CREATE INDEX "requestForQuoteLine_requestForQuoteId_idx" ON "requestForQuoteLine" ("requestForQuoteId");
-CREATE INDEX "requestForQuoteLine_partId_idx" ON "requestForQuoteLine" ("partId");
+CREATE INDEX "requestForQuoteLine_itemId_idx" ON "requestForQuoteLine" ("itemId");
CREATE INDEX "requestForQuoteLine_locationId_idx" ON "requestForQuoteLine" ("locationId");
CREATE TABLE "requestForQuoteSupplier" (
@@ -155,7 +155,7 @@ CREATE OR REPLACE VIEW "requestForQuotes" WITH(SECURITY_INVOKER=true) AS
uu."avatarUrl" AS "updatedByAvatar",
l."name" AS "locationName",
array_agg(rs."supplierId") AS "supplierIds",
- array_agg(rl."partId") AS "partIds",
+ array_agg(rl."itemId") AS "itemIds",
EXISTS(SELECT 1 FROM "requestForQuoteFavorite" pf WHERE pf."requestForQuoteId" = r.id AND pf."userId" = auth.uid()::text) AS favorite
FROM "requestForQuote" r
LEFT JOIN "location" l
diff --git a/packages/database/supabase/migrations/20240206224405_quotes.sql b/packages/database/supabase/migrations/20240206224405_quotes.sql
index 61af7eec15..7c335ab250 100644
--- a/packages/database/supabase/migrations/20240206224405_quotes.sql
+++ b/packages/database/supabase/migrations/20240206224405_quotes.sql
@@ -64,7 +64,7 @@ CREATE TABLE "quoteLine" (
"quoteId" TEXT NOT NULL,
"quoteRevisionId" INTEGER NOT NULL DEFAULT 0,
"status" "quoteLineStatus" NOT NULL DEFAULT 'Draft',
- "partId" TEXT NOT NULL,
+ "itemId" TEXT NOT NULL,
"description" TEXT NOT NULL,
"customerPartId" TEXT,
"customerPartRevision" TEXT,
@@ -78,7 +78,7 @@ CREATE TABLE "quoteLine" (
CONSTRAINT "quoteLine_pkey" PRIMARY KEY ("id"),
CONSTRAINT "quoteLine_quoteId_fkey" FOREIGN KEY ("quoteId") REFERENCES "quote" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "quoteLine_partId_fkey" FOREIGN KEY ("partId", "companyId") REFERENCES "part" ("id", "companyId") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "quoteLine_itemId_fkey" FOREIGN KEY ("itemId") REFERENCES "item" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT "quoteLine_unitOfMeasureCode_fkey" FOREIGN KEY ("unitOfMeasureCode", "companyId") REFERENCES "unitOfMeasure" ("code", "companyId") ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT "quoteLine_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT "quoteLine_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
@@ -92,7 +92,7 @@ CREATE TABLE "quoteAssembly" (
"quoteId" TEXT NOT NULL,
"quoteLineId" TEXT NOT NULL,
"parentAssemblyId" TEXT,
- "partId" TEXT NOT NULL,
+ "itemId" TEXT NOT NULL,
"description" TEXT,
"unitOfMeasureCode" TEXT,
"quantityPerParent" NUMERIC(10, 2) NOT NULL DEFAULT 0,
@@ -107,7 +107,7 @@ CREATE TABLE "quoteAssembly" (
CONSTRAINT "quoteAssembly_quoteId_fkey" FOREIGN KEY ("quoteId") REFERENCES "quote" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "quoteAssembly_quoteLineId_fkey" FOREIGN KEY ("quoteLineId") REFERENCES "quoteLine" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "quoteAssembly_parentAssemblyId_fkey" FOREIGN KEY ("parentAssemblyId") REFERENCES "quoteAssembly" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "quoteAssembly_partId_fkey" FOREIGN KEY ("partId", "companyId") REFERENCES "part" ("id", "companyId") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "quoteAssembly_itemId_fkey" FOREIGN KEY ("itemId") REFERENCES "item" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT "quoteAssembly_unitOfMeasureCode_fkey" FOREIGN KEY ("unitOfMeasureCode", "companyId") REFERENCES "unitOfMeasure" ("code", "companyId") ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT "quoteAssembly_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT "quoteAssembly_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
@@ -159,7 +159,7 @@ CREATE TABLE "quoteMaterial" (
"quoteId" TEXT NOT NULL,
"quoteLineId" TEXT NOT NULL,
"quoteOperationId" TEXT NOT NULL,
- "partId" TEXT NOT NULL,
+ "itemId" TEXT NOT NULL,
"description" TEXT NOT NULL,
"quantity" NUMERIC(10, 2) NOT NULL DEFAULT 0,
"unitOfMeasureCode" TEXT,
@@ -175,7 +175,7 @@ CREATE TABLE "quoteMaterial" (
CONSTRAINT "quoteMaterial_quoteId_fkey" FOREIGN KEY ("quoteId") REFERENCES "quote" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "quoteMaterial_quoteLineId_fkey" FOREIGN KEY ("quoteLineId") REFERENCES "quoteLine" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "quoteMaterial_quoteOperationId_fkey" FOREIGN KEY ("quoteOperationId") REFERENCES "quoteOperation" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "quoteMaterial_partId_fkey" FOREIGN KEY ("partId", "companyId") REFERENCES "part" ("id", "companyId") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "quoteMaterial_itemId_fkey" FOREIGN KEY ("itemId") REFERENCES "item" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT "quoteMaterial_unitOfMeasureCode_fkey" FOREIGN KEY ("unitOfMeasureCode", "companyId") REFERENCES "unitOfMeasure" ("code", "companyId") ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT "quoteMaterial_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT "quoteMaterial_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
@@ -242,7 +242,7 @@ CREATE OR REPLACE VIEW "quotes" WITH(SECURITY_INVOKER=true) AS
uu."fullName" AS "updatedByFullName",
uu."avatarUrl" AS "updatedByAvatar",
l."name" AS "locationName",
- array_agg(ql."partId") AS "partIds",
+ array_agg(ql."itemId") AS "itemIds",
EXISTS(SELECT 1 FROM "quoteFavorite" pf WHERE pf."quoteId" = q.id AND pf."userId" = auth.uid()::text) AS favorite
FROM "quote" q
LEFT JOIN "customer" c
diff --git a/packages/database/supabase/migrations/20240324175747_assignee.sql b/packages/database/supabase/migrations/20240324175747_assignee.sql
index c3817d6413..5882fcaf8b 100644
--- a/packages/database/supabase/migrations/20240324175747_assignee.sql
+++ b/packages/database/supabase/migrations/20240324175747_assignee.sql
@@ -24,11 +24,11 @@ CREATE OR REPLACE VIEW "parts" WITH(SECURITY_INVOKER=true) AS
LEFT JOIN "itemGroup" pg ON pg.id = i."itemGroupId"
LEFT JOIN (
SELECT
- "partId",
+ "itemId",
array_agg(ps."supplierId") AS "supplierIds"
- FROM "partSupplier" ps
- GROUP BY "partId"
- ) ps ON ps."partId" = p.id;
+ FROM "itemSupplier" ps
+ GROUP BY "itemId"
+ ) ps ON ps."itemId" = p."itemId";
DROP VIEW "purchaseOrders";
CREATE OR REPLACE VIEW "purchaseOrders" WITH(SECURITY_INVOKER=true) AS
@@ -92,13 +92,13 @@ CREATE OR REPLACE VIEW "quotes" WITH(SECURITY_INVOKER=true) AS
SELECT
q.*,
l."name" AS "locationName",
- ql."partIds",
+ ql."itemIds",
EXISTS(SELECT 1 FROM "quoteFavorite" pf WHERE pf."quoteId" = q.id AND pf."userId" = auth.uid()::text) AS favorite
FROM "quote" q
LEFT JOIN (
SELECT
"quoteId",
- array_agg("partId") AS "partIds"
+ array_agg("itemId") AS "itemIds"
FROM "quoteLine"
GROUP BY "quoteId"
) ql ON ql."quoteId" = q.id
@@ -120,7 +120,7 @@ CREATE OR REPLACE VIEW "requestForQuotes" WITH(SECURITY_INVOKER=true) AS
r.*,
l."name" AS "locationName",
rs."supplierIds",
- rp."partIds",
+ rp."itemIds",
EXISTS(SELECT 1 FROM "requestForQuoteFavorite" pf WHERE pf."requestForQuoteId" = r.id AND pf."userId" = auth.uid()::text) AS favorite
FROM "requestForQuote" r
LEFT JOIN "location" l
@@ -136,7 +136,7 @@ LEFT JOIN (
LEFT JOIN (
SELECT
"requestForQuoteId",
- array_agg(rp."partId") AS "partIds"
+ array_agg(rp."itemId") AS "itemIds"
FROM "requestForQuoteLine" rp
GROUP BY "requestForQuoteId"
) rp
@@ -187,6 +187,6 @@ CREATE OR REPLACE VIEW "suppliers" WITH(SECURITY_INVOKER=true) AS
SELECT
"supplierId",
COUNT(*) AS "count"
- FROM "partSupplier"
+ FROM "itemSupplier"
GROUP BY "supplierId"
) p ON p."supplierId" = s.id;
\ No newline at end of file
diff --git a/packages/database/supabase/migrations/20240402052512_purchasing-conversion-factors.sql b/packages/database/supabase/migrations/20240402052512_purchasing-conversion-factors.sql
index 6ff55ca438..e03a457afc 100644
--- a/packages/database/supabase/migrations/20240402052512_purchasing-conversion-factors.sql
+++ b/packages/database/supabase/migrations/20240402052512_purchasing-conversion-factors.sql
@@ -1,7 +1,7 @@
ALTER TABLE "purchaseOrderLine" ADD COLUMN "conversionFactor" NUMERIC(10, 2) DEFAULT 1;
ALTER TABLE "purchaseInvoiceLine" ADD COLUMN "conversionFactor" NUMERIC(10, 2) DEFAULT 1;
-ALTER TABLE "partSupplier" ADD COLUMN "unitPrice" NUMERIC(10, 2) DEFAULT 0;
+ALTER TABLE "itemSupplier" ADD COLUMN "unitPrice" NUMERIC(10, 2) DEFAULT 0;
ALTER TABLE "unitOfMeasure" DROP CONSTRAINT "unitOfMeasure_code_check";
@@ -10,23 +10,17 @@ CREATE OR REPLACE VIEW "purchaseOrderLines" WITH(SECURITY_INVOKER=true) AS
SELECT
pol.*,
po."supplierId" ,
- -- p.name AS "partName",
- -- p.description AS "partDescription",
- ps."supplierPartId",
- -- s.name AS "serviceName",
- -- s.description AS "serviceDescription",
- ss."supplierServiceId"
+ i.name as "itemName",
+ i.description as "itemDescription",
+ ps."supplierPartId"
FROM "purchaseOrderLine" pol
INNER JOIN "purchaseOrder" po
ON po.id = pol."purchaseOrderId"
- LEFT OUTER JOIN "part" p
- ON p.id = pol."partId"
- LEFT OUTER JOIN "partSupplier" ps
- ON p.id = ps."partId" AND po."supplierId" = ps."supplierId"
- LEFT OUTER JOIN "service" s
- ON s.id = pol."serviceId"
- LEFT OUTER JOIN "serviceSupplier" ss
- ON s.id = ss."serviceId" AND po."supplierId" = ss."supplierId";
+ -- TODO: this is an unnecessary join, we should remove it after replacing PO line with item instead of part
+ LEFT OUTER JOIN "item" i
+ ON i.id = pol."itemId"
+ LEFT OUTER JOIN "itemSupplier" ps
+ ON i.id = ps."itemId" AND po."supplierId" = ps."supplierId";
ALTER TABLE "receiptLine" ADD COLUMN "conversionFactor" NUMERIC(10, 2) DEFAULT 1;
diff --git a/packages/database/supabase/migrations/20240412224648_sales-orders.sql b/packages/database/supabase/migrations/20240412224648_sales-orders.sql
index 8265048e34..9d9055bc3b 100644
--- a/packages/database/supabase/migrations/20240412224648_sales-orders.sql
+++ b/packages/database/supabase/migrations/20240412224648_sales-orders.sql
@@ -54,8 +54,15 @@ CREATE INDEX "salesOrder_companyId_idx" ON "salesOrder" ("companyId");
CREATE TYPE "salesOrderLineType" AS ENUM (
'Comment',
+ 'G/L Account',
+ 'Fixed Asset',
'Part',
- 'Service'
+ 'Material',
+ 'Tool',
+ 'Hardware',
+ 'Service',
+ 'Consumable',
+ 'Fixture'
);
CREATE TABLE "salesOrderStatusHistory" (
@@ -75,8 +82,7 @@ CREATE TABLE "salesOrderLine" (
"id" TEXT NOT NULL DEFAULT xid(),
"salesOrderId" TEXT NOT NULL,
"salesOrderLineType" "salesOrderLineType" NOT NULL,
- "partId" TEXT,
- "serviceId" TEXT,
+ "itemId" TEXT,
"accountNumber" TEXT,
"assetId" TEXT,
"description" TEXT,
@@ -104,32 +110,36 @@ CREATE TABLE "salesOrderLine" (
CHECK (
(
"salesOrderLineType" = 'Comment' AND
- "partId" IS NULL AND
- "serviceId" IS NULL AND
+ "itemId" IS NULL AND
"accountNumber" IS NULL AND
"assetId" IS NULL AND
"description" IS NOT NULL
)
OR (
- "salesOrderLineType" = 'Part' AND
- "partId" IS NOT NULL AND
- "serviceId" IS NULL AND
+ (
+ "salesOrderLineType" = 'Part' OR
+ "salesOrderLineType" = 'Material' OR
+ "salesOrderLineType" = 'Tool' OR
+ "salesOrderLineType" = 'Hardware' OR
+ "salesOrderLineType" = 'Consumable' OR
+ "salesOrderLineType" = 'Fixture' OR
+ "salesOrderLineType" = 'Service'
+ ) AND
+ "itemId" IS NOT NULL AND
"accountNumber" IS NULL AND
"assetId" IS NULL
)
OR (
- "salesOrderLineType" = 'Service' AND
- "partId" IS NULL AND
- "serviceId" IS NOT NULL AND
+ "salesOrderLineType" = 'Fixed Asset' AND
+ "itemId" IS NULL AND
"accountNumber" IS NULL AND
- "assetId" IS NULL
+ "assetId" IS NOT NULL
)
),
CONSTRAINT "salesOrderLine_pkey" PRIMARY KEY ("id"),
CONSTRAINT "salesOrderLine_salesOrderId_fkey" FOREIGN KEY ("salesOrderId") REFERENCES "salesOrder" ("id") ON DELETE CASCADE,
- CONSTRAINT "salesOrderLine_partId_fkey" FOREIGN KEY ("partId", "companyId") REFERENCES "part" ("id", "companyId") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "salesOrderLine_serviceId_fkey" FOREIGN KEY ("serviceId", "companyId") REFERENCES "service" ("id", "companyId") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "salesOrderLine_itemId_fkey" FOREIGN KEY ("itemId") REFERENCES "item" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "salesOrderLine_accountNumber_fkey" FOREIGN KEY ("accountNumber", "companyId") REFERENCES "account" ("number", "companyId") ON DELETE CASCADE ON UPDATE CASCADE,
-- TODO: Add assetId foreign key
CONSTRAINT "salesOrderLine_shelfId_fkey" FOREIGN KEY ("shelfId", "locationId") REFERENCES "shelf" ("id", "locationId") ON DELETE CASCADE,
@@ -623,106 +633,11 @@ CREATE OR REPLACE VIEW "customers" WITH(SECURITY_INVOKER=true) AS
CREATE OR REPLACE VIEW "salesOrderLines" WITH(SECURITY_INVOKER=true) AS
SELECT
sol.*,
- so."customerId"
- -- ,
- -- p.name AS "partName",
- -- p.description AS "partDescription"
+ so."customerId",
+ i.name AS "itemName",
+ i.description AS "itemDescription"
FROM "salesOrderLine" sol
INNER JOIN "salesOrder" so
ON so.id = sol."salesOrderId"
- LEFT OUTER JOIN "part" p
- ON p.id = sol."partId";
-
-/*CREATE OR REPLACE VIEW "salesOrderLocations" WITH(SECURITY_INVOKER=true) AS
- SELECT
- so.id,
- s.name AS "supplierName",
- sa."addressLine1" AS "supplierAddressLine1",
- sa."addressLine2" AS "supplierAddressLine2",
- sa."city" AS "supplierCity",
- sa."state" AS "supplierState",
- sa."postalCode" AS "supplierPostalCode",
- sa."countryCode" AS "supplierCountryCode",
- dl.name AS "deliveryName",
- dl."addressLine1" AS "deliveryAddressLine1",
- dl."addressLine2" AS "deliveryAddressLine2",
- dl."city" AS "deliveryCity",
- dl."state" AS "deliveryState",
- dl."postalCode" AS "deliveryPostalCode",
- dl."countryCode" AS "deliveryCountryCode",
- pod."dropShipment",
- c.name AS "customerName",
- ca."addressLine1" AS "customerAddressLine1",
- ca."addressLine2" AS "customerAddressLine2",
- ca."city" AS "customerCity",
- ca."state" AS "customerState",
- ca."postalCode" AS "customerPostalCode",
- ca."countryCode" AS "customerCountryCode"
- FROM "salesOrder" so
- LEFT OUTER JOIN "supplier" s
- ON s.id = po."supplierId"
- LEFT OUTER JOIN "supplierLocation" sl
- ON sl.id = po."supplierLocationId"
- LEFT OUTER JOIN "address" sa
- ON sa.id = sl."addressId"
- INNER JOIN "purchaseOrderDelivery" pod
- ON pod.id = po.id
- LEFT OUTER JOIN "location" dl
- ON dl.id = pod."locationId"
- LEFT OUTER JOIN "customer" c
- ON c.id = pod."customerId"
- LEFT OUTER JOIN "customerLocation" cl
- ON cl.id = pod."customerLocationId"
- LEFT OUTER JOIN "address" ca
- ON ca.id = cl."addressId";*/
-
-/*
-DROP VIEW "partQuantities";
-CREATE OR REPLACE VIEW "partQuantities" AS
- SELECT
- p."id" AS "partId",
- loc."id" AS "locationId",
- COALESCE(SUM(pl."quantity"), 0) AS "quantityOnHand",
- COALESCE(pol."quantityToReceive", 0) AS "quantityOnPurchaseOrder",
- COALESCE(sol."quantityToSend", 0) AS "quantityOnSalesOrder",
- 0 AS "quantityOnProdOrder",
- 0 AS "quantityAvailable"
- FROM "part" p
- CROSS JOIN "location" loc
- LEFT JOIN "partLedger" pl
- ON pl."partId" = p."id" AND pl."locationId" = loc."id"
- LEFT JOIN (
- SELECT
- pol."partId",
- pol."locationId",
- COALESCE(SUM(GREATEST(pol."quantityToReceive", 0)), 0) AS "quantityToReceive"
- FROM "purchaseOrderLine" pol
- INNER JOIN "purchaseOrder" po
- ON pol."purchaseOrderId" = po."id"
- WHERE po."status" != 'Draft'
- AND po."status" != 'Rejected'
- AND po."status" != 'Closed'
- GROUP BY
- pol."partId",
- pol."locationId"
- ) pol ON pol."partId" = p."id" AND pol."locationId" = loc."id"
- LEFT JOIN (
- SELECT
- sol."partId",
- sol."locationId",
- COALESCE(SUM(GREATEST(sol."quantityToSend", 0)), 0) AS "quantityToSend"
- FROM "salesOrderLine" sol
- INNER JOIN "salesOrder" so
- ON sol."salesOrderId" = so."id"
- WHERE so."status" != 'Draft'
- AND so."status" != 'Cancelled'
- AND so."status" != 'Needs Approval'
- GROUP BY
- sol."partId",
- sol."locationId"
- ) sol ON sol."partId" = p."id" AND sol."locationId" = loc."id"
- GROUP BY
- p."id",
- loc."id",
- pol."quantityToReceive",
- sol."quantityToSend"*/
+ LEFT OUTER JOIN "item" i
+ ON i.id = sol."itemId";
diff --git a/packages/database/supabase/migrations/20240511125727_seed_custom_fields.sql b/packages/database/supabase/migrations/20240511125727_seed_custom_fields.sql
index 6115e5f4d6..189d63708d 100644
--- a/packages/database/supabase/migrations/20240511125727_seed_custom_fields.sql
+++ b/packages/database/supabase/migrations/20240511125727_seed_custom_fields.sql
@@ -21,13 +21,13 @@ VALUES
('journalLine', 'Journal Line', 'Accounting'),
('location', 'Location', 'Resources'),
('part', 'Part', 'Parts'),
-('partCost', 'Part Cost', 'Parts'),
+('itemCost', 'Item Cost', 'Parts'),
('itemGroup', 'Item Group', 'Parts'),
-('partInventory', 'Part Inventory', 'Parts'),
-('partPlanning', 'Part Planning', 'Parts'),
-('partReplenishment', 'Part Replenishment', 'Parts'),
-('partSupplier', 'Part Supplier', 'Parts'),
-('partUnitSalePrice', 'Part Unit Sale Price', 'Parts'),
+('itemInventory', 'Item Inventory', 'Parts'),
+('itemPlanning', 'Item Planning', 'Parts'),
+('itemReplenishment', 'Item Replenishment', 'Parts'),
+('itemSupplier', 'Item Supplier', 'Parts'),
+('itemUnitSalePrice', 'Item Unit Sale Price', 'Parts'),
('partner', 'Partner', 'Resources'),
('paymentTerm', 'Payment Term', 'Accounting'),
('purchaseInvoice', 'Purchase Invoice', 'Invoicing'),