Skip to content

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

feat: llm implementation of warehouse transfers

Brad Barbin9b78384a6f16
diff --git a/apps/erp/app/modules/inventory/inventory.models.ts b/apps/erp/app/modules/inventory/inventory.models.ts
index 2425257589..f670c44d49 100644
--- a/apps/erp/app/modules/inventory/inventory.models.ts
+++ b/apps/erp/app/modules/inventory/inventory.models.ts
@@ -178,7 +178,7 @@ export const shippingMethodValidator = z.object({
id: zfd.text(z.string().optional()),
name: z.string().min(1, { message: "Name is required" }),
carrier: z.enum(["UPS", "FedEx", "USPS", "DHL", "Other"], {
- errorMap: (issue, ctx) => ({
+ errorMap: () => ({
message: "Carrier is required",
}),
}),
@@ -194,3 +194,49 @@ export const splitValidator = z.object({
locationId: z.string().min(1, { message: "Location ID is required" }),
quantity: zfd.numeric(z.number()),
});
+
+export const warehouseTransferStatusType = [
+ "Draft",
+ "Confirmed",
+ "In Transit",
+ "Partially Received",
+ "Received",
+ "Cancelled"
+] as const;
+
+export const warehouseTransferValidator = z.object({
+ id: z.string().min(1),
+ transferId: z.string().min(1, { message: "Transfer ID is required" }),
+ fromLocationId: z.string().min(1, { message: "From Location is required" }),
+ toLocationId: z.string().min(1, { message: "To Location is required" }),
+ status: z.enum(warehouseTransferStatusType).optional(),
+ transferDate: zfd.text(z.string().optional()),
+ expectedReceiptDate: zfd.text(z.string().optional()),
+ notes: zfd.text(z.string().optional()),
+ reference: zfd.text(z.string().optional()),
+}).refine(
+ (data) => data.fromLocationId !== data.toLocationId,
+ {
+ message: "From and To locations must be different",
+ path: ["toLocationId"]
+ }
+);
+
+export const warehouseTransferLineValidator = z.object({
+ id: z.string().min(1).optional(),
+ transferId: z.string().min(1, { message: "Transfer ID is required" }),
+ itemId: z.string().min(1, { message: "Item is required" }),
+ quantity: zfd.numeric(z.number().min(0.0001, { message: "Quantity must be greater than 0" })),
+ fromLocationId: z.string().min(1, { message: "From Location is required" }),
+ fromShelfId: zfd.text(z.string().optional()),
+ toLocationId: z.string().min(1, { message: "To Location is required" }),
+ toShelfId: zfd.text(z.string().optional()),
+ unitOfMeasureCode: zfd.text(z.string().optional()),
+ notes: zfd.text(z.string().optional()),
+}).refine(
+ (data) => data.fromLocationId !== data.toLocationId,
+ {
+ message: "From and To locations must be different",
+ path: ["toLocationId"]
+ }
+);
diff --git a/apps/erp/app/modules/inventory/inventory.service.ts b/apps/erp/app/modules/inventory/inventory.service.ts
index 6d5696bd78..d88454df91 100644
--- a/apps/erp/app/modules/inventory/inventory.service.ts
+++ b/apps/erp/app/modules/inventory/inventory.service.ts
@@ -15,6 +15,7 @@ import type {
shelfValidator,
shipmentValidator,
shippingMethodValidator,
+ warehouseTransferValidator,
} from "./inventory.models";
export async function deleteBatchProperty(
@@ -861,3 +862,168 @@ export async function upsertShipment(
.select("id")
.single();
}
+
+// Warehouse Transfer functions
+export async function getWarehouseTransfers(
+ client: SupabaseClient<Database>,
+ companyId: string,
+ args: GenericQueryFilters & {
+ search: string | null;
+ }
+) {
+ let query = client
+ .from("warehouseTransfer")
+ .select(
+ "*, fromLocation:location!fromLocationId(name), toLocation:location!toLocationId(name)",
+ {
+ count: "exact",
+ }
+ )
+ .eq("companyId", companyId);
+
+ if (args.search) {
+ query = query.or(
+ `transferId.ilike.%${args.search}%,reference.ilike.%${args.search}%`
+ );
+ }
+
+ query = setGenericQueryFilters(query, args, [
+ { column: "transferId", ascending: false },
+ ]);
+ return query;
+}
+
+export async function getWarehouseTransfer(
+ client: SupabaseClient<Database>,
+ transferId: string
+) {
+ return client
+ .from("warehouseTransfer")
+ .select(
+ "*, fromLocation:location!fromLocationId(*), toLocation:location!toLocationId(*)"
+ )
+ .eq("id", transferId)
+ .single();
+}
+
+export async function getWarehouseTransferLines(
+ client: SupabaseClient<Database>,
+ transferId: string
+) {
+ return client
+ .from("warehouseTransferLine")
+ .select(
+ "*, item(*), fromShelf:shelf!fromShelfId(name), toShelf:shelf!toShelfId(name)"
+ )
+ .eq("transferId", transferId);
+}
+
+export async function deleteWarehouseTransfer(
+ client: SupabaseClient<Database>,
+ transferId: string
+) {
+ return client.from("warehouseTransfer").delete().eq("id", transferId);
+}
+
+export async function deleteWarehouseTransferLine(
+ client: SupabaseClient<Database>,
+ transferLineId: string
+) {
+ return client.from("warehouseTransferLine").delete().eq("id", transferLineId);
+}
+
+export async function upsertWarehouseTransfer(
+ client: SupabaseClient<Database>,
+ transfer:
+ | (Omit<z.infer<typeof warehouseTransferValidator>, "id" | "transferId"> & {
+ transferId: string;
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof warehouseTransferValidator>, "id" | "transferId"> & {
+ id: string;
+ transferId: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+) {
+ if ("createdBy" in transfer) {
+ return client
+ .from("warehouseTransfer")
+ .insert([transfer])
+ .select("*")
+ .single();
+ }
+ return client
+ .from("warehouseTransfer")
+ .update({
+ ...sanitize(transfer),
+ updatedAt: today(getLocalTimeZone()).toString(),
+ })
+ .eq("id", transfer.id)
+ .select("id")
+ .single();
+}
+
+export async function shipWarehouseTransfer(
+ client: SupabaseClient<Database>,
+ transferId: string,
+ quantity: number,
+ updatedBy: string
+) {
+ // Update all transfer lines to mark quantities as shipped
+ const linesUpdate = await client
+ .from("warehouseTransferLine")
+ .update({
+ shippedQuantity: quantity,
+ updatedBy,
+ updatedAt: new Date().toISOString(),
+ })
+ .eq("transferId", transferId);
+
+ if (linesUpdate.error) {
+ return linesUpdate;
+ }
+
+ // Update transfer status to In Transit
+ return client
+ .from("warehouseTransfer")
+ .update({
+ status: "In Transit",
+ updatedBy,
+ updatedAt: new Date().toISOString(),
+ })
+ .eq("id", transferId);
+}
+
+export async function receiveWarehouseTransfer(
+ client: SupabaseClient<Database>,
+ transferId: string,
+ quantity: number,
+ updatedBy: string
+) {
+ // Update all transfer lines to mark quantities as received
+ const linesUpdate = await client
+ .from("warehouseTransferLine")
+ .update({
+ receivedQuantity: quantity,
+ updatedBy,
+ updatedAt: new Date().toISOString(),
+ })
+ .eq("transferId", transferId);
+
+ if (linesUpdate.error) {
+ return linesUpdate;
+ }
+
+ // Update transfer status to Received
+ return client
+ .from("warehouseTransfer")
+ .update({
+ status: "Received",
+ updatedBy,
+ updatedAt: new Date().toISOString(),
+ })
+ .eq("id", transferId);
+}
diff --git a/apps/erp/app/modules/inventory/types.ts b/apps/erp/app/modules/inventory/types.ts
index 9e75292496..63bd49fc72 100644
--- a/apps/erp/app/modules/inventory/types.ts
+++ b/apps/erp/app/modules/inventory/types.ts
@@ -11,6 +11,8 @@ import type {
getShippingMethods,
getShipmentTracking,
getTrackedEntities,
+ getWarehouseTransfers,
+ getWarehouseTransferLines,
} from "./inventory.service";
export type BatchProperty = NonNullable<
@@ -70,6 +72,14 @@ export type TrackedEntity = NonNullable<
Awaited<ReturnType<typeof getTrackedEntities>>["data"]
>[number];
+export type WarehouseTransfer = NonNullable<
+ Awaited<ReturnType<typeof getWarehouseTransfers>>["data"]
+>[number];
+
+export type WarehouseTransferLine = NonNullable<
+ Awaited<ReturnType<typeof getWarehouseTransferLines>>["data"]
+>[number];
+
export interface Activity {
id: string;
type: string;
diff --git a/apps/erp/app/modules/inventory/ui/WarehouseTransfers/WarehouseTransferForm.tsx b/apps/erp/app/modules/inventory/ui/WarehouseTransfers/WarehouseTransferForm.tsx
new file mode 100644
index 0000000000..ec89136e7e
--- /dev/null
+++ b/apps/erp/app/modules/inventory/ui/WarehouseTransfers/WarehouseTransferForm.tsx
@@ -0,0 +1,62 @@
+import { ValidatedForm } from "@carbon/form";
+import {
+ Card,
+ CardContent,
+ CardHeader,
+ CardTitle,
+ VStack,
+} from "@carbon/react";
+import type { z } from "zod";
+import {
+ DatePicker,
+ Hidden,
+ Input,
+ Location,
+ Submit,
+ TextArea,
+} from "~/components/Form";
+import { warehouseTransferValidator } from "../../inventory.models";
+
+type WarehouseTransferFormProps = {
+ initialValues: z.infer<typeof warehouseTransferValidator>;
+};
+
+const WarehouseTransferForm = ({ initialValues }: WarehouseTransferFormProps) => {
+ return (
+ <ValidatedForm
+ validator={warehouseTransferValidator}
+ method="post"
+ defaultValues={initialValues}
+ className="w-full"
+ >
+ <Card className="w-full">
+ <CardHeader>
+ <CardTitle>Transfer Details</CardTitle>
+ </CardHeader>
+ <CardContent>
+ <VStack spacing={4}>
+ <Hidden name="id" />
+ <Input name="transferId" label="Transfer ID" />
+
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
+ <Location name="fromLocationId" label="From Location" />
+ <Location name="toLocationId" label="To Location" />
+ </div>
+
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
+ <DatePicker name="transferDate" label="Transfer Date" />
+ <DatePicker name="expectedReceiptDate" label="Expected Receipt Date" />
+ </div>
+
+ <Input name="reference" label="Reference" />
+ <TextArea name="notes" label="Notes" />
+
+ <Submit>Save Transfer</Submit>
+ </VStack>
+ </CardContent>
+ </Card>
+ </ValidatedForm>
+ );
+};
+
+export default WarehouseTransferForm;
\ No newline at end of file
diff --git a/apps/erp/app/modules/inventory/ui/WarehouseTransfers/WarehouseTransferHeader.tsx b/apps/erp/app/modules/inventory/ui/WarehouseTransfers/WarehouseTransferHeader.tsx
new file mode 100644
index 0000000000..2453a363c7
--- /dev/null
+++ b/apps/erp/app/modules/inventory/ui/WarehouseTransfers/WarehouseTransferHeader.tsx
@@ -0,0 +1,41 @@
+import { Heading, HStack } from "@carbon/react";
+import { Link } from "@remix-run/react";
+import { usePermissions } from "~/hooks";
+import { path } from "~/utils/path";
+import type { WarehouseTransfer } from "../../types";
+import WarehouseTransferStatus from "./WarehouseTransferStatus";
+
+type WarehouseTransferHeaderProps = {
+ warehouseTransfer: WarehouseTransfer;
+};
+
+const WarehouseTransferHeader = ({
+ warehouseTransfer,
+}: WarehouseTransferHeaderProps) => {
+ const permissions = usePermissions();
+
+ const canShip =
+ warehouseTransfer.status === "Confirmed" &&
+ warehouseTransfer.shippedQuantity < warehouseTransfer.totalQuantity;
+
+ const canReceive =
+ warehouseTransfer.status === "In Transit" ||
+ warehouseTransfer.status === "Partially Received";
+
+ return (
+ <div className="flex flex-shrink-0 items-center justify-between px-4 py-2 bg-card border-b border-border h-[50px] overflow-x-auto scrollbar-hide dark:border-none dark:shadow-[inset_0_0_1px_rgb(255_255_255_/_0.24),_0_0_0_0.5px_rgb(0,0,0,1),0px_0px_4px_rgba(0,_0,_0,_0.08)]">
+ <HStack className="w-full justify-between">
+ <HStack>
+ <Link to={path.to.warehouseTransferDetails(warehouseTransfer.id)}>
+ <Heading size="h4" className="flex items-center gap-2">
+ <span>{warehouseTransfer.transferId}</span>
+ </Heading>
+ </Link>
+ <WarehouseTransferStatus status={warehouseTransfer.status} />
+ </HStack>
+ </HStack>
+ </div>
+ );
+};
+
+export default WarehouseTransferHeader;
diff --git a/apps/erp/app/modules/inventory/ui/WarehouseTransfers/WarehouseTransferLines.tsx b/apps/erp/app/modules/inventory/ui/WarehouseTransfers/WarehouseTransferLines.tsx
new file mode 100644
index 0000000000..b499314a00
--- /dev/null
+++ b/apps/erp/app/modules/inventory/ui/WarehouseTransfers/WarehouseTransferLines.tsx
@@ -0,0 +1,113 @@
+import { VStack } from "@carbon/react";
+import type { ColumnDef } from "@tanstack/react-table";
+import { useMemo } from "react";
+import { LuHash, LuPackage, LuMapPin } from "react-icons/lu";
+import { Table } from "~/components";
+import type { WarehouseTransferLine } from "../../types";
+
+type WarehouseTransferLinesProps = {
+ warehouseTransferLines: WarehouseTransferLine[];
+ transferId: string;
+};
+
+const WarehouseTransferLines = ({ warehouseTransferLines }: WarehouseTransferLinesProps) => {
+ const columns = useMemo<ColumnDef<WarehouseTransferLine>[]>(() => [
+ {
+ accessorKey: "itemReadableId",
+ header: "Item",
+ cell: ({ row }) => row.original.item?.readableIdWithRevision || row.original.itemReadableId || "N/A",
+ meta: {
+ icon: <LuPackage />,
+ },
+ },
+ {
+ id: "itemName",
+ header: "Item Name",
+ cell: ({ row }) => row.original.item?.name || "N/A",
+ meta: {
+ icon: <LuHash />,
+ },
+ },
+ {
+ accessorKey: "quantity",
+ header: "Quantity",
+ cell: ({ row }) => {
+ const quantity = Number(row.original.quantity);
+ return quantity.toLocaleString();
+ },
+ meta: {
+ icon: <LuHash />,
+ },
+ },
+ {
+ accessorKey: "shippedQuantity",
+ header: "Shipped",
+ cell: ({ row }) => {
+ const quantity = Number(row.original.shippedQuantity || 0);
+ return quantity.toLocaleString();
+ },
+ meta: {
+ icon: <LuHash />,
+ },
+ },
+ {
+ accessorKey: "receivedQuantity",
+ header: "Received",
+ cell: ({ row }) => {
+ const quantity = Number(row.original.receivedQuantity || 0);
+ return quantity.toLocaleString();
+ },
+ meta: {
+ icon: <LuHash />,
+ },
+ },
+ {
+ id: "fromShelf",
+ header: "From Shelf",
+ cell: ({ row }) => row.original.fromShelf?.name || "N/A",
+ meta: {
+ icon: <LuMapPin />,
+ },
+ },
+ {
+ id: "toShelf",
+ header: "To Shelf",
+ cell: ({ row }) => row.original.toShelf?.name || "N/A",
+ meta: {
+ icon: <LuMapPin />,
+ },
+ },
+ {
+ accessorKey: "unitOfMeasureCode",
+ header: "UoM",
+ cell: ({ row }) => row.original.unitOfMeasureCode || "N/A",
+ meta: {
+ icon: <LuHash />,
+ },
+ },
+ {
+ accessorKey: "notes",
+ header: "Notes",
+ cell: ({ row }) => row.original.notes || "",
+ meta: {
+ icon: <LuHash />,
+ },
+ },
+ ], []);
+
+ return (
+ <VStack spacing={4} className="w-full">
+ <Table<WarehouseTransferLine>
+ data={warehouseTransferLines}
+ columns={columns}
+ count={warehouseTransferLines.length}
+ title="Transfer Lines"
+ defaultColumnVisibility={{
+ notes: false,
+ }}
+ />
+ </VStack>
+ );
+};
+
+export default WarehouseTransferLines;
\ No newline at end of file
diff --git a/apps/erp/app/modules/inventory/ui/WarehouseTransfers/WarehouseTransferStatus.tsx b/apps/erp/app/modules/inventory/ui/WarehouseTransfers/WarehouseTransferStatus.tsx
new file mode 100644
index 0000000000..147dfe38eb
--- /dev/null
+++ b/apps/erp/app/modules/inventory/ui/WarehouseTransfers/WarehouseTransferStatus.tsx
@@ -0,0 +1,27 @@
+import { Badge } from "@carbon/react";
+import type { warehouseTransferStatusType } from "../../inventory.models";
+
+type Props = {
+ status: (typeof warehouseTransferStatusType)[number];
+};
+
+const WarehouseTransferStatus = ({ status }: Props) => {
+ switch (status) {
+ case "Draft":
+ return <Badge variant="secondary">Draft</Badge>;
+ case "Confirmed":
+ return <Badge variant="yellow">Confirmed</Badge>;
+ case "In Transit":
+ return <Badge variant="blue">In Transit</Badge>;
+ case "Partially Received":
+ return <Badge variant="yellow">Partially Received</Badge>;
+ case "Received":
+ return <Badge variant="green">Received</Badge>;
+ case "Cancelled":
+ return <Badge variant="destructive">Cancelled</Badge>;
+ default:
+ return <Badge variant="secondary">{status}</Badge>;
+ }
+};
+
+export default WarehouseTransferStatus;
diff --git a/apps/erp/app/modules/inventory/ui/WarehouseTransfers/WarehouseTransfersTable.tsx b/apps/erp/app/modules/inventory/ui/WarehouseTransfers/WarehouseTransfersTable.tsx
new file mode 100644
index 0000000000..88c3a5192a
--- /dev/null
+++ b/apps/erp/app/modules/inventory/ui/WarehouseTransfers/WarehouseTransfersTable.tsx
@@ -0,0 +1,274 @@
+import { MenuIcon, MenuItem, useDisclosure } from "@carbon/react";
+import { formatDate } from "@carbon/utils";
+import { useNavigate } from "@remix-run/react";
+import type { ColumnDef } from "@tanstack/react-table";
+import { memo, useCallback, useMemo, useState } from "react";
+import {
+ LuBookMarked,
+ LuCalendar,
+ LuClock,
+ LuHash,
+ LuMapPin,
+ LuPencil,
+ LuTrash,
+ LuUser,
+} from "react-icons/lu";
+import { EmployeeAvatar, Hyperlink, New, Table } from "~/components";
+import { ConfirmDelete } from "~/components/Modals";
+import { usePermissions, useRealtime, useUrlParams } from "~/hooks";
+import { useCustomColumns } from "~/hooks/useCustomColumns";
+import { usePeople } from "~/stores";
+import { path } from "~/utils/path";
+import { warehouseTransferStatusType } from "../../inventory.models";
+import type { WarehouseTransfer } from "../../types";
+import WarehouseTransferStatus from "./WarehouseTransferStatus";
+
+type WarehouseTransfersTableProps = {
+ data: WarehouseTransfer[];
+ count: number;
+};
+
+const WarehouseTransfersTable = memo(
+ ({ data, count }: WarehouseTransfersTableProps) => {
+ useRealtime(
+ "warehouseTransfer",
+ `id=in.(${data.map((d) => d.id).join(",")})`
+ );
+
+ const [params] = useUrlParams();
+ const navigate = useNavigate();
+ const permissions = usePermissions();
+
+ const rows = useMemo(() => data, [data]);
+ const [people] = usePeople();
+ const customColumns =
+ useCustomColumns<WarehouseTransfer>("warehouseTransfer");
+
+ const columns = useMemo<ColumnDef<WarehouseTransfer>[]>(() => {
+ const result: ColumnDef<(typeof rows)[number]>[] = [
+ {
+ accessorKey: "transferId",
+ header: "Transfer ID",
+ cell: ({ row }) => (
+ <Hyperlink to={path.to.warehouseTransferDetails(row.original.id!)}>
+ {row.original.transferId}
+ </Hyperlink>
+ ),
+ meta: {
+ icon: <LuBookMarked />,
+ },
+ },
+ {
+ accessorKey: "status",
+ header: "Status",
+ cell: (item) => {
+ const status =
+ item.getValue<(typeof warehouseTransferStatusType)[number]>();
+ return <WarehouseTransferStatus status={status} />;
+ },
+ meta: {
+ filter: {
+ type: "static",
+ options: warehouseTransferStatusType.map((type) => ({
+ value: type,
+ label: <WarehouseTransferStatus status={type} />,
+ })),
+ },
+ pluralHeader: "Statuses",
+ icon: <LuClock />,
+ },
+ },
+ {
+ id: "fromLocation",
+ header: "From Location",
+ cell: ({ row }) => row.original.fromLocation?.name || "N/A",
+ meta: {
+ icon: <LuMapPin />,
+ },
+ },
+ {
+ id: "toLocation",
+ header: "To Location",
+ cell: ({ row }) => row.original.toLocation?.name || "N/A",
+ meta: {
+ icon: <LuMapPin />,
+ },
+ },
+ {
+ accessorKey: "reference",
+ header: "Reference",
+ cell: (item) => item.getValue(),
+ meta: {
+ icon: <LuHash />,
+ },
+ },
+ {
+ accessorKey: "transferDate",
+ header: "Transfer Date",
+ cell: (item) => {
+ const date = item.getValue<string>();
+ return date ? formatDate(date) : "N/A";
+ },
+ meta: {
+ icon: <LuCalendar />,
+ },
+ },
+ {
+ accessorKey: "expectedReceiptDate",
+ header: "Expected Receipt",
+ cell: (item) => {
+ const date = item.getValue<string>();
+ return date ? formatDate(date) : "N/A";
+ },
+ meta: {
+ icon: <LuCalendar />,
+ },
+ },
+ {
+ id: "createdBy",
+ header: "Created By",
+ cell: ({ row }) => (
+ <EmployeeAvatar employeeId={row.original.createdBy} />
+ ),
+ meta: {
+ filter: {
+ type: "static",
+ options: people.map((employee) => ({
+ value: employee.id,
+ label: employee.name,
+ })),
+ },
+ icon: <LuUser />,
+ },
+ },
+ {
+ accessorKey: "createdAt",
+ header: "Created At",
+ cell: (item) => formatDate(item.getValue<string>()),
+ meta: {
+ icon: <LuCalendar />,
+ },
+ },
+ {
+ id: "updatedBy",
+ header: "Updated By",
+ cell: ({ row }) => (
+ <EmployeeAvatar employeeId={row.original.updatedBy} />
+ ),
+ meta: {
+ filter: {
+ type: "static",
+ options: people.map((employee) => ({
+ value: employee.id,
+ label: employee.name,
+ })),
+ },
+ icon: <LuUser />,
+ },
+ },
+ {
+ accessorKey: "updatedAt",
+ header: "Updated At",
+ cell: (item) => formatDate(item.getValue<string>()),
+ meta: {
+ icon: <LuCalendar />,
+ },
+ },
+ ];
+
+ return [...result, ...customColumns];
+ }, [people, customColumns]);
+
+ const [selectedTransfer, setSelectedTransfer] =
+ useState<WarehouseTransfer | null>(null);
+ const deleteTransferModal = useDisclosure();
+
+ const renderContextMenu = useCallback(
+ (row: WarehouseTransfer) => {
+ return (
+ <>
+ <MenuItem
+ disabled={!permissions.can("update", "inventory")}
+ onClick={() => {
+ navigate(
+ `${path.to.warehouseTransferDetails(
+ row.id!
+ )}?${params.toString()}`
+ );
+ }}
+ >
+ <MenuIcon icon={<LuPencil />} />
+ {row.status === "Received" ? "View Transfer" : "Edit Transfer"}
+ </MenuItem>
+ <MenuItem
+ disabled={
+ !permissions.can("delete", "inventory") ||
+ row.status === "In Transit" ||
+ row.status === "Received"
+ }
+ destructive
+ onClick={() => {
+ setSelectedTransfer(row);
+ deleteTransferModal.onOpen();
+ }}
+ >
+ <MenuIcon icon={<LuTrash />} />
+ Delete Transfer
+ </MenuItem>
+ </>
+ );
+ },
+ [deleteTransferModal, navigate, params, permissions]
+ );
+
+ return (
+ <>
+ <Table<(typeof data)[number]>
+ data={data}
+ columns={columns}
+ count={count}
+ defaultColumnPinning={{
+ left: ["transferId"],
+ }}
+ defaultColumnVisibility={{
+ createdAt: false,
+ createdBy: false,
+ updatedAt: false,
+ updatedBy: false,
+ }}
+ primaryAction={
+ permissions.can("create", "inventory") && (
+ <New
+ label="Warehouse Transfer"
+ to={path.to.newWarehouseTransfer}
+ />
+ )
+ }
+ renderContextMenu={renderContextMenu}
+ title="Warehouse Transfers"
+ table="warehouseTransfer"
+ withSavedView
+ />
+ {selectedTransfer && selectedTransfer.id && (
+ <ConfirmDelete
+ action={path.to.deleteWarehouseTransfer(selectedTransfer.id)}
+ isOpen={deleteTransferModal.isOpen}
+ name={selectedTransfer.transferId!}
+ text={`Are you sure you want to delete ${selectedTransfer.transferId!}? This cannot be undone.`}
+ onCancel={() => {
+ deleteTransferModal.onClose();
+ setSelectedTransfer(null);
+ }}
+ onSubmit={() => {
+ deleteTransferModal.onClose();
+ setSelectedTransfer(null);
+ }}
+ />
+ )}
+ </>
+ );
+ }
+);
+
+WarehouseTransfersTable.displayName = "WarehouseTransfersTable";
+export default WarehouseTransfersTable;
diff --git a/apps/erp/app/modules/inventory/ui/WarehouseTransfers/index.ts b/apps/erp/app/modules/inventory/ui/WarehouseTransfers/index.ts
new file mode 100644
index 0000000000..8f7f9cda3f
--- /dev/null
+++ b/apps/erp/app/modules/inventory/ui/WarehouseTransfers/index.ts
@@ -0,0 +1,5 @@
+export { default as WarehouseTransfersTable } from "./WarehouseTransfersTable";
+export { default as WarehouseTransferHeader } from "./WarehouseTransferHeader";
+export { default as WarehouseTransferLines } from "./WarehouseTransferLines";
+export { default as WarehouseTransferStatus } from "./WarehouseTransferStatus";
+export { default as WarehouseTransferForm } from "./WarehouseTransferForm";
\ No newline at end of file
diff --git a/apps/erp/app/modules/inventory/ui/index.ts b/apps/erp/app/modules/inventory/ui/index.ts
index df10a78433..2a312d9047 100644
--- a/apps/erp/app/modules/inventory/ui/index.ts
+++ b/apps/erp/app/modules/inventory/ui/index.ts
@@ -3,4 +3,5 @@ export * from "./Inventory";
export * from "./Receipts";
export * from "./Shelves";
export * from "./ShippingMethods";
+export * from "./WarehouseTransfers";
export { useInventorySubmodules };
diff --git a/apps/erp/app/modules/inventory/ui/useInventorySubmodules.tsx b/apps/erp/app/modules/inventory/ui/useInventorySubmodules.tsx
index 3e9d87427d..d64f7c8876 100644
--- a/apps/erp/app/modules/inventory/ui/useInventorySubmodules.tsx
+++ b/apps/erp/app/modules/inventory/ui/useInventorySubmodules.tsx
@@ -1,4 +1,5 @@
import {
+ LuArrowRightLeft,
LuHandCoins,
LuNetwork,
LuQrCode,
@@ -26,6 +27,12 @@ const inventoryRoutes: AuthenticatedRouteGroup[] = [
icon: <LuTruck />,
table: "shipment",
},
+ {
+ name: "Transfers",
+ to: path.to.warehouseTransfers,
+ icon: <LuArrowRightLeft />,
+ table: "warehouseTransfer",
+ },
],
},
{
diff --git a/apps/erp/app/routes/x+/inventory+/warehouse-transfers.tsx b/apps/erp/app/routes/x+/inventory+/warehouse-transfers.tsx
new file mode 100644
index 0000000000..0869bfef4e
--- /dev/null
+++ b/apps/erp/app/routes/x+/inventory+/warehouse-transfers.tsx
@@ -0,0 +1,62 @@
+import { error } from "@carbon/auth";
+import { requirePermissions } from "@carbon/auth/auth.server";
+import { flash } from "@carbon/auth/session.server";
+import { VStack } from "@carbon/react";
+import { Outlet, useLoaderData } from "@remix-run/react";
+import type { LoaderFunctionArgs } from "@vercel/remix";
+import { json, redirect } from "@vercel/remix";
+import { getWarehouseTransfers } from "~/modules/inventory";
+import WarehouseTransfersTable from "~/modules/inventory/ui/WarehouseTransfers/WarehouseTransfersTable";
+import type { Handle } from "~/utils/handle";
+import { path } from "~/utils/path";
+import { getGenericQueryFilters } from "~/utils/query";
+
+export const handle: Handle = {
+ breadcrumb: "Warehouse Transfers",
+ to: path.to.warehouseTransfers,
+};
+
+export async function loader({ request }: LoaderFunctionArgs) {
+ const { client, companyId } = await requirePermissions(request, {
+ view: "inventory",
+ });
+
+ const url = new URL(request.url);
+ const searchParams = new URLSearchParams(url.search);
+ const search = searchParams.get("search");
+ const { limit, offset, sorts, filters } =
+ getGenericQueryFilters(searchParams);
+
+ const [warehouseTransfers] = await Promise.all([
+ getWarehouseTransfers(client, companyId, {
+ search,
+ limit,
+ offset,
+ sorts,
+ filters,
+ }),
+ ]);
+
+ if (warehouseTransfers.error) {
+ throw redirect(
+ path.to.authenticatedRoot,
+ await flash(request, error(null, "Error loading warehouse transfers"))
+ );
+ }
+
+ return json({
+ warehouseTransfers: warehouseTransfers.data ?? [],
+ count: warehouseTransfers.count ?? 0,
+ });
+}
+
+export default function WarehouseTransfersRoute() {
+ const { warehouseTransfers, count } = useLoaderData<typeof loader>();
+
+ return (
+ <VStack spacing={0} className="h-full">
+ <WarehouseTransfersTable data={warehouseTransfers} count={count ?? 0} />
+ <Outlet />
+ </VStack>
+ );
+}
\ No newline at end of file
diff --git a/apps/erp/app/routes/x+/warehouse-transfer+/$transferId.delete.tsx b/apps/erp/app/routes/x+/warehouse-transfer+/$transferId.delete.tsx
new file mode 100644
index 0000000000..08e123d235
--- /dev/null
+++ b/apps/erp/app/routes/x+/warehouse-transfer+/$transferId.delete.tsx
@@ -0,0 +1,33 @@
+import { error, success } from "@carbon/auth";
+import { requirePermissions } from "@carbon/auth/auth.server";
+import { flash } from "@carbon/auth/session.server";
+import type { ActionFunctionArgs } from "@vercel/remix";
+import { redirect } from "@vercel/remix";
+import { deleteWarehouseTransfer } from "~/modules/inventory";
+import { path } from "~/utils/path";
+
+export async function action({ request, params }: ActionFunctionArgs) {
+ const { client } = await requirePermissions(request, {
+ delete: "inventory",
+ });
+
+ const { transferId } = params;
+ if (!transferId) throw new Response("Not found", { status: 404 });
+
+ const result = await deleteWarehouseTransfer(client, transferId);
+
+ if (result.error) {
+ throw redirect(
+ path.to.warehouseTransferDetails(transferId),
+ await flash(
+ request,
+ error(result.error, "Failed to delete warehouse transfer")
+ )
+ );
+ }
+
+ throw redirect(
+ path.to.warehouseTransfers,
+ await flash(request, success("Warehouse transfer deleted successfully"))
+ );
+}
\ No newline at end of file
diff --git a/apps/erp/app/routes/x+/warehouse-transfer+/$transferId.receive.tsx b/apps/erp/app/routes/x+/warehouse-transfer+/$transferId.receive.tsx
new file mode 100644
index 0000000000..20f869f04f
--- /dev/null
+++ b/apps/erp/app/routes/x+/warehouse-transfer+/$transferId.receive.tsx
@@ -0,0 +1,33 @@
+import { error, success } from "@carbon/auth";
+import { requirePermissions } from "@carbon/auth/auth.server";
+import { flash } from "@carbon/auth/session.server";
+import type { ActionFunctionArgs } from "@vercel/remix";
+import { redirect } from "@vercel/remix";
+import { receiveWarehouseTransfer } from "~/modules/inventory";
+import { path } from "~/utils/path";
+
+export async function action({ request, params }: ActionFunctionArgs) {
+ const { client, userId } = await requirePermissions(request, {
+ update: "inventory",
+ });
+
+ const { transferId } = params;
+ if (!transferId) throw new Response("Not found", { status: 404 });
+
+ const result = await receiveWarehouseTransfer(client, transferId, 0, userId);
+
+ if (result.error) {
+ throw redirect(
+ path.to.warehouseTransferDetails(transferId),
+ await flash(
+ request,
+ error(result.error, "Failed to receive warehouse transfer")
+ )
+ );
+ }
+
+ throw redirect(
+ path.to.warehouseTransferDetails(transferId),
+ await flash(request, success("Warehouse transfer received successfully"))
+ );
+}
diff --git a/apps/erp/app/routes/x+/warehouse-transfer+/$transferId.ship.tsx b/apps/erp/app/routes/x+/warehouse-transfer+/$transferId.ship.tsx
new file mode 100644
index 0000000000..495baee373
--- /dev/null
+++ b/apps/erp/app/routes/x+/warehouse-transfer+/$transferId.ship.tsx
@@ -0,0 +1,33 @@
+import { error, success } from "@carbon/auth";
+import { requirePermissions } from "@carbon/auth/auth.server";
+import { flash } from "@carbon/auth/session.server";
+import type { ActionFunctionArgs } from "@vercel/remix";
+import { redirect } from "@vercel/remix";
+import { shipWarehouseTransfer } from "~/modules/inventory";
+import { path } from "~/utils/path";
+
+export async function action({ request, params }: ActionFunctionArgs) {
+ const { client, userId } = await requirePermissions(request, {
+ update: "inventory",
+ });
+
+ const { transferId } = params;
+ if (!transferId) throw new Response("Not found", { status: 404 });
+
+ const result = await shipWarehouseTransfer(client, transferId, userId);
+
+ if (result.error) {
+ throw redirect(
+ path.to.warehouseTransferDetails(transferId),
+ await flash(
+ request,
+ error(result.error, "Failed to ship warehouse transfer")
+ )
+ );
+ }
+
+ throw redirect(
+ path.to.warehouseTransferDetails(transferId),
+ await flash(request, success("Warehouse transfer shipped successfully"))
+ );
+}
\ No newline at end of file
diff --git a/apps/erp/app/routes/x+/warehouse-transfer+/$transferId.tsx b/apps/erp/app/routes/x+/warehouse-transfer+/$transferId.tsx
new file mode 100644
index 0000000000..d114b4a0a1
--- /dev/null
+++ b/apps/erp/app/routes/x+/warehouse-transfer+/$transferId.tsx
@@ -0,0 +1,71 @@
+import { error } from "@carbon/auth";
+import { requirePermissions } from "@carbon/auth/auth.server";
+import { flash } from "@carbon/auth/session.server";
+import { VStack } from "@carbon/react";
+import { Outlet, useLoaderData } from "@remix-run/react";
+import type { LoaderFunctionArgs } from "@vercel/remix";
+import { json, redirect } from "@vercel/remix";
+import { getWarehouseTransfer, getWarehouseTransferLines } from "~/modules/inventory";
+import WarehouseTransferHeader from "~/modules/inventory/ui/WarehouseTransfers/WarehouseTransferHeader";
+import WarehouseTransferLines from "~/modules/inventory/ui/WarehouseTransfers/WarehouseTransferLines";
+import type { Handle } from "~/utils/handle";
+import { path } from "~/utils/path";
+
+export const handle: Handle = {
+ breadcrumb: "Warehouse Transfer Details",
+ to: path.to.warehouseTransfers,
+};
+
+export async function loader({ request, params }: LoaderFunctionArgs) {
+ const { client } = await requirePermissions(request, {
+ view: "inventory",
+ });
+
+ const { transferId } = params;
+ if (!transferId) throw new Response("Not found", { status: 404 });
+
+ const [warehouseTransfer, warehouseTransferLines] = await Promise.all([
+ getWarehouseTransfer(client, transferId),
+ getWarehouseTransferLines(client, transferId),
+ ]);
+
+ if (warehouseTransfer.error) {
+ throw redirect(
+ path.to.warehouseTransfers,
+ await flash(
+ request,
+ error(warehouseTransfer.error, "Failed to load warehouse transfer")
+ )
+ );
+ }
+
+ if (warehouseTransferLines.error) {
+ throw redirect(
+ path.to.warehouseTransfers,
+ await flash(
+ request,
+ error(warehouseTransferLines.error, "Failed to load warehouse transfer lines")
+ )
+ );
+ }
+
+ return json({
+ warehouseTransfer: warehouseTransfer.data,
+ warehouseTransferLines: warehouseTransferLines.data ?? [],
+ });
+}
+
+export default function WarehouseTransferRoute() {
+ const { warehouseTransfer, warehouseTransferLines } = useLoaderData<typeof loader>();
+
+ return (
+ <VStack spacing={4} className="h-full p-4">
+ <WarehouseTransferHeader warehouseTransfer={warehouseTransfer} />
+ <WarehouseTransferLines
+ warehouseTransferLines={warehouseTransferLines}
+ transferId={warehouseTransfer.id}
+ />
+ <Outlet />
+ </VStack>
+ );
+}
\ No newline at end of file
diff --git a/apps/erp/app/routes/x+/warehouse-transfer+/new.tsx b/apps/erp/app/routes/x+/warehouse-transfer+/new.tsx
new file mode 100644
index 0000000000..289fd1abc0
--- /dev/null
+++ b/apps/erp/app/routes/x+/warehouse-transfer+/new.tsx
@@ -0,0 +1,43 @@
+import { error } from "@carbon/auth";
+import { requirePermissions } from "@carbon/auth/auth.server";
+import { flash } from "@carbon/auth/session.server";
+import { redirect, type LoaderFunctionArgs } from "@vercel/remix";
+import { nanoid } from "nanoid";
+import { upsertWarehouseTransfer } from "~/modules/inventory";
+import { getUserDefaults } from "~/modules/users/users.server";
+import type { Handle } from "~/utils/handle";
+import { path } from "~/utils/path";
+
+export const handle: Handle = {
+ breadcrumb: "New Transfer",
+ to: path.to.warehouseTransfers,
+};
+
+export async function loader({ request }: LoaderFunctionArgs) {
+ const { client, companyId, userId } = await requirePermissions(request, {
+ create: "inventory",
+ });
+
+ const defaults = await getUserDefaults(client, userId, companyId);
+
+ // Generate a new transfer ID
+ const transferId = `WT-${Date.now()}`;
+
+ const newTransfer = await upsertWarehouseTransfer(client, {
+ transferId,
+ fromLocationId: defaults.data?.locationId ?? "",
+ toLocationId: "",
+ status: "Draft",
+ companyId,
+ createdBy: userId,
+ });
+
+ if (newTransfer.error || !newTransfer.data) {
+ throw redirect(
+ path.to.warehouseTransfers,
+ await flash(request, error(newTransfer.error, "Failed to create warehouse transfer"))
+ );
+ }
+
+ throw redirect(path.to.warehouseTransferDetails(newTransfer.data.id));
+}
\ No newline at end of file
diff --git a/apps/erp/app/utils/path.ts b/apps/erp/app/utils/path.ts
index 6ffaedd44e..c813c85a1d 100644
--- a/apps/erp/app/utils/path.ts
+++ b/apps/erp/app/utils/path.ts
@@ -1218,6 +1218,17 @@ export const path = {
shipmentPost: (id: string) => generatePath(`${x}/shipment/${id}/post`),
shippingMethod: (id: string) =>
generatePath(`${x}/inventory/shipping-methods/${id}`),
+ warehouseTransfers: `${x}/inventory/warehouse-transfers`,
+ warehouseTransfer: (id: string) => generatePath(`${x}/warehouse-transfer/${id}`),
+ warehouseTransferDetails: (id: string) =>
+ generatePath(`${x}/warehouse-transfer/${id}/details`),
+ warehouseTransferShip: (id: string) =>
+ generatePath(`${x}/warehouse-transfer/${id}/ship`),
+ warehouseTransferReceive: (id: string) =>
+ generatePath(`${x}/warehouse-transfer/${id}/receive`),
+ newWarehouseTransfer: `${x}/warehouse-transfer/new`,
+ deleteWarehouseTransfer: (id: string) =>
+ generatePath(`${x}/warehouse-transfer/${id}/delete`),
shippingMethods: `${x}/inventory/shipping-methods`,
supplier: (id: string) => generatePath(`${x}/supplier/${id}`),
suppliers: `${x}/purchasing/suppliers`,
diff --git a/packages/database/src/swagger-docs-schema.ts b/packages/database/src/swagger-docs-schema.ts
index 928a84bf9c..159045e9e1 100644
--- a/packages/database/src/swagger-docs-schema.ts
+++ b/packages/database/src/swagger-docs-schema.ts
@@ -7815,6 +7815,267 @@ export default {
tags: ["partners"],
},
},
+ "/warehouseTransferLine": {
+ get: {
+ parameters: [
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.id",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.transferId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.itemId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.itemReadableId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.quantity",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.shippedQuantity",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.receivedQuantity",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.fromLocationId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.fromShelfId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.toLocationId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.toShelfId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.unitOfMeasureCode",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.notes",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.companyId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.createdBy",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.createdAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.updatedBy",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.updatedAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.customFields",
+ },
+ {
+ $ref: "#/parameters/select",
+ },
+ {
+ $ref: "#/parameters/order",
+ },
+ {
+ $ref: "#/parameters/range",
+ },
+ {
+ $ref: "#/parameters/rangeUnit",
+ },
+ {
+ $ref: "#/parameters/offset",
+ },
+ {
+ $ref: "#/parameters/limit",
+ },
+ {
+ $ref: "#/parameters/preferCount",
+ },
+ ],
+ responses: {
+ "200": {
+ description: "OK",
+ schema: {
+ items: {
+ $ref: "#/definitions/warehouseTransferLine",
+ },
+ type: "array",
+ },
+ },
+ "206": {
+ description: "Partial Content",
+ },
+ },
+ tags: ["warehouseTransferLine"],
+ },
+ post: {
+ parameters: [
+ {
+ $ref: "#/parameters/body.warehouseTransferLine",
+ },
+ {
+ $ref: "#/parameters/select",
+ },
+ {
+ $ref: "#/parameters/preferPost",
+ },
+ ],
+ responses: {
+ "201": {
+ description: "Created",
+ },
+ },
+ tags: ["warehouseTransferLine"],
+ },
+ delete: {
+ parameters: [
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.id",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.transferId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.itemId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.itemReadableId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.quantity",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.shippedQuantity",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.receivedQuantity",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.fromLocationId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.fromShelfId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.toLocationId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.toShelfId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.unitOfMeasureCode",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.notes",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.companyId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.createdBy",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.createdAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.updatedBy",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.updatedAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.customFields",
+ },
+ {
+ $ref: "#/parameters/preferReturn",
+ },
+ ],
+ responses: {
+ "204": {
+ description: "No Content",
+ },
+ },
+ tags: ["warehouseTransferLine"],
+ },
+ patch: {
+ parameters: [
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.id",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.transferId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.itemId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.itemReadableId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.quantity",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.shippedQuantity",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.receivedQuantity",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.fromLocationId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.fromShelfId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.toLocationId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.toShelfId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.unitOfMeasureCode",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.notes",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.companyId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.createdBy",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.createdAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.updatedBy",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.updatedAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransferLine.customFields",
+ },
+ {
+ $ref: "#/parameters/body.warehouseTransferLine",
+ },
+ {
+ $ref: "#/parameters/preferReturn",
+ },
+ ],
+ responses: {
+ "204": {
+ description: "No Content",
+ },
+ },
+ tags: ["warehouseTransferLine"],
+ },
+ },
"/jobMaterialWithMakeMethodId": {
get: {
parameters: [
@@ -30681,6 +30942,258 @@ export default {
tags: ["receiptLine"],
},
},
+ "/warehouseTransfer": {
+ get: {
+ parameters: [
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.id",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.transferId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.fromLocationId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.toLocationId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.status",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.transferDate",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.expectedReceiptDate",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.notes",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.reference",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.totalQuantity",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.shippedQuantity",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.receivedQuantity",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.companyId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.createdBy",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.createdAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.updatedBy",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.updatedAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.customFields",
+ },
+ {
+ $ref: "#/parameters/select",
+ },
+ {
+ $ref: "#/parameters/order",
+ },
+ {
+ $ref: "#/parameters/range",
+ },
+ {
+ $ref: "#/parameters/rangeUnit",
+ },
+ {
+ $ref: "#/parameters/offset",
+ },
+ {
+ $ref: "#/parameters/limit",
+ },
+ {
+ $ref: "#/parameters/preferCount",
+ },
+ ],
+ responses: {
+ "200": {
+ description: "OK",
+ schema: {
+ items: {
+ $ref: "#/definitions/warehouseTransfer",
+ },
+ type: "array",
+ },
+ },
+ "206": {
+ description: "Partial Content",
+ },
+ },
+ tags: ["warehouseTransfer"],
+ },
+ post: {
+ parameters: [
+ {
+ $ref: "#/parameters/body.warehouseTransfer",
+ },
+ {
+ $ref: "#/parameters/select",
+ },
+ {
+ $ref: "#/parameters/preferPost",
+ },
+ ],
+ responses: {
+ "201": {
+ description: "Created",
+ },
+ },
+ tags: ["warehouseTransfer"],
+ },
+ delete: {
+ parameters: [
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.id",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.transferId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.fromLocationId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.toLocationId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.status",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.transferDate",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.expectedReceiptDate",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.notes",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.reference",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.totalQuantity",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.shippedQuantity",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.receivedQuantity",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.companyId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.createdBy",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.createdAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.updatedBy",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.updatedAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.customFields",
+ },
+ {
+ $ref: "#/parameters/preferReturn",
+ },
+ ],
+ responses: {
+ "204": {
+ description: "No Content",
+ },
+ },
+ tags: ["warehouseTransfer"],
+ },
+ patch: {
+ parameters: [
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.id",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.transferId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.fromLocationId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.toLocationId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.status",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.transferDate",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.expectedReceiptDate",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.notes",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.reference",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.totalQuantity",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.shippedQuantity",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.receivedQuantity",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.companyId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.createdBy",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.createdAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.updatedBy",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.updatedAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.warehouseTransfer.customFields",
+ },
+ {
+ $ref: "#/parameters/body.warehouseTransfer",
+ },
+ {
+ $ref: "#/parameters/preferReturn",
+ },
+ ],
+ responses: {
+ "204": {
+ description: "No Content",
+ },
+ },
+ tags: ["warehouseTransfer"],
+ },
+ },
"/companyIntegration": {
get: {
parameters: [
@@ -62016,6 +62529,123 @@ export default {
},
type: "object",
},
+ warehouseTransferLine: {
+ required: [
+ "id",
+ "transferId",
+ "itemId",
+ "quantity",
+ "shippedQuantity",
+ "receivedQuantity",
+ "fromLocationId",
+ "toLocationId",
+ "companyId",
+ "createdBy",
+ "createdAt",
+ ],
+ properties: {
+ id: {
+ default: "public.xid()",
+ description: "Note:\nThis is a Primary Key.<pk/>",
+ format: "text",
+ type: "string",
+ },
+ transferId: {
+ description:
+ "Note:\nThis is a Foreign Key to `warehouseTransfer.id`.<fk table='warehouseTransfer' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ itemId: {
+ description:
+ "Note:\nThis is a Foreign Key to `item.id`.<fk table='item' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ itemReadableId: {
+ format: "text",
+ type: "string",
+ },
+ quantity: {
+ default: 0,
+ format: "numeric",
+ type: "number",
+ },
+ shippedQuantity: {
+ default: 0,
+ format: "numeric",
+ type: "number",
+ },
+ receivedQuantity: {
+ default: 0,
+ format: "numeric",
+ type: "number",
+ },
+ fromLocationId: {
+ description:
+ "Note:\nThis is a Foreign Key to `location.id`.<fk table='location' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ fromShelfId: {
+ description:
+ "Note:\nThis is a Foreign Key to `shelf.id`.<fk table='shelf' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ toLocationId: {
+ description:
+ "Note:\nThis is a Foreign Key to `location.id`.<fk table='location' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ toShelfId: {
+ description:
+ "Note:\nThis is a Foreign Key to `shelf.id`.<fk table='shelf' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ unitOfMeasureCode: {
+ format: "text",
+ type: "string",
+ },
+ notes: {
+ format: "text",
+ type: "string",
+ },
+ companyId: {
+ description:
+ "Note:\nThis is a Foreign Key to `company.id`.<fk table='company' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ createdBy: {
+ description:
+ "Note:\nThis is a Foreign Key to `user.id`.<fk table='user' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ createdAt: {
+ default: "now()",
+ format: "timestamp with time zone",
+ type: "string",
+ },
+ updatedBy: {
+ description:
+ "Note:\nThis is a Foreign Key to `user.id`.<fk table='user' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ updatedAt: {
+ format: "timestamp with time zone",
+ type: "string",
+ },
+ customFields: {
+ format: "jsonb",
+ },
+ },
+ type: "object",
+ },
jobMaterialWithMakeMethodId: {
properties: {
id: {
@@ -72744,6 +73374,120 @@ export default {
},
type: "object",
},
+ warehouseTransfer: {
+ required: [
+ "id",
+ "transferId",
+ "fromLocationId",
+ "toLocationId",
+ "status",
+ "totalQuantity",
+ "shippedQuantity",
+ "receivedQuantity",
+ "companyId",
+ "createdBy",
+ "createdAt",
+ ],
+ properties: {
+ id: {
+ default: "public.xid()",
+ description: "Note:\nThis is a Primary Key.<pk/>",
+ format: "text",
+ type: "string",
+ },
+ transferId: {
+ format: "text",
+ type: "string",
+ },
+ fromLocationId: {
+ description:
+ "Note:\nThis is a Foreign Key to `location.id`.<fk table='location' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ toLocationId: {
+ description:
+ "Note:\nThis is a Foreign Key to `location.id`.<fk table='location' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ status: {
+ default: "Draft",
+ enum: [
+ "Draft",
+ "Confirmed",
+ "In Transit",
+ "Partially Received",
+ "Received",
+ "Cancelled",
+ ],
+ format: 'public."warehouseTransferStatus"',
+ type: "string",
+ },
+ transferDate: {
+ format: "date",
+ type: "string",
+ },
+ expectedReceiptDate: {
+ format: "date",
+ type: "string",
+ },
+ notes: {
+ format: "text",
+ type: "string",
+ },
+ reference: {
+ format: "text",
+ type: "string",
+ },
+ totalQuantity: {
+ default: 0,
+ format: "numeric",
+ type: "number",
+ },
+ shippedQuantity: {
+ default: 0,
+ format: "numeric",
+ type: "number",
+ },
+ receivedQuantity: {
+ default: 0,
+ format: "numeric",
+ type: "number",
+ },
+ companyId: {
+ description:
+ "Note:\nThis is a Foreign Key to `company.id`.<fk table='company' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ createdBy: {
+ description:
+ "Note:\nThis is a Foreign Key to `user.id`.<fk table='user' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ createdAt: {
+ default: "now()",
+ format: "timestamp with time zone",
+ type: "string",
+ },
+ updatedBy: {
+ description:
+ "Note:\nThis is a Foreign Key to `user.id`.<fk table='user' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ updatedAt: {
+ format: "timestamp with time zone",
+ type: "string",
+ },
+ customFields: {
+ format: "jsonb",
+ },
+ },
+ type: "object",
+ },
companyIntegration: {
required: ["id", "metadata", "companyId", "active", "updatedAt"],
properties: {
@@ -87594,6 +88338,129 @@ export default {
in: "query",
type: "string",
},
+ "body.warehouseTransferLine": {
+ name: "warehouseTransferLine",
+ description: "warehouseTransferLine",
+ required: false,
+ in: "body",
+ schema: {
+ $ref: "#/definitions/warehouseTransferLine",
+ },
+ },
+ "rowFilter.warehouseTransferLine.id": {
+ name: "id",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.warehouseTransferLine.transferId": {
+ name: "transferId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.warehouseTransferLine.itemId": {
+ name: "itemId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.warehouseTransferLine.itemReadableId": {
+ name: "itemReadableId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.warehouseTransferLine.quantity": {
+ name: "quantity",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.warehouseTransferLine.shippedQuantity": {
+ name: "shippedQuantity",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.warehouseTransferLine.receivedQuantity": {
+ name: "receivedQuantity",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.warehouseTransferLine.fromLocationId": {
+ name: "fromLocationId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.warehouseTransferLine.fromShelfId": {
+ name: "fromShelfId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.warehouseTransferLine.toLocationId": {
+ name: "toLocationId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.warehouseTransferLine.toShelfId": {
+ name: "toShelfId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.warehouseTransferLine.unitOfMeasureCode": {
+ name: "unitOfMeasureCode",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.warehouseTransferLine.notes": {
+ name: "notes",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.warehouseTransferLine.companyId": {
+ name: "companyId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.warehouseTransferLine.createdBy": {
+ name: "createdBy",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.warehouseTransferLine.createdAt": {
+ name: "createdAt",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.warehouseTransferLine.updatedBy": {
+ name: "updatedBy",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.warehouseTransferLine.updatedAt": {
+ name: "updatedAt",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.warehouseTransferLine.customFields": {
+ name: "customFields",
+ required: false,
+ in: "query",
+ type: "string",
+ },
"body.jobMaterialWithMakeMethodId": {
name: "jobMaterialWithMakeMethodId",
description: "jobMaterialWithMakeMethodId",
@@ -99771,6 +100638,123 @@ export default {
in: "query",
type: "string",
},
+ "body.warehouseTransfer": {
+ name: "warehouseTransfer",
+ description: "warehouseTransfer",
+ required: false,
+ in: "body",
+ schema: {
+ $ref: "#/definitions/warehouseTransfer",
+ },
+ },
+ "rowFilter.warehouseTransfer.id": {
+ name: "id",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.warehouseTransfer.transferId": {
+ name: "transferId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.warehouseTransfer.fromLocationId": {
+ name: "fromLocationId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.warehouseTransfer.toLocationId": {
+ name: "toLocationId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.warehouseTransfer.status": {
+ name: "status",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.warehouseTransfer.transferDate": {
+ name: "transferDate",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.warehouseTransfer.expectedReceiptDate": {
+ name: "expectedReceiptDate",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.warehouseTransfer.notes": {
+ name: "notes",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.warehouseTransfer.reference": {
+ name: "reference",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.warehouseTransfer.totalQuantity": {
+ name: "totalQuantity",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.warehouseTransfer.shippedQuantity": {
+ name: "shippedQuantity",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.warehouseTransfer.receivedQuantity": {
+ name: "receivedQuantity",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.warehouseTransfer.companyId": {
+ name: "companyId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.warehouseTransfer.createdBy": {
+ name: "createdBy",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.warehouseTransfer.createdAt": {
+ name: "createdAt",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.warehouseTransfer.updatedBy": {
+ name: "updatedBy",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.warehouseTransfer.updatedAt": {
+ name: "updatedAt",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.warehouseTransfer.customFields": {
+ name: "customFields",
+ required: false,
+ in: "query",
+ type: "string",
+ },
"body.companyIntegration": {
name: "companyIntegration",
description: "companyIntegration",
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index 00aa83e10e..48277c0715 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -34335,6 +34335,424 @@ export type Database = {
},
]
}
+ warehouseTransfer: {
+ Row: {
+ companyId: string
+ createdAt: string
+ createdBy: string
+ customFields: Json | null
+ expectedReceiptDate: string | null
+ fromLocationId: string
+ id: string
+ notes: string | null
+ receivedQuantity: number
+ reference: string | null
+ shippedQuantity: number
+ status: Database["public"]["Enums"]["warehouseTransferStatus"]
+ toLocationId: string
+ totalQuantity: number
+ transferDate: string | null
+ transferId: string
+ updatedAt: string | null
+ updatedBy: string | null
+ }
+ Insert: {
+ companyId: string
+ createdAt?: string
+ createdBy: string
+ customFields?: Json | null
+ expectedReceiptDate?: string | null
+ fromLocationId: string
+ id?: string
+ notes?: string | null
+ receivedQuantity?: number
+ reference?: string | null
+ shippedQuantity?: number
+ status?: Database["public"]["Enums"]["warehouseTransferStatus"]
+ toLocationId: string
+ totalQuantity?: number
+ transferDate?: string | null
+ transferId: string
+ updatedAt?: string | null
+ updatedBy?: string | null
+ }
+ Update: {
+ companyId?: string
+ createdAt?: string
+ createdBy?: string
+ customFields?: Json | null
+ expectedReceiptDate?: string | null
+ fromLocationId?: string
+ id?: string
+ notes?: string | null
+ receivedQuantity?: number
+ reference?: string | null
+ shippedQuantity?: number
+ status?: Database["public"]["Enums"]["warehouseTransferStatus"]
+ toLocationId?: string
+ totalQuantity?: number
+ transferDate?: string | null
+ transferId?: string
+ updatedAt?: string | null
+ updatedBy?: string | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "warehouseTransfer_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransfer_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransfer_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "warehouseTransfer_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "warehouseTransfer_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransfer_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransfer_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransfer_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransfer_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "warehouseTransfer_fromLocationId_fkey"
+ columns: ["fromLocationId"]
+ isOneToOne: false
+ referencedRelation: "location"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransfer_toLocationId_fkey"
+ columns: ["toLocationId"]
+ isOneToOne: false
+ referencedRelation: "location"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransfer_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransfer_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransfer_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransfer_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransfer_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ ]
+ }
+ warehouseTransferLine: {
+ Row: {
+ companyId: string
+ createdAt: string
+ createdBy: string
+ customFields: Json | null
+ fromLocationId: string
+ fromShelfId: string | null
+ id: string
+ itemId: string
+ itemReadableId: string | null
+ notes: string | null
+ quantity: number
+ receivedQuantity: number
+ shippedQuantity: number
+ toLocationId: string
+ toShelfId: string | null
+ transferId: string
+ unitOfMeasureCode: string | null
+ updatedAt: string | null
+ updatedBy: string | null
+ }
+ Insert: {
+ companyId: string
+ createdAt?: string
+ createdBy: string
+ customFields?: Json | null
+ fromLocationId: string
+ fromShelfId?: string | null
+ id?: string
+ itemId: string
+ itemReadableId?: string | null
+ notes?: string | null
+ quantity?: number
+ receivedQuantity?: number
+ shippedQuantity?: number
+ toLocationId: string
+ toShelfId?: string | null
+ transferId: string
+ unitOfMeasureCode?: string | null
+ updatedAt?: string | null
+ updatedBy?: string | null
+ }
+ Update: {
+ companyId?: string
+ createdAt?: string
+ createdBy?: string
+ customFields?: Json | null
+ fromLocationId?: string
+ fromShelfId?: string | null
+ id?: string
+ itemId?: string
+ itemReadableId?: string | null
+ notes?: string | null
+ quantity?: number
+ receivedQuantity?: number
+ shippedQuantity?: number
+ toLocationId?: string
+ toShelfId?: string | null
+ transferId?: string
+ unitOfMeasureCode?: string | null
+ updatedAt?: string | null
+ updatedBy?: string | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "warehouseTransferLine_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_fromLocationId_fkey"
+ columns: ["fromLocationId"]
+ isOneToOne: false
+ referencedRelation: "location"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_fromShelfId_fkey"
+ columns: ["fromShelfId"]
+ isOneToOne: false
+ referencedRelation: "shelf"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "consumables"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "item"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "materials"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "parts"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "tools"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_toLocationId_fkey"
+ columns: ["toLocationId"]
+ isOneToOne: false
+ referencedRelation: "location"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_toShelfId_fkey"
+ columns: ["toShelfId"]
+ isOneToOne: false
+ referencedRelation: "shelf"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_transferId_fkey"
+ columns: ["transferId"]
+ isOneToOne: false
+ referencedRelation: "warehouseTransfer"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_unitOfMeasureCode_fkey"
+ columns: ["unitOfMeasureCode", "companyId"]
+ isOneToOne: false
+ referencedRelation: "unitOfMeasure"
+ referencedColumns: ["code", "companyId"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ ]
+ }
webhook: {
Row: {
active: boolean
@@ -47168,6 +47586,13 @@ export type Database = {
tableViewType: "Public" | "Private"
trackedEntityStatus: "Available" | "Reserved" | "On Hold" | "Consumed"
trackingSource: "Purchased" | "Manufactured"
+ warehouseTransferStatus:
+ | "Draft"
+ | "Confirmed"
+ | "In Transit"
+ | "Partially Received"
+ | "Received"
+ | "Cancelled"
}
CompositeTypes: {
[_ in never]: never
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index 00aa83e10e..48277c0715 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -34335,6 +34335,424 @@ export type Database = {
},
]
}
+ warehouseTransfer: {
+ Row: {
+ companyId: string
+ createdAt: string
+ createdBy: string
+ customFields: Json | null
+ expectedReceiptDate: string | null
+ fromLocationId: string
+ id: string
+ notes: string | null
+ receivedQuantity: number
+ reference: string | null
+ shippedQuantity: number
+ status: Database["public"]["Enums"]["warehouseTransferStatus"]
+ toLocationId: string
+ totalQuantity: number
+ transferDate: string | null
+ transferId: string
+ updatedAt: string | null
+ updatedBy: string | null
+ }
+ Insert: {
+ companyId: string
+ createdAt?: string
+ createdBy: string
+ customFields?: Json | null
+ expectedReceiptDate?: string | null
+ fromLocationId: string
+ id?: string
+ notes?: string | null
+ receivedQuantity?: number
+ reference?: string | null
+ shippedQuantity?: number
+ status?: Database["public"]["Enums"]["warehouseTransferStatus"]
+ toLocationId: string
+ totalQuantity?: number
+ transferDate?: string | null
+ transferId: string
+ updatedAt?: string | null
+ updatedBy?: string | null
+ }
+ Update: {
+ companyId?: string
+ createdAt?: string
+ createdBy?: string
+ customFields?: Json | null
+ expectedReceiptDate?: string | null
+ fromLocationId?: string
+ id?: string
+ notes?: string | null
+ receivedQuantity?: number
+ reference?: string | null
+ shippedQuantity?: number
+ status?: Database["public"]["Enums"]["warehouseTransferStatus"]
+ toLocationId?: string
+ totalQuantity?: number
+ transferDate?: string | null
+ transferId?: string
+ updatedAt?: string | null
+ updatedBy?: string | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "warehouseTransfer_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransfer_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransfer_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "warehouseTransfer_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "warehouseTransfer_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransfer_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransfer_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransfer_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransfer_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "warehouseTransfer_fromLocationId_fkey"
+ columns: ["fromLocationId"]
+ isOneToOne: false
+ referencedRelation: "location"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransfer_toLocationId_fkey"
+ columns: ["toLocationId"]
+ isOneToOne: false
+ referencedRelation: "location"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransfer_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransfer_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransfer_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransfer_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransfer_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ ]
+ }
+ warehouseTransferLine: {
+ Row: {
+ companyId: string
+ createdAt: string
+ createdBy: string
+ customFields: Json | null
+ fromLocationId: string
+ fromShelfId: string | null
+ id: string
+ itemId: string
+ itemReadableId: string | null
+ notes: string | null
+ quantity: number
+ receivedQuantity: number
+ shippedQuantity: number
+ toLocationId: string
+ toShelfId: string | null
+ transferId: string
+ unitOfMeasureCode: string | null
+ updatedAt: string | null
+ updatedBy: string | null
+ }
+ Insert: {
+ companyId: string
+ createdAt?: string
+ createdBy: string
+ customFields?: Json | null
+ fromLocationId: string
+ fromShelfId?: string | null
+ id?: string
+ itemId: string
+ itemReadableId?: string | null
+ notes?: string | null
+ quantity?: number
+ receivedQuantity?: number
+ shippedQuantity?: number
+ toLocationId: string
+ toShelfId?: string | null
+ transferId: string
+ unitOfMeasureCode?: string | null
+ updatedAt?: string | null
+ updatedBy?: string | null
+ }
+ Update: {
+ companyId?: string
+ createdAt?: string
+ createdBy?: string
+ customFields?: Json | null
+ fromLocationId?: string
+ fromShelfId?: string | null
+ id?: string
+ itemId?: string
+ itemReadableId?: string | null
+ notes?: string | null
+ quantity?: number
+ receivedQuantity?: number
+ shippedQuantity?: number
+ toLocationId?: string
+ toShelfId?: string | null
+ transferId?: string
+ unitOfMeasureCode?: string | null
+ updatedAt?: string | null
+ updatedBy?: string | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "warehouseTransferLine_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_fromLocationId_fkey"
+ columns: ["fromLocationId"]
+ isOneToOne: false
+ referencedRelation: "location"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_fromShelfId_fkey"
+ columns: ["fromShelfId"]
+ isOneToOne: false
+ referencedRelation: "shelf"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "consumables"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "item"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "materials"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "parts"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "tools"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_toLocationId_fkey"
+ columns: ["toLocationId"]
+ isOneToOne: false
+ referencedRelation: "location"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_toShelfId_fkey"
+ columns: ["toShelfId"]
+ isOneToOne: false
+ referencedRelation: "shelf"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_transferId_fkey"
+ columns: ["transferId"]
+ isOneToOne: false
+ referencedRelation: "warehouseTransfer"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_unitOfMeasureCode_fkey"
+ columns: ["unitOfMeasureCode", "companyId"]
+ isOneToOne: false
+ referencedRelation: "unitOfMeasure"
+ referencedColumns: ["code", "companyId"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "warehouseTransferLine_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ ]
+ }
webhook: {
Row: {
active: boolean
@@ -47168,6 +47586,13 @@ export type Database = {
tableViewType: "Public" | "Private"
trackedEntityStatus: "Available" | "Reserved" | "On Hold" | "Consumed"
trackingSource: "Purchased" | "Manufactured"
+ warehouseTransferStatus:
+ | "Draft"
+ | "Confirmed"
+ | "In Transit"
+ | "Partially Received"
+ | "Received"
+ | "Cancelled"
}
CompositeTypes: {
[_ in never]: never
diff --git a/packages/database/supabase/migrations/20250726000000_warehouse-transfers.sql b/packages/database/supabase/migrations/20250726000000_warehouse-transfers.sql
new file mode 100644
index 0000000000..5df39fe504
--- /dev/null
+++ b/packages/database/supabase/migrations/20250726000000_warehouse-transfers.sql
@@ -0,0 +1,207 @@
+-- Warehouse Transfer Status
+CREATE TYPE "warehouseTransferStatus" AS ENUM (
+ 'Draft',
+ 'Confirmed',
+ 'In Transit',
+ 'Partially Received',
+ 'Received',
+ 'Cancelled'
+);
+
+-- Warehouse Transfer Table
+CREATE TABLE "warehouseTransfer" (
+ "id" TEXT NOT NULL DEFAULT xid(),
+ "transferId" TEXT NOT NULL,
+ "fromLocationId" TEXT NOT NULL,
+ "toLocationId" TEXT NOT NULL,
+ "status" "warehouseTransferStatus" NOT NULL DEFAULT 'Draft',
+ "transferDate" DATE,
+ "expectedReceiptDate" DATE,
+ "notes" TEXT,
+ "reference" TEXT,
+ "totalQuantity" NUMERIC(18, 4) NOT NULL DEFAULT 0,
+ "shippedQuantity" NUMERIC(18, 4) NOT NULL DEFAULT 0,
+ "receivedQuantity" NUMERIC(18, 4) NOT NULL DEFAULT 0,
+ "companyId" TEXT NOT NULL,
+ "createdBy" TEXT NOT NULL,
+ "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
+ "updatedBy" TEXT,
+ "updatedAt" TIMESTAMP WITH TIME ZONE,
+ "customFields" JSONB
+);
+
+-- Warehouse Transfer Line Table
+CREATE TABLE "warehouseTransferLine" (
+ "id" TEXT NOT NULL DEFAULT xid(),
+ "transferId" TEXT NOT NULL,
+ "itemId" TEXT NOT NULL,
+ "itemReadableId" TEXT,
+ "quantity" NUMERIC(18, 4) NOT NULL DEFAULT 0,
+ "shippedQuantity" NUMERIC(18, 4) NOT NULL DEFAULT 0,
+ "receivedQuantity" NUMERIC(18, 4) NOT NULL DEFAULT 0,
+ "fromLocationId" TEXT NOT NULL,
+ "fromShelfId" TEXT,
+ "toLocationId" TEXT NOT NULL,
+ "toShelfId" TEXT,
+ "unitOfMeasureCode" TEXT,
+ "notes" TEXT,
+ "companyId" TEXT NOT NULL,
+ "createdBy" TEXT NOT NULL,
+ "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
+ "updatedBy" TEXT,
+ "updatedAt" TIMESTAMP WITH TIME ZONE,
+ "customFields" JSONB
+);
+
+-- Primary Keys
+ALTER TABLE "warehouseTransfer" ADD CONSTRAINT "warehouseTransfer_pkey" PRIMARY KEY ("id");
+ALTER TABLE "warehouseTransferLine" ADD CONSTRAINT "warehouseTransferLine_pkey" PRIMARY KEY ("id");
+
+-- Foreign Key Constraints
+ALTER TABLE "warehouseTransfer" ADD CONSTRAINT "warehouseTransfer_fromLocationId_fkey"
+ FOREIGN KEY ("fromLocationId") REFERENCES "location"("id") ON DELETE RESTRICT;
+
+ALTER TABLE "warehouseTransfer" ADD CONSTRAINT "warehouseTransfer_toLocationId_fkey"
+ FOREIGN KEY ("toLocationId") REFERENCES "location"("id") ON DELETE RESTRICT;
+
+ALTER TABLE "warehouseTransfer" ADD CONSTRAINT "warehouseTransfer_companyId_fkey"
+ FOREIGN KEY ("companyId") REFERENCES "company"("id") ON DELETE CASCADE;
+
+ALTER TABLE "warehouseTransfer" ADD CONSTRAINT "warehouseTransfer_createdBy_fkey"
+ FOREIGN KEY ("createdBy") REFERENCES "user"("id") ON DELETE RESTRICT;
+
+ALTER TABLE "warehouseTransfer" ADD CONSTRAINT "warehouseTransfer_updatedBy_fkey"
+ FOREIGN KEY ("updatedBy") REFERENCES "user"("id") ON DELETE RESTRICT;
+
+ALTER TABLE "warehouseTransferLine" ADD CONSTRAINT "warehouseTransferLine_transferId_fkey"
+ FOREIGN KEY ("transferId") REFERENCES "warehouseTransfer"("id") ON DELETE CASCADE;
+
+ALTER TABLE "warehouseTransferLine" ADD CONSTRAINT "warehouseTransferLine_itemId_fkey"
+ FOREIGN KEY ("itemId") REFERENCES "item"("id") ON DELETE RESTRICT;
+
+ALTER TABLE "warehouseTransferLine" ADD CONSTRAINT "warehouseTransferLine_fromLocationId_fkey"
+ FOREIGN KEY ("fromLocationId") REFERENCES "location"("id") ON DELETE RESTRICT;
+
+ALTER TABLE "warehouseTransferLine" ADD CONSTRAINT "warehouseTransferLine_toLocationId_fkey"
+ FOREIGN KEY ("toLocationId") REFERENCES "location"("id") ON DELETE RESTRICT;
+
+ALTER TABLE "warehouseTransferLine" ADD CONSTRAINT "warehouseTransferLine_fromShelfId_fkey"
+ FOREIGN KEY ("fromShelfId") REFERENCES "shelf"("id") ON DELETE SET NULL;
+
+ALTER TABLE "warehouseTransferLine" ADD CONSTRAINT "warehouseTransferLine_toShelfId_fkey"
+ FOREIGN KEY ("toShelfId") REFERENCES "shelf"("id") ON DELETE SET NULL;
+
+ALTER TABLE "warehouseTransferLine" ADD CONSTRAINT "warehouseTransferLine_unitOfMeasureCode_fkey"
+ FOREIGN KEY ("unitOfMeasureCode", "companyId") REFERENCES "unitOfMeasure"("code", "companyId") ON DELETE SET NULL;
+
+ALTER TABLE "warehouseTransferLine" ADD CONSTRAINT "warehouseTransferLine_companyId_fkey"
+ FOREIGN KEY ("companyId") REFERENCES "company"("id") ON DELETE CASCADE;
+
+ALTER TABLE "warehouseTransferLine" ADD CONSTRAINT "warehouseTransferLine_createdBy_fkey"
+ FOREIGN KEY ("createdBy") REFERENCES "user"("id") ON DELETE RESTRICT;
+
+ALTER TABLE "warehouseTransferLine" ADD CONSTRAINT "warehouseTransferLine_updatedBy_fkey"
+ FOREIGN KEY ("updatedBy") REFERENCES "user"("id") ON DELETE RESTRICT;
+
+-- Unique Constraints
+ALTER TABLE "warehouseTransfer" ADD CONSTRAINT "warehouseTransfer_transferId_companyId_key"
+ UNIQUE ("transferId", "companyId");
+
+-- Indexes
+CREATE INDEX "warehouseTransfer_companyId_idx" ON "warehouseTransfer"("companyId");
+CREATE INDEX "warehouseTransfer_fromLocationId_idx" ON "warehouseTransfer"("fromLocationId");
+CREATE INDEX "warehouseTransfer_toLocationId_idx" ON "warehouseTransfer"("toLocationId");
+CREATE INDEX "warehouseTransfer_status_idx" ON "warehouseTransfer"("status");
+CREATE INDEX "warehouseTransfer_transferDate_idx" ON "warehouseTransfer"("transferDate");
+
+CREATE INDEX "warehouseTransferLine_transferId_idx" ON "warehouseTransferLine"("transferId");
+CREATE INDEX "warehouseTransferLine_itemId_idx" ON "warehouseTransferLine"("itemId");
+CREATE INDEX "warehouseTransferLine_fromLocationId_idx" ON "warehouseTransferLine"("fromLocationId");
+CREATE INDEX "warehouseTransferLine_toLocationId_idx" ON "warehouseTransferLine"("toLocationId");
+CREATE INDEX "warehouseTransferLine_companyId_idx" ON "warehouseTransferLine"("companyId");
+
+-- RLS Policies
+ALTER TABLE "warehouseTransfer" ENABLE ROW LEVEL SECURITY;
+ALTER TABLE "warehouseTransferLine" ENABLE ROW LEVEL SECURITY;
+
+-- Warehouse Transfer Policies
+CREATE POLICY "SELECT" ON "warehouseTransfer"
+FOR SELECT USING (
+ "companyId" = ANY (
+ (
+ SELECT
+ get_companies_with_employee_permission('inventory_view')
+ )::text[]
+ )
+);
+
+CREATE POLICY "INSERT" ON "warehouseTransfer"
+FOR INSERT WITH CHECK (
+ "companyId" = ANY (
+ (
+ SELECT
+ get_companies_with_employee_permission('inventory_create')
+ )::text[]
+ )
+);
+
+CREATE POLICY "UPDATE" ON "warehouseTransfer"
+FOR UPDATE USING (
+ "companyId" = ANY (
+ (
+ SELECT
+ get_companies_with_employee_permission('inventory_update')
+ )::text[]
+ )
+);
+
+CREATE POLICY "DELETE" ON "warehouseTransfer"
+FOR DELETE USING (
+ "companyId" = ANY (
+ (
+ SELECT
+ get_companies_with_employee_permission('inventory_delete')
+ )::text[]
+ )
+);
+
+-- Warehouse Transfer Line Policies
+CREATE POLICY "SELECT" ON "warehouseTransferLine"
+FOR SELECT USING (
+ "companyId" = ANY (
+ (
+ SELECT
+ get_companies_with_employee_permission('inventory_view')
+ )::text[]
+ )
+);
+
+CREATE POLICY "INSERT" ON "warehouseTransferLine"
+FOR INSERT WITH CHECK (
+ "companyId" = ANY (
+ (
+ SELECT
+ get_companies_with_employee_permission('inventory_create')
+ )::text[]
+ )
+);
+
+CREATE POLICY "UPDATE" ON "warehouseTransferLine"
+FOR UPDATE USING (
+ "companyId" = ANY (
+ (
+ SELECT
+ get_companies_with_employee_permission('inventory_update')
+ )::text[]
+ )
+);
+
+CREATE POLICY "DELETE" ON "warehouseTransferLine"
+FOR DELETE USING (
+ "companyId" = ANY (
+ (
+ SELECT
+ get_companies_with_employee_permission('inventory_delete')
+ )::text[]
+ )
+);