fix: confirm grocycode is of PRODUCT type in GetProductIdFromBarcode

This commit is contained in:
David Mott 2021-08-15 18:19:04 +10:00
parent d23f730a0b
commit e5989895d8

View File

@ -697,6 +697,10 @@ class StockService extends BaseService
if (Grocycode::Validate($barcode))
{
$gc = new Grocycode($barcode);
if ($gc->GetType() != Grocycode::PRODUCT)
{
throw new \Exception("Grocycode $barcode is not a product code");
}
return intval($gc->GetId());
}