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.

Implement aggregated stock movements view (#939)

Naveen Kashyap967ac6a20ed0
diff --git a/apps/erp/app/components/Activity.tsx b/apps/erp/app/components/Activity.tsx
index b7a51cf84d..4a94528ebb 100644
--- a/apps/erp/app/components/Activity.tsx
+++ b/apps/erp/app/components/Activity.tsx
@@ -1,14 +1,31 @@
+import { cn } from "@carbon/react";
import type { ReactNode } from "react";
-import { useDateFormatter } from "~/hooks";
+import { useDateFormatter, useHighlightFlash } from "~/hooks";
import { usePeople } from "~/stores";
import Avatar from "./Avatar";
+type Person = { id: string; name: string; avatarUrl: string | null };
+
+// Build (and cache) an id→person Map keyed on the people array's identity. The
+// nanostore hands back a stable reference until the roster changes, so every
+// Activity row shares one O(1) lookup instead of each doing an O(n) `find`.
+const peopleByIdCache = new WeakMap<object, Map<string, Person>>();
+function peopleById(people: readonly Person[]) {
+ let map = peopleByIdCache.get(people);
+ if (!map) {
+ map = new Map(people.map((person) => [person.id, person]));
+ peopleByIdCache.set(people, map);
+ }
+ return map;
+}
+
type ActivityProps = {
employeeId: string;
activityMessage: ReactNode;
activityTime: string;
activityIcon?: ReactNode;
comment?: string | null;
+ highlighted?: boolean;
};
const Activity = ({
@@ -16,16 +33,25 @@ const Activity = ({
activityMessage,
activityTime,
activityIcon,
- comment
+ comment,
+ highlighted = false
}: ActivityProps) => {
const { formatTimeAgo } = useDateFormatter();
const [people] = usePeople();
+ const { ref, isFlashing } = useHighlightFlash<HTMLLIElement>(highlighted);
+
if (!employeeId) return null;
- const person = people.find((p) => p.id === employeeId);
+ const person = peopleById(people).get(employeeId);
return (
- <li className="relative flex-grow w-full border rounded-lg bg-card p-6 pl-14">
+ <li
+ ref={ref}
+ className={cn(
+ "relative flex-grow w-full border rounded-lg bg-card p-6 pl-14 transition-colors duration-150",
+ isFlashing && "bg-accent"
+ )}
+ >
<div className="absolute left-3 top-6 flex items-center justify-center w-10 h-10">
<Avatar
path={person?.avatarUrl ?? undefined}
@@ -38,14 +64,14 @@ const Activity = ({
<span className="font-semibold mr-1">
{person?.name ?? "Carbon Admin"}
</span>
- <span className="text-gray-400">{activityMessage}</span>
+ <span className="text-muted-foreground">{activityMessage}</span>
</p>
{comment && (
<p className="text-sm text-muted-foreground mt-1 italic">
{comment}
</p>
)}
- <div className="text-sm text-gray-400 mt-1">
+ <div className="text-sm text-muted-foreground mt-1">
{formatTimeAgo(activityTime)}
</div>
</div>
diff --git a/apps/erp/app/components/InfiniteScroll.tsx b/apps/erp/app/components/InfiniteScroll.tsx
index e7eff6fd72..390ecb678d 100644
--- a/apps/erp/app/components/InfiniteScroll.tsx
+++ b/apps/erp/app/components/InfiniteScroll.tsx
@@ -6,10 +6,11 @@ import { useInView } from "react-intersection-observer";
import Empty from "./Empty";
interface InfiniteScrollProps<T extends { id: string }> {
- component: React.FC<{ item: T }>;
+ component: React.FC<{ item: T; highlightId?: string }>;
items: T[];
loadMore: () => Promise<void>;
hasMore: boolean;
+ highlightId?: string;
}
export function LoadingSkeleton({
@@ -19,27 +20,19 @@ export function LoadingSkeleton({
}) {
return (
<>
- <div ref={ref} className="flex items-center space-x-4 p-4">
- <Skeleton className="h-8 w-8 rounded-full" />
- <div className="space-y-2">
- <Skeleton className="h-4 w-[250px]" />
- <Skeleton className="h-4 w-[200px]" />
- </div>
- </div>
- <div className="flex items-center space-x-4 p-4">
- <Skeleton className="h-8 w-8 rounded-full" />
- <div className="space-y-2">
- <Skeleton className="h-4 w-[250px]" />
- <Skeleton className="h-4 w-[200px]" />
- </div>
- </div>
- <div className="flex items-center space-x-4 p-4">
- <Skeleton className="h-8 w-8 rounded-full" />
- <div className="space-y-2">
- <Skeleton className="h-4 w-[250px]" />
- <Skeleton className="h-4 w-[200px]" />
+ {[0, 1, 2].map((i) => (
+ <div
+ key={i}
+ ref={i === 0 ? ref : undefined}
+ className="flex items-center space-x-4 p-4"
+ >
+ <Skeleton className="h-8 w-8 rounded-full" />
+ <div className="space-y-2">
+ <Skeleton className="h-4 w-[250px]" />
+ <Skeleton className="h-4 w-[200px]" />
+ </div>
</div>
- </div>
+ ))}
</>
);
}
@@ -48,7 +41,8 @@ export default function InfiniteScroll<T extends { id: string }>({
component: Component,
items,
loadMore,
- hasMore
+ hasMore,
+ highlightId
}: InfiniteScrollProps<T>) {
const { ref, inView } = useInView({
threshold: 0
@@ -68,7 +62,9 @@ export default function InfiniteScroll<T extends { id: string }>({
<Empty />
</div>
) : (
- items.map((item) => <Component key={item.id} item={item} />)
+ items.map((item) => (
+ <Component key={item.id} item={item} highlightId={highlightId} />
+ ))
)}
<div ref={ref}>{hasMore && <LoadingSkeleton />}</div>
</ul>
diff --git a/apps/erp/app/hooks/index.ts b/apps/erp/app/hooks/index.ts
index 5495d9085d..075a7451e5 100644
--- a/apps/erp/app/hooks/index.ts
+++ b/apps/erp/app/hooks/index.ts
@@ -10,6 +10,7 @@ import { useCurrencyFormatter } from "./useCurrencyFormatter";
import { useDateFormatter } from "./useDateFormatter";
import { useFlags } from "./useFlags";
import { useGooglePlaces } from "./useGooglePlaces";
+import { useHighlightFlash } from "./useHighlightFlash";
import { useAllModules, useModules, useSettingsModule } from "./useModules";
import { useMovingCellRef } from "./useMovingCellRef";
import { useNextItemId } from "./useNextItemId";
@@ -31,6 +32,7 @@ export {
useDateFormatter,
useFlags,
useGooglePlaces,
+ useHighlightFlash,
useAllModules,
useModules,
useSettingsModule,
diff --git a/apps/erp/app/hooks/useDebouncedRealtime.ts b/apps/erp/app/hooks/useDebouncedRealtime.ts
new file mode 100644
index 0000000000..f002a17098
--- /dev/null
+++ b/apps/erp/app/hooks/useDebouncedRealtime.ts
@@ -0,0 +1,49 @@
+import { useRealtimeChannel } from "@carbon/react";
+import { useEffect, useRef } from "react";
+import { useRevalidator } from "react-router";
+import { useUser } from "./useUser";
+
+/**
+ * Like `useRealtime`, but coalesces a burst of change events into a single
+ * route revalidation after `debounceMs` of quiet.
+ *
+ * Use for append-heavy tables (e.g. `itemLedger`) where one business action
+ * inserts many rows at once: without debouncing, a 300-row posting would fire
+ * 300 `revalidate()` calls. Subscribe with a `companyId=eq.<id>` filter so new
+ * inserts (not just changes to already-loaded rows) trigger a refetch.
+ */
+export function useDebouncedRealtime(
+ table: string,
+ filter: string | undefined,
+ debounceMs = 1500
+) {
+ const { company } = useUser();
+ const revalidator = useRevalidator();
+ const timeout = useRef<ReturnType<typeof setTimeout> | null>(null);
+
+ useEffect(
+ () => () => {
+ if (timeout.current) clearTimeout(timeout.current);
+ },
+ []
+ );
+
+ return useRealtimeChannel({
+ topic: `postgres_changes:${table}`,
+ dependencies: [company.id, filter, debounceMs],
+ setup(channel) {
+ return channel.on(
+ "postgres_changes",
+ { event: "*", schema: "public", table, filter },
+ () => {
+ // Inserts are already scoped to this company by the `filter` arg, so
+ // every event here is relevant — just coalesce the burst.
+ if (timeout.current) clearTimeout(timeout.current);
+ timeout.current = setTimeout(() => {
+ revalidator.revalidate();
+ }, debounceMs);
+ }
+ );
+ }
+ });
+}
diff --git a/apps/erp/app/hooks/useHighlightFlash.ts b/apps/erp/app/hooks/useHighlightFlash.ts
new file mode 100644
index 0000000000..b18037a61a
--- /dev/null
+++ b/apps/erp/app/hooks/useHighlightFlash.ts
@@ -0,0 +1,37 @@
+import { useEffect, useRef, useState } from "react";
+
+/**
+ * Drives the "flash this row" affordance used when a list entry is navigated to
+ * via a `highlight` param. When `highlighted` flips true it scrolls the element
+ * into view and blinks `isFlashing` a few times so the eye can find the row.
+ *
+ * Returns a `ref` to attach to the element to flash and an `isFlashing` flag to
+ * toggle a highlight class with (pair it with a `transition-colors` on the node).
+ */
+export function useHighlightFlash<T extends HTMLElement = HTMLElement>(
+ highlighted: boolean
+) {
+ const ref = useRef<T>(null);
+ const [isFlashing, setIsFlashing] = useState(false);
+
+ useEffect(() => {
+ if (!highlighted) return;
+ ref.current?.scrollIntoView({ behavior: "smooth", block: "center" });
+
+ // Blink a few times to draw attention to the row, then settle.
+ let toggles = 0;
+ const maxToggles = 6; // 3 on/off cycles
+ setIsFlashing(true);
+ const interval = setInterval(() => {
+ toggles += 1;
+ setIsFlashing((prev) => !prev);
+ if (toggles >= maxToggles) {
+ clearInterval(interval);
+ setIsFlashing(false);
+ }
+ }, 250);
+ return () => clearInterval(interval);
+ }, [highlighted]);
+
+ return { ref, isFlashing };
+}
diff --git a/apps/erp/app/modules/inventory/inventory.models.ts b/apps/erp/app/modules/inventory/inventory.models.ts
index ce5a14cd9e..be61dc4883 100644
--- a/apps/erp/app/modules/inventory/inventory.models.ts
+++ b/apps/erp/app/modules/inventory/inventory.models.ts
@@ -42,7 +42,14 @@ export const itemLedgerDocumentTypes = [
"Posted Assembly",
"Inventory Receipt",
"Inventory Shipment",
- "Direct Transfer"
+ "Direct Transfer",
+ "Job Consumption",
+ "Job Receipt",
+ "Batch Split",
+ "Purchase Order",
+ "Maintenance Consumption",
+ "Non-Conformance",
+ "Inbound Inspection"
] as const;
export const trackedEntityStatus = [
diff --git a/apps/erp/app/modules/inventory/inventory.service.ts b/apps/erp/app/modules/inventory/inventory.service.ts
index 0ca317d139..37b6e5788a 100644
--- a/apps/erp/app/modules/inventory/inventory.service.ts
+++ b/apps/erp/app/modules/inventory/inventory.service.ts
@@ -169,7 +169,9 @@ export async function getItemLedgerPage(
let query = client
.from("itemLedger")
- .select("*, storageUnit(name)", { count: "exact" })
+ .select("*, storageUnit(name), trackedEntity(readableId)", {
+ count: "exact"
+ })
.eq("itemId", itemId)
.eq("companyId", companyId)
.eq("locationId", locationId)
@@ -191,6 +193,66 @@ export async function getItemLedgerPage(
};
}
+/**
+ * Keyset-paginated item-ledger activity for the per-item Activity panel.
+ *
+ * Pages on `entryNumber` (a NOT NULL, per-company-unique, monotonic insertion
+ * sequence that is co-ordered with `createdAt`), which lets us:
+ * - anchor the first load directly on a specific entry (`inclusive` + the
+ * entry's `entryNumber`) instead of paging from newest, and
+ * - load in both directions (`older` below, `newer` above).
+ *
+ * Returns rows newest→oldest regardless of direction. No `count` — `hasMore` is
+ * inferred from a full page, so there's no whole-table count per request.
+ */
+export async function getItemLedgerActivity(
+ client: SupabaseClient<Database>,
+ args: {
+ itemId: string;
+ companyId: string;
+ locationId: string;
+ /** entryNumber to page from; omit to start from the newest entry. */
+ entryNumber?: number;
+ direction?: "older" | "newer";
+ /** include the cursor row itself (used for the anchored first load). */
+ inclusive?: boolean;
+ }
+) {
+ const pageSize = 20;
+ const direction = args.direction ?? "older";
+
+ let query = client
+ .from("itemLedger")
+ .select("*, storageUnit(name), trackedEntity(readableId)")
+ .eq("itemId", args.itemId)
+ .eq("companyId", args.companyId)
+ .eq("locationId", args.locationId);
+
+ if (args.entryNumber !== undefined) {
+ if (direction === "older") {
+ query = args.inclusive
+ ? query.lte("entryNumber", args.entryNumber)
+ : query.lt("entryNumber", args.entryNumber);
+ } else {
+ query = args.inclusive
+ ? query.gte("entryNumber", args.entryNumber)
+ : query.gt("entryNumber", args.entryNumber);
+ }
+ }
+
+ // Scan toward the requested direction so the page is contiguous with the
+ // cursor, then always hand back newest→oldest for rendering/prepending.
+ query = query
+ .order("entryNumber", { ascending: direction === "newer" })
+ .limit(pageSize);
+
+ const { data, error } = await query;
+
+ const rows =
+ direction === "newer" ? (data ?? []).slice().reverse() : (data ?? []);
+ return { data: rows, hasMore: (data?.length ?? 0) === pageSize, error };
+}
+
export async function getBatchProperties(
client: SupabaseClient<Database>,
itemIds: string[],
@@ -908,6 +970,37 @@ export async function searchStorageUnitsWithAncestors(
};
}
+export async function getStockMovements(
+ client: SupabaseClient<Database>,
+ companyId: string,
+ args: GenericQueryFilters & {
+ search: string | null;
+ }
+) {
+ let query = client
+ .from("itemLedgers")
+ .select("*", {
+ count: "exact"
+ })
+ .eq("companyId", companyId);
+
+ if (args.search) {
+ // Strip characters that are structural in a PostgREST `.or(...)` filter
+ // (comma separates conditions, parens group them) so the search value can't
+ // alter the filter shape.
+ const search = args.search.replace(/[,()\\]/g, " ");
+ query = query.or(
+ `itemReadableId.ilike.%${search}%,itemDescription.ilike.%${search}%,locationName.ilike.%${search}%,storageUnitName.ilike.%${search}%,trackedEntityReadableId.ilike.%${search}%`
+ );
+ }
+
+ query = setGenericQueryFilters(query, args, [
+ { column: "createdAt", ascending: false },
+ { column: "entryNumber", ascending: false }
+ ]);
+ return query;
+}
+
export async function getShipments(
client: SupabaseClient<Database>,
companyId: string,
diff --git a/apps/erp/app/modules/inventory/types.ts b/apps/erp/app/modules/inventory/types.ts
index 94b80d0bf3..fd40c75e6e 100644
--- a/apps/erp/app/modules/inventory/types.ts
+++ b/apps/erp/app/modules/inventory/types.ts
@@ -11,6 +11,7 @@ import type {
getShipments,
getShipmentTracking,
getShippingMethods,
+ getStockMovements,
getStockTransferLines,
getStockTransfers,
getTrackedEntities,
@@ -58,6 +59,10 @@ export type Shipment = NonNullable<
Awaited<ReturnType<typeof getShipments>>["data"]
>[number];
+export type StockMovement = NonNullable<
+ Awaited<ReturnType<typeof getStockMovements>>["data"]
+>[number];
+
export type ShipmentLine = NonNullable<
Awaited<ReturnType<typeof getShipmentLines>>["data"]
>[number];
diff --git a/apps/erp/app/modules/inventory/ui/Inventory/InventoryActivity.tsx b/apps/erp/app/modules/inventory/ui/Inventory/InventoryActivity.tsx
index 252ecbcb84..c6ec817276 100644
--- a/apps/erp/app/modules/inventory/ui/Inventory/InventoryActivity.tsx
+++ b/apps/erp/app/modules/inventory/ui/Inventory/InventoryActivity.tsx
@@ -1,10 +1,21 @@
-import { LuArrowRightLeft, LuCircleMinus, LuCirclePlus } from "react-icons/lu";
-import { Hyperlink } from "~/components";
+import { memo } from "react";
+import {
+ LuArrowRightLeft,
+ LuExternalLink,
+ LuMoveDown,
+ LuMoveUp
+} from "react-icons/lu";
+import { Link } from "react-router";
import Activity from "~/components/Activity";
import { path } from "~/utils/path";
import type { ItemLedger } from "../../types";
const getActivityText = (ledgerRecord: ItemLedger) => {
+ // Prefer the entity's readable serial/batch number; fall back to the raw
+ // tracked-entity id when it has none (e.g. unnumbered receipt batches).
+ const trackedEntityLabel =
+ ledgerRecord.trackedEntity?.readableId || ledgerRecord.trackedEntityId;
+
switch (ledgerRecord.documentType) {
case "Purchase Receipt":
return `received ${ledgerRecord.quantity} units${
@@ -12,10 +23,10 @@ const getActivityText = (ledgerRecord: ItemLedger) => {
? ` to ${ledgerRecord.storageUnit.name}`
: ""
}${
- ledgerRecord.trackedEntityId
+ trackedEntityLabel
? ` from ${
Math.abs(ledgerRecord.quantity) > 1 ? "batch" : "serial"
- } ${ledgerRecord.trackedEntityId}`
+ } ${trackedEntityLabel}`
: ""
}`;
case "Purchase Invoice":
@@ -30,10 +41,8 @@ const getActivityText = (ledgerRecord: ItemLedger) => {
? ` from ${ledgerRecord.storageUnit.name}`
: ""
}${
- ledgerRecord.trackedEntityId
- ? ` of ${Math.abs(ledgerRecord.quantity) > 1 ? "batch" : "serial"} ${
- ledgerRecord.trackedEntityId
- }`
+ trackedEntityLabel
+ ? ` of ${Math.abs(ledgerRecord.quantity) > 1 ? "batch" : "serial"} ${trackedEntityLabel}`
: ""
}`;
case "Sales Invoice":
@@ -129,33 +138,39 @@ const getActivityText = (ledgerRecord: ItemLedger) => {
{ledgerRecord.storageUnit?.name
? `from ${ledgerRecord.storageUnit.name} `
: ""}
- {ledgerRecord.trackedEntityId ? (
+ {trackedEntityLabel ? (
<>
from {Math.abs(ledgerRecord.quantity) > 1 ? "batch" : "serial"}{" "}
- {ledgerRecord.trackedEntityId}{" "}
+ {trackedEntityLabel}{" "}
</>
) : null}
{ledgerRecord.documentLineId && ledgerRecord.documentId ? (
<>
to a{" "}
- <Hyperlink
- className="inline-flex"
+ <Link
+ className="inline-flex items-center gap-1 font-medium text-foreground hover:text-primary"
to={`${path.to.jobProductionEvents(
ledgerRecord.documentId!
)}?filter=jobOperationId:eq:${ledgerRecord.documentLineId}`}
+ target="_blank"
+ rel="noopener noreferrer"
>
- job operation
- </Hyperlink>
+ <span>job operation</span>
+ <LuExternalLink className="size-3.5" />
+ </Link>
</>
) : ledgerRecord.documentId ? (
<>
to a{" "}
- <Hyperlink
- className="inline-flex"
+ <Link
+ className="inline-flex items-center gap-1 font-medium text-foreground hover:text-primary"
to={path.to.jobDetails(ledgerRecord.documentId!)}
+ target="_blank"
+ rel="noopener noreferrer"
>
- job
- </Hyperlink>
+ <span>job</span>
+ <LuExternalLink className="size-3.5" />
+ </Link>
</>
) : null}
</span>
@@ -167,21 +182,24 @@ const getActivityText = (ledgerRecord: ItemLedger) => {
{ledgerRecord.storageUnit?.name
? `from ${ledgerRecord.storageUnit.name} `
: ""}
- {ledgerRecord.trackedEntityId ? (
+ {trackedEntityLabel ? (
<>
from {Math.abs(ledgerRecord.quantity) > 1 ? "batch" : "serial"}{" "}
- {ledgerRecord.trackedEntityId}{" "}
+ {trackedEntityLabel}{" "}
</>
) : null}
{ledgerRecord.documentId ? (
<>
to a{" "}
- <Hyperlink
- className="inline-flex"
+ <Link
+ className="inline-flex items-center gap-1 font-medium text-foreground hover:text-primary"
to={path.to.maintenanceDispatch(ledgerRecord.documentId!)}
+ target="_blank"
+ rel="noopener noreferrer"
>
- maintenance dispatch
- </Hyperlink>
+ <span>maintenance dispatch</span>
+ <LuExternalLink className="size-3.5" />
+ </Link>
</>
) : null}
</span>
@@ -196,12 +214,15 @@ const getActivityText = (ledgerRecord: ItemLedger) => {
: ""}{" "}
from a
</span>{" "}
- <Hyperlink
- className="inline-flex"
+ <Link
+ className="inline-flex items-center gap-1 font-medium text-foreground hover:text-primary"
to={path.to.jobDetails(ledgerRecord.documentId!)}
+ target="_blank"
+ rel="noopener noreferrer"
>
- job
- </Hyperlink>
+ <span>job</span>
+ <LuExternalLink className="size-3.5" />
+ </Link>
</>
);
default:
@@ -215,10 +236,8 @@ const getActivityText = (ledgerRecord: ItemLedger) => {
? ` to ${ledgerRecord.storageUnit?.name}`
: ""
}${
- ledgerRecord.trackedEntityId
- ? ` for ${Math.abs(ledgerRecord.quantity) > 1 ? "batch" : "serial"} ${
- ledgerRecord.trackedEntityId
- }`
+ trackedEntityLabel
+ ? ` for ${Math.abs(ledgerRecord.quantity) > 1 ? "batch" : "serial"} ${trackedEntityLabel}`
: ""
}`;
case "Negative Adjmt.":
@@ -227,10 +246,8 @@ const getActivityText = (ledgerRecord: ItemLedger) => {
? ` to ${ledgerRecord.storageUnit.name}`
: ""
}${
- ledgerRecord.trackedEntityId
- ? ` for ${Math.abs(ledgerRecord.quantity) > 1 ? "batch" : "serial"} ${
- ledgerRecord.trackedEntityId
- }`
+ trackedEntityLabel
+ ? ` for ${Math.abs(ledgerRecord.quantity) > 1 ? "batch" : "serial"} ${trackedEntityLabel}`
: ""
}`;
default:
@@ -241,12 +258,12 @@ const getActivityText = (ledgerRecord: ItemLedger) => {
const getActivityIcon = (ledgerRecord: ItemLedger) => {
switch (ledgerRecord.entryType) {
case "Transfer":
- return <LuArrowRightLeft className="text-blue-500 w-5 h-5" />;
+ return <LuArrowRightLeft className="text-blue-500 text-lg" />;
case "Positive Adjmt.":
- return <LuCirclePlus className="text-emerald-500 w-5 h-5" />;
+ return <LuMoveUp className="text-emerald-500 text-lg" />;
case "Negative Adjmt.":
case "Consumption":
- return <LuCircleMinus className="text-red-500 w-5 h-5" />;
+ return <LuMoveDown className="text-red-500 text-lg" />;
default:
return "";
}
@@ -254,18 +271,24 @@ const getActivityIcon = (ledgerRecord: ItemLedger) => {
type InventoryActivityProps = {
item: ItemLedger;
+ highlightId?: string;
};
-const InventoryActivity = ({ item }: InventoryActivityProps) => {
- return (
- <Activity
- employeeId={item.createdBy}
- activityMessage={getActivityText(item)}
- activityTime={item.createdAt}
- activityIcon={getActivityIcon(item)}
- comment={item.comment}
- />
- );
-};
+const InventoryActivity = memo(
+ ({ item, highlightId }: InventoryActivityProps) => {
+ return (
+ <Activity
+ employeeId={item.createdBy}
+ activityMessage={getActivityText(item)}
+ activityTime={item.createdAt}
+ activityIcon={getActivityIcon(item)}
+ comment={item.comment}
+ highlighted={highlightId === item.id}
+ />
+ );
+ }
+);
+
+InventoryActivity.displayName = "InventoryActivity";
export default InventoryActivity;
diff --git a/apps/erp/app/modules/inventory/ui/StockMovements/StockMovementsTable.tsx b/apps/erp/app/modules/inventory/ui/StockMovements/StockMovementsTable.tsx
new file mode 100644
index 0000000000..f9472ce424
--- /dev/null
+++ b/apps/erp/app/modules/inventory/ui/StockMovements/StockMovementsTable.tsx
@@ -0,0 +1,250 @@
+import { HStack, VStack } from "@carbon/react";
+import { useLingui } from "@lingui/react/macro";
+import type { ColumnDef } from "@tanstack/react-table";
+import { memo, useMemo } from "react";
+import {
+ LuArrowRightLeft,
+ LuCalendar,
+ LuFileText,
+ LuHash,
+ LuMapPin,
+ LuMoveDown,
+ LuMoveUp,
+ LuPackage,
+ LuQrCode,
+ LuUser,
+ LuWarehouse
+} from "react-icons/lu";
+import { EmployeeAvatar, Hyperlink, ItemThumbnail, Table } from "~/components";
+import { Enumerable } from "~/components/Enumerable";
+import { useLocations } from "~/components/Form/Location";
+import { useDateFormatter, useUser } from "~/hooks";
+import { useDebouncedRealtime } from "~/hooks/useDebouncedRealtime";
+import type { MethodItemType } from "~/modules/shared";
+import { usePeople } from "~/stores";
+import { path } from "~/utils/path";
+import {
+ itemLedgerDocumentTypes,
+ itemLedgerTypes
+} from "../../inventory.models";
+import type { StockMovement } from "../../types";
+
+type StockMovementsTableProps = {
+ data: StockMovement[];
+ count: number;
+};
+
+const StockMovementsTable = memo(
+ ({ data, count }: StockMovementsTableProps) => {
+ const { t } = useLingui();
+ const { formatDate } = useDateFormatter();
+ const { company } = useUser();
+ const [people] = usePeople();
+ const locations = useLocations();
+ const locationsById = useMemo(
+ () => new Map(locations.map((l) => [l.value, l.label])),
+ [locations]
+ );
+
+ // Company-wide realtime: a single posting can insert many itemLedger rows
+ // at once, so coalesce the burst into one route revalidation (1.5s debounce
+ // inside useDebouncedRealtime) rather than revalidating per event.
+ useDebouncedRealtime("itemLedger", `companyId=eq.${company.id}`);
+
+ const columns = useMemo<ColumnDef<StockMovement>[]>(() => {
+ return [
+ {
+ accessorKey: "itemReadableId",
+ header: t`Item`,
+ cell: ({ row }) => (
+ <HStack className="py-1">
+ <ItemThumbnail
+ size="sm"
+ thumbnailPath={row.original.thumbnailPath}
+ type={row.original.itemType as MethodItemType}
+ />
+ <Hyperlink to={getInventoryItemActivityPath(row.original)}>
+ <VStack spacing={0}>
+ <span>{row.original.itemReadableId}</span>
+ {row.original.itemDescription && (
+ <span className="text-muted-foreground text-xs">
+ {row.original.itemDescription}
+ </span>
+ )}
+ </VStack>
+ </Hyperlink>
+ </HStack>
+ ),
+ meta: {
+ icon: <LuPackage />
+ }
+ },
+ {
+ accessorKey: "entryType",
+ header: t`Entry Type`,
+ cell: (item) => <Enumerable value={item.getValue<string>()} />,
+ meta: {
+ filter: {
+ type: "static",
+ options: itemLedgerTypes.map((type) => ({
+ value: type,
+ label: <Enumerable value={type} />
+ }))
+ },
+ icon: <LuArrowRightLeft />
+ }
+ },
+ {
+ accessorKey: "documentType",
+ header: t`Document Type`,
+ cell: (item) => <Enumerable value={item.getValue<string>()} />,
+ meta: {
+ filter: {
+ type: "static",
+ options: itemLedgerDocumentTypes.map((type) => ({
+ value: type,
+ label: <Enumerable value={type} />
+ }))
+ },
+ icon: <LuFileText />
+ }
+ },
+ {
+ accessorKey: "quantity",
+ header: t`Quantity`,
+ cell: ({ row }) => {
+ const value = row.original.quantity;
+ if (!value)
+ return (
+ <HStack
+ spacing={1}
+ className="font-medium text-muted-foreground"
+ >
+ <LuMoveUp className="invisible text-lg" />
+ <span>{value}</span>
+ </HStack>
+ );
+ const isPositive = value > 0;
+ return (
+ <HStack spacing={1} className="font-medium">
+ {isPositive ? (
+ <LuMoveUp className="text-success text-lg" />
+ ) : (
+ <LuMoveDown className="text-destructive text-lg" />
+ )}
+ <span>{Math.abs(value)}</span>
+ </HStack>
+ );
+ },
+ meta: {
+ icon: <LuHash />
+ }
+ },
+ {
+ accessorKey: "locationId",
+ header: t`Location`,
+ cell: ({ row }) => (
+ <Enumerable
+ value={
+ row.original.locationId
+ ? (locationsById.get(row.original.locationId) ?? null)
+ : null
+ }
+ />
+ ),
+ meta: {
+ filter: {
+ type: "static",
+ options: locations.map((location) => ({
+ value: location.value,
+ label: <Enumerable value={location.label} />
+ }))
+ },
+ icon: <LuMapPin />
+ }
+ },
+ {
+ accessorKey: "storageUnitName",
+ header: t`Storage Unit`,
+ cell: ({ row }) => row.original.storageUnitName ?? "",
+ meta: {
+ icon: <LuWarehouse />
+ }
+ },
+ {
+ accessorKey: "trackedEntityReadableId",
+ header: t`Tracked Entity`,
+ cell: ({ row }) =>
+ row.original.trackedEntityReadableId ||
+ row.original.trackedEntityId,
+ meta: {
+ icon: <LuQrCode />
+ }
+ },
+ {
+ accessorKey: "postingDate",
+ header: t`Posting Date`,
+ cell: (item) => formatDate(item.getValue<string>()),
+ meta: {
+ icon: <LuCalendar />
+ }
+ },
+ {
+ id: "createdBy",
+ header: t`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: t`Created At`,
+ cell: (item) => formatDate(item.getValue<string>()),
+ meta: {
+ icon: <LuCalendar />
+ }
+ }
+ ];
+ }, [people, locations, locationsById, t, formatDate]);
+
+ return (
+ <Table<(typeof data)[number]>
+ data={data}
+ columns={columns}
+ count={count}
+ defaultColumnPinning={{
+ left: ["itemReadableId"]
+ }}
+ title={t`Stock Movements`}
+ table="itemLedger"
+ withSavedView
+ />
+ );
+ }
+);
+
+StockMovementsTable.displayName = "StockMovementsTable";
+export default StockMovementsTable;
+
+// Opens the item's side panel on the Activity tab inside the Inventory
+// (Quantities) layout:
+// - `search` filters the list behind it to this item (readableIdWithRevision)
+// - `location` loads the location this entry lives in (the panel is location-scoped)
+// - `highlight` is the itemLedger row id, so the panel flashes this exact entry
+function getInventoryItemActivityPath(movement: StockMovement) {
+ const params = new URLSearchParams();
+ if (movement.itemReadableId) params.set("search", movement.itemReadableId);
+ if (movement.locationId) params.set("location", movement.locationId);
+ params.set("highlight", movement.id ?? "");
+ return `${path.to.inventoryItemActivity(movement.itemId ?? "")}?${params.toString()}`;
+}
diff --git a/apps/erp/app/modules/inventory/ui/useInventorySubmodules.tsx b/apps/erp/app/modules/inventory/ui/useInventorySubmodules.tsx
index 500051d26e..faef4b8df4 100644
--- a/apps/erp/app/modules/inventory/ui/useInventorySubmodules.tsx
+++ b/apps/erp/app/modules/inventory/ui/useInventorySubmodules.tsx
@@ -1,5 +1,6 @@
import { useLingui } from "@lingui/react/macro";
import {
+ LuArrowDownUp,
LuArrowRightLeft,
LuClipboardList,
LuHandCoins,
@@ -74,6 +75,13 @@ export default function useInventorySubmodules() {
icon: <LuTally5 />,
table: "inventory"
},
+ {
+ name: t`Stock Movements`,
+ to: path.to.stockMovements,
+ role: "employee",
+ icon: <LuArrowDownUp />,
+ table: "itemLedger"
+ },
{
name: t`Tracked Entities`,
to: path.to.trackedEntities,
diff --git a/apps/erp/app/routes/api+/mcp+/lib/tool-metadata.json b/apps/erp/app/routes/api+/mcp+/lib/tool-metadata.json
index 4a88ed0196..c41efac711 100644
--- a/apps/erp/app/routes/api+/mcp+/lib/tool-metadata.json
+++ b/apps/erp/app/routes/api+/mcp+/lib/tool-metadata.json
@@ -1,6 +1,6 @@
{
- "generated": "2026-06-26T23:06:34.350Z",
- "totalTools": 1219,
+ "generated": "2026-06-27T00:36:56.346Z",
+ "totalTools": 1221,
"modules": 15,
"tools": [
{
@@ -3598,6 +3598,48 @@
]
}
},
+ {
+ "name": "inventory_getItemLedgerActivity",
+ "module": "inventory",
+ "classification": "READ",
+ "description": "get item ledger activity",
+ "paramCount": 5,
+ "serviceParams": [
+ "client",
+ "args"
+ ],
+ "injectAuth": [
+ "companyId"
+ ],
+ "schema": {
+ "type": "object",
+ "properties": {
+ "itemId": {
+ "type": "string"
+ },
+ "locationId": {
+ "type": "string"
+ },
+ "omit to start from the newest entry. */\n entryNumber": {
+ "type": "number"
+ },
+ "direction": {
+ "type": "string",
+ "enum": [
+ "older",
+ "newer"
+ ]
+ },
+ "/** include the cursor row itself (used for the anchored first load). */\n inclusive": {
+ "type": "boolean"
+ }
+ },
+ "required": [
+ "itemId",
+ "locationId"
+ ]
+ }
+ },
{
"name": "inventory_getBatchProperties",
"module": "inventory",
@@ -4627,6 +4669,45 @@
]
}
},
+ {
+ "name": "inventory_getStockMovements",
+ "module": "inventory",
+ "classification": "READ",
+ "description": "get stock movements",
+ "paramCount": 3,
+ "serviceParams": [
+ "client",
+ "companyId",
+ "args"
+ ],
+ "injectAuth": [
+ "companyId"
+ ],
+ "schema": {
+ "type": "object",
+ "properties": {
+ "args": {
+ "type": "object",
+ "properties": {
+ "limit": {
+ "type": "integer",
+ "default": 100
+ },
+ "offset": {
+ "type": "integer",
+ "default": 0
+ },
+ "search": {
+ "type": [
+ "string",
+ "null"
+ ]
+ }
+ }
+ }
+ }
+ }
+ },
{
"name": "inventory_getShipments",
"module": "inventory",
diff --git a/apps/erp/app/routes/x+/inventory+/quantities+/$itemId.activity.tsx b/apps/erp/app/routes/x+/inventory+/quantities+/$itemId.activity.tsx
index a31445a772..a2a947c54d 100644
--- a/apps/erp/app/routes/x+/inventory+/quantities+/$itemId.activity.tsx
+++ b/apps/erp/app/routes/x+/inventory+/quantities+/$itemId.activity.tsx
@@ -1,13 +1,15 @@
import { error, notFound, useCarbon } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
+import { Button } from "@carbon/react";
import { Trans } from "@lingui/react/macro";
-import { useCallback, useState } from "react";
+import { useCallback, useRef, useState } from "react";
+import { LuChevronUp } from "react-icons/lu";
import type { LoaderFunctionArgs } from "react-router";
import { redirect, useLoaderData } from "react-router";
import InfiniteScroll from "~/components/InfiniteScroll";
import type { ItemLedger } from "~/modules/inventory";
-import { getItemLedgerPage, InventoryActivity } from "~/modules/inventory";
+import { getItemLedgerActivity, InventoryActivity } from "~/modules/inventory";
import { getLocationsList } from "~/modules/resources";
import { getUserDefaults } from "~/modules/users/users.server";
import { path } from "~/utils/path";
@@ -23,6 +25,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
const url = new URL(request.url);
const searchParams = new URLSearchParams(url.search);
let locationId = searchParams.get("location");
+ const highlightId = searchParams.get("highlight");
if (!locationId) {
const userDefaults = await getUserDefaults(client, userId, companyId);
@@ -53,84 +56,174 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
locationId = locations.data?.[0].id as string;
}
- const itemLedgerRecords = await getItemLedgerPage(
- client,
- itemId,
- companyId,
- locationId,
- true
- );
- if (itemLedgerRecords.error || !itemLedgerRecords.data) {
+ // When arriving via a `highlight` param, anchor the first page directly on
+ // that entry (load it + older below) so it's on screen no matter how old it
+ // is — instead of paging from newest until we reach it.
+ let anchorEntryNumber: number | null = null;
+ if (highlightId) {
+ const anchor = await client
+ .from("itemLedger")
+ .select("entryNumber")
+ .eq("id", highlightId)
+ .eq("companyId", companyId)
+ .maybeSingle();
+ anchorEntryNumber = anchor.data?.entryNumber ?? null;
+ }
+
+ // The activity page and the "is there anything newer than the anchor?"
+ // existence check both depend only on `anchorEntryNumber`, not on each other —
+ // run them in parallel to save a roundtrip on highlight navigations.
+ const [itemLedgerRecords, newer] = await Promise.all([
+ getItemLedgerActivity(client, {
+ itemId,
+ companyId,
+ locationId,
+ entryNumber: anchorEntryNumber ?? undefined,
+ direction: "older",
+ inclusive: anchorEntryNumber !== null
+ }),
+ anchorEntryNumber !== null
+ ? client
+ .from("itemLedger")
+ .select("id")
+ .eq("itemId", itemId)
+ .eq("companyId", companyId)
+ .eq("locationId", locationId)
+ .gt("entryNumber", anchorEntryNumber)
+ .limit(1)
+ : Promise.resolve({ data: [] as { id: string }[] })
+ ]);
+ if (itemLedgerRecords.error) {
throw redirect(
path.to.inventory,
await flash(
request,
- error(itemLedgerRecords, "Failed to load item inventory activity")
+ error(itemLedgerRecords.error, "Failed to load item inventory activity")
)
);
}
+ // Only offer "Load newer" when entries actually exist above the anchor.
+ const hasNewer = (newer.data?.length ?? 0) > 0;
+
return {
initialItemLedgers: itemLedgerRecords.data,
itemId,
companyId,
- locationId
+ locationId,
+ highlightId,
+ hasOlder: itemLedgerRecords.hasMore,
+ hasNewer
};
}
export default function ItemInventoryActivityRoute() {
- const { initialItemLedgers, itemId, companyId, locationId } =
- useLoaderData<typeof loader>();
+ const {
+ initialItemLedgers,
+ itemId,
+ companyId,
+ locationId,
+ highlightId,
+ hasOlder: initialHasOlder,
+ hasNewer: initialHasNewer
+ } = useLoaderData<typeof loader>();
const { carbon } = useCarbon();
const [itemLedgers, setItemLedgers] =
useState<ItemLedger[]>(initialItemLedgers);
- const [page, setPage] = useState(1);
- const [isLoading, setIsLoading] = useState(false);
- const [hasMore, setHasMore] = useState(true);
-
- const loadMoreItemLedgers = useCallback(async () => {
- if (isLoading || !hasMore) return;
+ const [hasOlder, setHasOlder] = useState(initialHasOlder);
+ const [hasNewer, setHasNewer] = useState(initialHasNewer);
+ const [isLoadingNewer, setIsLoadingNewer] = useState(false);
+
+ // Mirror the values the paging callbacks read into refs so the callbacks stay
+ // referentially stable across appends — otherwise InfiniteScroll's
+ // IntersectionObserver effect re-subscribes on every loaded page.
+ const oldestEntryNumber = useRef<number | null>(
+ initialItemLedgers[initialItemLedgers.length - 1]?.entryNumber ?? null
+ );
+ const newestEntryNumber = useRef<number | null>(
+ initialItemLedgers[0]?.entryNumber ?? null
+ );
+ const loadingOlder = useRef(false);
+ const loadingNewer = useRef(false);
+ const hasOlderRef = useRef(initialHasOlder);
+ const hasNewerRef = useRef(initialHasNewer);
- setIsLoading(true);
+ const loadOlder = useCallback(async () => {
+ const cursor = oldestEntryNumber.current;
+ if (loadingOlder.current || !hasOlderRef.current || cursor === null) return;
+ loadingOlder.current = true;
- const newItemLedgers = await getItemLedgerPage(
- carbon!,
+ const result = await getItemLedgerActivity(carbon!, {
itemId,
companyId,
locationId,
- true,
- page + 1
- );
-
- if (newItemLedgers.data && newItemLedgers.data.length > 0) {
- setItemLedgers((prevItemLedgers) => [
- ...prevItemLedgers,
- ...newItemLedgers.data
- ]);
- setPage((prevPage) => prevPage + 1);
- } else {
- setHasMore(false);
+ entryNumber: cursor,
+ direction: "older"
+ });
+
+ if (result.data.length > 0) {
+ oldestEntryNumber.current =
+ result.data[result.data.length - 1].entryNumber;
+ setItemLedgers((prev) => [...prev, ...result.data]);
}
+ hasOlderRef.current = result.hasMore;
+ setHasOlder(result.hasMore);
+ loadingOlder.current = false;
+ }, [carbon, itemId, companyId, locationId]);
+
+ const loadNewer = useCallback(async () => {
+ const cursor = newestEntryNumber.current;
+ if (loadingNewer.current || !hasNewerRef.current || cursor === null) return;
+ loadingNewer.current = true;
+ setIsLoadingNewer(true);
+
+ const result = await getItemLedgerActivity(carbon!, {
+ itemId,
+ companyId,
+ locationId,
+ entryNumber: cursor,
+ direction: "newer"
+ });
- setIsLoading(false);
- }, [page, carbon, companyId, locationId, itemId, isLoading, hasMore]);
+ if (result.data.length > 0) {
+ newestEntryNumber.current = result.data[0].entryNumber;
+ setItemLedgers((prev) => [...result.data, ...prev]);
+ }
+ hasNewerRef.current = result.hasMore;
+ setHasNewer(result.hasMore);
+ loadingNewer.current = false;
+ setIsLoadingNewer(false);
+ }, [carbon, itemId, companyId, locationId]);
return (
- <>
- <div className="w-full space-y-4 pt-6 px-4">
- <h2 className="text-2xl font-semibold mb-4">
- <Trans>Activity</Trans>
- </h2>
-
- <InfiniteScroll
- component={InventoryActivity}
- items={itemLedgers}
- loadMore={loadMoreItemLedgers}
- hasMore={hasMore}
- />
- </div>
- </>
+ <div className="w-full space-y-4 pt-6 px-4">
+ <h2 className="text-2xl font-semibold mb-4">
+ <Trans>Activity</Trans>
+ </h2>
+
+ {hasNewer && (
+ <div className="flex justify-center">
+ <Button
+ variant="secondary"
+ leftIcon={<LuChevronUp />}
+ isLoading={isLoadingNewer}
+ isDisabled={isLoadingNewer}
+ onClick={loadNewer}
+ >
+ <Trans>Load newer</Trans>
+ </Button>
+ </div>
+ )}
+
+ <InfiniteScroll
+ component={InventoryActivity}
+ items={itemLedgers}
+ loadMore={loadOlder}
+ hasMore={hasOlder}
+ highlightId={highlightId ?? undefined}
+ />
+ </div>
);
}
diff --git a/apps/erp/app/routes/x+/inventory+/stock-movements.tsx b/apps/erp/app/routes/x+/inventory+/stock-movements.tsx
new file mode 100644
index 0000000000..1e683450ea
--- /dev/null
+++ b/apps/erp/app/routes/x+/inventory+/stock-movements.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 { msg } from "@lingui/core/macro";
+import type { LoaderFunctionArgs } from "react-router";
+import { redirect, useLoaderData } from "react-router";
+import { getStockMovements } from "~/modules/inventory";
+import StockMovementsTable from "~/modules/inventory/ui/StockMovements/StockMovementsTable";
+import type { Handle } from "~/utils/handle";
+import { path } from "~/utils/path";
+import { getGenericQueryFilters } from "~/utils/query";
+
+export const handle: Handle = {
+ breadcrumb: msg`Stock Movements`,
+ to: path.to.stockMovements
+};
+
+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 movements = await getStockMovements(client, companyId, {
+ search,
+ limit,
+ offset,
+ sorts,
+ filters
+ });
+
+ if (movements.error) {
+ throw redirect(
+ path.to.authenticatedRoot,
+ await flash(
+ request,
+ error(movements.error, "Error loading stock movements")
+ )
+ );
+ }
+
+ return {
+ movements: movements.data ?? [],
+ count: movements.count ?? 0
+ };
+}
+
+export default function StockMovementsRoute() {
+ const { movements, count } = useLoaderData<typeof loader>();
+
+ return (
+ <VStack spacing={0} className="h-full">
+ <StockMovementsTable data={movements} count={count ?? 0} />
+ </VStack>
+ );
+}
diff --git a/apps/erp/app/utils/path.ts b/apps/erp/app/utils/path.ts
index 53989b46a5..754913c7ae 100644
--- a/apps/erp/app/utils/path.ts
+++ b/apps/erp/app/utils/path.ts
@@ -983,6 +983,7 @@ export const path = {
inventoryItemAdjustment: (id: string) =>
generatePath(`${x}/inventory/quantities/${id}/adjustment`),
inventoryRoot: `${x}/inventory`,
+ stockMovements: `${x}/inventory/stock-movements`,
inventorySettings: `${x}/settings/inventory`,
invoicing: `${x}/invoicing`,
issues: `${x}/quality/issues`,
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index 2822f42df6..22bd406b07 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -53277,6 +53277,167 @@ export type Database = {
},
]
}
+ itemLedgers: {
+ Row: {
+ comment: string | null
+ companyId: string | null
+ createdAt: string | null
+ createdBy: string | null
+ documentId: string | null
+ documentLineId: string | null
+ documentType:
+ | Database["public"]["Enums"]["itemLedgerDocumentType"]
+ | null
+ entryNumber: number | null
+ entryType: Database["public"]["Enums"]["itemLedgerType"] | null
+ externalDocumentId: string | null
+ id: string | null
+ itemDescription: string | null
+ itemId: string | null
+ itemReadableId: string | null
+ itemType: Database["public"]["Enums"]["itemType"] | null
+ locationId: string | null
+ locationName: string | null
+ postingDate: string | null
+ quantity: number | null
+ storageUnitId: string | null
+ storageUnitName: string | null
+ thumbnailPath: string | null
+ trackedEntityId: string | null
+ trackedEntityReadableId: string | null
+ trackedEntityStatus:
+ | Database["public"]["Enums"]["trackedEntityStatus"]
+ | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "itemLedger_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemLedger_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemLedger_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemLedger_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemLedger_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "itemLedger_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "consumables"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemLedger_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "item"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemLedger_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "materials"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemLedger_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "parts"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemLedger_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "services"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemLedger_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "tools"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemLedger_locationId_fkey"
+ columns: ["locationId"]
+ isOneToOne: false
+ referencedRelation: "location"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemLedger_storageUnitId_fkey"
+ columns: ["storageUnitId"]
+ isOneToOne: false
+ referencedRelation: "storageUnit"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemLedger_trackedEntityId_fkey"
+ columns: ["trackedEntityId"]
+ isOneToOne: false
+ referencedRelation: "trackedEntity"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "partLeger_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "partLeger_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "partLeger_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "partLeger_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ ]
+ }
itemStockQuantities: {
Row: {
companyId: string | null
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index 2822f42df6..22bd406b07 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -53277,6 +53277,167 @@ export type Database = {
},
]
}
+ itemLedgers: {
+ Row: {
+ comment: string | null
+ companyId: string | null
+ createdAt: string | null
+ createdBy: string | null
+ documentId: string | null
+ documentLineId: string | null
+ documentType:
+ | Database["public"]["Enums"]["itemLedgerDocumentType"]
+ | null
+ entryNumber: number | null
+ entryType: Database["public"]["Enums"]["itemLedgerType"] | null
+ externalDocumentId: string | null
+ id: string | null
+ itemDescription: string | null
+ itemId: string | null
+ itemReadableId: string | null
+ itemType: Database["public"]["Enums"]["itemType"] | null
+ locationId: string | null
+ locationName: string | null
+ postingDate: string | null
+ quantity: number | null
+ storageUnitId: string | null
+ storageUnitName: string | null
+ thumbnailPath: string | null
+ trackedEntityId: string | null
+ trackedEntityReadableId: string | null
+ trackedEntityStatus:
+ | Database["public"]["Enums"]["trackedEntityStatus"]
+ | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "itemLedger_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemLedger_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemLedger_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemLedger_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemLedger_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "itemLedger_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "consumables"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemLedger_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "item"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemLedger_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "materials"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemLedger_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "parts"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemLedger_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "services"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemLedger_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "tools"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemLedger_locationId_fkey"
+ columns: ["locationId"]
+ isOneToOne: false
+ referencedRelation: "location"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemLedger_storageUnitId_fkey"
+ columns: ["storageUnitId"]
+ isOneToOne: false
+ referencedRelation: "storageUnit"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "itemLedger_trackedEntityId_fkey"
+ columns: ["trackedEntityId"]
+ isOneToOne: false
+ referencedRelation: "trackedEntity"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "partLeger_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "partLeger_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "partLeger_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "partLeger_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ ]
+ }
itemStockQuantities: {
Row: {
companyId: string | null
diff --git a/packages/database/supabase/migrations/20260624153001_stock-movements-view.sql b/packages/database/supabase/migrations/20260624153001_stock-movements-view.sql
new file mode 100644
index 0000000000..c130bae2f7
--- /dev/null
+++ b/packages/database/supabase/migrations/20260624153001_stock-movements-view.sql
@@ -0,0 +1,45 @@
+-- Flattened, company-wide view over the itemLedger stock-movement table.
+-- Backs the aggregated "Stock Movements" list page (every item, all locations),
+-- exposing joined item/location/storage-unit names as flat columns so the generic
+-- search/sort/filter helpers work the same way they do for `kanbans` /
+-- `stockTransferLines`. security_invoker => inherits itemLedger RLS
+-- (SELECT requires inventory_view / accounting_view).
+CREATE OR REPLACE VIEW "itemLedgers" WITH (security_invoker = true) AS
+SELECT
+ il.*,
+ i."readableIdWithRevision" AS "itemReadableId",
+ i."name" AS "itemDescription",
+ i."type" AS "itemType",
+ l."name" AS "locationName",
+ su."name" AS "storageUnitName",
+ te."readableId" AS "trackedEntityReadableId",
+ CASE
+ WHEN i."thumbnailPath" IS NULL AND mu."thumbnailPath" IS NOT NULL
+ THEN mu."thumbnailPath"
+ ELSE i."thumbnailPath"
+ END AS "thumbnailPath"
+FROM "itemLedger" il
+INNER JOIN "item" i ON i."id" = il."itemId" AND i."companyId" = il."companyId"
+LEFT JOIN "modelUpload" mu ON mu."id" = i."modelUploadId"
+LEFT JOIN "location" l ON l."id" = il."locationId"
+LEFT JOIN "storageUnit" su ON su."id" = il."storageUnitId"
+LEFT JOIN "trackedEntity" te ON te."id" = il."trackedEntityId";
+
+-- Matches the default "newest first" sort exactly (company-scoped, createdAt then
+-- the monotonic entryNumber as a unique tiebreaker) so the page can be served by an
+-- index scan + limit, then nested-loop joined only for the returned rows. The
+-- entryNumber tiebreaker also keeps offset pagination stable when createdAt ties.
+CREATE INDEX IF NOT EXISTS "itemLedger_companyId_createdAt_entryNumber_idx"
+ ON "itemLedger" ("companyId", "createdAt" DESC, "entryNumber" DESC);
+
+DO $$
+BEGIN
+ IF NOT EXISTS (
+ SELECT 1 FROM pg_publication_tables
+ WHERE pubname = 'supabase_realtime'
+ AND schemaname = 'public'
+ AND tablename = 'itemLedger'
+ ) THEN
+ ALTER PUBLICATION supabase_realtime ADD TABLE "itemLedger";
+ END IF;
+END $$;
\ No newline at end of file
diff --git a/packages/locale/locales/de/erp.po b/packages/locale/locales/de/erp.po
index 768a2073fd..342bdda208 100644
--- a/packages/locale/locales/de/erp.po
+++ b/packages/locale/locales/de/erp.po
@@ -3287,6 +3287,9 @@ msgstr "Dokumentenkontrolle"
msgid "Document Templates"
msgstr "Dokumentvorlagen"
+msgid "Document Type"
+msgstr ""
+
msgid "Document:"
msgstr "Dokument:"
@@ -3844,6 +3847,9 @@ msgstr "Entitätstyp"
msgid "Entity type cannot be changed"
msgstr "Entitätstyp kann nicht geändert werden"
+msgid "Entry Type"
+msgstr ""
+
msgid "EORI"
msgstr "EORI"
@@ -5624,6 +5630,9 @@ msgstr "Listenparameter"
msgid "Live reloading"
msgstr "Live-Neuladen"
+msgid "Load newer"
+msgstr ""
+
msgid "Load Templates"
msgstr "Vorlagen laden"
@@ -9315,6 +9324,9 @@ msgstr "Schrittdatensätze"
msgid "Steps"
msgstr "Schritte"
+msgid "Stock Movements"
+msgstr ""
+
msgid "Stock Transfer ID"
msgstr "Lagerbestandstransfer-ID"
diff --git a/packages/locale/locales/en/erp.po b/packages/locale/locales/en/erp.po
index cf5320d4a9..93a3df9d84 100644
--- a/packages/locale/locales/en/erp.po
+++ b/packages/locale/locales/en/erp.po
@@ -3287,6 +3287,9 @@ msgstr "Document Control"
msgid "Document Templates"
msgstr "Document Templates"
+msgid "Document Type"
+msgstr "Document Type"
+
msgid "Document:"
msgstr "Document:"
@@ -3844,6 +3847,9 @@ msgstr "Entity Type"
msgid "Entity type cannot be changed"
msgstr "Entity type cannot be changed"
+msgid "Entry Type"
+msgstr "Entry Type"
+
msgid "EORI"
msgstr "EORI"
@@ -5624,6 +5630,9 @@ msgstr "List Parameters"
msgid "Live reloading"
msgstr "Live reloading"
+msgid "Load newer"
+msgstr "Load newer"
+
msgid "Load Templates"
msgstr "Load Templates"
@@ -9315,6 +9324,9 @@ msgstr "Step Records"
msgid "Steps"
msgstr "Steps"
+msgid "Stock Movements"
+msgstr "Stock Movements"
+
msgid "Stock Transfer ID"
msgstr "Stock Transfer ID"
diff --git a/packages/locale/locales/es/erp.po b/packages/locale/locales/es/erp.po
index 622bbb112f..27f669ad27 100644
--- a/packages/locale/locales/es/erp.po
+++ b/packages/locale/locales/es/erp.po
@@ -3287,6 +3287,9 @@ msgstr "Control de Documentos"
msgid "Document Templates"
msgstr "Plantillas de Documentos"
+msgid "Document Type"
+msgstr ""
+
msgid "Document:"
msgstr "Documento:"
@@ -3844,6 +3847,9 @@ msgstr "Tipo de Entidad"
msgid "Entity type cannot be changed"
msgstr "El tipo de entidad no puede ser cambiado"
+msgid "Entry Type"
+msgstr ""
+
msgid "EORI"
msgstr "EORI"
@@ -5624,6 +5630,9 @@ msgstr "Parámetros de Lista"
msgid "Live reloading"
msgstr "Recarga en vivo"
+msgid "Load newer"
+msgstr ""
+
msgid "Load Templates"
msgstr "Cargar Plantillas"
@@ -9315,6 +9324,9 @@ msgstr "Registros de Pasos"
msgid "Steps"
msgstr "Pasos"
+msgid "Stock Movements"
+msgstr ""
+
msgid "Stock Transfer ID"
msgstr "ID de Transferencia de Inventario"
diff --git a/packages/locale/locales/fr/erp.po b/packages/locale/locales/fr/erp.po
index 981e822813..7f32301974 100644
--- a/packages/locale/locales/fr/erp.po
+++ b/packages/locale/locales/fr/erp.po
@@ -3287,6 +3287,9 @@ msgstr "Contrôle des documents"
msgid "Document Templates"
msgstr "Modèles de documents"
+msgid "Document Type"
+msgstr ""
+
msgid "Document:"
msgstr "Document :"
@@ -3844,6 +3847,9 @@ msgstr "Type d'Entité"
msgid "Entity type cannot be changed"
msgstr "Le type d'entité ne peut pas être modifié"
+msgid "Entry Type"
+msgstr ""
+
msgid "EORI"
msgstr "EORI"
@@ -5624,6 +5630,9 @@ msgstr "Paramètres de liste"
msgid "Live reloading"
msgstr "Rechargement en direct"
+msgid "Load newer"
+msgstr ""
+
msgid "Load Templates"
msgstr "Charger les modèles"
@@ -9315,6 +9324,9 @@ msgstr "Enregistrements d'étapes"
msgid "Steps"
msgstr "Étapes"
+msgid "Stock Movements"
+msgstr ""
+
msgid "Stock Transfer ID"
msgstr "ID de transfert de stock"
diff --git a/packages/locale/locales/hi/erp.po b/packages/locale/locales/hi/erp.po
index f40ec89e35..1716dc2fe3 100644
--- a/packages/locale/locales/hi/erp.po
+++ b/packages/locale/locales/hi/erp.po
@@ -3287,6 +3287,9 @@ msgstr "दस्तावेज़ नियंत्रण"
msgid "Document Templates"
msgstr "दस्तावेज़ टेम्पलेट"
+msgid "Document Type"
+msgstr ""
+
msgid "Document:"
msgstr "दस्तावेज़:"
@@ -3844,6 +3847,9 @@ msgstr "इकाई प्रकार"
msgid "Entity type cannot be changed"
msgstr "इकाई प्रकार को परिवर्तित नहीं किया जा सकता"
+msgid "Entry Type"
+msgstr ""
+
msgid "EORI"
msgstr "EORI"
@@ -5624,6 +5630,9 @@ msgstr "सूची पैरामीटर"
msgid "Live reloading"
msgstr "लाइव रीलोडिंग"
+msgid "Load newer"
+msgstr ""
+
msgid "Load Templates"
msgstr "टेम्पलेट लोड करें"
@@ -9315,6 +9324,9 @@ msgstr "चरण रिकॉर्ड"
msgid "Steps"
msgstr "चरण"
+msgid "Stock Movements"
+msgstr ""
+
msgid "Stock Transfer ID"
msgstr "स्टॉक ट्रांसफर आईडी"
diff --git a/packages/locale/locales/it/erp.po b/packages/locale/locales/it/erp.po
index 78949a19ca..31f9f532d2 100644
--- a/packages/locale/locales/it/erp.po
+++ b/packages/locale/locales/it/erp.po
@@ -3287,6 +3287,9 @@ msgstr "Controllo Documenti"
msgid "Document Templates"
msgstr "Modelli di Documento"
+msgid "Document Type"
+msgstr ""
+
msgid "Document:"
msgstr "Documento:"
@@ -3844,6 +3847,9 @@ msgstr "Tipo di Entità"
msgid "Entity type cannot be changed"
msgstr "Il tipo di entità non può essere modificato"
+msgid "Entry Type"
+msgstr ""
+
msgid "EORI"
msgstr "EORI"
@@ -5624,6 +5630,9 @@ msgstr "Parametri Elenco"
msgid "Live reloading"
msgstr "Ricaricamento in tempo reale"
+msgid "Load newer"
+msgstr ""
+
msgid "Load Templates"
msgstr "Carica Modelli"
@@ -9315,6 +9324,9 @@ msgstr "Registri dei Passaggi"
msgid "Steps"
msgstr "Passaggi"
+msgid "Stock Movements"
+msgstr ""
+
msgid "Stock Transfer ID"
msgstr "ID Trasferimento Magazzino"
diff --git a/packages/locale/locales/ja/erp.po b/packages/locale/locales/ja/erp.po
index 9ede023526..633b550bfc 100644
--- a/packages/locale/locales/ja/erp.po
+++ b/packages/locale/locales/ja/erp.po
@@ -3287,6 +3287,9 @@ msgstr "ドキュメント管理"
msgid "Document Templates"
msgstr "ドキュメントテンプレート"
+msgid "Document Type"
+msgstr ""
+
msgid "Document:"
msgstr "ドキュメント:"
@@ -3844,6 +3847,9 @@ msgstr "エンティティタイプ"
msgid "Entity type cannot be changed"
msgstr "エンティティタイプは変更できません"
+msgid "Entry Type"
+msgstr ""
+
msgid "EORI"
msgstr "EORI"
@@ -5624,6 +5630,9 @@ msgstr "リストパラメータ"
msgid "Live reloading"
msgstr "ライブリロード中"
+msgid "Load newer"
+msgstr ""
+
msgid "Load Templates"
msgstr "テンプレートを読み込む"
@@ -9315,6 +9324,9 @@ msgstr "ステップレコード"
msgid "Steps"
msgstr "ステップ"
+msgid "Stock Movements"
+msgstr ""
+
msgid "Stock Transfer ID"
msgstr "在庫移動ID"
diff --git a/packages/locale/locales/pl/erp.po b/packages/locale/locales/pl/erp.po
index 31701b5687..3a147952bd 100644
--- a/packages/locale/locales/pl/erp.po
+++ b/packages/locale/locales/pl/erp.po
@@ -3287,6 +3287,9 @@ msgstr "Kontrola dokumentów"
msgid "Document Templates"
msgstr "Szablony dokumentów"
+msgid "Document Type"
+msgstr ""
+
msgid "Document:"
msgstr "Dokument:"
@@ -3844,6 +3847,9 @@ msgstr "Typ Jednostki"
msgid "Entity type cannot be changed"
msgstr "Typ jednostki nie może być zmieniony"
+msgid "Entry Type"
+msgstr ""
+
msgid "EORI"
msgstr "EORI"
@@ -5624,6 +5630,9 @@ msgstr "Parametry listy"
msgid "Live reloading"
msgstr "Odświeżanie na żywo"
+msgid "Load newer"
+msgstr ""
+
msgid "Load Templates"
msgstr "Załaduj szablony"
@@ -9315,6 +9324,9 @@ msgstr "Rekordy Kroków"
msgid "Steps"
msgstr "Kroki"
+msgid "Stock Movements"
+msgstr ""
+
msgid "Stock Transfer ID"
msgstr "Identyfikator Transferu Zapasów"
diff --git a/packages/locale/locales/pt/erp.po b/packages/locale/locales/pt/erp.po
index bb8d042317..99d048d226 100644
--- a/packages/locale/locales/pt/erp.po
+++ b/packages/locale/locales/pt/erp.po
@@ -3287,6 +3287,9 @@ msgstr "Controle de Documentos"
msgid "Document Templates"
msgstr "Modelos de Documentos"
+msgid "Document Type"
+msgstr ""
+
msgid "Document:"
msgstr "Documento:"
@@ -3844,6 +3847,9 @@ msgstr "Tipo de Entidade"
msgid "Entity type cannot be changed"
msgstr "O tipo de entidade não pode ser alterado"
+msgid "Entry Type"
+msgstr ""
+
msgid "EORI"
msgstr "EORI"
@@ -5624,6 +5630,9 @@ msgstr "Parâmetros de Lista"
msgid "Live reloading"
msgstr "Recarregamento ao vivo"
+msgid "Load newer"
+msgstr ""
+
msgid "Load Templates"
msgstr "Carregar Modelos"
@@ -9315,6 +9324,9 @@ msgstr "Registros de Etapas"
msgid "Steps"
msgstr "Etapas"
+msgid "Stock Movements"
+msgstr ""
+
msgid "Stock Transfer ID"
msgstr "ID de Transferência de Estoque"
diff --git a/packages/locale/locales/ru/erp.po b/packages/locale/locales/ru/erp.po
index 7cd7be83f1..75db7812d4 100644
--- a/packages/locale/locales/ru/erp.po
+++ b/packages/locale/locales/ru/erp.po
@@ -3287,6 +3287,9 @@ msgstr "Управление документами"
msgid "Document Templates"
msgstr "Шаблоны документов"
+msgid "Document Type"
+msgstr ""
+
msgid "Document:"
msgstr "Документ:"
@@ -3844,6 +3847,9 @@ msgstr "Тип Сущности"
msgid "Entity type cannot be changed"
msgstr "Тип сущности не может быть изменён"
+msgid "Entry Type"
+msgstr ""
+
msgid "EORI"
msgstr "EORI"
@@ -5624,6 +5630,9 @@ msgstr "Параметры списка"
msgid "Live reloading"
msgstr "Живая перезагрузка"
+msgid "Load newer"
+msgstr ""
+
msgid "Load Templates"
msgstr "Загрузить шаблоны"
@@ -9315,6 +9324,9 @@ msgstr "Записи этапов"
msgid "Steps"
msgstr "Шаги"
+msgid "Stock Movements"
+msgstr ""
+
msgid "Stock Transfer ID"
msgstr "ID передачи запасов"
diff --git a/packages/locale/locales/tr/erp.po b/packages/locale/locales/tr/erp.po
index c866c149c3..42bf6c0b3b 100644
--- a/packages/locale/locales/tr/erp.po
+++ b/packages/locale/locales/tr/erp.po
@@ -3287,6 +3287,9 @@ msgstr "Doküman Kontrolü"
msgid "Document Templates"
msgstr "Belge Şablonları"
+msgid "Document Type"
+msgstr ""
+
msgid "Document:"
msgstr "Belge:"
@@ -3844,6 +3847,9 @@ msgstr "Varlık Türü"
msgid "Entity type cannot be changed"
msgstr "Varlık türü değiştirilemez"
+msgid "Entry Type"
+msgstr ""
+
msgid "EORI"
msgstr "EORI"
@@ -5624,6 +5630,9 @@ msgstr "Liste Parametreleri"
msgid "Live reloading"
msgstr "Canlı yeniden yükleniyor"
+msgid "Load newer"
+msgstr ""
+
msgid "Load Templates"
msgstr "Şablonları Yükle"
@@ -9315,6 +9324,9 @@ msgstr "Adım Kayıtları"
msgid "Steps"
msgstr "Adımlar"
+msgid "Stock Movements"
+msgstr ""
+
msgid "Stock Transfer ID"
msgstr "Stok Transfer Kimliği"
diff --git a/packages/locale/locales/zh/erp.po b/packages/locale/locales/zh/erp.po
index eebe048fe1..fd4b17baa9 100644
--- a/packages/locale/locales/zh/erp.po
+++ b/packages/locale/locales/zh/erp.po
@@ -3287,6 +3287,9 @@ msgstr "文件控制"
msgid "Document Templates"
msgstr "文档模板"
+msgid "Document Type"
+msgstr ""
+
msgid "Document:"
msgstr "文档:"
@@ -3844,6 +3847,9 @@ msgstr "实体类型"
msgid "Entity type cannot be changed"
msgstr "实体类型无法更改"
+msgid "Entry Type"
+msgstr ""
+
msgid "EORI"
msgstr "EORI"
@@ -5624,6 +5630,9 @@ msgstr "列表参数"
msgid "Live reloading"
msgstr "实时重新加载"
+msgid "Load newer"
+msgstr ""
+
msgid "Load Templates"
msgstr "加载模板"
@@ -9315,6 +9324,9 @@ msgstr "步骤记录"
msgid "Steps"
msgstr "步骤"
+msgid "Stock Movements"
+msgstr ""
+
msgid "Stock Transfer ID"
msgstr "库存转移ID"