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
Merge origin/main into naveenkash/receipt-default-quantity-zero
naveenkash5b97859def9d
diff --cc .ai/lessons.mdindex ec578743b0,57e35837a0..96e4a94555--- a/.ai/lessons.md+++ b/.ai/lessons.md@@@ -3930,13 -3960,12 +3960,22 @@@ The write was then removed (nothing rea**Applies to:** every `useFetcher` used from a layout or provider, every background timer that submits or loads, `packages/react/src/ErrorBoundary/`.+ ## A posting's refusal only reaches the dialog when it is thrown as a 4xx++ **Context:** A refused receipt void showed "Failed to void receipt" with no reason. The guards inside the `post-receipt` posting said exactly why ("stock received on this receipt was moved, picked or shipped since it was received").++ **Problem:** `invokePosting` reads a plain `Error` as status 500 (the posting's default), and the operation passed every failure to `serverFnFailure` with a fixed message. So every refusal, and every new guard, was reported with the same generic text.++ **Rule:** Throw an authored refusal from a posting as `InvalidInputError` (or another `ServerFnError` below 500), never a plain `Error`. In the operation, below 500 return the error's own message (`error.message || <fallback>`); keep the generic message for 500, whose detail `toError` already withholds.++ **Applies to:** every operation that calls `invokePosting` and every posting body (`voidReceipt` / `postReceipt` in `inventory.server.ts`, `adjustInventory` follows the same shape).+++## 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 --cc apps/erp/app/routes/api+/mcp+/lib/tool-manifest.digest.jsonindex 39b5790a06,0b414935c6..4822eeec31--- a/apps/erp/app/routes/api+/mcp+/lib/tool-manifest.digest.json+++ b/apps/erp/app/routes/api+/mcp+/lib/tool-manifest.digest.json@@@ -1514,10 -1517,10 +1517,10 @@@{"name":"settings_enableCompanyAuditLog","classification":"WRITE","schema":"31b84d65b2ac","response":"a369dbcd055c","permission":"settings:update","paginates":false},{"name":"settings_getAccountsPayableBillingAddress","classification":"READ","schema":"31b84d65b2ac","response":"7c0b9dc6d441","permission":"settings:view","paginates":false},{"name":"settings_getAccountsReceivableBillingAddress","classification":"READ","schema":"31b84d65b2ac","response":"7c0b9dc6d441","permission":"settings:view","paginates":false},- {"name":"settings_getApiKeys","classification":"WRITE","schema":"e2389bb135b5","response":"14fbafc2ddf8","permission":"users:update","paginates":true},+ {"name":"settings_getApiKeys","classification":"WRITE","schema":"cd40ae40fad5","response":"14fbafc2ddf8","permission":"users:update","paginates":true},{"name":"settings_getCompanies","classification":"READ","schema":"31b84d65b2ac","response":"5783a32e0f4a","permission":"settings:view","paginates":false},{"name":"settings_getCompany","classification":"READ","schema":"31b84d65b2ac","response":"81a93f0029ec","permission":"settings:view","paginates":false},- {"name":"settings_getCompanySettings","classification":"READ","schema":"31b84d65b2ac","response":"689a7e333d99","permission":"settings:view","paginates":false},+ {"name":"settings_getCompanySettings","classification":"READ","schema":"31b84d65b2ac","response":"592dc0578df9","permission":"settings:view","paginates":false},{"name":"settings_getConfig","classification":"READ","schema":"31b84d65b2ac","response":"aa1021ff34cf","permission":"settings:view","paginates":false},{"name":"settings_getCurrentSequence","classification":"READ","schema":"31018ffa701d","response":"00404e686415","permission":"settings:view","paginates":false},{"name":"settings_getCustomField","classification":"READ","schema":"7f8214d1083f","response":"a533a796c094","permission":"settings:view","paginates":false},@@@ -1553,9 -1556,9 +1556,9 @@@{"name":"settings_updateAccountingSettings","classification":"WRITE","schema":"ecf0d5091645","response":"70bcf2b87ee3","permission":"settings:update","paginates":false},{"name":"settings_updateCompanyDetails","classification":"WRITE","schema":"f48dad39eb59","response":"3797626bd17e","permission":"settings:update","paginates":false},{"name":"settings_updateDimensionSync","classification":"WRITE","schema":"42c99362fccd","response":"f95fa90d0071","permission":"settings:update","paginates":false},- {"name":"settings_updateInventorySettings","classification":"WRITE","schema":"0e19706cf388","response":"8197b1c61474","permission":"settings:update","paginates":false},+ {"name":"settings_updateInventorySettings","classification":"WRITE","schema":"a76084d47705","response":"d62a56ef4842","permission":"settings:update","paginates":false},{"name":"settings_updateInvoicingSettings","classification":"WRITE","schema":"48fd9aba9ea8","response":"a32ee5ad2099","permission":"settings:update","paginates":false},- {"name":"settings_updateItemSerialSequence","classification":"WRITE","schema":"5544b362f82e","response":"3797626bd17e","permission":"settings:update","paginates":false},+ {"name":"settings_updateItemSerialSequence","classification":"WRITE","schema":"8e65da365dcb","response":"3797626bd17e","permission":"settings:update","paginates":false},{"name":"settings_updateItemsSettings","classification":"WRITE","schema":"e8ef8b2a7abb","response":"da26374a450b","permission":"settings:update","paginates":false},{"name":"settings_updatePlanningSettings","classification":"WRITE","schema":"0c543ed217a3","response":"0b9572e63423","permission":"settings:update","paginates":false},{"name":"settings_updatePostingSync","classification":"WRITE","schema":"a545e3ef8da3","response":"f95fa90d0071","permission":"settings:update","paginates":false},diff --cc packages/database/supabase/migrations/20261019185808_receipt-quantities-start-at-zero.sqlindex 69b555ffd2,0000000000..69b555ffd2mode 100644,000000..100644--- a/packages/database/supabase/migrations/20261019185808_receipt-quantities-start-at-zero.sql+++ b/packages/database/supabase/migrations/20261019185808_receipt-quantities-start-at-zero.sqldiff --cc packages/jobs/manifests/schema.jsonindex 844e159737,06f09732a4..93273458dd--- a/packages/jobs/manifests/schema.json+++ b/packages/jobs/manifests/schema.json@@@ -1,11 -1,11 +1,11 @@@{"kind": "carbon-company-backup","version": 1,- "schemaVersion": "20261017092614",- "schemaVersion": "20261017070014",++ "schemaVersion": "20261019185808","sourceCompanyId": "schema-baseline","sourceCompanyGroupId": null,"sourceCompanyName": null,- "exportedAt": "2026-10-17T16:04:06.119Z",- "exportedAt": "2026-10-17T07:08:05.778Z",++ "exportedAt": "2026-10-19T13:38:21.966Z","exportedBy": "schema-baseline","label": "schema baseline","includeStorage": "none",