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.

chore(inventory): keep only the comments that explain a non-obvious why

naveenkash1c341c62af56
diff --git a/apps/erp/app/modules/inventory/inventory.service.ts b/apps/erp/app/modules/inventory/inventory.service.ts
index 143ee18b73..800a169a56 100644
--- a/apps/erp/app/modules/inventory/inventory.service.ts
+++ b/apps/erp/app/modules/inventory/inventory.service.ts
@@ -10620,9 +10620,7 @@ export async function postReceipt(
}
}
- // A line received at 0 is left out: nothing arrived for it, so its
- // purchase order line keeps its received date and an outside
- // processing operation keeps its status.
+ // A line received at 0 must not touch its PO line or outside processing operation.
const receiptLinesByPurchaseOrderLineId = receiptLines.data.reduce<
Record<string, Database["public"]["Tables"]["receiptLine"]["Row"][]>
>((acc, receiptLine) => {
@@ -10776,9 +10774,7 @@ export async function postReceipt(
receiptLine?.receivedQuantity == null
? 0
: receiptLine.receivedQuantity;
- // An entity left on a line received at 0 stays as it is: it
- // has no item ledger row, so making it Available would create
- // stock that was never received.
+ // A line received at 0 writes no ledger row, so its entities stay as they are.
if (receiptLine && safeReceivedQuantity === 0) return acc;
const quantity = receiptLine?.requiresSerialTracking
@@ -11058,8 +11054,6 @@ export async function postReceipt(
normalQuantity: normalQty,
normalCost: normalPortionCost
} = receiptLineCosts[index]!;
- // A line nothing arrived for books nothing — the Sales Return and
- // Inbound Transfer branches skip it the same way.
if (receivedQuantity === 0) continue;
const itemTrackingType =
diff --git a/apps/erp/app/modules/inventory/ui/Receipts/ReceiptHeader.tsx b/apps/erp/app/modules/inventory/ui/Receipts/ReceiptHeader.tsx
index 90c85a561c..399125ea00 100644
--- a/apps/erp/app/modules/inventory/ui/Receipts/ReceiptHeader.tsx
+++ b/apps/erp/app/modules/inventory/ui/Receipts/ReceiptHeader.tsx
@@ -187,11 +187,7 @@ const ReceiptHeader = () => {
</Button>
))}
{!isPosted && !isVoided && (
- // A disabled button fires no pointer events and takes no focus,
- // so the span is the trigger, focusable only while it explains
- // the disabled button. Every line can start at 0 (receipt
- // quantities start at zero), which leaves Post disabled with no
- // other hint.
+ // A disabled button gets no pointer events or focus, so the span is the trigger.
<Tooltip>
<TooltipTrigger asChild>
<span tabIndex={postDisabled ? 0 : undefined}>
diff --git a/apps/erp/app/modules/shared/shared.service.ts b/apps/erp/app/modules/shared/shared.service.ts
index db16e65247..2250704650 100644
--- a/apps/erp/app/modules/shared/shared.service.ts
+++ b/apps/erp/app/modules/shared/shared.service.ts
@@ -10031,10 +10031,6 @@ async function getFallbackLocationId(
return location.data?.id ?? null;
}
-// Blind receiving (`companySettings.receiptQuantitiesStartAtZero`): when on, a
-// new receipt's lines start at a received quantity of 0 rather than what is
-// still to receive, so the receiver enters what actually arrived and a line
-// nothing arrived for stays at 0.
async function receiptQuantitiesStartAtZero(
db: Kysely<KyselyDatabase>,
companyId: string
diff --git a/apps/erp/app/routes/x+/settings+/inventory.tsx b/apps/erp/app/routes/x+/settings+/inventory.tsx
index 149e82ec00..1d026514d5 100644
--- a/apps/erp/app/routes/x+/settings+/inventory.tsx
+++ b/apps/erp/app/routes/x+/settings+/inventory.tsx
@@ -137,8 +137,6 @@ export default function InventorySettingsRoute() {
}
});
- // The switch saves on change through its own fetcher, so saving another
- // card cannot cancel it or disable it.
const toggleFetcher = useAction<typeof action>({
onSuccess: ({ data }) => {
if (data?.receiptQuantitiesStartAtZero === undefined) return;
diff --git a/apps/erp/test/database/receipt-quantities-start-at-zero.test.ts b/apps/erp/test/database/receipt-quantities-start-at-zero.test.ts
index 8a26736645..793f9c46b1 100644
--- a/apps/erp/test/database/receipt-quantities-start-at-zero.test.ts
+++ b/apps/erp/test/database/receipt-quantities-start-at-zero.test.ts
@@ -2,10 +2,6 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-// Blind receiving against the live database: with
-// `companySettings.receiptQuantitiesStartAtZero` on, a purchase-order receipt's
-// lines start at 0, and posting it books only the lines that were received.
-
import { expect } from "vitest";
import { postReceipt } from "../../app/modules/inventory/inventory.service";
import {
@@ -22,7 +18,6 @@ import {
import { handlesOf } from "./fixtures/handles";
import { databaseTest } from "./fixtures/local-database";
-/** A purchase order with two lines of 10 of the fixture's part. */
async function purchaseOrderWithTwoLines(f: Fixture): Promise<string> {
const purchaseOrderId = `${f.prefix}-po-blind`;
await seed(f, async (trx) => {
@@ -141,7 +136,6 @@ databaseTest(
[0, 10]
]);
- // The receiver counts 4 on the first line; nothing arrived for the second.
await f.db
.updateTable("receiptLine")
.set({ receivedQuantity: 4 })
@@ -185,7 +179,6 @@ databaseTest(
.execute();
expect(ledger.map((row) => Number(row.quantity))).toEqual([4]);
- // The line nothing arrived for keeps no received date.
const purchaseOrderLines = await f.db
.selectFrom("purchaseOrderLine")
.select(["id", "quantityReceived", "receivedComplete", "receivedDate"])
@@ -204,7 +197,6 @@ databaseTest(
[0, false, false]
]);
- // An entity on the zero line is not released into stock it never had.
const entity = await f.db
.selectFrom("trackedEntity")
.select(["status", "quantity"])
diff --git a/packages/database/supabase/migrations/20261019185808_receipt-quantities-start-at-zero.sql b/packages/database/supabase/migrations/20261019185808_receipt-quantities-start-at-zero.sql
index 69b555ffd2..b339799b86 100644
--- a/packages/database/supabase/migrations/20261019185808_receipt-quantities-start-at-zero.sql
+++ b/packages/database/supabase/migrations/20261019185808_receipt-quantities-start-at-zero.sql
@@ -1,5 +1,2 @@
--- Blind receiving: when on, a new receipt's lines start with a received
--- quantity of 0 instead of the outstanding quantity, so the receiver counts
--- each line and a line nothing arrived for stays at 0.
ALTER TABLE "companySettings"
ADD COLUMN IF NOT EXISTS "receiptQuantitiesStartAtZero" BOOLEAN NOT NULL DEFAULT false;
diff --git a/packages/jobs/manifests/schema.json b/packages/jobs/manifests/schema.json
index 93273458dd..6fd6e84e5f 100644
--- a/packages/jobs/manifests/schema.json
+++ b/packages/jobs/manifests/schema.json
@@ -5,7 +5,7 @@
"sourceCompanyId": "schema-baseline",
"sourceCompanyGroupId": null,
"sourceCompanyName": null,
- "exportedAt": "2026-10-19T13:38:21.966Z",
+ "exportedAt": "2026-10-19T13:53:09.008Z",
"exportedBy": "schema-baseline",
"label": "schema baseline",
"includeStorage": "none",