Fix product import defaulting to 1 in stock, allowing orders with zero real inventory
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`.
This commit is contained in:
@@ -236,7 +236,7 @@ export default function CatalogueBrowser({ tenantid, locationid, onClose }: Cata
|
|||||||
catalogueid: p.id,
|
catalogueid: p.id,
|
||||||
categoryid: validCategory,
|
categoryid: validCategory,
|
||||||
subcategoryid: 0,
|
subcategoryid: 0,
|
||||||
quantity: 1,
|
quantity: 0,
|
||||||
stocktype: "in",
|
stocktype: "in",
|
||||||
// Draft: lands in the Admin Catalogue only. It only becomes
|
// Draft: lands in the Admin Catalogue only. It only becomes
|
||||||
// visible to store users once the admin explicitly publishes
|
// visible to store users once the admin explicitly publishes
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ export default function ImportProductModal({
|
|||||||
catalogueid: product.id,
|
catalogueid: product.id,
|
||||||
categoryid: validCategory,
|
categoryid: validCategory,
|
||||||
subcategoryid: 0,
|
subcategoryid: 0,
|
||||||
quantity: 1,
|
quantity: 0,
|
||||||
stocktype: "in",
|
stocktype: "in",
|
||||||
status: "Draft",
|
status: "Draft",
|
||||||
retailprice: 0,
|
retailprice: 0,
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ async function fallbackCreateProductLocation(items: ImportCatalogueProductReques
|
|||||||
tenantid: item.tenantid,
|
tenantid: item.tenantid,
|
||||||
locationid: item.locationid,
|
locationid: item.locationid,
|
||||||
productid: item.catalogueid,
|
productid: item.catalogueid,
|
||||||
quantity: item.quantity || 1,
|
quantity: item.quantity ?? 0,
|
||||||
stocktype: item.stocktype || "in",
|
stocktype: item.stocktype || "in",
|
||||||
status: item.status || "Active",
|
status: item.status || "Active",
|
||||||
retailprice: item.retailprice || 0,
|
retailprice: item.retailprice || 0,
|
||||||
|
|||||||
Reference in New Issue
Block a user