mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-09-21 02:07:23 -04:00
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:
1 parent
d103790568
commit
2115fda4e5
1 file changed
+9
@@ -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');
|
||||
|
||||
Reference in new issue
Block a user