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(inventory): add Transfer kanban (storage-unit to storage-unit) (#1598)

Brad Barbin6211fd261ee1
diff --git a/.claude/rules/kanban-system.md b/.claude/rules/kanban-system.md
index da043e6f96..68081f3801 100644
--- a/.claude/rules/kanban-system.md
+++ b/.claude/rules/kanban-system.md
@@ -9,8 +9,8 @@ paths:
# Kanban System
Scan-based replenishment cards for inventory items, per location. Each kanban scan
-(via QR/label/URL) triggers either a purchase order (`Buy`) or a production job (`Make`).
-Lives in the inventory module.
+(via QR/label/URL) triggers a purchase order (`Buy`), a production job (`Make`), or a
+stock transfer (`Transfer`). Lives in the inventory module.
## Data model
@@ -18,9 +18,14 @@ Table `kanban` (initial migration `20250909012102_kanban.sql`; current state spa
**Composite PK `("id", "companyId")`.** Key columns:
- `id` TEXT default `id('kb')`, `itemId` FK→item (CASCADE), `companyId` FK→company
-- `replenishmentSystem` `itemReplenishmentSystem` enum, default `'Buy'`
+- `replenishmentSystem` `kanbanReplenishmentSystem` enum (`'Buy' | 'Make' | 'Transfer'`),
+ default `'Buy'` — **retyped from `itemReplenishmentSystem`** in `20260908143722_kanban-transfer.sql`
+ (Transfer is NOT added to `itemReplenishmentSystem`; that enum drives planning/MRP/demand)
- `quantity` INTEGER (reorder qty), `locationId` FK→location
-- `storageUnitId` FK→storageUnit (nullable) — **renamed from `shelfId`** in `20260417000100_storage-unit-rename.sql`
+- `storageUnitId` FK→storageUnit (nullable) — **renamed from `shelfId`** in `20260417000100_storage-unit-rename.sql`.
+ For a `Transfer` kanban this is the **destination** (to) bin.
+- `fromStorageUnitId` FK→storageUnit (nullable) — the **source** bin for a `Transfer` kanban
+ (`20260908143722_kanban-transfer.sql`)
- `supplierId` FK→supplier, `purchaseUnitOfMeasureCode` FK→unitOfMeasure, `conversionFactor` NUMERIC default 1 (Buy fields)
- `autoRelease` BOOL, `autoStartJob` BOOL, `completedBarcodeOverride` TEXT, `jobId` FK→job ON DELETE SET NULL (Make fields; `jobId`/auto-start added in `20251001001426_kanban-jobs.sql`)
- audit: `createdAt/By`, `updatedAt/By`
@@ -29,20 +34,22 @@ Indexes: `kanban_itemId_idx`, `kanban_locationId_idx` (companyId, locationId), `
RLS: SELECT = any employee role; INSERT/UPDATE/DELETE = `inventory_create`/`inventory_update`/`inventory_delete`.
**View `kanbans`** (SECURITY_INVOKER) is the read source for services/UI. Joins item, location,
-`storageUnit s`, `supplier su`, and `job j` — exposing `name`, `readableIdWithRevision`,
-`jobReadableId` (= `j."jobId"`), `locationName`, `storageUnitName`, `supplierName`, `thumbnailPath`.
-Recreated with storageUnit refs in `20260417000300_storage-unit-recreate-dependents.sql`.
+`storageUnit s` (destination), `storageUnit fs` (source), `supplier su`, and `job j` — exposing
+`name`, `readableIdWithRevision`, `jobReadableId` (= `j."jobId"`), `locationName`, `storageUnitName`,
+`fromStorageUnitName`, `supplierName`, `thumbnailPath`. Recreated with storageUnit refs in
+`20260417000300_storage-unit-recreate-dependents.sql`, then with the source-bin join in
+`20260908143722_kanban-transfer.sql`.
`kanbanOutput` setting (enum `('label','qrcode','url')`, default `'qrcode'`) is a per-company column on
`companySettings` (migration `20251001021231_kanban-settings.sql`), NOT a kanban-specific table.
## Code surfaces
-- Validator `kanbanValidator`: `apps/erp/app/modules/inventory/inventory.models.ts`. Fields match columns above; `.refine` requires `supplierId` when `replenishmentSystem === "Buy"`.
+- Validator `kanbanValidator`: `apps/erp/app/modules/inventory/inventory.models.ts`. Fields match columns above; enum is `kanbanReplenishmentSystemTypes` (`Buy`/`Make`/`Transfer`, distinct from the item-level `replenishmentSystemTypes`). `.refine`s require: `supplierId` when `Buy`; `fromStorageUnitId` + `storageUnitId` (and that they differ) when `Transfer`.
- Services: `apps/erp/app/modules/inventory/inventory.service.ts` — `getKanbans(client, locationId, companyId, args)`, `getKanban(client, kanbanId)`, `upsertKanban`, `deleteKanban`. Reads go through the `kanbans` view; writes hit `kanban`.
- `kanbanOutputTypes` + validator: `apps/erp/app/modules/settings/settings.models.ts`. Set via `x+/settings+/inventory.tsx`.
- UI: `apps/erp/app/modules/inventory/ui/Kanbans/KanbanForm.tsx` and `KanbansTable.tsx`.
- Form shows Buy fields (supplier/UoM/conversion) or Make fields (autoRelease, autoStartJob — gated on autoRelease, completedBarcodeOverride) conditionally. Form dropdown offers only `Buy`/`Make` (not `Buy and Make`).
+ Form shows Buy fields (supplier/UoM/conversion), Make fields (autoRelease, autoStartJob — gated on autoRelease, completedBarcodeOverride), or Transfer fields (From Storage Unit + the reused storage-unit field relabeled "To Storage Unit") conditionally. Dropdown offers `Buy`/`Make`/`Transfer`.
- Routes: list `x+/inventory+/kanbans.tsx` (auto-selects location, loads `kanbanOutput`), plus `kanbans.new.tsx`, `kanbans.$id.tsx`, `kanbans.delete.$id.tsx`.
## Path config (`apps/erp/app/utils/path.ts`)
@@ -60,7 +67,8 @@ API routes in `apps/erp/app/routes/api+/`: `kanban.$id.tsx`, `kanban.collision.$
`kanban.$id.tsx` (the "order"/create scan) branches on `replenishmentSystem`:
- **Make** — if a job is already linked (`jobReadableId`) it redirects to the collision route (no duplicate job); otherwise creates a job from the item, links it (`updateKanbanJob`), then `autoRelease` runs MRP + schedules and `autoStartJob` redirects into MES to start the first operation.
- **Buy** — reuses an existing draft/planned PO for the supplier (or creates one), adds a PO line with the kanban qty (applying `conversionFactor`/`purchaseUnitOfMeasureCode`/storage unit), redirects to the PO.
-- **Buy and Make** — not supported (errors).
+- **Transfer** — creates a new stock transfer (`insertStockTransfer`, status `Released`) with one line: `itemId`, `fromStorageUnitId` → `storageUnitId` (to), `quantity` (the "original amount"), and serial/batch flags derived from `item.itemTrackingType`. Redirects to the stock transfer, where the qty can be **partially picked** (`stockTransferLine.pickedQuantity`) at pick time. Each scan makes a new transfer (no collision concept). Storage rules are NOT evaluated on scan (a QR scan can't show the acknowledge dialog the interactive wizard uses).
+- **Buy and Make** — not a kanban option (the enum has no such value).
`start`/`complete` resolve the linked job's active operation and redirect to the MES operation start/complete endpoints; `link` navigates to the job/operation.
@@ -74,4 +82,5 @@ API routes in `apps/erp/app/routes/api+/`: `kanban.$id.tsx`, `kanban.collision.$
## Gotchas
- Newest migrations win: `shelfId` no longer exists — use `storageUnitId`/`storageUnitName`. PK is composite, so queries/upserts scope by `companyId`.
+- **Transfer** kanbans only use the `order` (create) scan — Start/Complete are Make-only. The `KanbansTable` storage-unit column renders `fromStorageUnitName → storageUnitName` for Transfer. `KanbanLabelPDF` shows the same `from → to` when `fromStorageUnitName` is set (else the single destination bin); the field is threaded through BOTH label paths — the interactive route (`labels.$action[.]pdf.tsx`) and the print-job resolver/renderer (`print-job/resolvers.ts` `KanbanCardItem` + `renderers.tsx`).
- `jobId` is auto-cleared (set NULL) when its job is completed/cancelled via the `sync_job_complete_or_canceled` event interceptor (`20260410031803_job-interceptors.sql`). A populated `jobReadableId` in the view means an active job → "order" scan collides.
diff --git a/apps/erp/app/modules/inventory/inventory.models.ts b/apps/erp/app/modules/inventory/inventory.models.ts
index 9f72775d24..10e976d5a2 100644
--- a/apps/erp/app/modules/inventory/inventory.models.ts
+++ b/apps/erp/app/modules/inventory/inventory.models.ts
@@ -69,6 +69,14 @@ export const replenishmentSystemTypes = [
"Buy and Make"
] as const;
+// Kanban-specific replenishment systems. Distinct from `replenishmentSystemTypes`
+// (an item-level enum used by planning/MRP): a kanban can Buy, Make, or Transfer.
+export const kanbanReplenishmentSystemTypes = [
+ "Buy",
+ "Make",
+ "Transfer"
+] as const;
+
export const receiptSourceDocumentType = [
// "Sales Order",
// "Sales Invoice",
@@ -240,7 +248,9 @@ export const kanbanValidator = z
.object({
id: zfd.text(z.string().optional()),
itemId: z.string().min(1, { message: "Item is required" }),
- replenishmentSystem: z.enum(replenishmentSystemTypes).default("Buy"),
+ replenishmentSystem: z.enum(kanbanReplenishmentSystemTypes, {
+ error: "Replenishment system is required"
+ }),
autoRelease: zfd.checkbox(),
autoStartJob: zfd.checkbox(),
completedBarcodeOverride: zfd.text(z.string().optional()),
@@ -249,6 +259,7 @@ export const kanbanValidator = z
),
locationId: z.string().min(1, { message: "Location is required" }),
storageUnitId: zfd.text(z.string().optional()),
+ fromStorageUnitId: zfd.text(z.string().optional()),
supplierId: zfd.text(z.string().optional()),
purchaseUnitOfMeasureCode: zfd.text(z.string().optional()),
conversionFactor: zfd.numeric(z.number().min(0).default(1))
@@ -259,6 +270,34 @@ export const kanbanValidator = z
message: "Supplier is required",
path: ["supplierId"]
}
+ )
+ // A Transfer moves stock between two storage units, so it needs a source
+ // (fromStorageUnitId) and a destination (storageUnitId).
+ .refine(
+ (data) =>
+ data.replenishmentSystem === "Transfer" ? !!data.fromStorageUnitId : true,
+ {
+ message: "From storage unit is required",
+ path: ["fromStorageUnitId"]
+ }
+ )
+ .refine(
+ (data) =>
+ data.replenishmentSystem === "Transfer" ? !!data.storageUnitId : true,
+ {
+ message: "To storage unit is required",
+ path: ["storageUnitId"]
+ }
+ )
+ .refine(
+ (data) =>
+ data.replenishmentSystem === "Transfer"
+ ? data.fromStorageUnitId !== data.storageUnitId
+ : true,
+ {
+ message: "From and to storage units must be different",
+ path: ["storageUnitId"]
+ }
);
export const receiptValidator = z.object({
diff --git a/apps/erp/app/modules/inventory/ui/Kanbans/KanbanForm.tsx b/apps/erp/app/modules/inventory/ui/Kanbans/KanbanForm.tsx
index 3145bde3ec..a89323c01b 100644
--- a/apps/erp/app/modules/inventory/ui/Kanbans/KanbanForm.tsx
+++ b/apps/erp/app/modules/inventory/ui/Kanbans/KanbanForm.tsx
@@ -31,8 +31,8 @@ import {
import { useUser } from "~/hooks";
import type { MethodItemType } from "~/modules/shared/types";
import {
- kanbanValidator,
- replenishmentSystemTypes
+ kanbanReplenishmentSystemTypes,
+ kanbanValidator
} from "../../inventory.models";
type KanbanFormValues = z.infer<typeof kanbanValidator>;
@@ -53,6 +53,9 @@ const KanbanForm = ({ initialValues, onClose }: KanbanFormProps) => {
const [storageUnitId, setStorageUnitId] = useState<string | null>(
initialValues.storageUnitId || null
);
+ const [fromStorageUnitId, setFromStorageUnitId] = useState<string | null>(
+ initialValues.fromStorageUnitId || null
+ );
const [itemType, setItemType] = useState<MethodItemType | "Item">("Item");
const [itemId, setItemId] = useState<string>(initialValues.itemId || "");
@@ -93,7 +96,11 @@ const KanbanForm = ({ initialValues, onClose }: KanbanFormProps) => {
toast.error(t`Failed to load item details`);
return;
}
- setSelectedReplenishmentSystem(item.data?.replenishmentSystem || "Buy");
+ // The item-level enum can be "Buy and Make", which a kanban cannot be —
+ // map anything other than "Make" (incl. "Buy and Make"/null) to "Buy".
+ setSelectedReplenishmentSystem(
+ item.data?.replenishmentSystem === "Make" ? "Make" : "Buy"
+ );
if (storageUnit.data?.defaultStorageUnitId) {
setStorageUnitId(storageUnit.data.defaultStorageUnitId);
}
@@ -169,8 +176,11 @@ const KanbanForm = ({ initialValues, onClose }: KanbanFormProps) => {
const onLocationChange = (value: { value: string } | null) => {
setLocationId(value?.value || "");
setStorageUnitId(null);
+ setFromStorageUnitId(null);
};
+ const isTransfer = selectedReplenishmentSystem === "Transfer";
+
return (
<Drawer open onOpenChange={onClose}>
<DrawerContent>
@@ -227,12 +237,10 @@ const KanbanForm = ({ initialValues, onClose }: KanbanFormProps) => {
setSelectedReplenishmentSystem(value.value);
}
}}
- options={replenishmentSystemTypes
- .filter((type) => type !== "Buy and Make")
- .map((type) => ({
- value: type,
- label: <Enumerable value={type} />
- }))}
+ options={kanbanReplenishmentSystemTypes.map((type) => ({
+ value: type,
+ label: <Enumerable value={type} />
+ }))}
/>
{selectedReplenishmentSystem === "Buy" && (
@@ -282,14 +290,24 @@ const KanbanForm = ({ initialValues, onClose }: KanbanFormProps) => {
isReadOnly={isEditing}
/>
+ {isTransfer && (
+ <StorageUnit
+ name="fromStorageUnitId"
+ label={t`From Storage Unit`}
+ locationId={locationId}
+ value={fromStorageUnitId ?? undefined}
+ onChange={(value) =>
+ setFromStorageUnitId(value?.id ?? null)
+ }
+ />
+ )}
+
<StorageUnit
name="storageUnitId"
- label={t`Storage Unit`}
+ label={isTransfer ? t`To Storage Unit` : t`Storage Unit`}
locationId={locationId}
value={storageUnitId ?? undefined}
- onChange={(value) => {
- if (value) setStorageUnitId(value?.id ?? null);
- }}
+ onChange={(value) => setStorageUnitId(value?.id ?? null)}
/>
{selectedReplenishmentSystem === "Make" && (
diff --git a/apps/erp/app/modules/inventory/ui/Kanbans/KanbansTable.tsx b/apps/erp/app/modules/inventory/ui/Kanbans/KanbansTable.tsx
index 458bfcf23e..942eb69086 100644
--- a/apps/erp/app/modules/inventory/ui/Kanbans/KanbansTable.tsx
+++ b/apps/erp/app/modules/inventory/ui/Kanbans/KanbansTable.tsx
@@ -178,7 +178,7 @@ const KanbansTable = memo(
</a>
</TooltipTrigger>
<TooltipContent>
- {t`Label to create a ${row.original.replenishmentSystem === "Make" ? "Job" : "Order"} for this kanban`}
+ {t`Label to create a ${getKanbanCreateNoun(row.original.replenishmentSystem)} for this kanban`}
</TooltipContent>
</Tooltip>
{row.original.replenishmentSystem === "Make" && (
@@ -255,7 +255,7 @@ const KanbansTable = memo(
</HoverCardTrigger>
</TooltipTrigger>
<TooltipContent>
- {t`QR Code to create a ${row.original.replenishmentSystem === "Make" ? "Job" : "Order"} for this kanban`}
+ {t`QR Code to create a ${getKanbanCreateNoun(row.original.replenishmentSystem)} for this kanban`}
</TooltipContent>
</Tooltip>
<HoverCardContent
@@ -356,11 +356,9 @@ const KanbansTable = memo(
<CopyBadge
text="Create"
url={path.to.api.kanban(row.original.id!)}
- tooltip={`Copy link to create a ${
- row.original.replenishmentSystem === "Make"
- ? "Job"
- : "Order"
- } for this kanban`}
+ tooltip={`Copy link to create a ${getKanbanCreateNoun(
+ row.original.replenishmentSystem
+ )} for this kanban`}
/>
{row.original.replenishmentSystem === "Make" && (
<>
@@ -409,7 +407,7 @@ const KanbansTable = memo(
meta: {
filter: {
type: "static",
- options: ["Buy", "Make"].map((type) => ({
+ options: ["Buy", "Make", "Transfer"].map((type) => ({
value: type,
label: <Enumerable value={type} />
}))
@@ -437,7 +435,16 @@ const KanbansTable = memo(
{
accessorKey: "storageUnitName",
header: t`Storage Unit`,
- cell: ({ row }) => row.original.storageUnitName || "",
+ cell: ({ row }) =>
+ row.original.replenishmentSystem === "Transfer" ? (
+ <span>
+ {row.original.fromStorageUnitName || "—"}
+ {" → "}
+ {row.original.storageUnitName || "—"}
+ </span>
+ ) : (
+ row.original.storageUnitName || ""
+ ),
meta: {
icon: <LuMapPin />
}
@@ -664,6 +671,14 @@ KanbansTable.displayName = "KanbansTable";
export default KanbansTable;
+// The document a "create" scan produces: a Job for Make, a Transfer for
+// Transfer, otherwise a purchase Order.
+function getKanbanCreateNoun(replenishmentSystem: string | null) {
+ if (replenishmentSystem === "Make") return "Job";
+ if (replenishmentSystem === "Transfer") return "Transfer";
+ return "Order";
+}
+
function getLocationPath(locationId: string) {
return `${path.to.kanbans}?location=${locationId}`;
}
diff --git a/apps/erp/app/routes/api+/kanban.$id.tsx b/apps/erp/app/routes/api+/kanban.$id.tsx
index 05ee09d76e..127e050d7c 100644
--- a/apps/erp/app/routes/api+/kanban.$id.tsx
+++ b/apps/erp/app/routes/api+/kanban.$id.tsx
@@ -13,7 +13,11 @@ import { Suspense } from "react";
import type { LoaderFunctionArgs } from "react-router";
import { Await, useLoaderData } from "react-router";
import { Redirect } from "~/components/Redirect";
-import { getDefaultStorageUnitForJob, getKanban } from "~/modules/inventory";
+import {
+ getDefaultStorageUnitForJob,
+ getKanban,
+ insertStockTransfer
+} from "~/modules/inventory";
import { getItemReplenishment } from "~/modules/items";
import {
getActiveJobOperationByJobId,
@@ -347,6 +351,84 @@ async function handleKanban({
data: path.to.purchaseOrder(purchaseOrderId!),
error: null
};
+ } else if (kanban.data.replenishmentSystem === "Transfer") {
+ if (!kanban.data.itemId) {
+ return { data: null, error: "Failed to create stock transfer" };
+ }
+
+ if (!kanban.data.fromStorageUnitId || !kanban.data.storageUnitId) {
+ return {
+ data: null,
+ error: "Kanban is missing a from or to storage unit"
+ };
+ }
+
+ // Defense in depth: confirm BOTH storage units belong to this company and
+ // this kanban's location before moving stock. A stock transfer is
+ // intra-location, and the ids could have been set to another location's (or
+ // company's) bin — validate rather than trust the stored ids (CWE-639).
+ const storageUnits = await client
+ .from("storageUnit")
+ .select("id")
+ .in("id", [kanban.data.fromStorageUnitId, kanban.data.storageUnitId])
+ .eq("companyId", companyId)
+ .eq("locationId", kanban.data.locationId!);
+
+ const validIds = new Set((storageUnits.data ?? []).map((s) => s.id));
+ if (
+ !validIds.has(kanban.data.fromStorageUnitId) ||
+ !validIds.has(kanban.data.storageUnitId)
+ ) {
+ return {
+ data: null,
+ error: "Storage unit does not belong to the kanban location"
+ };
+ }
+
+ // Derive tracking from the item so the transfer line demands the right
+ // serial/batch handling at pick time. insertStockTransfer expands a
+ // serial-tracked line of qty > 1 into individual qty-1 lines.
+ const item = await client
+ .from("item")
+ .select("itemTrackingType")
+ .eq("id", kanban.data.itemId)
+ .eq("companyId", companyId)
+ .single();
+
+ if (item.error) {
+ logger.error("Kanban operation failed", { error: item.error });
+ return { data: null, error: "Failed to get item" };
+ }
+
+ const trackingType = item.data?.itemTrackingType;
+
+ const createStockTransfer = await insertStockTransfer(client, {
+ locationId: kanban.data.locationId!,
+ lines: [
+ {
+ itemId: kanban.data.itemId,
+ fromStorageUnitId: kanban.data.fromStorageUnitId,
+ toStorageUnitId: kanban.data.storageUnitId,
+ quantity: kanban.data.quantity!,
+ requiresSerialTracking: trackingType === "Serial",
+ requiresBatchTracking: trackingType === "Batch"
+ }
+ ],
+ companyId,
+ createdBy: userId
+ });
+
+ if (createStockTransfer.error || !createStockTransfer.data) {
+ logger.error("Kanban operation failed", {
+ error: createStockTransfer.error
+ });
+ return { data: null, error: "Failed to create stock transfer" };
+ }
+
+ return {
+ data: path.to.stockTransfer(createStockTransfer.data.id),
+ error: null
+ };
} else {
return {
data: null,
diff --git a/apps/erp/app/routes/api+/mcp+/lib/tool-manifest.digest.json b/apps/erp/app/routes/api+/mcp+/lib/tool-manifest.digest.json
index 68579a19a0..26b56bfbc6 100644
--- a/apps/erp/app/routes/api+/mcp+/lib/tool-manifest.digest.json
+++ b/apps/erp/app/routes/api+/mcp+/lib/tool-manifest.digest.json
@@ -198,10 +198,10 @@
{"name":"inventory_getInventoryValuationTieOut","classification":"READ","paramCount":1,"schema":"cb789596bf56","response":"20aee38c95a3","injectAuth":"companyId","permission":"inventory:view"},
{"name":"inventory_getItemLedgerActivity","classification":"READ","paramCount":5,"schema":"b898b72c5939","response":"c27606350e62","injectAuth":"companyId","permission":"inventory:view"},
{"name":"inventory_getItemLedgerPage","classification":"READ","paramCount":4,"schema":"de680470ebb1","response":"c27606350e62","injectAuth":"companyId","permission":"inventory:view"},
- {"name":"inventory_getKanban","classification":"READ","paramCount":1,"schema":"369f807bc840","response":"a54d43903486","injectAuth":"companyId","permission":"inventory:view"},
- {"name":"inventory_getKanbans","classification":"READ","paramCount":2,"schema":"68cb4a73d5a9","response":"1e5027ab2d56","injectAuth":"companyId","permission":"inventory:view"},
+ {"name":"inventory_getKanban","classification":"READ","paramCount":1,"schema":"369f807bc840","response":"c5aa7a081ed4","injectAuth":"companyId","permission":"inventory:view"},
+ {"name":"inventory_getKanbans","classification":"READ","paramCount":2,"schema":"68cb4a73d5a9","response":"fa96e94d8dda","injectAuth":"companyId","permission":"inventory:view"},
{"name":"inventory_getPickingList","classification":"READ","paramCount":1,"schema":"0a4ec3e7319b","response":"227255936b96","injectAuth":"companyId","permission":"inventory:view"},
- {"name":"inventory_getPickingListAvailability","classification":"READ","paramCount":1,"schema":"0a4ec3e7319b","response":"d8bb760d2850","injectAuth":"companyId","permission":"inventory:view"},
+ {"name":"inventory_getPickingListAvailability","classification":"READ","paramCount":1,"schema":"0a4ec3e7319b","response":"dc7546a2e5ad","injectAuth":"companyId","permission":"inventory:view"},
{"name":"inventory_getPickingListLine","classification":"READ","paramCount":1,"schema":"063a6777d378","response":"b51ad23d436f","injectAuth":"companyId","permission":"inventory:view"},
{"name":"inventory_getPickingListLines","classification":"READ","paramCount":1,"schema":"0a4ec3e7319b","response":"cc66c1b66f31","injectAuth":"companyId","permission":"inventory:view"},
{"name":"inventory_getPickingListLineTrackedEntities","classification":"READ","paramCount":1,"schema":"063a6777d378","response":"51dd622ce168","injectAuth":"companyId","permission":"inventory:view"},
@@ -279,7 +279,7 @@
{"name":"inventory_updateWarehouseTransfer","classification":"WRITE","paramCount":10,"schema":"a809aeb69e6d","response":"3797626bd17e","injectAuth":"companyId+updatedBy","permission":"inventory:update"},
{"name":"inventory_updateWarehouseTransferStatus","classification":"WRITE","paramCount":2,"schema":"70cb7f36b2a6","response":"bcde375ebd4c","injectAuth":"companyId+updatedBy","permission":"inventory:update"},
{"name":"inventory_upsertBatchProperty","classification":"WRITE","paramCount":6,"schema":"6fcfef7093ed","response":"bcde375ebd4c","injectAuth":"companyId+createdBy+updatedBy","permission":"inventory:create+update"},
- {"name":"inventory_upsertKanban","classification":"WRITE","paramCount":12,"schema":"4c86c371e2dc","response":"3797626bd17e","injectAuth":"companyId+createdBy+updatedBy","permission":"inventory:create+update"},
+ {"name":"inventory_upsertKanban","classification":"WRITE","paramCount":13,"schema":"838748628347","response":"3797626bd17e","injectAuth":"companyId+createdBy+updatedBy","permission":"inventory:create+update"},
{"name":"inventory_upsertPickingList","classification":"WRITE","paramCount":6,"schema":"d14da5a24597","response":"3797626bd17e","injectAuth":"companyId+createdBy+updatedBy","permission":"inventory:create+update"},
{"name":"inventory_upsertPickingListLine","classification":"WRITE","paramCount":8,"schema":"a674c3f5c5e8","response":"3797626bd17e","injectAuth":"companyId+createdBy+updatedBy","permission":"inventory:create+update"},
{"name":"inventory_upsertReceipt","classification":"WRITE","paramCount":8,"schema":"353c030ac288","response":"3797626bd17e","injectAuth":"companyId+createdBy+updatedBy","permission":"inventory:create+update"},
@@ -392,7 +392,7 @@
{"name":"items_findChangeNoticesForItem","classification":"READ","paramCount":2,"schema":"10c8230a9f49","response":"e0196d4b0041","injectAuth":"companyId","permission":"parts:view"},
{"name":"items_findOtherOpenChangeNoticesForItem","classification":"READ","paramCount":2,"schema":"8a1da983320d","response":"e0196d4b0041","injectAuth":"companyId","permission":"parts:view"},
{"name":"items_getBomHasShelfLifeManagedInput","classification":"READ","paramCount":1,"schema":"623ca47a6c74","response":"7cb541e84f22","injectAuth":"companyId","permission":"parts:view"},
- {"name":"items_getBomItemAttributes","classification":"READ","paramCount":1,"schema":"c4ca22fd1816","response":"d8bb760d2850","injectAuth":"companyId","permission":"parts:view"},
+ {"name":"items_getBomItemAttributes","classification":"READ","paramCount":1,"schema":"c4ca22fd1816","response":"dc7546a2e5ad","injectAuth":"companyId","permission":"parts:view"},
{"name":"items_getChangeNotice","classification":"READ","paramCount":1,"schema":"29578070edb2","response":"09c0b464284c","injectAuth":"companyId","permission":"parts:view"},
{"name":"items_getChangeNoticeActions","classification":"READ","paramCount":1,"schema":"29578070edb2","response":"949f86b5cda3","injectAuth":"companyId","permission":"parts:view"},
{"name":"items_getChangeNoticeAffectedItems","classification":"READ","paramCount":1,"schema":"29578070edb2","response":"5483e69d7515","injectAuth":"companyId","permission":"parts:view"},
@@ -767,11 +767,11 @@
{"name":"production_insertJob","classification":"WRITE","paramCount":2,"schema":"fea224e085b1","response":"ad63dfd9d877","injectAuth":"companyId+createdBy+updatedBy","permission":"production:create"},
{"name":"production_invalidateAssemblyModelCache","classification":"DESTRUCTIVE","paramCount":1,"schema":"277f7d872d8c","response":"bcde375ebd4c","injectAuth":"companyId","permission":"production:update"},
{"name":"production_issueMaterial","classification":"WRITE","paramCount":7,"schema":"0408bd8c9bde","response":"none","injectAuth":"companyId","permission":"production:update"},
- {"name":"production_maxToolQuantityByItem","classification":"WRITE","paramCount":1,"schema":"8b9e90037b9a","response":"d8bb760d2850","injectAuth":"companyId","permission":"production:update"},
+ {"name":"production_maxToolQuantityByItem","classification":"WRITE","paramCount":1,"schema":"8b9e90037b9a","response":"dc7546a2e5ad","injectAuth":"companyId","permission":"production:update"},
{"name":"production_movePeopleAssignment","classification":"DESTRUCTIVE","paramCount":2,"schema":"a726aa587ccc","response":"fe5e1dc03da5","injectAuth":"companyId+updatedBy","permission":"production:update"},
{"name":"production_movePeopleWeek","classification":"DESTRUCTIVE","paramCount":5,"schema":"fec8ebf1add4","response":"3badaa1686e8","injectAuth":"companyId+updatedBy","permission":"production:update"},
{"name":"production_notifyScheduleInputsChanged","classification":"WRITE","paramCount":3,"schema":"172bee52ed70","response":"none","injectAuth":"companyId","permission":"production:update"},
- {"name":"production_planAssemblyStepMarkerSync","classification":"WRITE","paramCount":2,"schema":"f32958f213ae","response":"bec53722aec4","injectAuth":"companyId","permission":"production:update"},
+ {"name":"production_planAssemblyStepMarkerSync","classification":"WRITE","paramCount":2,"schema":"f32958f213ae","response":"133d83f1706f","injectAuth":"companyId","permission":"production:update"},
{"name":"production_pullJobMaterialMakeMethod","classification":"WRITE","paramCount":2,"schema":"e27f48bbab4c","response":"bcde375ebd4c","injectAuth":"companyId","permission":"production:update"},
{"name":"production_reassignAssemblyStepComponents","classification":"DESTRUCTIVE","paramCount":4,"schema":"99f3d689165d","response":"none","injectAuth":"companyId","permission":"production:update"},
{"name":"production_recalculateJobMakeMethodRequirements","classification":"WRITE","paramCount":1,"schema":"3797626bd17e","response":"none","injectAuth":"companyId+updatedBy","permission":"production:update"},
diff --git a/apps/erp/app/routes/file+/kanban+/labels.$action[.]pdf.tsx b/apps/erp/app/routes/file+/kanban+/labels.$action[.]pdf.tsx
index 288815ab15..fdb55d989b 100644
--- a/apps/erp/app/routes/file+/kanban+/labels.$action[.]pdf.tsx
+++ b/apps/erp/app/routes/file+/kanban+/labels.$action[.]pdf.tsx
@@ -93,6 +93,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
locationName: kanban.locationName || "",
storageUnitId: kanban.storageUnitId,
storageUnitName: kanban.storageUnitName,
+ fromStorageUnitName: kanban.fromStorageUnitName,
supplierName: kanban.supplierName,
quantity: kanban.quantity ?? 0,
unitOfMeasureCode: kanban.purchaseUnitOfMeasureCode,
diff --git a/apps/erp/app/routes/x+/inventory+/kanbans.$id.tsx b/apps/erp/app/routes/x+/inventory+/kanbans.$id.tsx
index f22f000b79..1c7423a48e 100644
--- a/apps/erp/app/routes/x+/inventory+/kanbans.$id.tsx
+++ b/apps/erp/app/routes/x+/inventory+/kanbans.$id.tsx
@@ -74,6 +74,7 @@ export default function EditKanbanRoute() {
replenishmentSystem: kanban?.replenishmentSystem ?? "Buy",
locationId: kanban?.locationId ?? "",
storageUnitId: kanban?.storageUnitId ?? "",
+ fromStorageUnitId: kanban?.fromStorageUnitId ?? "",
supplierId: kanban?.supplierId ?? "",
purchaseUnitOfMeasureCode: kanban?.purchaseUnitOfMeasureCode ?? "",
conversionFactor: kanban?.conversionFactor ?? 1,
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index a0c2561330..16cb277bce 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -25861,13 +25861,14 @@ export type Database = {
conversionFactor: number
createdAt: string
createdBy: string
+ fromStorageUnitId: string | null
id: string
itemId: string
jobId: string | null
locationId: string
purchaseUnitOfMeasureCode: string | null
quantity: number
- replenishmentSystem: Database["public"]["Enums"]["itemReplenishmentSystem"]
+ replenishmentSystem: Database["public"]["Enums"]["kanbanReplenishmentSystem"]
storageUnitId: string | null
supplierId: string | null
updatedAt: string | null
@@ -25881,13 +25882,14 @@ export type Database = {
conversionFactor?: number
createdAt?: string
createdBy: string
+ fromStorageUnitId?: string | null
id?: string
itemId: string
jobId?: string | null
locationId: string
purchaseUnitOfMeasureCode?: string | null
quantity: number
- replenishmentSystem?: Database["public"]["Enums"]["itemReplenishmentSystem"]
+ replenishmentSystem?: Database["public"]["Enums"]["kanbanReplenishmentSystem"]
storageUnitId?: string | null
supplierId?: string | null
updatedAt?: string | null
@@ -25901,13 +25903,14 @@ export type Database = {
conversionFactor?: number
createdAt?: string
createdBy?: string
+ fromStorageUnitId?: string | null
id?: string
itemId?: string
jobId?: string | null
locationId?: string
purchaseUnitOfMeasureCode?: string | null
quantity?: number
- replenishmentSystem?: Database["public"]["Enums"]["itemReplenishmentSystem"]
+ replenishmentSystem?: Database["public"]["Enums"]["kanbanReplenishmentSystem"]
storageUnitId?: string | null
supplierId?: string | null
updatedAt?: string | null
@@ -25977,6 +25980,13 @@ export type Database = {
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
+ {
+ foreignKeyName: "kanban_fromStorageUnitId_fkey"
+ columns: ["fromStorageUnitId"]
+ isOneToOne: false
+ referencedRelation: "storageUnit"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "kanban_itemId_fkey"
columns: ["itemId"]
@@ -67261,6 +67271,8 @@ export type Database = {
conversionFactor: number | null
createdAt: string | null
createdBy: string | null
+ fromStorageUnitId: string | null
+ fromStorageUnitName: string | null
id: string | null
itemId: string | null
jobId: string | null
@@ -67272,7 +67284,7 @@ export type Database = {
quantity: number | null
readableIdWithRevision: string | null
replenishmentSystem:
- | Database["public"]["Enums"]["itemReplenishmentSystem"]
+ | Database["public"]["Enums"]["kanbanReplenishmentSystem"]
| null
storageUnitId: string | null
storageUnitName: string | null
@@ -67346,6 +67358,13 @@ export type Database = {
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
+ {
+ foreignKeyName: "kanban_fromStorageUnitId_fkey"
+ columns: ["fromStorageUnitId"]
+ isOneToOne: false
+ referencedRelation: "storageUnit"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "kanban_itemId_fkey"
columns: ["itemId"]
@@ -68662,14 +68681,14 @@ export type Database = {
},
{
foreignKeyName: "partner_id_fkey"
- columns: ["supplierLocationId"]
+ columns: ["id"]
isOneToOne: false
referencedRelation: "supplierLocation"
referencedColumns: ["id"]
},
{
foreignKeyName: "partner_id_fkey"
- columns: ["id"]
+ columns: ["supplierLocationId"]
isOneToOne: false
referencedRelation: "supplierLocation"
referencedColumns: ["id"]
@@ -70327,14 +70346,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["supplierCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["supplierCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -73754,21 +73773,21 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["shipmentCountryCode"]
+ columns: ["invoiceCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["invoiceCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["shipmentCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -74315,14 +74334,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["paymentCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["paymentCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -80765,6 +80784,7 @@ export type Database = {
| "Inbound Inspection"
| "Scrap"
kanbanOutput: "label" | "qrcode" | "url"
+ kanbanReplenishmentSystem: "Buy" | "Make" | "Transfer"
macrsConvention: "Half-Year" | "Mid-Quarter"
macrsPropertyClass: "3" | "5" | "7" | "10" | "15" | "20" | "27.5" | "39"
maintenanceDispatchPriority: "Low" | "Medium" | "High" | "Critical"
@@ -82174,6 +82194,7 @@ export const Constants = {
"Scrap",
],
kanbanOutput: ["label", "qrcode", "url"],
+ kanbanReplenishmentSystem: ["Buy", "Make", "Transfer"],
macrsConvention: ["Half-Year", "Mid-Quarter"],
macrsPropertyClass: ["3", "5", "7", "10", "15", "20", "27.5", "39"],
maintenanceDispatchPriority: ["Low", "Medium", "High", "Critical"],
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index a0c2561330..16cb277bce 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -25861,13 +25861,14 @@ export type Database = {
conversionFactor: number
createdAt: string
createdBy: string
+ fromStorageUnitId: string | null
id: string
itemId: string
jobId: string | null
locationId: string
purchaseUnitOfMeasureCode: string | null
quantity: number
- replenishmentSystem: Database["public"]["Enums"]["itemReplenishmentSystem"]
+ replenishmentSystem: Database["public"]["Enums"]["kanbanReplenishmentSystem"]
storageUnitId: string | null
supplierId: string | null
updatedAt: string | null
@@ -25881,13 +25882,14 @@ export type Database = {
conversionFactor?: number
createdAt?: string
createdBy: string
+ fromStorageUnitId?: string | null
id?: string
itemId: string
jobId?: string | null
locationId: string
purchaseUnitOfMeasureCode?: string | null
quantity: number
- replenishmentSystem?: Database["public"]["Enums"]["itemReplenishmentSystem"]
+ replenishmentSystem?: Database["public"]["Enums"]["kanbanReplenishmentSystem"]
storageUnitId?: string | null
supplierId?: string | null
updatedAt?: string | null
@@ -25901,13 +25903,14 @@ export type Database = {
conversionFactor?: number
createdAt?: string
createdBy?: string
+ fromStorageUnitId?: string | null
id?: string
itemId?: string
jobId?: string | null
locationId?: string
purchaseUnitOfMeasureCode?: string | null
quantity?: number
- replenishmentSystem?: Database["public"]["Enums"]["itemReplenishmentSystem"]
+ replenishmentSystem?: Database["public"]["Enums"]["kanbanReplenishmentSystem"]
storageUnitId?: string | null
supplierId?: string | null
updatedAt?: string | null
@@ -25977,6 +25980,13 @@ export type Database = {
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
+ {
+ foreignKeyName: "kanban_fromStorageUnitId_fkey"
+ columns: ["fromStorageUnitId"]
+ isOneToOne: false
+ referencedRelation: "storageUnit"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "kanban_itemId_fkey"
columns: ["itemId"]
@@ -67261,6 +67271,8 @@ export type Database = {
conversionFactor: number | null
createdAt: string | null
createdBy: string | null
+ fromStorageUnitId: string | null
+ fromStorageUnitName: string | null
id: string | null
itemId: string | null
jobId: string | null
@@ -67272,7 +67284,7 @@ export type Database = {
quantity: number | null
readableIdWithRevision: string | null
replenishmentSystem:
- | Database["public"]["Enums"]["itemReplenishmentSystem"]
+ | Database["public"]["Enums"]["kanbanReplenishmentSystem"]
| null
storageUnitId: string | null
storageUnitName: string | null
@@ -67346,6 +67358,13 @@ export type Database = {
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
+ {
+ foreignKeyName: "kanban_fromStorageUnitId_fkey"
+ columns: ["fromStorageUnitId"]
+ isOneToOne: false
+ referencedRelation: "storageUnit"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "kanban_itemId_fkey"
columns: ["itemId"]
@@ -68662,14 +68681,14 @@ export type Database = {
},
{
foreignKeyName: "partner_id_fkey"
- columns: ["supplierLocationId"]
+ columns: ["id"]
isOneToOne: false
referencedRelation: "supplierLocation"
referencedColumns: ["id"]
},
{
foreignKeyName: "partner_id_fkey"
- columns: ["id"]
+ columns: ["supplierLocationId"]
isOneToOne: false
referencedRelation: "supplierLocation"
referencedColumns: ["id"]
@@ -70327,14 +70346,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["supplierCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["supplierCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -73754,21 +73773,21 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["shipmentCountryCode"]
+ columns: ["invoiceCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["invoiceCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["shipmentCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -74315,14 +74334,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["paymentCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["paymentCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -80765,6 +80784,7 @@ export type Database = {
| "Inbound Inspection"
| "Scrap"
kanbanOutput: "label" | "qrcode" | "url"
+ kanbanReplenishmentSystem: "Buy" | "Make" | "Transfer"
macrsConvention: "Half-Year" | "Mid-Quarter"
macrsPropertyClass: "3" | "5" | "7" | "10" | "15" | "20" | "27.5" | "39"
maintenanceDispatchPriority: "Low" | "Medium" | "High" | "Critical"
@@ -82174,6 +82194,7 @@ export const Constants = {
"Scrap",
],
kanbanOutput: ["label", "qrcode", "url"],
+ kanbanReplenishmentSystem: ["Buy", "Make", "Transfer"],
macrsConvention: ["Half-Year", "Mid-Quarter"],
macrsPropertyClass: ["3", "5", "7", "10", "15", "20", "27.5", "39"],
maintenanceDispatchPriority: ["Low", "Medium", "High", "Critical"],
diff --git a/packages/database/supabase/migrations/20260908143722_kanban-transfer.sql b/packages/database/supabase/migrations/20260908143722_kanban-transfer.sql
new file mode 100644
index 0000000000..0ccd994469
--- /dev/null
+++ b/packages/database/supabase/migrations/20260908143722_kanban-transfer.sql
@@ -0,0 +1,59 @@
+-- Kanban Transfer support.
+--
+-- A "Transfer" kanban creates a stock transfer from one storage unit to another
+-- within a location. The existing "storageUnitId" is reused as the DESTINATION
+-- (to) bin — consistent with Buy/Make, where it is the bin stock lands in — and
+-- a new "fromStorageUnitId" holds the SOURCE bin.
+--
+-- The kanban replenishment system is retyped from "itemReplenishmentSystem"
+-- (Buy | Make | Buy and Make) to a kanban-specific enum. "Transfer" is NOT added
+-- to "itemReplenishmentSystem" on purpose: that enum drives item planning, MRP,
+-- and demand, where Transfer is not a valid item-level replenishment method.
+
+CREATE TYPE "kanbanReplenishmentSystem" AS ENUM ('Buy', 'Make', 'Transfer');
+
+-- The "kanbans" view is SELECT k.*, so it must be dropped before the column
+-- retype and recreated afterwards (also picks up the new column + join).
+DROP VIEW IF EXISTS "kanbans";
+
+ALTER TABLE "kanban" ALTER COLUMN "replenishmentSystem" DROP DEFAULT;
+
+-- The old enum (itemReplenishmentSystem) allowed 'Buy and Make', which the new
+-- kanban-specific enum does not. Map any such rows to 'Buy' before the cast so
+-- the type change cannot abort. (The kanban form never offered 'Buy and Make',
+-- so in practice this is a no-op guard against direct DB/API/import writes.)
+UPDATE "kanban" SET "replenishmentSystem" = 'Buy'
+WHERE "replenishmentSystem" = 'Buy and Make';
+
+ALTER TABLE "kanban"
+ ALTER COLUMN "replenishmentSystem" TYPE "kanbanReplenishmentSystem"
+ USING "replenishmentSystem"::text::"kanbanReplenishmentSystem";
+ALTER TABLE "kanban" ALTER COLUMN "replenishmentSystem" SET DEFAULT 'Buy';
+
+ALTER TABLE "kanban" ADD COLUMN "fromStorageUnitId" TEXT
+ REFERENCES "storageUnit"("id") ON DELETE CASCADE;
+
+CREATE INDEX "kanban_fromStorageUnitId_idx" ON "kanban" ("fromStorageUnitId");
+
+CREATE VIEW "kanbans" WITH(SECURITY_INVOKER=true) AS
+SELECT
+ k.*,
+ i.name,
+ i."readableIdWithRevision",
+ j."jobId" as "jobReadableId",
+ l.name as "locationName",
+ s.name as "storageUnitName",
+ fs.name as "fromStorageUnitName",
+ su.name as "supplierName",
+ CASE
+ WHEN i."thumbnailPath" IS NULL AND mu."thumbnailPath" IS NOT NULL THEN mu."thumbnailPath"
+ ELSE i."thumbnailPath"
+ END AS "thumbnailPath"
+FROM "kanban" k
+JOIN "item" i ON k."itemId" = i."id"
+LEFT JOIN "modelUpload" mu ON mu.id = i."modelUploadId"
+JOIN "location" l ON k."locationId" = l."id"
+LEFT JOIN "storageUnit" s ON k."storageUnitId" = s."id"
+LEFT JOIN "storageUnit" fs ON k."fromStorageUnitId" = fs."id"
+LEFT JOIN "supplier" su ON k."supplierId" = su."id"
+LEFT JOIN "job" j ON k."jobId" = j."id";
diff --git a/packages/documents/src/pdf/KanbanLabelPDF.tsx b/packages/documents/src/pdf/KanbanLabelPDF.tsx
index 3c5170d141..0b8607313a 100644
--- a/packages/documents/src/pdf/KanbanLabelPDF.tsx
+++ b/packages/documents/src/pdf/KanbanLabelPDF.tsx
@@ -12,6 +12,7 @@ interface KanbanLabel {
supplierName?: string | null;
storageUnitId?: string | null;
storageUnitName?: string | null;
+ fromStorageUnitName?: string | null;
quantity: number;
unitOfMeasureCode?: string | null;
thumbnail?: string | null;
@@ -186,7 +187,15 @@ const KanbanLabelPDF = ({
"border-t border-gray-300 pt-2 mt-2 flex flex-col items-center text-center text-[14pt]"
)}
>
- {label.storageUnitName ? (
+ {label.fromStorageUnitName ? (
+ // Transfer kanban: show the source -> destination bins.
+ // Use ASCII "->": the built-in Helvetica font has no
+ // U+2192 glyph, so an arrow renders as a missing box.
+ <Text>
+ {label.fromStorageUnitName} {"->"}{" "}
+ {label.storageUnitName || label.locationName}
+ </Text>
+ ) : label.storageUnitName ? (
<Text>{label.storageUnitName}</Text>
) : (
<Text>{label.locationName}</Text>
diff --git a/packages/jobs/src/inngest/functions/tasks/print-job/renderers.tsx b/packages/jobs/src/inngest/functions/tasks/print-job/renderers.tsx
index 9e849c4fef..9d5ccbae25 100644
--- a/packages/jobs/src/inngest/functions/tasks/print-job/renderers.tsx
+++ b/packages/jobs/src/inngest/functions/tasks/print-job/renderers.tsx
@@ -221,6 +221,7 @@ async function renderKanbanCardPDF(
locationName: item.locationName,
storageUnitId: item.storageUnitId,
storageUnitName: item.storageUnitName,
+ fromStorageUnitName: item.fromStorageUnitName,
supplierName: item.supplierName,
quantity: item.quantity,
unitOfMeasureCode: item.unitOfMeasureCode,
diff --git a/packages/jobs/src/inngest/functions/tasks/print-job/resolvers.ts b/packages/jobs/src/inngest/functions/tasks/print-job/resolvers.ts
index 302f4fb59f..36919ec6d9 100644
--- a/packages/jobs/src/inngest/functions/tasks/print-job/resolvers.ts
+++ b/packages/jobs/src/inngest/functions/tasks/print-job/resolvers.ts
@@ -11,6 +11,7 @@ export type KanbanCardItem = {
locationName: string;
storageUnitId: string | null;
storageUnitName: string | null;
+ fromStorageUnitName: string | null;
supplierName: string | null;
quantity: number;
unitOfMeasureCode: string | null;
@@ -74,6 +75,7 @@ export async function resolveKanbanData(
locationName: kanban.locationName || "",
storageUnitId: kanban.storageUnitId,
storageUnitName: kanban.storageUnitName,
+ fromStorageUnitName: kanban.fromStorageUnitName,
supplierName: kanban.supplierName,
quantity: kanban.quantity ?? 0,
unitOfMeasureCode: kanban.purchaseUnitOfMeasureCode,
diff --git a/packages/locale/locales/de/erp.po b/packages/locale/locales/de/erp.po
index b46ce4e13f..fa8caa9fff 100644
--- a/packages/locale/locales/de/erp.po
+++ b/packages/locale/locales/de/erp.po
@@ -8994,7 +8994,7 @@ msgstr "Bezeichnung"
msgid "Label to complete the current operation for this kanban"
msgstr "Etikett zum Abschließen des aktuellen Vorgangs für dieses Kanban"
-#. placeholder {0}: row.original.replenishmentSystem === "Make" ? "Job" : "Order"
+#. placeholder {0}: getKanbanCreateNoun(row.original.replenishmentSystem)
msgid "Label to create a {0} for this kanban"
msgstr "Etikett zum Erstellen eines {0} für diesen Kanban"
@@ -12827,7 +12827,7 @@ msgstr "Zur Buchhaltung senden"
msgid "Putting your data back"
msgstr "Ihre Daten werden wiederhergestellt"
-#. placeholder {0}: row.original.replenishmentSystem === "Make" ? "Job" : "Order"
+#. placeholder {0}: getKanbanCreateNoun(row.original.replenishmentSystem)
msgid "QR Code to create a {0} for this kanban"
msgstr "QR-Code zum Erstellen eines {0} für diesen Kanban"
diff --git a/packages/locale/locales/en/erp.po b/packages/locale/locales/en/erp.po
index 07ad5e7b07..54824a7b74 100644
--- a/packages/locale/locales/en/erp.po
+++ b/packages/locale/locales/en/erp.po
@@ -8994,7 +8994,7 @@ msgstr "Label"
msgid "Label to complete the current operation for this kanban"
msgstr "Label to complete the current operation for this kanban"
-#. placeholder {0}: row.original.replenishmentSystem === "Make" ? "Job" : "Order"
+#. placeholder {0}: getKanbanCreateNoun(row.original.replenishmentSystem)
msgid "Label to create a {0} for this kanban"
msgstr "Label to create a {0} for this kanban"
@@ -12827,7 +12827,7 @@ msgstr "Push to accounting"
msgid "Putting your data back"
msgstr "Putting your data back"
-#. placeholder {0}: row.original.replenishmentSystem === "Make" ? "Job" : "Order"
+#. placeholder {0}: getKanbanCreateNoun(row.original.replenishmentSystem)
msgid "QR Code to create a {0} for this kanban"
msgstr "QR Code to create a {0} for this kanban"
diff --git a/packages/locale/locales/es/erp.po b/packages/locale/locales/es/erp.po
index aaf6251b15..892aa66506 100644
--- a/packages/locale/locales/es/erp.po
+++ b/packages/locale/locales/es/erp.po
@@ -8994,7 +8994,7 @@ msgstr "Etiqueta"
msgid "Label to complete the current operation for this kanban"
msgstr "Etiqueta para completar la operación actual de este kanban"
-#. placeholder {0}: row.original.replenishmentSystem === "Make" ? "Job" : "Order"
+#. placeholder {0}: getKanbanCreateNoun(row.original.replenishmentSystem)
msgid "Label to create a {0} for this kanban"
msgstr "Etiqueta para crear un {0} para este kanban"
@@ -12827,7 +12827,7 @@ msgstr "Enviar a contabilidad"
msgid "Putting your data back"
msgstr "Restaurando tus datos"
-#. placeholder {0}: row.original.replenishmentSystem === "Make" ? "Job" : "Order"
+#. placeholder {0}: getKanbanCreateNoun(row.original.replenishmentSystem)
msgid "QR Code to create a {0} for this kanban"
msgstr "Código QR para crear un {0} para este kanban"
diff --git a/packages/locale/locales/fr/erp.po b/packages/locale/locales/fr/erp.po
index 714fdd78fb..dfbfd9d62f 100644
--- a/packages/locale/locales/fr/erp.po
+++ b/packages/locale/locales/fr/erp.po
@@ -8994,7 +8994,7 @@ msgstr "Étiquette"
msgid "Label to complete the current operation for this kanban"
msgstr "Étiquette pour terminer l'opération actuelle pour ce kanban"
-#. placeholder {0}: row.original.replenishmentSystem === "Make" ? "Job" : "Order"
+#. placeholder {0}: getKanbanCreateNoun(row.original.replenishmentSystem)
msgid "Label to create a {0} for this kanban"
msgstr "Étiquette pour créer un {0} pour ce kanban"
@@ -12827,7 +12827,7 @@ msgstr "Envoyer vers la comptabilité"
msgid "Putting your data back"
msgstr "Restauration de vos données"
-#. placeholder {0}: row.original.replenishmentSystem === "Make" ? "Job" : "Order"
+#. placeholder {0}: getKanbanCreateNoun(row.original.replenishmentSystem)
msgid "QR Code to create a {0} for this kanban"
msgstr "Code QR pour créer un {0} pour ce kanban"
diff --git a/packages/locale/locales/hi/erp.po b/packages/locale/locales/hi/erp.po
index da67bb0a46..4c2839ea7f 100644
--- a/packages/locale/locales/hi/erp.po
+++ b/packages/locale/locales/hi/erp.po
@@ -8994,7 +8994,7 @@ msgstr "लेबल"
msgid "Label to complete the current operation for this kanban"
msgstr "इस कानबान के लिए वर्तमान ऑपरेशन पूर्ण करें"
-#. placeholder {0}: row.original.replenishmentSystem === "Make" ? "Job" : "Order"
+#. placeholder {0}: getKanbanCreateNoun(row.original.replenishmentSystem)
msgid "Label to create a {0} for this kanban"
msgstr "इस कानबान के लिए एक {0} बनाएँ"
@@ -12827,7 +12827,7 @@ msgstr "लेखांकन को धकेलें"
msgid "Putting your data back"
msgstr "आपका डेटा वापस डाल रहे हैं"
-#. placeholder {0}: row.original.replenishmentSystem === "Make" ? "Job" : "Order"
+#. placeholder {0}: getKanbanCreateNoun(row.original.replenishmentSystem)
msgid "QR Code to create a {0} for this kanban"
msgstr "इस कानबान के लिए एक {0} बनाने के लिए QR कोड"
diff --git a/packages/locale/locales/it/erp.po b/packages/locale/locales/it/erp.po
index ae241ec677..c2db673484 100644
--- a/packages/locale/locales/it/erp.po
+++ b/packages/locale/locales/it/erp.po
@@ -8994,7 +8994,7 @@ msgstr "Etichetta"
msgid "Label to complete the current operation for this kanban"
msgstr "Etichetta per completare l'operazione corrente per questo kanban"
-#. placeholder {0}: row.original.replenishmentSystem === "Make" ? "Job" : "Order"
+#. placeholder {0}: getKanbanCreateNoun(row.original.replenishmentSystem)
msgid "Label to create a {0} for this kanban"
msgstr "Etichetta per creare un {0} per questo kanban"
@@ -12827,7 +12827,7 @@ msgstr "Invia alla contabilità"
msgid "Putting your data back"
msgstr "Ripristino dei dati"
-#. placeholder {0}: row.original.replenishmentSystem === "Make" ? "Job" : "Order"
+#. placeholder {0}: getKanbanCreateNoun(row.original.replenishmentSystem)
msgid "QR Code to create a {0} for this kanban"
msgstr "Codice QR per creare un {0} per questo kanban"
diff --git a/packages/locale/locales/ja/erp.po b/packages/locale/locales/ja/erp.po
index b130ba06b3..2f4f308ae8 100644
--- a/packages/locale/locales/ja/erp.po
+++ b/packages/locale/locales/ja/erp.po
@@ -8994,7 +8994,7 @@ msgstr "ラベル"
msgid "Label to complete the current operation for this kanban"
msgstr "このかんばんの現在の工程を完了するためのラベル"
-#. placeholder {0}: row.original.replenishmentSystem === "Make" ? "Job" : "Order"
+#. placeholder {0}: getKanbanCreateNoun(row.original.replenishmentSystem)
msgid "Label to create a {0} for this kanban"
msgstr "このかんばんの{0}を作成するためのラベル"
@@ -12827,7 +12827,7 @@ msgstr "会計にプッシュ"
msgid "Putting your data back"
msgstr "データを復元中"
-#. placeholder {0}: row.original.replenishmentSystem === "Make" ? "Job" : "Order"
+#. placeholder {0}: getKanbanCreateNoun(row.original.replenishmentSystem)
msgid "QR Code to create a {0} for this kanban"
msgstr "このかんばんの{0}を作成するためのQR Code"
diff --git a/packages/locale/locales/ko/erp.po b/packages/locale/locales/ko/erp.po
index b1fb940d50..e09b6ea7a0 100644
--- a/packages/locale/locales/ko/erp.po
+++ b/packages/locale/locales/ko/erp.po
@@ -8994,7 +8994,7 @@ msgstr "라벨"
msgid "Label to complete the current operation for this kanban"
msgstr "이 칸반의 현재 공정작업을 완료하는 라벨"
-#. placeholder {0}: row.original.replenishmentSystem === "Make" ? "Job" : "Order"
+#. placeholder {0}: getKanbanCreateNoun(row.original.replenishmentSystem)
msgid "Label to create a {0} for this kanban"
msgstr "이 칸반의 {0}을(를) 생성하는 라벨"
@@ -12827,7 +12827,7 @@ msgstr "회계로 푸시"
msgid "Putting your data back"
msgstr "데이터 복원 중"
-#. placeholder {0}: row.original.replenishmentSystem === "Make" ? "Job" : "Order"
+#. placeholder {0}: getKanbanCreateNoun(row.original.replenishmentSystem)
msgid "QR Code to create a {0} for this kanban"
msgstr "이 칸반에 대한 {0}을(를) 생성하는 QR 코드"
diff --git a/packages/locale/locales/pl/erp.po b/packages/locale/locales/pl/erp.po
index 20bbcf86e0..ea4f5d839a 100644
--- a/packages/locale/locales/pl/erp.po
+++ b/packages/locale/locales/pl/erp.po
@@ -8994,7 +8994,7 @@ msgstr "Etykieta"
msgid "Label to complete the current operation for this kanban"
msgstr "Etykieta do ukończenia bieżącej operacji dla tego kanbanu"
-#. placeholder {0}: row.original.replenishmentSystem === "Make" ? "Job" : "Order"
+#. placeholder {0}: getKanbanCreateNoun(row.original.replenishmentSystem)
msgid "Label to create a {0} for this kanban"
msgstr "Etykieta do utworzenia {0} dla tego kanbanu"
@@ -12827,7 +12827,7 @@ msgstr "Wyślij do systemu księgowego"
msgid "Putting your data back"
msgstr "Przywracanie twoich danych"
-#. placeholder {0}: row.original.replenishmentSystem === "Make" ? "Job" : "Order"
+#. placeholder {0}: getKanbanCreateNoun(row.original.replenishmentSystem)
msgid "QR Code to create a {0} for this kanban"
msgstr "Kod QR do utworzenia {0} dla tego kanbanu"
diff --git a/packages/locale/locales/pt/erp.po b/packages/locale/locales/pt/erp.po
index 5be0f0442c..292a23cb30 100644
--- a/packages/locale/locales/pt/erp.po
+++ b/packages/locale/locales/pt/erp.po
@@ -8994,7 +8994,7 @@ msgstr "Rótulo"
msgid "Label to complete the current operation for this kanban"
msgstr "Etiqueta para concluir a operação atual para este kanban"
-#. placeholder {0}: row.original.replenishmentSystem === "Make" ? "Job" : "Order"
+#. placeholder {0}: getKanbanCreateNoun(row.original.replenishmentSystem)
msgid "Label to create a {0} for this kanban"
msgstr "Etiqueta para criar um {0} para este kanban"
@@ -12827,7 +12827,7 @@ msgstr "Enviar para contabilidade"
msgid "Putting your data back"
msgstr "Colocando seus dados de volta"
-#. placeholder {0}: row.original.replenishmentSystem === "Make" ? "Job" : "Order"
+#. placeholder {0}: getKanbanCreateNoun(row.original.replenishmentSystem)
msgid "QR Code to create a {0} for this kanban"
msgstr "Código QR para criar um {0} para este kanban"
diff --git a/packages/locale/locales/ru/erp.po b/packages/locale/locales/ru/erp.po
index 2693b8c63d..a290a96d24 100644
--- a/packages/locale/locales/ru/erp.po
+++ b/packages/locale/locales/ru/erp.po
@@ -8994,7 +8994,7 @@ msgstr "Метка"
msgid "Label to complete the current operation for this kanban"
msgstr "Этикетка для завершения текущей операции для этого канбана"
-#. placeholder {0}: row.original.replenishmentSystem === "Make" ? "Job" : "Order"
+#. placeholder {0}: getKanbanCreateNoun(row.original.replenishmentSystem)
msgid "Label to create a {0} for this kanban"
msgstr "Этикетка для создания {0} для этого канбана"
@@ -12827,7 +12827,7 @@ msgstr "Отправить в бухгалтерию"
msgid "Putting your data back"
msgstr "Восстановление ваших данных"
-#. placeholder {0}: row.original.replenishmentSystem === "Make" ? "Job" : "Order"
+#. placeholder {0}: getKanbanCreateNoun(row.original.replenishmentSystem)
msgid "QR Code to create a {0} for this kanban"
msgstr "QR-код для создания {0} для этого канбана"
diff --git a/packages/locale/locales/tr/erp.po b/packages/locale/locales/tr/erp.po
index 8161d3ad44..1a05203113 100644
--- a/packages/locale/locales/tr/erp.po
+++ b/packages/locale/locales/tr/erp.po
@@ -8994,7 +8994,7 @@ msgstr "Etiket"
msgid "Label to complete the current operation for this kanban"
msgstr "Bu kanban için mevcut işlemi tamamlamak üzere etiket"
-#. placeholder {0}: row.original.replenishmentSystem === "Make" ? "Job" : "Order"
+#. placeholder {0}: getKanbanCreateNoun(row.original.replenishmentSystem)
msgid "Label to create a {0} for this kanban"
msgstr "Bu kanban için bir {0} oluşturmak için"
@@ -12827,7 +12827,7 @@ msgstr "Muhasebede gönder"
msgid "Putting your data back"
msgstr "Verileriniz geri konuluyor"
-#. placeholder {0}: row.original.replenishmentSystem === "Make" ? "Job" : "Order"
+#. placeholder {0}: getKanbanCreateNoun(row.original.replenishmentSystem)
msgid "QR Code to create a {0} for this kanban"
msgstr "Bu kanban için bir {0} oluşturmak için QR Kod"
diff --git a/packages/locale/locales/zh/erp.po b/packages/locale/locales/zh/erp.po
index b932af7384..da3bd11119 100644
--- a/packages/locale/locales/zh/erp.po
+++ b/packages/locale/locales/zh/erp.po
@@ -8994,7 +8994,7 @@ msgstr "标签"
msgid "Label to complete the current operation for this kanban"
msgstr "用于完成此看板当前操作的标签"
-#. placeholder {0}: row.original.replenishmentSystem === "Make" ? "Job" : "Order"
+#. placeholder {0}: getKanbanCreateNoun(row.original.replenishmentSystem)
msgid "Label to create a {0} for this kanban"
msgstr "用于为此看板创建 {0} 的标签"
@@ -12827,7 +12827,7 @@ msgstr "推送到会计系统"
msgid "Putting your data back"
msgstr "正在恢复您的数据"
-#. placeholder {0}: row.original.replenishmentSystem === "Make" ? "Job" : "Order"
+#. placeholder {0}: getKanbanCreateNoun(row.original.replenishmentSystem)
msgid "QR Code to create a {0} for this kanban"
msgstr "二维码以为此看板创建{0}"