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.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
docs(inventory): zero-line posting effects in the receipts rule; lesson on filtering per-line maps
naveenkash47882dc48c00
diff --git a/.ai/lessons.md b/.ai/lessons.mdindex a2342be0e4..ec578743b0 100644--- a/.ai/lessons.md+++ b/.ai/lessons.md@@ -3929,3 +3929,14 @@ The write was then removed (nothing reads it), so the rail always starts collaps**Rule:** A request a timer or event sends on its own (not one the user started) must not be able to fail into a boundary: skip it while `navigator.onLine` is false and retry on `online`. Both error boundaries treat `isNetworkError` as a lost connection and revalidate when the connection or the tab comes back; a successful revalidation clears `state.errors`.**Applies to:** every `useFetcher` used from a layout or provider, every background timer that submits or loads, `packages/react/src/ErrorBoundary/`.++## A skip inside a posting loop does not cover maps built before the loop++**Context:** Making `postReceipt` (PO path) ignore a receipt line received at 0 (receipt quantities can start at zero, 2026-10).++**Problem:** The fix added `if (receivedQuantity === 0) continue;` to the per-line ledger loop. Three side-effect maps were built earlier from every line: `receiptLinesByPurchaseOrderLineId` (PO line `receivedDate`, outside-processing operation status) and `trackedEntityUpdates` (entity status and the Receive activity). A zero line still stamped its PO line received today, and a batch left on it became Available at its full quantity with no item ledger row. Review caught it, not the tests.++**Rule:** When a posting must ignore a line, filter it where every per-line collection is built, not only in the loop that writes the ledger. List every map or array derived from the lines and check each. Pin the skipped line's absence in a test: assert the side effects did not happen, not only that the ledger row is missing.++**Applies to:** `postReceipt` / `postShipment` and every posting in `inventory.service.ts` that builds update maps before its write loop.+diff --git a/.claude/rules/shipments-receipts-ui-patterns.md b/.claude/rules/shipments-receipts-ui-patterns.mdindex d83dcbf909..6a7b122e4d 100644--- a/.claude/rules/shipments-receipts-ui-patterns.md+++ b/.claude/rules/shipments-receipts-ui-patterns.md@@ -152,7 +152,10 @@ the service-role client + Kysely `db.transaction()`, and branch on `sourceDocumeticked unit through `returnRentalUnit` and moves its `fixedAsset.locationId` to the receipt'slocation; `returnRentalUnit` in `sales.service.ts`), and `Sales Return Order`(customer RMA re-entry at original outbound cost, entities to On Hold). The PO, transfer and RMA branches skip a- line received at 0 — it books no `itemLedger`, cost layer or journal line. PO path: inserts `itemLedger`+ line received at 0 — it books no `itemLedger`, cost layer or journal line. In the PO path a line+ received at 0 is also left out of `receiptLinesByPurchaseOrderLineId` (its PO line keeps its+ `receivedDate`, an outside-processing operation its status) and out of `trackedEntityUpdates` (a+ batch or serial still on it is not set Available and gets no Receive activity). PO path: inserts `itemLedger`(entry types `Positive/Negative Adjmt.` by sign), GR/IR + inventory `journalLine`s for everycompany (the journal is Provisional before the accounting cutover, Posted after it), advances PO line `quantityReceived`/`receivedComplete` and PO `status`,flips tracked entities to `Available` (**`On Hold` if the item has a Receipt-usage inspection