From 02b52580002cb4c7f57c1c380f3605f50fb4e708 Mon Sep 17 00:00:00 2001 From: Suriya Date: Thu, 23 Jul 2026 16:24:58 +0530 Subject: [PATCH] Fix product import defaulting to 1 in stock, allowing orders with zero real inventory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Quick-import buttons hardcoded quantity:1, which the backend writes straight to the stock ledger as an "in" entry — letting one order go through for a product that was never actually stocked. Default to 0 instead, and fix a fallback path that was silently coercing an explicit 0 back to 1 via `|| 1`. --- src/components/CatalogueBrowser.tsx | 2 +- src/components/ImportProductModal.tsx | 2 +- src/services/catalogueApi.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/CatalogueBrowser.tsx b/src/components/CatalogueBrowser.tsx index 1da7c6b..b3a3a8c 100644 --- a/src/components/CatalogueBrowser.tsx +++ b/src/components/CatalogueBrowser.tsx @@ -236,7 +236,7 @@ export default function CatalogueBrowser({ tenantid, locationid, onClose }: Cata catalogueid: p.id, categoryid: validCategory, subcategoryid: 0, - quantity: 1, + quantity: 0, stocktype: "in", // Draft: lands in the Admin Catalogue only. It only becomes // visible to store users once the admin explicitly publishes diff --git a/src/components/ImportProductModal.tsx b/src/components/ImportProductModal.tsx index fcbc5a4..7a5b247 100644 --- a/src/components/ImportProductModal.tsx +++ b/src/components/ImportProductModal.tsx @@ -143,7 +143,7 @@ export default function ImportProductModal({ catalogueid: product.id, categoryid: validCategory, subcategoryid: 0, - quantity: 1, + quantity: 0, stocktype: "in", status: "Draft", retailprice: 0, diff --git a/src/services/catalogueApi.ts b/src/services/catalogueApi.ts index b7b3bf1..ecbd1bd 100644 --- a/src/services/catalogueApi.ts +++ b/src/services/catalogueApi.ts @@ -103,7 +103,7 @@ async function fallbackCreateProductLocation(items: ImportCatalogueProductReques tenantid: item.tenantid, locationid: item.locationid, productid: item.catalogueid, - quantity: item.quantity || 1, + quantity: item.quantity ?? 0, stocktype: item.stocktype || "in", status: item.status || "Active", retailprice: item.retailprice || 0,