fix(models): validate existence of stock location before setting as default

- Added check to ensure that the stock location exists and is not deleted before attempting to set it as the default.

Signed-off-by: objecttothis <17935339+objecttothis@users.noreply.github.com>
This commit is contained in:
objecttothis committed 2026-08-19 17:17:08 +04:00
1 parent d103790568
commit 2115fda4e5
1 file changed
+9
+9
View File
@@ -159,6 +159,15 @@ class Stock_location extends Model
*/
public function setDefaultLocation(int $locationId): bool
{
$exists = $this->db->table('stock_locations')
->where('location_id', $locationId)
->where('deleted', 0)
->countAllResults();
if ($exists === 0) {
return false;
}
$this->db->transStart();
$builder = $this->db->table('stock_locations');