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: include comment in inventory adjustment

Brad Barbin3e5bfaa962ad
diff --git a/apps/erp/app/components/Activity.tsx b/apps/erp/app/components/Activity.tsx
index 5ae93e38c0..9d686606c5 100644
--- a/apps/erp/app/components/Activity.tsx
+++ b/apps/erp/app/components/Activity.tsx
@@ -8,13 +8,15 @@ type ActivityProps = {
activityMessage: ReactNode;
activityTime: string;
activityIcon?: ReactNode;
+ comment?: string | null;
};
const Activity = ({
employeeId,
activityMessage,
activityTime,
- activityIcon
+ activityIcon,
+ comment
}: ActivityProps) => {
const [people] = usePeople();
if (!employeeId) return null;
@@ -37,6 +39,11 @@ const Activity = ({
</span>
<span className="text-gray-400">{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">
{formatTimeAgo(activityTime)}
</div>
diff --git a/apps/erp/app/modules/inventory/inventory.models.ts b/apps/erp/app/modules/inventory/inventory.models.ts
index 472d1ab1ec..579a314f0a 100644
--- a/apps/erp/app/modules/inventory/inventory.models.ts
+++ b/apps/erp/app/modules/inventory/inventory.models.ts
@@ -105,7 +105,8 @@ export const inventoryAdjustmentValidator = z.object({
adjustmentType: z.enum([...itemLedgerTypes, "Set Quantity"]),
quantity: zfd.numeric(z.number()),
trackedEntityId: zfd.text(z.string().optional()),
- readableId: zfd.text(z.string().optional())
+ readableId: zfd.text(z.string().optional()),
+ comment: zfd.text(z.string().optional())
});
export const itemLedgerValidator = z.object({
diff --git a/apps/erp/app/modules/inventory/inventory.service.ts b/apps/erp/app/modules/inventory/inventory.service.ts
index c3cac528e6..2f3901ae49 100644
--- a/apps/erp/app/modules/inventory/inventory.service.ts
+++ b/apps/erp/app/modules/inventory/inventory.service.ts
@@ -914,12 +914,13 @@ export async function insertManualInventoryAdjustment(
createdBy: string;
}
) {
- const { adjustmentType, readableId, originalShelfId, ...rest } =
+ const { adjustmentType, readableId, originalShelfId, comment, ...rest } =
inventoryAdjustment;
const data = {
...rest,
entryType:
- adjustmentType === "Set Quantity" ? "Positive Adjmt." : adjustmentType // This will be overwritten below
+ adjustmentType === "Set Quantity" ? "Positive Adjmt." : adjustmentType, // This will be overwritten below
+ comment: comment || null
};
const shelfQuantities = await client.rpc(
@@ -975,7 +976,8 @@ export async function insertManualInventoryAdjustment(
entryType: "Negative Adjmt." as const,
quantity: -currentQuantityOnHand,
companyId: data.companyId,
- createdBy: data.createdBy
+ createdBy: data.createdBy,
+ comment: data.comment
}
])
.select("*")
@@ -997,7 +999,8 @@ export async function insertManualInventoryAdjustment(
entryType: "Positive Adjmt." as const,
quantity: currentQuantityOnHand,
companyId: data.companyId,
- createdBy: data.createdBy
+ createdBy: data.createdBy,
+ comment: data.comment
}
])
.select("*")
diff --git a/apps/erp/app/modules/inventory/ui/Inventory/InventoryActivity.tsx b/apps/erp/app/modules/inventory/ui/Inventory/InventoryActivity.tsx
index 5c6bac7325..c7737a8e26 100644
--- a/apps/erp/app/modules/inventory/ui/Inventory/InventoryActivity.tsx
+++ b/apps/erp/app/modules/inventory/ui/Inventory/InventoryActivity.tsx
@@ -221,6 +221,7 @@ const InventoryActivity = ({ item }: InventoryActivityProps) => {
activityMessage={getActivityText(item)}
activityTime={item.createdAt}
activityIcon={getActivityIcon(item)}
+ comment={item.comment}
/>
);
};
diff --git a/apps/erp/app/modules/inventory/ui/Inventory/InventoryShelves.tsx b/apps/erp/app/modules/inventory/ui/Inventory/InventoryShelves.tsx
index febe756521..d32b9979b0 100644
--- a/apps/erp/app/modules/inventory/ui/Inventory/InventoryShelves.tsx
+++ b/apps/erp/app/modules/inventory/ui/Inventory/InventoryShelves.tsx
@@ -46,7 +46,7 @@ import {
import { Outlet } from "react-router";
import type { z } from "zod";
import { Enumerable } from "~/components/Enumerable";
-import { Input, Location, Select, Shelf } from "~/components/Form";
+import { Input, Location, Select, Shelf, TextArea } from "~/components/Form";
import { useUnitOfMeasure } from "~/components/Form/UnitOfMeasure";
import { usePermissions } from "~/hooks";
import type {
@@ -342,6 +342,7 @@ const InventoryShelves = ({
value={itemUnitOfMeasure?.label ?? ""}
isReadOnly
/>
+ <TextArea name="comment" label="Comment" />
</VStack>
</ModalBody>
<ModalFooter>
diff --git a/packages/database/src/swagger-docs-schema.ts b/packages/database/src/swagger-docs-schema.ts
index 34612031dc..99d0ebb48b 100644
--- a/packages/database/src/swagger-docs-schema.ts
+++ b/packages/database/src/swagger-docs-schema.ts
@@ -13098,6 +13098,9 @@ export default {
{
$ref: "#/parameters/rowFilter.itemLedger.trackedEntityId",
},
+ {
+ $ref: "#/parameters/rowFilter.itemLedger.comment",
+ },
{
$ref: "#/parameters/select",
},
@@ -13205,6 +13208,9 @@ export default {
{
$ref: "#/parameters/rowFilter.itemLedger.trackedEntityId",
},
+ {
+ $ref: "#/parameters/rowFilter.itemLedger.comment",
+ },
{
$ref: "#/parameters/preferReturn",
},
@@ -13266,6 +13272,9 @@ export default {
{
$ref: "#/parameters/rowFilter.itemLedger.trackedEntityId",
},
+ {
+ $ref: "#/parameters/rowFilter.itemLedger.comment",
+ },
{
$ref: "#/parameters/body.itemLedger",
},
@@ -75728,6 +75737,10 @@ export default {
format: "text",
type: "string",
},
+ comment: {
+ format: "text",
+ type: "string",
+ },
},
type: "object",
},
@@ -107066,6 +107079,12 @@ export default {
in: "query",
type: "string",
},
+ "rowFilter.itemLedger.comment": {
+ name: "comment",
+ required: false,
+ in: "query",
+ type: "string",
+ },
"body.shippingTerm": {
name: "shippingTerm",
description: "shippingTerm",
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index 9af29808d1..d720f0c31c 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -9524,6 +9524,7 @@ export type Database = {
}
itemLedger: {
Row: {
+ comment: string | null
companyId: string
createdAt: string
createdBy: string
@@ -9544,6 +9545,7 @@ export type Database = {
trackedEntityId: string | null
}
Insert: {
+ comment?: string | null
companyId: string
createdAt?: string
createdBy?: string
@@ -9564,6 +9566,7 @@ export type Database = {
trackedEntityId?: string | null
}
Update: {
+ comment?: string | null
companyId?: string
createdAt?: string
createdBy?: string
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index 9af29808d1..d720f0c31c 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -9524,6 +9524,7 @@ export type Database = {
}
itemLedger: {
Row: {
+ comment: string | null
companyId: string
createdAt: string
createdBy: string
@@ -9544,6 +9545,7 @@ export type Database = {
trackedEntityId: string | null
}
Insert: {
+ comment?: string | null
companyId: string
createdAt?: string
createdBy?: string
@@ -9564,6 +9566,7 @@ export type Database = {
trackedEntityId?: string | null
}
Update: {
+ comment?: string | null
companyId?: string
createdAt?: string
createdBy?: string
diff --git a/packages/database/supabase/migrations/20260319025427_inventory-adjustment-comment.sql b/packages/database/supabase/migrations/20260319025427_inventory-adjustment-comment.sql
new file mode 100644
index 0000000000..5277317e01
--- /dev/null
+++ b/packages/database/supabase/migrations/20260319025427_inventory-adjustment-comment.sql
@@ -0,0 +1 @@
+ALTER TABLE "itemLedger" ADD COLUMN "comment" TEXT;